diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-12 03:04:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-12 03:04:11 +0000 |
commit | 7fa5e608d33d7b87763b37b4dc7793e2ae58c882 (patch) | |
tree | 94ff652cbd2984ef2505edf8d578db7785970153 /test | |
parent | da786437a7be37f8807410a82071ace6089df97e (diff) | |
download | ruby-7fa5e608d33d7b87763b37b4dc7793e2ae58c882.tar.gz |
array.c: freeze in callback
* array.c (rb_ary_uniq_bang): must not be modified once frozen even in
a callback method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_array.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 49628215b5..6807598054 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1569,6 +1569,15 @@ class TestArray < Test::Unit::TestCase assert_equal(nil, b) end + def test_uniq_bang_with_freeze + ary = [1,2] + orig = ary.dup + assert_raise(RuntimeError, "frozen during comparison") { + ary.uniq! {|v| ary.freeze; 1} + } + assert_equal(orig, ary, "must not be modified once frozen") + end + def test_unshift a = @cls[] assert_equal(@cls['cat'], a.unshift('cat')) |