summaryrefslogtreecommitdiff
path: root/test/ruby/test_array.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-12 03:04:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-12 03:04:11 +0000
commit7fa5e608d33d7b87763b37b4dc7793e2ae58c882 (patch)
tree94ff652cbd2984ef2505edf8d578db7785970153 /test/ruby/test_array.rb
parentda786437a7be37f8807410a82071ace6089df97e (diff)
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/ruby/test_array.rb')
-rw-r--r--test/ruby/test_array.rb9
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'))