* test/lib/test/unit.rb: added test files with `_test` suffix for json

upstream.
* test/json: merge original test files from json upstream.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2016-07-13 13:27:07 +00:00
Родитель 2ac58e6891
Коммит a7b5d45466
13 изменённых файлов: 43 добавлений и 63 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Wed Jul 13 22:14:23 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* test/lib/test/unit.rb: added test files with `_test` suffix for json
upstream.
* test/json: merge original test files from json upstream.
Wed Jul 13 18:09:42 2016 Martin Duerst <duerst@it.aoyama.ac.jp> Wed Jul 13 18:09:42 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* enc/iso_8859_9.c, test/ruby/enc/test_case_comprehensive.rb: * enc/iso_8859_9.c, test/ruby/enc/test_case_comprehensive.rb:

Просмотреть файл

@ -1,4 +1,4 @@
# frozen_string_literal: false #frozen_string_literal: false
require 'test_helper' require 'test_helper'
require 'json/add/core' require 'json/add/core'
require 'json/add/complex' require 'json/add/complex'
@ -7,7 +7,7 @@ require 'json/add/bigdecimal'
require 'json/add/ostruct' require 'json/add/ostruct'
require 'date' require 'date'
class TestJSONAddition < Test::Unit::TestCase class JSONAdditionTest < Test::Unit::TestCase
include JSON include JSON
class A class A
@ -61,7 +61,7 @@ class TestJSONAddition < Test::Unit::TestCase
def to_json(*args) def to_json(*args)
{ {
'json_class' => 'TestJSONAddition::Nix', 'json_class' => 'JSONAdditionTest::Nix',
}.to_json(*args) }.to_json(*args)
end end
end end
@ -93,7 +93,7 @@ class TestJSONAddition < Test::Unit::TestCase
a_hash = parse(json, :create_additions => false) a_hash = parse(json, :create_additions => false)
assert_kind_of Hash, a_hash assert_kind_of Hash, a_hash
assert_equal( assert_equal(
{"args"=>[666], "json_class"=>"TestJSONAddition::A"}.sort_by { |k,| k }, {"args"=>[666], "json_class"=>"JSONAdditionTest::A"}.sort_by { |k,| k },
a_hash.sort_by { |k,| k } a_hash.sort_by { |k,| k }
) )
end end
@ -102,7 +102,7 @@ class TestJSONAddition < Test::Unit::TestCase
b = B.new b = B.new
assert !B.json_creatable? assert !B.json_creatable?
json = generate(b) json = generate(b)
assert_equal({ "json_class"=>"TestJSONAddition::B" }, parse(json)) assert_equal({ "json_class"=>"JSONAdditionTest::B" }, parse(json))
end end
def test_extended_json_fail2 def test_extended_json_fail2

Просмотреть файл

@ -1,9 +1,9 @@
# frozen_string_literal: false #frozen_string_literal: false
require 'test_helper' require 'test_helper'
require 'stringio' require 'stringio'
require 'tempfile' require 'tempfile'
class TestJSONCommonInterface < Test::Unit::TestCase class JSONCommonInterfaceTest < Test::Unit::TestCase
include JSON include JSON
def setup def setup
@ -47,7 +47,7 @@ class TestJSONCommonInterface < Test::Unit::TestCase
end end
def test_deep_const_get def test_deep_const_get
assert_raise(ArgumentError) { JSON.deep_const_get('Nix::Da') } assert_raises(ArgumentError) { JSON.deep_const_get('Nix::Da') }
assert_equal File::SEPARATOR, JSON.deep_const_get('File::SEPARATOR') assert_equal File::SEPARATOR, JSON.deep_const_get('File::SEPARATOR')
end end
@ -93,8 +93,8 @@ class TestJSONCommonInterface < Test::Unit::TestCase
def test_load_null def test_load_null
assert_equal nil, JSON.load(nil, nil, :allow_blank => true) assert_equal nil, JSON.load(nil, nil, :allow_blank => true)
assert_raise(TypeError) { JSON.load(nil, nil, :allow_blank => false) } assert_raises(TypeError) { JSON.load(nil, nil, :allow_blank => false) }
assert_raise(JSON::ParserError) { JSON.load('', nil, :allow_blank => false) } assert_raises(JSON::ParserError) { JSON.load('', nil, :allow_blank => false) }
end end
def test_dump def test_dump

Просмотреть файл

@ -1,8 +1,8 @@
# encoding: utf-8 # encoding: utf-8
# frozen_string_literal: false #frozen_string_literal: false
require 'test_helper' require 'test_helper'
class TestJSONEncoding < Test::Unit::TestCase class JSONEncodingTest < Test::Unit::TestCase
include JSON include JSON
def setup def setup

Просмотреть файл

@ -0,0 +1,15 @@
#frozen_string_literal: false
require 'test_helper'
class JSONExtParserTest < Test::Unit::TestCase
if defined?(JSON::Ext::Parser)
def test_allocate
parser = JSON::Ext::Parser.new("{}")
assert_raise(TypeError, '[ruby-core:35079]') do
parser.__send__(:initialize, "{}")
end
parser = JSON::Ext::Parser.allocate
assert_raise(TypeError, '[ruby-core:35079]') { parser.source }
end
end
end

