diff --git a/gc.c b/gc.c index 6c3da3bc81..634ba0d41c 100644 --- a/gc.c +++ b/gc.c @@ -6257,7 +6257,7 @@ Init_GC(void) rb_define_method(rb_cWeakMap, "[]", wmap_aref, 1); rb_define_method(rb_cWeakMap, "include?", wmap_has_key, 1); rb_define_method(rb_cWeakMap, "member?", wmap_has_key, 1); - rb_define_method(rb_cWeakMap, "key?", wmap_has_key, 0); + rb_define_method(rb_cWeakMap, "key?", wmap_has_key, 1); rb_define_method(rb_cWeakMap, "inspect", wmap_inspect, 0); rb_define_method(rb_cWeakMap, "each", wmap_each, 0); rb_define_method(rb_cWeakMap, "each_pair", wmap_each, 0); diff --git a/test/test_weakref.rb b/test/test_weakref.rb index d0d40d470b..27a8499615 100644 --- a/test/test_weakref.rb +++ b/test/test_weakref.rb @@ -18,9 +18,11 @@ class TestWeakRef < Test::Unit::TestCase def test_recycled weak, str = make_weakref assert_nothing_raised(WeakRef::RefError) {weak.to_s} + assert_predicate(weak, :weakref_alive?) ObjectSpace.garbage_collect ObjectSpace.garbage_collect assert_raise(WeakRef::RefError) {weak.to_s} + assert_not_predicate(weak, :weakref_alive?) end def test_not_reference_different_object