diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-12 03:05:45 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-12 03:05:45 +0000 |
commit | 062d2ee6f798205c3046730d0d348cfd0d0bc09d (patch) | |
tree | 8be6c2e72c796c481906978565bc116661e4fe9a /test/json/test_json_generate.rb | |
parent | f1194eb9b08b7c7be39e168c1f9620e377bee472 (diff) |
* ext/json: merge JSON 1.7.7.
This includes security fix. [CVE-2013-0269]
https://github.com/flori/json/commit/d0a62f3ced7560daba2ad546d83f0479a5ae2cf2
https://groups.google.com/d/topic/rubyonrails-security/4_YvCpLzL58/discussion
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/json/test_json_generate.rb')
-rwxr-xr-x | test/json/test_json_generate.rb | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/test/json/test_json_generate.rb b/test/json/test_json_generate.rb index 04368a4c8b..1c8f0bc968 100755 --- a/test/json/test_json_generate.rb +++ b/test/json/test_json_generate.rb @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -# -*- coding: utf-8 -*- +# encoding: utf-8 require 'test/unit' require File.join(File.dirname(__FILE__), 'setup_variant') @@ -130,7 +130,7 @@ EOT :quirks_mode => false, :depth => 0, :indent => " ", - :max_nesting => 19, + :max_nesting => 100, :object_nl => "\n", :space => " ", :space_before => "", @@ -147,7 +147,7 @@ EOT :quirks_mode => false, :depth => 0, :indent => "", - :max_nesting => 19, + :max_nesting => 100, :object_nl => "", :space => "", :space_before => "", @@ -200,7 +200,7 @@ EOT s = JSON.state.new assert_equal 0, s.depth assert_raises(JSON::NestingError) { ary.to_json(s) } - assert_equal 19, s.depth + assert_equal 100, s.depth end def test_buffer_initial_length @@ -228,6 +228,30 @@ EOT EOS end if GC.respond_to?(:stress=) + def test_configure_using_configure_and_merge + numbered_state = { + :indent => "1", + :space => '2', + :space_before => '3', + :object_nl => '4', + :array_nl => '5' + } + state1 = JSON.state.new + state1.merge(numbered_state) + assert_equal '1', state1.indent + assert_equal '2', state1.space + assert_equal '3', state1.space_before + assert_equal '4', state1.object_nl + assert_equal '5', state1.array_nl + state2 = JSON.state.new + state2.configure(numbered_state) + assert_equal '1', state2.indent + assert_equal '2', state2.space + assert_equal '3', state2.space_before + assert_equal '4', state2.object_nl + assert_equal '5', state2.array_nl + end + if defined?(JSON::Ext::Generator) def test_broken_bignum # [ruby-core:38867] pid = fork do @@ -249,4 +273,29 @@ EOT # introducing race conditions of tests are run in parallel end end + + def test_hash_likeness_set_symbol + state = JSON.state.new + assert_equal nil, state[:foo] + assert_equal nil.class, state[:foo].class + assert_equal nil, state['foo'] + state[:foo] = :bar + assert_equal :bar, state[:foo] + assert_equal :bar, state['foo'] + state_hash = state.to_hash + assert_kind_of Hash, state_hash + assert_equal :bar, state_hash[:foo] + end + + def test_hash_likeness_set_string + state = JSON.state.new + assert_equal nil, state[:foo] + assert_equal nil, state['foo'] + state['foo'] = :bar + assert_equal :bar, state[:foo] + assert_equal :bar, state['foo'] + state_hash = state.to_hash + assert_kind_of Hash, state_hash + assert_equal :bar, state_hash[:foo] + end end |