Skip to content

Commit

Permalink
Move non-linux specs for Rational exponents with ArgumentErrors
Browse files Browse the repository at this point in the history
The check for ArgumentError is performed within Ruby itself, and
unrelated to bugs in pow() in glibc. These specs should run on Linux
too.
  • Loading branch information
herwinw authored and andrykonchin committed Dec 28, 2024
1 parent 8b46336 commit 1ada0bc
Showing 1 changed file with 18 additions and 20 deletions.
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 "raises an ArgumentError when self < -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
end
end

Expand Down

0 comments on commit 1ada0bc

Please sign in to comment.