diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-10 05:17:19 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-10 05:17:19 +0000 |
commit | 0326725b24dee6a82bb21bfa370072b326403155 (patch) | |
tree | e3349f44c8ef978f60ad8b3ade8be5881a86e5e5 /test | |
parent | 9bd802f5567d78551668c51f091deb05e43b97ea (diff) | |
download | ruby-0326725b24dee6a82bb21bfa370072b326403155.tar.gz |
gc.c: check arguments first
* gc.c (wmap_aset): check if both arguments are able to finalize
before setting finalizers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_weakmap.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_weakmap.rb b/test/ruby/test_weakmap.rb index 0f147a6b0f..053ad88cfa 100644 --- a/test/ruby/test_weakmap.rb +++ b/test/ruby/test_weakmap.rb @@ -14,6 +14,20 @@ class TestWeakMap < Test::Unit::TestCase assert_not_same(x, @wm["FOO".downcase]) end + def test_aset_const + x = Object.new + assert_raise(ArgumentError) {@wm[true] = x} + assert_raise(ArgumentError) {@wm[false] = x} + assert_raise(ArgumentError) {@wm[nil] = x} + assert_raise(RuntimeError) {@wm[42] = x} + assert_raise(RuntimeError) {@wm[:foo] = x} + assert_raise(ArgumentError) {@wm[x] = true} + assert_raise(ArgumentError) {@wm[x] = false} + assert_raise(ArgumentError) {@wm[x] = nil} + assert_raise(RuntimeError) {@wm[x] = 42} + assert_raise(RuntimeError) {@wm[x] = :foo} + end + def test_include? m = __callee__[/test_(.*)/, 1] x = Object.new |