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

ruby-changes:34277

From: tenderlove <ko1@a...>
Date: Fri, 6 Jun 2014 07:43:14 +0900 (JST)
Subject: [ruby-changes:34277] tenderlove:r46358 (trunk): * ext/psych/lib/psych/visitors/yaml_tree.rb: dump empty symbols with a

tenderlove	2014-06-06 07:42:58 +0900 (Fri, 06 Jun 2014)

  New Revision: 46358

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

  Log:
    * ext/psych/lib/psych/visitors/yaml_tree.rb: dump empty symbols with a
      tag so that they can be parsed on input. [Bug #9873] [ruby-core:62825]
    * test/psych/test_symbol.rb: test for change

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/visitors/yaml_tree.rb
    trunk/test/psych/test_symbol.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46357)
+++ ChangeLog	(revision 46358)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jun  6 07:41:41 2014  Aaron Patterson <aaron@t...>
+
+	* ext/psych/lib/psych/visitors/yaml_tree.rb: dump empty symbols with a
+	  tag so that they can be parsed on input. [Bug #9873] [ruby-core:62825]
+	* test/psych/test_symbol.rb: test for change
+
 Thu Jun  5 16:08:39 2014  Koichi Sasada  <ko1@a...>
 
 	* gc.c (gc_page_sweep): refactoring.
Index: ext/psych/lib/psych/visitors/yaml_tree.rb
===================================================================
--- ext/psych/lib/psych/visitors/yaml_tree.rb	(revision 46357)
+++ ext/psych/lib/psych/visitors/yaml_tree.rb	(revision 46358)
@@ -378,7 +378,11 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/yaml_tree.rb#L378
       end
 
       def visit_Symbol o
-        @emitter.scalar ":#{o}", nil, nil, true, false, Nodes::Scalar::ANY
+        if o.empty?
+          @emitter.scalar "", nil, '!ruby/symbol', false, false, Nodes::Scalar::ANY
+        else
+          @emitter.scalar ":#{o}", nil, nil, true, false, Nodes::Scalar::ANY
+        end
       end
 
       private
Index: test/psych/test_symbol.rb
===================================================================
--- test/psych/test_symbol.rb	(revision 46357)
+++ test/psych/test_symbol.rb	(revision 46358)
@@ -2,6 +2,14 @@ require_relative 'helper' https://github.com/ruby/ruby/blob/trunk/test/psych/test_symbol.rb#L2
 
 module Psych
   class TestSymbol < TestCase
+    def test_cycle_empty
+      assert_cycle :''
+    end
+
+    def test_cycle_colon
+      assert_cycle :':'
+    end
+
     def test_cycle
       assert_cycle :a
     end

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

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