add core/fixnum/plus spec

This commit is contained in:
Laurent Sansonetti
2014-04-20 00:41:13 +02:00
parent 862b6b0d4e
commit c654a6868c
2 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
class Core_Fixnum_Plus_Mock1 < Java::Lang::Object
def to_int
10
end
end
describe "Fixnum#+" do
it "returns self plus the given Integer" do
(491 + 2).should == 493
(90210 + 10).should == 90220
p 9, bignum_value, 9 + bignum_value
p 1001 + 5.219
(9 + bignum_value).should == 9223372036854775817
(1001 + 5.219).should == 1006.219
end
it "raises a TypeError when given a non-Integer" do
lambda {
obj = Core_Fixnum_Plus_Mock1.new
13 + obj
}.should raise_error(TypeError)
lambda { 13 + "10" }.should raise_error(TypeError)
lambda { 13 + :symbol }.should raise_error(TypeError)
end
end

View File

@@ -185,6 +185,18 @@ class Object
# XXX we probably should be smarter here.
obj
end
def nan_value
0/0.0
end
def infinity_value
1/0.0
end
def bignum_value(plus=0)
0x8000_0000_0000_0000 + plus
end
end
class MainActivity < Android::App::Activity