mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-01 09:31:20 +08:00
add core/fixnum/plus spec
This commit is contained in:
27
test/test-android/app/core/fixnum/plus_spec.rb
Normal file
27
test/test-android/app/core/fixnum/plus_spec.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user