diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2019-09-07 16:01:16 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2019-09-07 16:05:15 +0900 |
commit | 1e008105bc4576af46036f1c73f96f7f93bee319 (patch) | |
tree | 52bb069d7af5ca839e659e10b3e577ab6b01fe4e /test/ruby/test_array.rb | |
parent | c725a4e48fc30cb60e539e86c917698209184345 (diff) | |
download | ruby-1e008105bc4576af46036f1c73f96f7f93bee319.tar.gz |
compile.c (compile_list): emit newarraykwsplat only at the last chunk
`[{}, {}, {}, ..., {}, *{}]` is wrongly created.
A big array literal is created and concatenated for every 256 elements.
The newarraykwsplat must be emitted only at the last chunk.
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r-- | test/ruby/test_array.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 335c2dc042..955a00ad99 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -3213,6 +3213,14 @@ class TestArray < Test::Unit::TestCase assert_raise(TypeError) {[1].sum("")} end + def test_big_array_literal_with_kwsplat + lit = "[" + 10000.times { lit << "{}," } + lit << "**{}]" + + assert_equal(10000, eval(lit).size) + end + private def need_continuation unless respond_to?(:callcc, true) |