2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2018-01-29 11:08:16 -05:00
|
|
|
|
|
|
|
describe "Integer#~" do
|
|
|
|
context "fixnum" do
|
|
|
|
it "returns self with each bit flipped" do
|
|
|
|
(~0).should == -1
|
|
|
|
(~1221).should == -1222
|
|
|
|
(~-2).should == 1
|
|
|
|
(~-599).should == 598
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "bignum" do
|
|
|
|
it "returns self with each bit flipped" do
|
2022-01-28 08:42:38 -05:00
|
|
|
(~bignum_value(48)).should == -18446744073709551665
|
|
|
|
(~(-bignum_value(21))).should == 18446744073709551636
|
|
|
|
(~bignum_value(1)).should == -18446744073709551618
|
2018-01-29 11:08:16 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|