Created
April 5, 2010 23:27
-
-
Save kronos/357015 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/spec/ruby/core/bignum/bit_and_spec.rb b/spec/ruby/core/bignum/bit_and_spec.rb | |
| index d77fa4b..d141f7b 100644 | |
| --- a/spec/ruby/core/bignum/bit_and_spec.rb | |
| +++ b/spec/ruby/core/bignum/bit_and_spec.rb | |
| @@ -12,9 +12,21 @@ describe "Bignum#&" do | |
| (@bignum & bignum_value(9921)).should == 9223372036854775809 | |
| ((2*bignum_value) & 1).should == 0 | |
| + ((2*bignum_value) & (2*bignum_value)).should == 18446744073709551616 | |
| + end | |
| + | |
| + it "returns self bitwise AND other when one operand is negative" do | |
| ((2*bignum_value) & -1).should == 18446744073709551616 | |
| ((4*bignum_value) & -1).should == 36893488147419103232 | |
| - ((2*bignum_value) & (2*bignum_value)).should == 18446744073709551616 | |
| + (@bignum & -0xffffffffffffff5).should == 9223372036854775809 | |
| + (@bignum & -@bignum).should == 1 | |
| + (@bignum & -0x8000000000000000).should == 9223372036854775808 | |
| + end | |
| + | |
| + it "returns self bitwise AND other when both operands are negative" do | |
| + (-@bignum & -0x4000000000000005).should == -13835058055282163717 | |
| + (-@bignum & -@bignum).should == -9223372036854775813 | |
| + (-@bignum & -0x4000000000000000).should == -13835058055282163712 | |
| end | |
| ruby_version_is ""..."1.9" do | |
| diff --git a/spec/ruby/core/bignum/bit_or_spec.rb b/spec/ruby/core/bignum/bit_or_spec.rb | |
| index 45ddb6d..d98ed73 100644 | |
| --- a/spec/ruby/core/bignum/bit_or_spec.rb | |
| +++ b/spec/ruby/core/bignum/bit_or_spec.rb | |
| @@ -11,6 +11,18 @@ describe "Bignum#|" do | |
| (@bignum | bignum_value).should == 9223372036854775819 | |
| end | |
| + it "returns self bitwise OR other when one operand is negative" do | |
| + (@bignum | -0x40000000000000000).should == -64563604257983430645 | |
| + (@bignum | -@bignum).should == -1 | |
| + (@bignum | -0x8000000000000000).should == -9223372036854775797 | |
| + end | |
| + | |
| + it "returns self bitwise OR other when both operands are negative" do | |
| + (-@bignum | -0x4000000000000005).should == -1 | |
| + (-@bignum | -@bignum).should == -9223372036854775819 | |
| + (-@bignum | -0x4000000000000000).should == -11 | |
| + end | |
| + | |
| ruby_version_is ""..."1.9" do | |
| it "coerces Float arguments to Integers" do | |
| (bignum_value | bignum_value(0xffff).to_f).should == 9223372036854841344 | |
| diff --git a/spec/ruby/core/bignum/bit_xor_spec.rb b/spec/ruby/core/bignum/bit_xor_spec.rb | |
| index 38a5850..bc57ad8 100644 | |
| --- a/spec/ruby/core/bignum/bit_xor_spec.rb | |
| +++ b/spec/ruby/core/bignum/bit_xor_spec.rb | |
| @@ -11,6 +11,18 @@ describe "Bignum#^" do | |
| (@bignum ^ 14).should == 9223372036854775836 | |
| end | |
| + it "returns self bitwise EXCLUSIVE OR other when one operand is negative" do | |
| + (@bignum ^ -0x40000000000000000).should == -64563604257983430638 | |
| + (@bignum ^ -@bignum).should == -4 | |
| + (@bignum ^ -0x8000000000000000).should == -18446744073709551598 | |
| + end | |
| + | |
| + it "returns self bitwise EXCLUSIVE OR other when both operands are negative" do | |
| + (-@bignum ^ -0x40000000000000000).should == 64563604257983430638 | |
| + (-@bignum ^ -@bignum).should == 0 | |
| + (-@bignum ^ -0x4000000000000000).should == 13835058055282163694 | |
| + end | |
| + | |
| ruby_version_is ""..."1.9" do | |
| it "coerces Float arguments into Integers" do | |
| (@bignum ^ 14.5).should == 9223372036854775836 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment