diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-21 01:56:10 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-21 01:56:10 +0000 |
commit | 6f37c467d47483aac7bf5336a72446452e7ae251 (patch) | |
tree | eb2abc252214e476ba0787062b7ec4a6ddd8fea0 /test/psych | |
parent | 816c7900fd084509583953d7b2739e8412b0834d (diff) | |
download | ruby-6f37c467d47483aac7bf5336a72446452e7ae251.tar.gz |
* ext/psych/lib/psych/json/stream.rb: do not emit custom tags in maps
or sequences when emitting JSON.
* ext/psych/lib/psych/json/tree_builder.rb: do not emit custom tags in
sequences when emitting JSON.
* test/psych/json/test_stream.rb: tests for custom stream emits.
* test/psych/test_json_tree.rb: tests for JSON emits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych')
-rw-r--r-- | test/psych/json/test_stream.rb | 20 | ||||
-rw-r--r-- | test/psych/test_json_tree.rb | 11 |
2 files changed, 31 insertions, 0 deletions
diff --git a/test/psych/json/test_stream.rb b/test/psych/json/test_stream.rb index 252535abaa..45d0219aad 100644 --- a/test/psych/json/test_stream.rb +++ b/test/psych/json/test_stream.rb @@ -71,6 +71,26 @@ module Psych assert_match(/["]two["]/, json) end + class Foo; end + + def test_json_dump_exclude_tag + @stream << Foo.new + json = @io.string + refute_match('Foo', json) + end + + class Bar + def encode_with coder + coder.represent_seq 'omg', %w{ a b c } + end + end + + def test_json_list_dump_exclude_tag + @stream << Bar.new + json = @io.string + refute_match('omg', json) + end + def test_time time = Time.utc(2010, 10, 10) @stream.push({'a' => time }) diff --git a/test/psych/test_json_tree.rb b/test/psych/test_json_tree.rb index 423a528b81..b694560367 100644 --- a/test/psych/test_json_tree.rb +++ b/test/psych/test_json_tree.rb @@ -31,6 +31,17 @@ module Psych assert_match(/['"]two['"]/, json) end + class Bar + def encode_with coder + coder.represent_seq 'omg', %w{ a b c } + end + end + + def test_json_list_dump_exclude_tag + json = Psych.to_json Bar.new + refute_match('omg', json) + end + def test_list_to_json list = %w{ one two } json = Psych.to_json(list) |