From 0326725b24dee6a82bb21bfa370072b326403155 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 10 Dec 2013 05:17:19 +0000 Subject: 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 --- test/ruby/test_weakmap.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/ruby') 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 -- cgit v1.2.3