summaryrefslogtreecommitdiffhomepage
path: root/test/t/integer.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-05-13 18:16:52 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-05-13 18:16:52 +0900
commit15a2003aeb64c02b52d6473be8543c431b316a7f (patch)
treefb8d73914300e7d595a87c24796c48b0dfd91890 /test/t/integer.rb
parenta38f8fe606a526af56a0ed41113c7f9ac7cb5314 (diff)
parent964ce6e3272f18325bda7756420409600120a99e (diff)
downloadmruby-15a2003aeb64c02b52d6473be8543c431b316a7f.tar.gz
mruby-15a2003aeb64c02b52d6473be8543c431b316a7f.zip
Merge pull request #2190 from cremno/mrbtest-mrb_int-constants
test fixnum overflow for add, sub and mul
Diffstat (limited to 'test/t/integer.rb')
-rw-r--r--test/t/integer.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/t/integer.rb b/test/t/integer.rb
index 3673c0f1e..b15d4645d 100644
--- a/test/t/integer.rb
+++ b/test/t/integer.rb
@@ -18,6 +18,14 @@ assert('Integer#+', '15.2.8.3.1') do
assert_raise(TypeError){ 0+nil }
assert_raise(TypeError){ 1+nil }
+
+ c = Mrbtest::FIXNUM_MAX + 1
+ d = Mrbtest::FIXNUM_MAX.__send__(:+, 1)
+ e = Mrbtest::FIXNUM_MAX + 1.0
+ assert_equal Float, c.class
+ assert_equal Float, d.class
+ assert_float e, c
+ assert_float e, d
end
assert('Integer#-', '15.2.8.3.2') do
@@ -26,6 +34,14 @@ assert('Integer#-', '15.2.8.3.2') do
assert_equal 1, a
assert_equal 1.0, b
+
+ c = Mrbtest::FIXNUM_MIN - 1
+ d = Mrbtest::FIXNUM_MIN.__send__(:-, 1)
+ e = Mrbtest::FIXNUM_MIN - 1.0
+ assert_equal Float, c.class
+ assert_equal Float, d.class
+ assert_float e, c
+ assert_float e, d
end
assert('Integer#*', '15.2.8.3.3') do
@@ -37,6 +53,14 @@ assert('Integer#*', '15.2.8.3.3') do
assert_raise(TypeError){ 0*nil }
assert_raise(TypeError){ 1*nil }
+
+ c = Mrbtest::FIXNUM_MAX * 2
+ d = Mrbtest::FIXNUM_MAX.__send__(:*, 2)
+ e = Mrbtest::FIXNUM_MAX * 2.0
+ assert_equal Float, c.class
+ assert_equal Float, d.class
+ assert_float e, c
+ assert_float e, d
end
assert('Integer#/', '15.2.8.3.4') do