Guest User

Untitled

a guest
May 5th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. diff --git a/spec/ruby/core/bignum/bit_and_spec.rb b/spec/ruby/core/bignum/bit_and_spec.rb
  2. index d77fa4b..d141f7b 100644
  3. --- a/spec/ruby/core/bignum/bit_and_spec.rb
  4. +++ b/spec/ruby/core/bignum/bit_and_spec.rb
  5. @@ -12,9 +12,21 @@ describe "Bignum#&" do
  6. (@bignum & bignum_value(9921)).should == 9223372036854775809
  7.  
  8. ((2*bignum_value) & 1).should == 0
  9. + ((2*bignum_value) & (2*bignum_value)).should == 18446744073709551616
  10. + end
  11. +
  12. + it "returns self bitwise AND other when one operand is negative" do
  13. ((2*bignum_value) & -1).should == 18446744073709551616
  14. ((4*bignum_value) & -1).should == 36893488147419103232
  15. - ((2*bignum_value) & (2*bignum_value)).should == 18446744073709551616
  16. + (@bignum & -0xffffffffffffff5).should == 9223372036854775809
  17. + (@bignum & -@bignum).should == 1
  18. + (@bignum & -0x8000000000000000).should == 9223372036854775808
  19. + end
  20. +
  21. + it "returns self bitwise AND other when both operands are negative" do
  22. + (-@bignum & -0x4000000000000005).should == -13835058055282163717
  23. + (-@bignum & -@bignum).should == -9223372036854775813
  24. + (-@bignum & -0x4000000000000000).should == -13835058055282163712
  25. end
  26.  
  27. ruby_version_is ""..."1.9" do
  28. diff --git a/spec/ruby/core/bignum/bit_or_spec.rb b/spec/ruby/core/bignum/bit_or_spec.rb
  29. index 45ddb6d..d98ed73 100644
  30. --- a/spec/ruby/core/bignum/bit_or_spec.rb
  31. +++ b/spec/ruby/core/bignum/bit_or_spec.rb
  32. @@ -11,6 +11,18 @@ describe "Bignum#|" do
  33. (@bignum | bignum_value).should == 9223372036854775819
  34. end
  35.  
  36. + it "returns self bitwise OR other when one operand is negative" do
  37. + (@bignum | -0x40000000000000000).should == -64563604257983430645
  38. + (@bignum | -@bignum).should == -1
  39. + (@bignum | -0x8000000000000000).should == -9223372036854775797
  40. + end
  41. +
  42. + it "returns self bitwise OR other when both operands are negative" do
  43. + (-@bignum | -0x4000000000000005).should == -1
  44. + (-@bignum | -@bignum).should == -9223372036854775819
  45. + (-@bignum | -0x4000000000000000).should == -11
  46. + end
  47. +
  48. ruby_version_is ""..."1.9" do
  49. it "coerces Float arguments to Integers" do
  50. (bignum_value | bignum_value(0xffff).to_f).should == 9223372036854841344
  51. diff --git a/spec/ruby/core/bignum/bit_xor_spec.rb b/spec/ruby/core/bignum/bit_xor_spec.rb
  52. index 38a5850..bc57ad8 100644
  53. --- a/spec/ruby/core/bignum/bit_xor_spec.rb
  54. +++ b/spec/ruby/core/bignum/bit_xor_spec.rb
  55. @@ -11,6 +11,18 @@ describe "Bignum#^" do
  56. (@bignum ^ 14).should == 9223372036854775836
  57. end
  58.  
  59. + it "returns self bitwise EXCLUSIVE OR other when one operand is negative" do
  60. + (@bignum ^ -0x40000000000000000).should == -64563604257983430638
  61. + (@bignum ^ -@bignum).should == -4
  62. + (@bignum ^ -0x8000000000000000).should == -18446744073709551598
  63. + end
  64. +
  65. + it "returns self bitwise EXCLUSIVE OR other when both operands are negative" do
  66. + (-@bignum ^ -0x40000000000000000).should == 64563604257983430638
  67. + (-@bignum ^ -@bignum).should == 0
  68. + (-@bignum ^ -0x4000000000000000).should == 13835058055282163694
  69. + end
  70. +
  71. ruby_version_is ""..."1.9" do
  72. it "coerces Float arguments into Integers" do
  73. (@bignum ^ 14.5).should == 9223372036854775836
Add Comment
Please, Sign In to add comment