diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | test/json/json_addition_test.rb (renamed from test/json/test_json_addition.rb) | 10 | ||||
-rw-r--r-- | test/json/json_common_interface_test.rb (renamed from test/json/test_json_common_interface.rb) | 10 | ||||
-rw-r--r-- | test/json/json_encoding_test.rb (renamed from test/json/test_json_encoding.rb) | 4 | ||||
-rw-r--r-- | test/json/json_ext_parser_test.rb | 15 | ||||
-rw-r--r-- | test/json/json_fixtures_test.rb (renamed from test/json/test_json_fixtures.rb) | 4 | ||||
-rw-r--r-- | test/json/json_generator_test.rb (renamed from test/json/test_json_generator.rb) | 15 | ||||
-rw-r--r-- | test/json/json_generic_object_test.rb (renamed from test/json/test_json_generic_object.rb) | 4 | ||||
-rw-r--r-- | test/json/json_parser_test.rb (renamed from test/json/test_json_parser.rb) | 2 | ||||
-rw-r--r-- | test/json/json_string_matching_test.rb (renamed from test/json/test_json_string_matching.rb) | 4 | ||||
-rw-r--r-- | test/json/test_helper.rb | 1 | ||||
-rw-r--r-- | test/json/test_json_ext_parser.rb | 28 | ||||
-rw-r--r-- | test/lib/test/unit.rb | 3 |
13 files changed, 43 insertions, 63 deletions
@@ -1,3 +1,9 @@ +Wed Jul 13 22:14:23 2016 SHIBATA Hiroshi <[email protected]> + + * 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 <[email protected]> * enc/iso_8859_9.c, test/ruby/enc/test_case_comprehensive.rb: diff --git a/test/json/test_json_addition.rb b/test/json/json_addition_test.rb index 7a49d62d73..a028e0f08a 100644 --- a/test/json/test_json_addition.rb +++ b/test/json/json_addition_test.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 diff --git a/test/json/test_json_common_interface.rb b/test/json/json_common_interface_test.rb index 3b222b35e0..b2051d4c50 100644 --- a/test/json/test_json_common_interface.rb +++ b/test/json/json_common_interface_test.rb @@ -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 diff --git a/test/json/test_json_encoding.rb b/test/json/json_encoding_test.rb index ede6402842..29ae02e563 100644 --- a/test/json/test_json_encoding.rb +++ b/test/json/json_encoding_test.rb @@ -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 diff --git a/test/json/json_ext_parser_test.rb b/test/json/json_ext_parser_test.rb new file mode 100644 index 0000000000..c5a030ea8a --- /dev/null +++ b/test/json/json_ext_parser_test.rb @@ -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 diff --git a/test/json/test_json_fixtures.rb b/test/json/json_fixtures_test.rb index 59bcb12637..01954fe707 100644 --- a/test/json/test_json_fixtures.rb +++ b/test/json/json_fixtures_test.rb @@ -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'] } diff --git a/test/json/test_json_generator.rb b/test/json/json_generator_test.rb index 05235b39db..18b08337f8 100644 --- a/test/json/test_json_generator.rb +++ b/test/json/json_generator_test.rb @@ -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 diff --git a/test/json/test_json_generic_object.rb b/test/json/json_generic_object_test.rb index a3fd6b860a..82742dcd63 100644 --- a/test/json/test_json_generic_object.rb +++ b/test/json/json_generic_object_test.rb @@ -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 diff --git a/test/json/test_json_parser.rb b/test/json/json_parser_test.rb index 98193bfbf7..c1c2779b96 100644 --- a/test/json/test_json_parser.rb +++ b/test/json/json_parser_test.rb @@ -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 diff --git a/test/json/test_json_string_matching.rb b/test/json/json_string_matching_test.rb index 530e3644fa..5d55dc31b0 100644 --- a/test/json/test_json_string_matching.rb +++ b/test/json/json_string_matching_test.rb @@ -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 diff --git a/test/json/test_helper.rb b/test/json/test_helper.rb index 69edb627e8..7e99c29d0d 100644 --- a/test/json/test_helper.rb +++ b/test/json/test_helper.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: false case ENV['JSON'] when 'pure' $:.unshift 'lib' diff --git a/test/json/test_json_ext_parser.rb b/test/json/test_json_ext_parser.rb deleted file mode 100644 index 5cd12f0dcb..0000000000 --- a/test/json/test_json_ext_parser.rb +++ /dev/null @@ -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 diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb index d34e11afa7..dfbccc055c 100644 --- a/test/lib/test/unit.rb +++ b/test/lib/test/unit.rb @@ -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 |