summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-22 02:51:14 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-22 02:51:14 +0000
commit6e5aa6311a5798145daf0c42ce0a757c333f7155 (patch)
tree98c1d4f63de5396cac034eea48b875eccad16645 /test
parent5b1c06c74b65e12c8e552bacf6faed5c0b2826cd (diff)
* ext/psych/lib/psych/visitors/to_ruby.rb: fixing merge key support
when multiple merge keys are specified. * test/psych/test_merge_keys.rb: tests for multi-merge key support git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_merge_keys.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/psych/test_merge_keys.rb b/test/psych/test_merge_keys.rb
index 9aadcc85e5..fef8892727 100644
--- a/test/psych/test_merge_keys.rb
+++ b/test/psych/test_merge_keys.rb
@@ -17,5 +17,56 @@ bar:
"bar" => { "hello" => "world", "baz" => "boo" } }
assert_equal hash, Psych.load(yaml)
end
+
+ def test_multiple_maps
+ yaml = <<-eoyaml
+---
+- &CENTER { x: 1, y: 2 }
+- &LEFT { x: 0, y: 2 }
+- &BIG { r: 10 }
+- &SMALL { r: 1 }
+
+# All the following maps are equal:
+
+- # Merge multiple maps
+ << : [ *CENTER, *BIG ]
+ label: center/big
+ eoyaml
+
+ hash = {
+ 'x' => 1,
+ 'y' => 2,
+ 'r' => 10,
+ 'label' => 'center/big'
+ }
+
+ assert_equal hash, Psych.load(yaml)[4]
+ end
+
+ def test_override
+ yaml = <<-eoyaml
+---
+- &CENTER { x: 1, y: 2 }
+- &LEFT { x: 0, y: 2 }
+- &BIG { r: 10 }
+- &SMALL { r: 1 }
+
+# All the following maps are equal:
+
+- # Override
+ << : [ *BIG, *LEFT, *SMALL ]
+ x: 1
+ label: center/big
+ eoyaml
+
+ hash = {
+ 'x' => 1,
+ 'y' => 2,
+ 'r' => 10,
+ 'label' => 'center/big'
+ }
+
+ assert_equal hash, Psych.load(yaml)[4]
+ end
end
end