aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_bignum.rb5
-rw-r--r--test/ruby/test_fixnum.rb4
-rw-r--r--test/ruby/test_float.rb7
-rw-r--r--test/ruby/test_symbol.rb4
4 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index d9e689ce48..a9193b9452 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -505,4 +505,9 @@ class TestBignum < Test::Unit::TestCase
def o.coerce(x); [x, 2**100]; end
assert_equal((2**200).to_f, (2**300).fdiv(o))
end
+
+ def test_singleton_method
+ # this test assumes 32bit/64bit platform
+ assert_raise(TypeError) { a = 1 << 64; def a.foo; end }
+ end
end
diff --git a/test/ruby/test_fixnum.rb b/test/ruby/test_fixnum.rb
index 95a273bb94..a031923b02 100644
--- a/test/ruby/test_fixnum.rb
+++ b/test/ruby/test_fixnum.rb
@@ -271,4 +271,8 @@ class TestFixnum < Test::Unit::TestCase
def test_xor_with_nonintegral_numeric
assert_raise(TypeError, "#1792") { 1 ^ DummyNumeric.new }
end
+
+ def test_singleton_method
+ assert_raise(TypeError) { a = 1; def a.foo; end }
+ end
end
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb
index a63c18f8bc..2ac394465f 100644
--- a/test/ruby/test_float.rb
+++ b/test/ruby/test_float.rb
@@ -600,4 +600,11 @@ class TestFloat < Test::Unit::TestCase
assert_operator(n, :<=, e)
end
end
+
+ def test_singleton_method
+ # flonum on 64bit platform
+ assert_raise(TypeError) { a = 1.0; def a.foo; end }
+ # always not flonum
+ assert_raise(TypeError) { a = Float::INFINITY; def a.foo; end }
+ end
end
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index f39883bafa..89b7b4f8c9 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -168,4 +168,8 @@ class TestSymbol < Test::Unit::TestCase
assert_equal(Encoding::UTF_8, "\u{2192}".intern.encoding)
assert_raise(EncodingError) {"\xb0a".force_encoding("utf-8").intern}
end
+
+ def test_singleton_method
+ assert_raise(TypeError) { a = :foo; def a.foo; end }
+ end
end