summaryrefslogtreecommitdiff
path: root/test/ruby/test_array.rb
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-08-26 16:20:36 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-08-26 16:20:36 +0000
commitef626cd09c448df9193c8d5f40143317d0185fd9 (patch)
tree41250168958f447607567448bc79ac55a50f2170 /test/ruby/test_array.rb
parent080e04e863cbbd6d6ec0aa4b00c92ffb095a7ce3 (diff)
merge revision(s) ec8e5f5aa64e2a54cf1e303f2b012c98e8d521ba,5a187e26adc8aa32367f294c1496935c7356d386: [Backport #15952]
array.c: always check frozenness in Array#unshift. Fixes [Bug #15952] Closes: https://github.com/ruby/ruby/pull/2251 array.c add back shared array optimization to ary_ensure_room_for_unshift Bug fix in commit ec8e5f5aa64e2a [Bug #15952] disabled an optimization in this function. Closes: https://github.com/ruby/ruby/pull/2252 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@67771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r--test/ruby/test_array.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index abd8d066fd..3212ed3aca 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1895,6 +1895,17 @@ class TestArray < Test::Unit::TestCase
assert_equal(@cls[@cls[1,2], nil, 'dog', 'cat'], a.unshift(@cls[1, 2]))
end
+ def test_unshift_frozen
+ bug15952 = '[Bug #15952]'
+ assert_raise(FrozenError, bug15952) do
+ a = [1] * 100
+ b = a[4..-1]
+ a.replace([1])
+ b.freeze
+ b.unshift("a")
+ end
+ end
+
def test_OR # '|'
assert_equal(@cls[], @cls[] | @cls[])
assert_equal(@cls[1], @cls[1] | @cls[])