summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb6
-rw-r--r--test/psych/test_symbol.rb8
3 files changed, 19 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ca26052bb84..569db972c03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Jun 6 07:41:41 2014 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * 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@atdot.net>
* gc.c (gc_page_sweep): refactoring.
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index ff0fcd204c8..96260daffa2 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/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 2b4470d184f..558a6728861 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