From c654a6868cb5789103f35b31247191bc76f28695 Mon Sep 17 00:00:00 2001 From: Laurent Sansonetti Date: Sun, 20 Apr 2014 00:41:13 +0200 Subject: [PATCH] add core/fixnum/plus spec --- .../test-android/app/core/fixnum/plus_spec.rb | 27 +++++++++++++++++++ test/test-android/app/main.rb | 12 +++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/test-android/app/core/fixnum/plus_spec.rb diff --git a/test/test-android/app/core/fixnum/plus_spec.rb b/test/test-android/app/core/fixnum/plus_spec.rb new file mode 100644 index 00000000..86b6d4be --- /dev/null +++ b/test/test-android/app/core/fixnum/plus_spec.rb @@ -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 diff --git a/test/test-android/app/main.rb b/test/test-android/app/main.rb index f24ce14e..b1129062 100644 --- a/test/test-android/app/main.rb +++ b/test/test-android/app/main.rb @@ -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