Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update descriptions for rational exponent for Ruby 3.4 #1229

Merged
merged 2 commits into from
Dec 28, 2024
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