mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
Support for unified Integer class in Ruby 2.4+
Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005
This commit is contained in:
parent
ec6adc8986
commit
f5966bb55a
3 changed files with 13 additions and 13 deletions
|
@ -18,7 +18,7 @@ for type in [TrueClass, FalseClass, NilClass, Float] do
|
|||
end
|
||||
end
|
||||
|
||||
for type in [Class, Object, Array, Hash, String, Symbol, Time, Proc, Method, Fixnum] do
|
||||
for type in [Class, Object, Array, Hash, String, Symbol, Time, Proc, Method, Integer] do
|
||||
type.class_eval do
|
||||
include V8::Conversion.const_get(type.name)
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class V8::Conversion
|
||||
module Fixnum
|
||||
module Integer
|
||||
def to_ruby
|
||||
self
|
||||
end
|
||||
|
|
|
@ -21,30 +21,30 @@ describe V8::Conversion do
|
|||
klass.test.should be_instance_of(::Set)
|
||||
end
|
||||
|
||||
context "::Fixnum" do
|
||||
context "::Integer" do
|
||||
context "for 32-bit numbers" do
|
||||
it "should convert positive integer" do
|
||||
cxt['fixnum_a'] = 123
|
||||
cxt['fixnum_a'].should == 123
|
||||
cxt['fixnum_a'].should be_instance_of(Fixnum)
|
||||
cxt['integer_a'] = 123
|
||||
cxt['integer_a'].should == 123
|
||||
cxt['integer_a'].should be_kind_of(Integer)
|
||||
end
|
||||
|
||||
it "should convert negative integer" do
|
||||
cxt['fixnum_b'] = -123
|
||||
cxt['fixnum_b'].should == -123
|
||||
cxt['fixnum_b'].should be_instance_of(Fixnum)
|
||||
cxt['integer_b'] = -123
|
||||
cxt['integer_b'].should == -123
|
||||
cxt['integer_b'].should be_kind_of(Integer)
|
||||
end
|
||||
end
|
||||
|
||||
context "for 64-bit numbers" do
|
||||
it "should convert positive integer" do
|
||||
cxt['fixnum_c'] = 0x100000000
|
||||
cxt['fixnum_c'].should == 0x100000000
|
||||
cxt['integer_c'] = 0x100000000
|
||||
cxt['integer_c'].should == 0x100000000
|
||||
end
|
||||
|
||||
it "should convert negative integer" do
|
||||
cxt['fixnum_d'] = -0x100000000
|
||||
cxt['fixnum_d'].should == -0x100000000
|
||||
cxt['integer_d'] = -0x100000000
|
||||
cxt['integer_d'].should == -0x100000000
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue