summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2010-03-13 21:11:58 +0100
committerFlorian Frank <flori@ping.de>2010-03-13 21:11:58 +0100
commitc3e8dd92f04b010366e4d7152c83c7486af93e1e (patch)
tree883b600b03e7a5788f50fe4f71b4fe9f88f7ef9f /tests
parent92b013ce8e0a5c3caefd15f450409ed69aa539f2 (diff)
parent3db50701a4a71e49709c63483d2ba4b5a408373b (diff)
downloadjson-c3e8dd92f04b010366e4d7152c83c7486af93e1e.tar.gz
Merge commit 'v1.2.3'
Merged in some additional features from the v1.2 branch.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_json.rb7
-rwxr-xr-xtests/test_json_generate.rb4
2 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_json.rb b/tests/test_json.rb
index 736c57b..3d26ddb 100755
--- a/tests/test_json.rb
+++ b/tests/test_json.rb
@@ -302,6 +302,13 @@ EOT
assert_equal too_deep, ok
end
+ def test_symbolize_names
+ assert_equal({ "foo" => "bar", "baz" => "quux" },
+ JSON.parse('{"foo":"bar", "baz":"quux"}'))
+ assert_equal({ :foo => "bar", :baz => "quux" },
+ JSON.parse('{"foo":"bar", "baz":"quux"}', :symbolize_names => true))
+ end
+
def test_load_dump
too_deep = '[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]'
assert_equal too_deep, JSON.dump(eval(too_deep))
diff --git a/tests/test_json_generate.rb b/tests/test_json_generate.rb
index d57602c..26ca1ad 100755
--- a/tests/test_json_generate.rb
+++ b/tests/test_json_generate.rb
@@ -88,6 +88,8 @@ EOT
json = generate({1=>2}, nil)
assert_equal('{"1":2}', json)
s = JSON.state.new
+ assert s.check_circular?
+ assert s[:check_circular?]
h = { 1=>2 }
h[3] = h
assert_raises(JSON::NestingError) { generate(h) }
@@ -96,6 +98,8 @@ EOT
a = [ 1, 2 ]
a << a
assert_raises(JSON::NestingError) { generate(a, s) }
+ assert s.check_circular?
+ assert s[:check_circular?]
end
def test_allow_nan