Просмотреть файл

@ -1,7 +1,7 @@
# frozen_string_literal: false #frozen_string_literal: false
require 'test_helper' require 'test_helper'
class TestJSONFixtures < Test::Unit::TestCase class JSONFixturesTest < Test::Unit::TestCase
def setup def setup
fixtures = File.join(File.dirname(__FILE__), 'fixtures/{fail,pass}.json') fixtures = File.join(File.dirname(__FILE__), 'fixtures/{fail,pass}.json')
passed, failed = Dir[fixtures].partition { |f| f['pass'] } passed, failed = Dir[fixtures].partition { |f| f['pass'] }

Просмотреть файл

@ -4,7 +4,7 @@
require 'test_helper' require 'test_helper'
class TestJSONGenerator < Test::Unit::TestCase class JSONGeneratorTest < Test::Unit::TestCase
include JSON include JSON
def setup def setup
@ -373,17 +373,4 @@ EOT
assert_equal '["foo"]', JSON.generate([s.new('foo')]) assert_equal '["foo"]', JSON.generate([s.new('foo')])
end end
end end
if EnvUtil.gc_stress_to_class?
def assert_no_memory_leak(code, *rest, **opt)
code = "8.times {20_000.times {begin #{code}; rescue NoMemoryError; end}; GC.start}"
super(["-rjson/ext/generator"],
"GC.add_stress_to_class(JSON::Ext::Generator::State); "\
"#{code}", code, *rest, rss: true, limit: 1.1, **opt)
end
def test_no_memory_leak_allocate
assert_no_memory_leak("JSON::Ext::Generator::State.allocate")
end
end
end end

Просмотреть файл

@ -1,7 +1,7 @@
# frozen_string_literal: false #frozen_string_literal: false
require 'test_helper' require 'test_helper'
class TestJSONGenericObject < Test::Unit::TestCase class JSONGenericObjectTest < Test::Unit::TestCase
include JSON include JSON
def setup def setup

Просмотреть файл

@ -5,7 +5,7 @@ require 'stringio'
require 'tempfile' require 'tempfile'
require 'ostruct' require 'ostruct'
class TestJSONParser < Test::Unit::TestCase class JSONParserTest < Test::Unit::TestCase
include JSON include JSON
def test_construction def test_construction

Просмотреть файл

@ -1,8 +1,8 @@
# frozen_string_literal: false #frozen_string_literal: false
require 'test_helper' require 'test_helper'
require 'time' require 'time'
class TestJSONStringMatching < Test::Unit::TestCase class JSONStringMatchingTest < Test::Unit::TestCase
include JSON include JSON
class TestTime < ::Time class TestTime < ::Time

Просмотреть файл

@ -1,4 +1,3 @@
# frozen_string_literal: false
case ENV['JSON'] case ENV['JSON']
when 'pure' when 'pure'
$:.unshift 'lib' $:.unshift 'lib'

Просмотреть файл

@ -1,28 +0,0 @@
# frozen_string_literal: false
require 'test_helper'
class TestJSONExtParser < Test::Unit::TestCase
if defined?(JSON::Ext::Parser)
def test_allocate
parser = JSON::Ext::Parser.new("{}")
assert_raise(TypeError, '[ruby-core:35079]') do
parser.__send__(:initialize, "{}")
end
parser = JSON::Ext::Parser.allocate
assert_raise(TypeError, '[ruby-core:35079]') { parser.source }
end
end
if EnvUtil.gc_stress_to_class?
def assert_no_memory_leak(code, *rest, **opt)
code = "8.times {20_000.times {begin #{code}; rescue NoMemoryError; end}; GC.start}"
super(["-rjson/ext/parser"],
"GC.add_stress_to_class(JSON::Ext::Parser); "\
"#{code}", code, *rest, rss: true, limit: 1.1, **opt)
end
def test_no_memory_leak_allocate
assert_no_memory_leak("JSON::Ext::Parser.allocate")
end
end
end

Просмотреть файл

@ -756,6 +756,7 @@ module Test
module GlobOption # :nodoc: all module GlobOption # :nodoc: all
@@testfile_prefix = "test" @@testfile_prefix = "test"
@@testfile_suffix = "test"
def setup_options(parser, options) def setup_options(parser, options)
super super
@ -782,7 +783,7 @@ module Test
next if f.empty? next if f.empty?
path = f path = f
end end
if !(match = Dir["#{path}/**/#{@@testfile_prefix}_*.rb"]).empty? if !(match = (Dir["#{path}/**/#{@@testfile_prefix}_*.rb"] + Dir["#{path}/**/*_#{@@testfile_suffix}.rb"]).uniq).empty?
if reject if reject
match.reject! {|n| match.reject! {|n|
n[(prefix.length+1)..-1] if prefix n[(prefix.length+1)..-1] if prefix