[前][次][番号順一覧][スレッド一覧]

ruby-changes:54257

From: nobu <ko1@a...>
Date: Thu, 20 Dec 2018 15:59:32 +0900 (JST)
Subject: [ruby-changes:54257] nobu:r66465 (trunk): Test separately to get rid of risk to modify unrelated hash

nobu	2018-12-20 15:59:27 +0900 (Thu, 20 Dec 2018)

  New Revision: 66465

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66465

  Log:
    Test separately to get rid of risk to modify unrelated hash

  Modified files:
    trunk/test/ruby/test_literal.rb
Index: test/ruby/test_literal.rb
===================================================================
--- test/ruby/test_literal.rb	(revision 66464)
+++ test/ruby/test_literal.rb	(revision 66465)
@@ -283,20 +283,23 @@ class TestRubyLiteral < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_literal.rb#L283
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]