diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-20 17:41:14 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-20 17:41:14 +0000 |
commit | a1299e85d648c96d3ae2834483bd53a00fbd425e (patch) | |
tree | c7fade34f792e138365b59af246ea316616c04e7 /test/json/test_json_generate.rb | |
parent | 3867226cdcf1b6fe1d2968b5f23a839e10121695 (diff) | |
download | ruby-a1299e85d648c96d3ae2834483bd53a00fbd425e.tar.gz ruby-a1299e85d648c96d3ae2834483bd53a00fbd425e.tar.xz ruby-a1299e85d648c96d3ae2834483bd53a00fbd425e.zip |
* ext/json: import JSON v 1.1.3.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/json/test_json_generate.rb')
-rw-r--r-- | test/json/test_json_generate.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/json/test_json_generate.rb b/test/json/test_json_generate.rb index e720b2d86..b7e0bc22c 100644 --- a/test/json/test_json_generate.rb +++ b/test/json/test_json_generate.rb @@ -70,6 +70,7 @@ EOT #assert s.check_circular h = { 1=>2 } h[3] = h + assert_raises(JSON::CircularDatastructure) { generate(h) } assert_raises(JSON::CircularDatastructure) { generate(h, s) } s = JSON.state.new(:check_circular => true) #assert s.check_circular @@ -77,4 +78,22 @@ EOT a << a assert_raises(JSON::CircularDatastructure) { generate(a, s) } end + + def test_allow_nan + assert_raises(GeneratorError) { generate([JSON::NaN]) } + assert_equal '[NaN]', generate([JSON::NaN], :allow_nan => true) + assert_equal '[NaN]', fast_generate([JSON::NaN]) + assert_raises(GeneratorError) { pretty_generate([JSON::NaN]) } + assert_equal "[\n NaN\n]", pretty_generate([JSON::NaN], :allow_nan => true) + assert_raises(GeneratorError) { generate([JSON::Infinity]) } + assert_equal '[Infinity]', generate([JSON::Infinity], :allow_nan => true) + assert_equal '[Infinity]', fast_generate([JSON::Infinity]) + assert_raises(GeneratorError) { pretty_generate([JSON::Infinity]) } + assert_equal "[\n Infinity\n]", pretty_generate([JSON::Infinity], :allow_nan => true) + assert_raises(GeneratorError) { generate([JSON::MinusInfinity]) } + assert_equal '[-Infinity]', generate([JSON::MinusInfinity], :allow_nan => true) + assert_equal '[-Infinity]', fast_generate([JSON::MinusInfinity]) + assert_raises(GeneratorError) { pretty_generate([JSON::MinusInfinity]) } + assert_equal "[\n -Infinity\n]", pretty_generate([JSON::MinusInfinity], :allow_nan => true) + end end |