summaryrefslogtreecommitdiff
path: root/tests/test_json.rb
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2013-02-04 23:28:30 +0100
committerFlorian Frank <flori@ping.de>2013-02-10 18:28:05 +0100
commit3ce359bbf308354b86e94248fc13dfd4b23c792e (patch)
tree296aebe8360d331cb47c1806a72cc420adc2a972 /tests/test_json.rb
parent93b31b8b588461901ed5ae0dc4e961ea3adbc55e (diff)
downloadjson-fix-additions-problem-v1.6.8.tar.gz
Security fix for create_additions problem 1.6.8v1.6.8fix-additions-problem-v1.6.8
Diffstat (limited to 'tests/test_json.rb')
-rwxr-xr-xtests/test_json.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/test_json.rb b/tests/test_json.rb
index 4b4bc55..84c0539 100755
--- a/tests/test_json.rb
+++ b/tests/test_json.rb
@@ -329,12 +329,12 @@ class TestJSON < Test::Unit::TestCase
def test_generate_core_subclasses_with_new_to_json
obj = SubHash2["foo" => SubHash2["bar" => true]]
obj_json = JSON(obj)
- obj_again = JSON(obj_json)
+ obj_again = JSON.parse(obj_json, :create_additions => true)
assert_kind_of SubHash2, obj_again
assert_kind_of SubHash2, obj_again['foo']
assert obj_again['foo']['bar']
assert_equal obj, obj_again
- assert_equal ["foo"], JSON(JSON(SubArray2["foo"]))
+ assert_equal ["foo"], JSON(JSON(SubArray2["foo"]), :create_additions => true)
end
def test_generate_core_subclasses_with_default_to_json
@@ -493,6 +493,12 @@ EOT
assert_equal nil, JSON.load('')
end
+ def test_load_with_options
+ small_hash = JSON("foo" => 'bar')
+ symbol_hash = { :foo => 'bar' }
+ assert_equal symbol_hash, JSON.load(small_hash, nil, :symbolize_names => true)
+ end
+
def test_dump
too_deep = '[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]'
assert_equal too_deep, JSON.dump(eval(too_deep))