From d99ac4f829dd0903f20e02de5dbba0ddc175c1f3 Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 1 Sep 2009 17:34:50 +0000 Subject: Add tests of JSON 1.1.9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/json/test_json_addition.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'test/json/test_json_addition.rb') diff --git a/test/json/test_json_addition.rb b/test/json/test_json_addition.rb index 2650db68f0..51e4a67f33 100755 --- a/test/json/test_json_addition.rb +++ b/test/json/test_json_addition.rb @@ -1,6 +1,12 @@ #!/usr/bin/env ruby +# -*- coding:utf-8 -*- require 'test/unit' +case ENV['JSON'] +when 'pure' then require 'json/pure' +when 'ext' then require 'json/ext' +else require 'json' +end require 'json/add/core' require 'date' @@ -17,7 +23,7 @@ class TC_JSONAddition < Test::Unit::TestCase def ==(other) a == other.a end - + def self.json_create(object) new(*object['args']) end @@ -89,11 +95,12 @@ class TC_JSONAddition < Test::Unit::TestCase c = C.new assert !C.json_creatable? json = generate(c) - assert_raise(ArgumentError) { JSON.parse(json) } + assert_raises(ArgumentError) { JSON.parse(json) } end def test_raw_strings raw = '' + raw.respond_to?(:encode!) and raw.encode!(Encoding::ASCII_8BIT) raw_array = [] for i in 0..255 raw << i @@ -129,7 +136,7 @@ EOT assert_equal s, JSON(JSON(s)) struct = Struct.new :foo, :bar s = struct.new 4711, 'foot' - assert_raise(JSONError) { JSON(s) } + assert_raises(JSONError) { JSON(s) } begin raise TypeError, "test me" rescue TypeError => e -- cgit v1.2.3