diff options
author | Benoit Daloze <eregontp@gmail.com> | 2022-01-28 14:42:38 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2022-01-28 14:42:38 +0100 |
commit | e0c5488ff9308b1a16718c64bc9096caca88ed83 (patch) | |
tree | b0ede98f96c4477c470bef45547abff525215b21 /spec/ruby/core/integer/shared | |
parent | bb5f71088774b14c96fe11718e5e1b7ffb20fff2 (diff) | |
download | ruby-e0c5488ff9308b1a16718c64bc9096caca88ed83.tar.gz |
Update to ruby/spec@902ab83
Diffstat (limited to 'spec/ruby/core/integer/shared')
-rw-r--r-- | spec/ruby/core/integer/shared/abs.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/integer/shared/exponent.rb | 11 | ||||
-rw-r--r-- | spec/ruby/core/integer/shared/modulo.rb | 10 |
3 files changed, 14 insertions, 11 deletions
diff --git a/spec/ruby/core/integer/shared/abs.rb b/spec/ruby/core/integer/shared/abs.rb index 946aa21864..43844c9065 100644 --- a/spec/ruby/core/integer/shared/abs.rb +++ b/spec/ruby/core/integer/shared/abs.rb @@ -11,8 +11,8 @@ describe :integer_abs, shared: true do context "bignum" do it "returns the absolute bignum value" do - bignum_value(39).send(@method).should == 9223372036854775847 - (-bignum_value(18)).send(@method).should == 9223372036854775826 + bignum_value(39).send(@method).should == 18446744073709551655 + (-bignum_value(18)).send(@method).should == 18446744073709551634 end end end diff --git a/spec/ruby/core/integer/shared/exponent.rb b/spec/ruby/core/integer/shared/exponent.rb index f949c514c8..15df518b7e 100644 --- a/spec/ruby/core/integer/shared/exponent.rb +++ b/spec/ruby/core/integer/shared/exponent.rb @@ -30,11 +30,13 @@ describe :integer_exponent, shared: true do (-2).send(@method, 30).should eql(1073741824) (-2).send(@method, 31).should eql(-2147483648) (-2).send(@method, 32).should eql(4294967296) + (-2).send(@method, 33).should eql(-8589934592) (-2).send(@method, 61).should eql(-2305843009213693952) (-2).send(@method, 62).should eql(4611686018427387904) (-2).send(@method, 63).should eql(-9223372036854775808) (-2).send(@method, 64).should eql(18446744073709551616) + (-2).send(@method, 65).should eql(-36893488147419103232) end it "can raise 1 to a bignum safely" do @@ -96,8 +98,8 @@ describe :integer_exponent, shared: true do end it "returns self raised to other power" do - (@bignum.send(@method, 4)).should == 7237005577332262361485077344629993318496048279512298547155833600056910050625 - (@bignum.send(@method, 1.2)).should be_close(57262152889751597425762.57804, TOLERANCE) + (@bignum.send(@method, 4)).should == 115792089237316196603666111261383895964500887398800252671052694326794607293761 + (@bignum.send(@method, 1.3)).should be_close(11109528802438156839288832.0, TOLERANCE) end it "raises a TypeError when given a non-Integer" do @@ -116,8 +118,9 @@ describe :integer_exponent, shared: true do end it "returns a complex number when negative and raised to a fractional power" do - ((-@bignum).send(@method, (1.0/3))) .should be_close(Complex(1048576,1816186.907597341), TOLERANCE) - ((-@bignum).send(@method, Rational(1,3))).should be_close(Complex(1048576,1816186.907597341), TOLERANCE) + (-bignum_value).send(@method, (1.0/2)).should be_close(Complex(0.0, 4294967296.0), TOLERANCE) + (-@bignum).send(@method, (1.0/3)) .should be_close(Complex(1321122.9748145656, 2288252.1154253655), TOLERANCE) + (-@bignum).send(@method, Rational(1,3)).should be_close(Complex(1321122.9748145656, 2288252.1154253655), TOLERANCE) end end end diff --git a/spec/ruby/core/integer/shared/modulo.rb b/spec/ruby/core/integer/shared/modulo.rb index b06d81e17d..f678a10806 100644 --- a/spec/ruby/core/integer/shared/modulo.rb +++ b/spec/ruby/core/integer/shared/modulo.rb @@ -48,11 +48,11 @@ describe :integer_modulo, shared: true do end it "returns the modulus obtained from dividing self by the given argument" do - @bignum.send(@method, 5).should == 3 - @bignum.send(@method, -5).should == -2 - @bignum.send(@method, -100).should == -92 - @bignum.send(@method, 2.22).should be_close(0.780180180180252, TOLERANCE) - @bignum.send(@method, bignum_value(10)).should == 9223372036854775808 + @bignum.send(@method, 5).should == 1 + @bignum.send(@method, -5).should == -4 + @bignum.send(@method, -100).should == -84 + @bignum.send(@method, 2.22).should be_close(1.5603603603605034, TOLERANCE) + @bignum.send(@method, bignum_value(10)).should == 18446744073709551616 end it "raises a ZeroDivisionError when the given argument is 0" do |