From 7a5dedf25c81aac6d14c35110e42f2f01d01a103 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Fri, 29 Aug 2014 21:02:19 +0000 Subject: * ext/psych/lib/psych/visitors/to_ruby.rb: quoted "<<" strings should not be treated as merge keys. * ext/psych/lib/psych/visitors/yaml_tree.rb: hashes with keys containing "<<" should roundtrip. * test/psych/test_merge_keys.rb: test for change. Fixes GH #203 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/psych/test_merge_keys.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/psych/test_merge_keys.rb') diff --git a/test/psych/test_merge_keys.rb b/test/psych/test_merge_keys.rb index ba8d2e77b3..8b263e5186 100644 --- a/test/psych/test_merge_keys.rb +++ b/test/psych/test_merge_keys.rb @@ -6,6 +6,26 @@ module Psych attr_reader :bar end + def test_roundtrip_with_chevron_key + h = {} + v = { 'a' => h, '<<' => h } + assert_cycle v + end + + def test_explicit_string + doc = Psych.load <<-eoyml +a: &me { hello: world } +b: { !!str '<<': *me } +eoyml + expected = { + "a" => { "hello" => "world" }, + "b" => { + "<<" => { "hello" => "world" } + } + } + assert_equal expected, doc + end + def test_mergekey_with_object s = <<-eoyml foo: &foo -- cgit v1.2.3