Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions shared/rational/exponent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,24 @@
(Rational(fixnum_max) ** -bignum_value)
}.should raise_error(ArgumentError)
end

it "raises an ArgumentError when self is < -1" do
-> {
(Rational(-2) ** bignum_value)
}.should raise_error(ArgumentError)
-> {
(Rational(fixnum_min) ** bignum_value)
}.should raise_error(ArgumentError)
end

it "raises an ArgumentError when self is < -1 and the exponent is negative" do
-> {
(Rational(-2) ** -bignum_value)
}.should raise_error(ArgumentError)
-> {
(Rational(fixnum_min) ** -bignum_value)
}.should raise_error(ArgumentError)
end
end

# Fails on linux due to pow() bugs in glibc: http://sources.redhat.com/bugzilla/show_bug.cgi?id=3866
Expand All @@ -148,26 +166,6 @@
}.should complain(/warning: in a\*\*b, b may be too big/)
end
end

ruby_version_is "3.4" do
it "returns positive Infinity when self < -1" do
-> {
(Rational(-2) ** bignum_value)
}.should raise_error(ArgumentError)
-> {
(Rational(fixnum_min) ** bignum_value)
}.should raise_error(ArgumentError)
end

it "returns 0.0 when self is < -1 and the exponent is negative" do
-> {
(Rational(-2) ** -bignum_value)
}.should raise_error(ArgumentError)
-> {
(Rational(fixnum_min) ** -bignum_value)
}.should raise_error(ArgumentError)
end
end
end
end

Expand Down
Loading