summaryrefslogtreecommitdiff
path: root/test/ruby/test_literal.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-20 06:59:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-20 06:59:27 +0000
commitfe8475d7df29e5b4775272754ba1989ac9a842a4 (patch)
tree2d0e3ee23f7a9ed4222079aa4e43d2d8a77021f3 /test/ruby/test_literal.rb
parentec7b1e475b1f8cb3ca775fec27227c6761d3b203 (diff)
Test separately to get rid of risk to modify unrelated hash
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_literal.rb')
-rw-r--r--test/ruby/test_literal.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index 37755422a1..2f3016e249 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -283,20 +283,23 @@ class TestRubyLiteral < Test::Unit::TestCase
assert_equal "literal", h["string"]
end
- def frozen_hash_literal_arg
- {0=>1,1=>4,2=>17}
- end
-
def test_hash_literal_frozen
- assert_not_include frozen_hash_literal_arg, 3
- assert_raise(FrozenError) do
- ObjectSpace.each_object(Hash) do |a|
- if a.class == Hash and !a.default_proc and a.size == 3
- a[3] = 8 if a[0] == 1 and a[1] == 4 and a[2] == 17
+ assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ def frozen_hash_literal_arg
+ {0=>1,1=>4,2=>17}
+ end
+
+ assert_not_include frozen_hash_literal_arg, 3
+ assert_raise(FrozenError) do
+ ObjectSpace.each_object(Hash) do |a|
+ if a.class == Hash and !a.default_proc and a.size == 3
+ a[3] = 8 if a[0] == 1 and a[1] == 4 and a[2] == 17
+ end
end
end
- end
- assert_not_include frozen_hash_literal_arg, 3
+ assert_not_include frozen_hash_literal_arg, 3
+ end;
end
def test_big_array_and_hash_literal