summaryrefslogtreecommitdiff
path: root/test/json
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-24 17:44:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-24 17:44:39 +0000
commit00b4a3f9c4aaf5aa038a9530ec515e1718ae1c42 (patch)
treeb57bc2afea00aa87978f691526dd7adc1b8a067d /test/json
parent48fdf59dcfbb6964d992b6f31d0eb6f023776145 (diff)
* test: assert_raises has been deprecated since a long time ago.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/json')
-rwxr-xr-xtest/json/test_json.rb70
-rwxr-xr-xtest/json/test_json_addition.rb4
-rwxr-xr-xtest/json/test_json_fixtures.rb2
-rw-r--r--test/json/test_json_generate.rb18
-rw-r--r--test/json/test_json_rails.rb2
-rwxr-xr-xtest/json/test_json_unicode.rb2
6 files changed, 49 insertions, 49 deletions
diff --git a/test/json/test_json.rb b/test/json/test_json.rb
index 2c706d5..8cb2267 100755
--- a/test/json/test_json.rb
+++ b/test/json/test_json.rb
@@ -49,10 +49,10 @@ class TC_JSON < Test::Unit::TestCase
assert_equal([23], parse('[23]'))
assert_equal([0.23], parse('[0.23]'))
assert_equal([0.0], parse('[0e0]'))
- assert_raises(JSON::ParserError) { parse('[+23.2]') }
- assert_raises(JSON::ParserError) { parse('[+23]') }
- assert_raises(JSON::ParserError) { parse('[.23]') }
- assert_raises(JSON::ParserError) { parse('[023]') }
+ assert_raise(JSON::ParserError) { parse('[+23.2]') }
+ assert_raise(JSON::ParserError) { parse('[+23]') }
+ assert_raise(JSON::ParserError) { parse('[.23]') }
+ assert_raise(JSON::ParserError) { parse('[023]') }
assert_equal_float [3.141], parse('[3.141]')
assert_equal_float [-3.141], parse('[-3.141]')
assert_equal_float [3.141], parse('[3141e-3]')
@@ -61,11 +61,11 @@ class TC_JSON < Test::Unit::TestCase
assert_equal_float [3.141], parse('[3141.0E-3]')
assert_equal_float [-3.141], parse('[-3141.0e-3]')
assert_equal_float [-3.141], parse('[-3141e-3]')
- assert_raises(ParserError) { parse('[NaN]') }
+ assert_raise(ParserError) { parse('[NaN]') }
assert parse('[NaN]', :allow_nan => true).first.nan?
- assert_raises(ParserError) { parse('[Infinity]') }
+ assert_raise(ParserError) { parse('[Infinity]') }
assert_equal [1.0/0], parse('[Infinity]', :allow_nan => true)
- assert_raises(ParserError) { parse('[-Infinity]') }
+ assert_raise(ParserError) { parse('[-Infinity]') }
assert_equal [-1.0/0], parse('[-Infinity]', :allow_nan => true)
assert_equal([""], parse('[""]'))
assert_equal(["foobar"], parse('["foobar"]'))
@@ -79,7 +79,7 @@ class TC_JSON < Test::Unit::TestCase
assert_equal({ "a" => nil }, parse('{"a":null}'))
assert_equal({ "a" => false }, parse('{ "a" : false } '))
assert_equal({ "a" => false }, parse('{"a":false}'))
- assert_raises(JSON::ParserError) { parse('{false}') }
+ assert_raise(JSON::ParserError) { parse('{false}') }
assert_equal({ "a" => true }, parse('{"a":true}'))
assert_equal({ "a" => true }, parse(' { "a" : true } '))
assert_equal({ "a" => -23 }, parse(' { "a" : -23 } '))
@@ -181,7 +181,7 @@ EOT
* comment */
}
EOT
- assert_raises(ParserError) { parse(json) }
+ assert_raise(ParserError) { parse(json) }
json = <<EOT
{
"key1":"value1" /* multi line
@@ -190,7 +190,7 @@ EOT
and again, throw an Error */
}
EOT
- assert_raises(ParserError) { parse(json) }
+ assert_raise(ParserError) { parse(json) }
json = <<EOT
{
"key1":"value1" /*/*/
@@ -226,32 +226,32 @@ EOT
end
def test_wrong_inputs
- assert_raises(ParserError) { JSON.parse('"foo"') }
- assert_raises(ParserError) { JSON.parse('123') }
- assert_raises(ParserError) { JSON.parse('[] bla') }
- assert_raises(ParserError) { JSON.parse('[] 1') }
- assert_raises(ParserError) { JSON.parse('[] []') }
- assert_raises(ParserError) { JSON.parse('[] {}') }
- assert_raises(ParserError) { JSON.parse('{} []') }
- assert_raises(ParserError) { JSON.parse('{} {}') }
- assert_raises(ParserError) { JSON.parse('[NULL]') }
- assert_raises(ParserError) { JSON.parse('[FALSE]') }
- assert_raises(ParserError) { JSON.parse('[TRUE]') }
- assert_raises(ParserError) { JSON.parse('[07] ') }
- assert_raises(ParserError) { JSON.parse('[0a]') }
- assert_raises(ParserError) { JSON.parse('[1.]') }
- assert_raises(ParserError) { JSON.parse(' ') }
+ assert_raise(ParserError) { JSON.parse('"foo"') }
+ assert_raise(ParserError) { JSON.parse('123') }
+ assert_raise(ParserError) { JSON.parse('[] bla') }
+ assert_raise(ParserError) { JSON.parse('[] 1') }
+ assert_raise(ParserError) { JSON.parse('[] []') }
+ assert_raise(ParserError) { JSON.parse('[] {}') }
+ assert_raise(ParserError) { JSON.parse('{} []') }
+ assert_raise(ParserError) { JSON.parse('{} {}') }
+ assert_raise(ParserError) { JSON.parse('[NULL]') }
+ assert_raise(ParserError) { JSON.parse('[FALSE]') }
+ assert_raise(ParserError) { JSON.parse('[TRUE]') }
+ assert_raise(ParserError) { JSON.parse('[07] ') }
+ assert_raise(ParserError) { JSON.parse('[0a]') }
+ assert_raise(ParserError) { JSON.parse('[1.]') }
+ assert_raise(ParserError) { JSON.parse(' ') }
end
def test_nesting
- assert_raises(JSON::NestingError) { JSON.parse '[[]]', :max_nesting => 1 }
- assert_raises(JSON::NestingError) { JSON.parser.new('[[]]', :max_nesting => 1).parse }
+ assert_raise(JSON::NestingError) { JSON.parse '[[]]', :max_nesting => 1 }
+ assert_raise(JSON::NestingError) { JSON.parser.new('[[]]', :max_nesting => 1).parse }
assert_equal [[]], JSON.parse('[[]]', :max_nesting => 2)
too_deep = '[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]'
too_deep_ary = eval too_deep
- assert_raises(JSON::NestingError) { JSON.parse too_deep }
- assert_raises(JSON::NestingError) { JSON.parser.new(too_deep).parse }
- assert_raises(JSON::NestingError) { JSON.parse too_deep, :max_nesting => 19 }
+ assert_raise(JSON::NestingError) { JSON.parse too_deep }
+ assert_raise(JSON::NestingError) { JSON.parser.new(too_deep).parse }
+ assert_raise(JSON::NestingError) { JSON.parse too_deep, :max_nesting => 19 }
ok = JSON.parse too_deep, :max_nesting => 20
assert_equal too_deep_ary, ok
ok = JSON.parse too_deep, :max_nesting => nil
@@ -260,10 +260,10 @@ EOT
assert_equal too_deep_ary, ok
ok = JSON.parse too_deep, :max_nesting => 0
assert_equal too_deep_ary, ok
- assert_raises(JSON::NestingError) { JSON.generate [[]], :max_nesting => 1 }
+ assert_raise(JSON::NestingError) { JSON.generate [[]], :max_nesting => 1 }
assert_equal '[[]]', JSON.generate([[]], :max_nesting => 2)
- assert_raises(JSON::NestingError) { JSON.generate too_deep_ary }
- assert_raises(JSON::NestingError) { JSON.generate too_deep_ary, :max_nesting => 19 }
+ assert_raise(JSON::NestingError) { JSON.generate too_deep_ary }
+ assert_raise(JSON::NestingError) { JSON.generate too_deep_ary, :max_nesting => 19 }
ok = JSON.generate too_deep_ary, :max_nesting => 20
assert_equal too_deep, ok
ok = JSON.generate too_deep_ary, :max_nesting => nil
@@ -278,8 +278,8 @@ EOT
too_deep = '[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]'
assert_equal too_deep, JSON.dump(eval(too_deep))
assert_kind_of String, Marshal.dump(eval(too_deep))
- assert_raises(ArgumentError) { JSON.dump(eval(too_deep), 19) }
- assert_raises(ArgumentError) { Marshal.dump(eval(too_deep), 19) }
+ assert_raise(ArgumentError) { JSON.dump(eval(too_deep), 19) }
+ assert_raise(ArgumentError) { Marshal.dump(eval(too_deep), 19) }
assert_equal too_deep, JSON.dump(eval(too_deep), 20)
assert_kind_of String, Marshal.dump(eval(too_deep), 20)
output = StringIO.new
diff --git a/test/json/test_json_addition.rb b/test/json/test_json_addition.rb
index cf8a92a..95b6166 100755
--- a/test/json/test_json_addition.rb
+++ b/test/json/test_json_addition.rb
@@ -89,7 +89,7 @@ class TC_JSONAddition < Test::Unit::TestCase
c = C.new
assert !C.json_creatable?
json = generate(c)
- assert_raises(ArgumentError) { JSON.parse(json) }
+ assert_raise(ArgumentError) { JSON.parse(json) }
end
def test_raw_strings
@@ -129,7 +129,7 @@ EOT
assert_equal s, JSON(JSON(s))
struct = Struct.new :foo, :bar
s = struct.new 4711, 'foot'
- assert_raises(JSONError) { JSON(s) }
+ assert_raise(JSONError) { JSON(s) }
begin
raise TypeError, "test me"
rescue TypeError => e
diff --git a/test/json/test_json_fixtures.rb b/test/json/test_json_fixtures.rb
index 33573cd..6cc1bfc 100755
--- a/test/json/test_json_fixtures.rb
+++ b/test/json/test_json_fixtures.rb
@@ -20,7 +20,7 @@ class TC_JSONFixtures < Test::Unit::TestCase
def test_failing
for name, source in @failed
- assert_raises(JSON::ParserError, JSON::NestingError,
+ assert_raise(JSON::ParserError, JSON::NestingError,
"Did not fail for fixture '#{name}'") do
JSON.parse(source)
end
diff --git a/test/json/test_json_generate.rb b/test/json/test_json_generate.rb
index b7e0bc2..8c55a40 100644
--- a/test/json/test_json_generate.rb
+++ b/test/json/test_json_generate.rb
@@ -70,30 +70,30 @@ EOT
#assert s.check_circular
h = { 1=>2 }
h[3] = h
- assert_raises(JSON::CircularDatastructure) { generate(h) }
- assert_raises(JSON::CircularDatastructure) { generate(h, s) }
+ assert_raise(JSON::CircularDatastructure) { generate(h) }
+ assert_raise(JSON::CircularDatastructure) { generate(h, s) }
s = JSON.state.new(:check_circular => true)
#assert s.check_circular
a = [ 1, 2 ]
a << a
- assert_raises(JSON::CircularDatastructure) { generate(a, s) }
+ assert_raise(JSON::CircularDatastructure) { generate(a, s) }
end
def test_allow_nan
- assert_raises(GeneratorError) { generate([JSON::NaN]) }
+ assert_raise(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_raise(GeneratorError) { pretty_generate([JSON::NaN]) }
assert_equal "[\n NaN\n]", pretty_generate([JSON::NaN], :allow_nan => true)
- assert_raises(GeneratorError) { generate([JSON::Infinity]) }
+ assert_raise(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_raise(GeneratorError) { pretty_generate([JSON::Infinity]) }
assert_equal "[\n Infinity\n]", pretty_generate([JSON::Infinity], :allow_nan => true)
- assert_raises(GeneratorError) { generate([JSON::MinusInfinity]) }
+ assert_raise(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_raise(GeneratorError) { pretty_generate([JSON::MinusInfinity]) }
assert_equal "[\n -Infinity\n]", pretty_generate([JSON::MinusInfinity], :allow_nan => true)
end
end
diff --git a/test/json/test_json_rails.rb b/test/json/test_json_rails.rb
index c0447dd..52dc29f 100644
--- a/test/json/test_json_rails.rb
+++ b/test/json/test_json_rails.rb
@@ -85,7 +85,7 @@ class TC_JSONRails < Test::Unit::TestCase
c = C.new # with rails addition all objects are theoretically creatable
assert C.json_creatable?
json = generate(c)
- assert_raises(ArgumentError) { JSON.parse(json) }
+ assert_raise(ArgumentError) { JSON.parse(json) }
end
def test_raw_strings
diff --git a/test/json/test_json_unicode.rb b/test/json/test_json_unicode.rb
index 862c6ea..b8a37c8 100755
--- a/test/json/test_json_unicode.rb
+++ b/test/json/test_json_unicode.rb
@@ -50,7 +50,7 @@ class TC_JSONUnicode < Test::Unit::TestCase
assert_equal json, JSON.generate(["" << i])
end
end
- assert_raises(JSON::GeneratorError) do
+ assert_raise(JSON::GeneratorError) do
JSON.generate(["\x80"])
end
assert_equal "\302\200", JSON.parse('["\u0080"]').first