summaryrefslogtreecommitdiff
path: root/test/json/test_json_generate.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-01 17:34:50 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-01 17:34:50 +0000
commitd99ac4f829dd0903f20e02de5dbba0ddc175c1f3 (patch)
tree18f7c54ef29c879c9a3c342bcea594bde36ca2b5 /test/json/test_json_generate.rb
parent596b68cc6b6333a3939ebca3ae09fecc491e5718 (diff)
Add tests of JSON 1.1.9.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/json/test_json_generate.rb')
-rw-r--r--test/json/test_json_generate.rb27
1 files changed, 17 insertions, 10 deletions
diff --git a/test/json/test_json_generate.rb b/test/json/test_json_generate.rb
index 8c55a40..bbb75ba 100644
--- a/test/json/test_json_generate.rb
+++ b/test/json/test_json_generate.rb
@@ -1,5 +1,12 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
require 'test/unit'
-require 'json'
+case ENV['JSON']
+when 'pure' then require 'json/pure'
+when 'ext' then require 'json/ext'
+else require 'json'
+end
class TC_JSONGenerate < Test::Unit::TestCase
include JSON
@@ -70,30 +77,30 @@ EOT
#assert s.check_circular
h = { 1=>2 }
h[3] = h
- assert_raise(JSON::CircularDatastructure) { generate(h) }
- assert_raise(JSON::CircularDatastructure) { generate(h, s) }
+ assert_raises(JSON::CircularDatastructure) { generate(h) }
+ assert_raises(JSON::CircularDatastructure) { generate(h, s) }
s = JSON.state.new(:check_circular => true)
#assert s.check_circular
a = [ 1, 2 ]
a << a
- assert_raise(JSON::CircularDatastructure) { generate(a, s) }
+ assert_raises(JSON::CircularDatastructure) { generate(a, s) }
end
def test_allow_nan
- assert_raise(GeneratorError) { generate([JSON::NaN]) }
+ assert_raises(GeneratorError) { generate([JSON::NaN]) }
assert_equal '[NaN]', generate([JSON::NaN], :allow_nan => true)
assert_equal '[NaN]', fast_generate([JSON::NaN])
- assert_raise(GeneratorError) { pretty_generate([JSON::NaN]) }
+ assert_raises(GeneratorError) { pretty_generate([JSON::NaN]) }
assert_equal "[\n NaN\n]", pretty_generate([JSON::NaN], :allow_nan => true)
- assert_raise(GeneratorError) { generate([JSON::Infinity]) }
+ assert_raises(GeneratorError) { generate([JSON::Infinity]) }
assert_equal '[Infinity]', generate([JSON::Infinity], :allow_nan => true)
assert_equal '[Infinity]', fast_generate([JSON::Infinity])
- assert_raise(GeneratorError) { pretty_generate([JSON::Infinity]) }
+ assert_raises(GeneratorError) { pretty_generate([JSON::Infinity]) }
assert_equal "[\n Infinity\n]", pretty_generate([JSON::Infinity], :allow_nan => true)
- assert_raise(GeneratorError) { generate([JSON::MinusInfinity]) }
+ assert_raises(GeneratorError) { generate([JSON::MinusInfinity]) }
assert_equal '[-Infinity]', generate([JSON::MinusInfinity], :allow_nan => true)
assert_equal '[-Infinity]', fast_generate([JSON::MinusInfinity])
- assert_raise(GeneratorError) { pretty_generate([JSON::MinusInfinity]) }
+ assert_raises(GeneratorError) { pretty_generate([JSON::MinusInfinity]) }
assert_equal "[\n -Infinity\n]", pretty_generate([JSON::MinusInfinity], :allow_nan => true)
end
end