Sha256: a7b1927b00d445c0330cfaa6920d92e601ce63277daa331f034772310a4aac90

Contents?: true

Size: 962 Bytes

Versions: 19

Compression:

Stored size: 962 Bytes

Contents

require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'

describe "Bignum#^" do
  before(:each) do
    @bignum = bignum_value(18) 
  end
  
  it "returns self bitwise EXCLUSIVE OR other" do
    (@bignum ^ 2).should == 9223372036854775824
    (@bignum ^ @bignum).should == 0
    (@bignum ^ 14).should == 9223372036854775836
    (bignum_value ^ bignum_value(0xffff).to_f).should == 65536
  end

  it "tries to convert the given argument to an Integer using to_int" do
    (@bignum ^ 14.5).should == 9223372036854775836
    
    (obj = mock('2')).should_receive(:to_int).and_return(2)
    (@bignum ^ obj).should == 9223372036854775824
  end
  
  it "raises a TypeError when the given argument can't be converted to Integer" do
    obj = mock('asdf')
    lambda { @bignum ^ obj }.should raise_error(TypeError)
    
    obj.should_receive(:to_int).and_return("asdf")
    lambda { @bignum ^ obj }.should raise_error(TypeError)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rhodes-2.0.0.beta11 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-2.0.0.beta10 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-2.0.0.beta9 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-2.0.0.beta8 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-2.0.0.beta7 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-2.0.0.beta6 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-2.0.0.beta4 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-2.0.0.beta3 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-1.5.5 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-2.0.0.beta2 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-2.0.0.beta1 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-1.5.4 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-1.5.3 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-1.5.2 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-1.5.1 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-1.5.0 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-1.4.2 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-1.4.1 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb
rhodes-1.4.0 spec/framework_spec/app/spec/core/bignum/bit_xor_spec.rb