summaryrefslogtreecommitdiff
path: root/test/psych/test_coder.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-04-09 08:36:24 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-04-09 08:36:24 -0700
commit6faec131cb140948003fff0a89064f737e3b1b4d (patch)
tree0423d8e7b70bda84c129e42929a8a2dbde7774af /test/psych/test_coder.rb
parent30f530721879c79154c628cc450eada400742ad3 (diff)
downloadpsych-6faec131cb140948003fff0a89064f737e3b1b4d.tar.gz
merging from ruby to psych
Diffstat (limited to 'test/psych/test_coder.rb')
-rw-r--r--test/psych/test_coder.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/psych/test_coder.rb b/test/psych/test_coder.rb
index deef6f2..0fa01ca 100644
--- a/test/psych/test_coder.rb
+++ b/test/psych/test_coder.rb
@@ -89,6 +89,31 @@ module Psych
end
end
+ def test_map_takes_block
+ coder = Psych::Coder.new 'foo'
+ tag = coder.tag
+ style = coder.style
+ coder.map { |map| map.add 'foo', 'bar' }
+ assert_equal 'bar', coder['foo']
+ assert_equal tag, coder.tag
+ assert_equal style, coder.style
+ end
+
+ def test_map_with_tag
+ coder = Psych::Coder.new 'foo'
+ coder.map('hello') { |map| map.add 'foo', 'bar' }
+ assert_equal 'bar', coder['foo']
+ assert_equal 'hello', coder.tag
+ end
+
+ def test_map_with_tag_and_style
+ coder = Psych::Coder.new 'foo'
+ coder.map('hello', 'world') { |map| map.add 'foo', 'bar' }
+ assert_equal 'bar', coder['foo']
+ assert_equal 'hello', coder.tag
+ assert_equal 'world', coder.style
+ end
+
def test_represent_map
thing = Psych.load(Psych.dump(RepresentWithMap.new))
assert_equal({ 'a' => 'b' }, thing.map)