зеркало из https://github.com/github/ruby.git
* 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:
Родитель
2ac58e6891
Коммит
a7b5d45466
|
@ -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>
|
||||
|
||||
* 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 'json/add/core'
|
||||
require 'json/add/complex'
|
||||
|
@ -7,7 +7,7 @@ require 'json/add/bigdecimal'
|
|||
require 'json/add/ostruct'
|
||||
require 'date'
|
||||
|
||||
class TestJSONAddition < Test::Unit::TestCase
|
||||
class JSONAdditionTest < Test::Unit::TestCase
|
||||
include JSON
|
||||
|
||||
class A
|
||||
|
@ -61,7 +61,7 @@ class TestJSONAddition < Test::Unit::TestCase
|
|||
|
||||
def to_json(*args)
|
||||
{
|
||||
'json_class' => 'TestJSONAddition::Nix',
|
||||
'json_class' => 'JSONAdditionTest::Nix',
|
||||
}.to_json(*args)
|
||||
end
|
||||
end
|
||||
|
@ -93,7 +93,7 @@ class TestJSONAddition < Test::Unit::TestCase
|
|||
a_hash = parse(json, :create_additions => false)
|
||||
assert_kind_of Hash, a_hash
|
||||
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 }
|
||||
)
|
||||
end
|
||||
|
@ -102,7 +102,7 @@ class TestJSONAddition < Test::Unit::TestCase
|
|||
b = B.new
|
||||
assert !B.json_creatable?
|
||||
json = generate(b)
|
||||
assert_equal({ "json_class"=>"TestJSONAddition::B" }, parse(json))
|
||||
assert_equal({ "json_class"=>"JSONAdditionTest::B" }, parse(json))
|
||||
end
|
||||
|
||||
def test_extended_json_fail2
|
|
@ -1,9 +1,9 @@
|
|||
# frozen_string_literal: false
|
||||
#frozen_string_literal: false
|
||||
require 'test_helper'
|
||||
require 'stringio'
|
||||
require 'tempfile'
|
||||
|
||||
class TestJSONCommonInterface < Test::Unit::TestCase
|
||||
class JSONCommonInterfaceTest < Test::Unit::TestCase
|
||||
include JSON
|
||||
|
||||
def setup
|
||||
|
@ -47,7 +47,7 @@ class TestJSONCommonInterface < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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')
|
||||
end
|
||||
|
||||
|
@ -93,8 +93,8 @@ class TestJSONCommonInterface < Test::Unit::TestCase
|
|||
|
||||
def test_load_null
|
||||
assert_equal nil, JSON.load(nil, nil, :allow_blank => true)
|
||||
assert_raise(TypeError) { JSON.load(nil, nil, :allow_blank => false) }
|
||||
assert_raise(JSON::ParserError) { JSON.load('', nil, :allow_blank => false) }
|
||||
assert_raises(TypeError) { JSON.load(nil, nil, :allow_blank => false) }
|
||||
assert_raises(JSON::ParserError) { JSON.load('', nil, :allow_blank => false) }
|
||||
end
|
||||
|
||||
def test_dump
|
|
@ -1,8 +1,8 @@
|
|||
# encoding: utf-8
|
||||
# frozen_string_literal: false
|
||||
#frozen_string_literal: false
|
||||
require 'test_helper'
|
||||
|
||||
class TestJSONEncoding < Test::Unit::TestCase
|
||||
class JSONEncodingTest < Test::Unit::TestCase
|
||||
include JSON
|
||||
|
||||
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'
|
||||
|
||||
class TestJSONFixtures < Test::Unit::TestCase
|
||||
class JSONFixturesTest < Test::Unit::TestCase
|
||||
def setup
|
||||
fixtures = File.join(File.dirname(__FILE__), 'fixtures/{fail,pass}.json')
|
||||
passed, failed = Dir[fixtures].partition { |f| f['pass'] }
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
require 'test_helper'
|
||||
|
||||
class TestJSONGenerator < Test::Unit::TestCase
|
||||
class JSONGeneratorTest < Test::Unit::TestCase
|
||||
include JSON
|
||||
|
||||
def setup
|
||||
|
@ -373,17 +373,4 @@ EOT
|
|||
assert_equal '["foo"]', JSON.generate([s.new('foo')])
|
||||
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
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: false
|
||||
#frozen_string_literal: false
|
||||
require 'test_helper'
|
||||
|
||||
class TestJSONGenericObject < Test::Unit::TestCase
|
||||
class JSONGenericObjectTest < Test::Unit::TestCase
|
||||
include JSON
|
||||
|
||||
def setup
|
|
@ -5,7 +5,7 @@ require 'stringio'
|
|||
require 'tempfile'
|
||||
require 'ostruct'
|
||||
|
||||
class TestJSONParser < Test::Unit::TestCase
|
||||
class JSONParserTest < Test::Unit::TestCase
|
||||
include JSON
|
||||
|
||||
def test_construction
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: false
|
||||
#frozen_string_literal: false
|
||||
require 'test_helper'
|
||||
require 'time'
|
||||
|
||||
class TestJSONStringMatching < Test::Unit::TestCase
|
||||
class JSONStringMatchingTest < Test::Unit::TestCase
|
||||
include JSON
|
||||
|
||||
class TestTime < ::Time
|
|
@ -1,4 +1,3 @@
|
|||
# frozen_string_literal: false
|
||||
case ENV['JSON']
|
||||
when 'pure'
|
||||
$:.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
|
||||
@@testfile_prefix = "test"
|
||||
@@testfile_suffix = "test"
|
||||
|
||||
def setup_options(parser, options)
|
||||
super
|
||||
|
@ -782,7 +783,7 @@ module Test
|
|||
next if f.empty?
|
||||
path = f
|
||||
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
|
||||
match.reject! {|n|
|
||||
n[(prefix.length+1)..-1] if prefix
|
||||
|
|
Загрузка…
Ссылка в новой задаче