summaryrefslogtreecommitdiff
path: root/test/ruby/test_literal.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_literal.rb')
-rw-r--r--test/ruby/test_literal.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index e7a7c76891..12b3eddd50 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -1,4 +1,5 @@
require 'test/unit'
+require_relative 'envutil'
class TestRubyLiteral < Test::Unit::TestCase
@@ -186,6 +187,13 @@ class TestRubyLiteral < Test::Unit::TestCase
assert_equal "literal", h["string"]
end
+ def test_big_array_and_hash_literal
+ assert_normal_exit %q{x = nil; raise if eval("[#{(1..1_000_000).map{'x'}.join(", ")}]").size != 1_000_000}, "", timeout: 300
+ assert_normal_exit %q{x = nil; raise if eval("[#{(1..1_000_000).to_a.join(", ")}]").size != 1_000_000}, "", timeout: 300
+ assert_normal_exit %q{x = nil; raise if eval("{#{(1..1_000_000).map{|n| "#{n} => x"}.join(', ')}}").size != 1_000_000}, "", timeout: 300
+ assert_normal_exit %q{x = nil; raise if eval("{#{(1..1_000_000).map{|n| "#{n} => #{n}"}.join(', ')}}").size != 1_000_000}, "", timeout: 300
+ end
+
def test_range
assert_instance_of Range, (1..2)
assert_equal(1..2, 1..2)