From 1695b6c7378b826ec1de64f07fccf6bc2f353017 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 5 Jun 2014 15:46:15 -0700 Subject: * 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 --- CHANGELOG.rdoc | 6 ++++++ lib/psych/visitors/yaml_tree.rb | 6 +++++- test/psych/test_symbol.rb | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index eadc02f..2ea6022 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -1,3 +1,9 @@ +Fri Jun 6 07:41:41 2014 Aaron Patterson + + * 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 + 2014-03-27 SHIBATA Hiroshi * ext/psych/yaml/scanner.c: merge libyaml 0.1.6 diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index ff0fcd2..96260da 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -378,7 +378,11 @@ module Psych 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 diff --git a/test/psych/test_symbol.rb b/test/psych/test_symbol.rb index 2b4470d..558a672 100644 --- a/test/psych/test_symbol.rb +++ b/test/psych/test_symbol.rb @@ -2,6 +2,14 @@ require_relative 'helper' 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 -- cgit v1.2.3