diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-16 21:33:59 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-16 21:33:59 +0000 |
commit | b3803cc49ad382e23291d75ce57ffb2b74bb9577 (patch) | |
tree | ae38d6b36985afa394bbf905ea0cd9cbf4d9d291 /test | |
parent | ddb6408f6ef338310065a87cd32b9ed3afbe9c46 (diff) | |
download | ruby-b3803cc49ad382e23291d75ce57ffb2b74bb9577.tar.gz |
* hash.c (initialize_copy): copy the underlying st_table on dup,
rather than copying the hash key by key. [ruby-core:48009]
* test/ruby/test_hash.rb: relevant tests for initialize_copy
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_hash.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 34d58a0354..1806746ef2 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -91,6 +91,15 @@ class TestHash < Test::Unit::TestCase $VERBOSE = @verbose end + def test_bad_initialize_copy + h = Class.new(Hash) { + def initialize_copy(h) + super(Object.new) + end + }.new + assert_raises(TypeError) { h.dup } + end + def test_s_AREF h = @cls["a" => 100, "b" => 200] assert_equal(100, h['a']) |