Avoid defining the same test class in multiple files

Should fix issues with parallel testing sometimes not running all
tests.

This should be viewed skipping whitespace changes.

Fixes [Bug #18731]
This commit is contained in:
Jeremy Evans 2022-04-22 13:01:43 -07:00
parent c2d38a0d2d
commit ab3cb29bd9
Notes: git 2022-04-23 07:00:43 +09:00
47 changed files with 1282 additions and 1358 deletions

View File

@ -2,8 +2,7 @@
require 'test/unit' require 'test/unit'
require "-test-/bignum" require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase class TestBignum_Big2str < Test::Unit::TestCase
class TestBig2str < Test::Unit::TestCase
SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT
BITSPERDIG = Bug::Bignum::BITSPERDIG BITSPERDIG = Bug::Bignum::BITSPERDIG
@ -27,4 +26,3 @@ class Test_Bignum < Test::Unit::TestCase
end end
end end
end

View File

@ -2,8 +2,7 @@
require 'test/unit' require 'test/unit'
require "-test-/bignum" require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase class TestBignum_BigZero < Test::Unit::TestCase
class TestBigZero < Test::Unit::TestCase
def test_equal_0 def test_equal_0
bug8204 = '[ruby-core:53893] [Bug #8204]' bug8204 = '[ruby-core:53893] [Bug #8204]'
(0..10).each do |i| (0..10).each do |i|
@ -17,4 +16,3 @@ class Test_Bignum < Test::Unit::TestCase
end end
end end
end end
end

View File

@ -2,8 +2,7 @@
require 'test/unit' require 'test/unit'
require "-test-/bignum" require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase class TestBignum_Div < Test::Unit::TestCase
class TestDiv < Test::Unit::TestCase
SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT
BITSPERDIG = Bug::Bignum::BITSPERDIG BITSPERDIG = Bug::Bignum::BITSPERDIG
@ -26,4 +25,3 @@ class Test_Bignum < Test::Unit::TestCase
rescue NotImplementedError rescue NotImplementedError
end end
end end
end

View File

@ -2,8 +2,7 @@
require 'test/unit' require 'test/unit'
require "-test-/bignum" require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase class TestBignum_Mul < Test::Unit::TestCase
class TestMul < Test::Unit::TestCase
SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT
BITSPERDIG = Bug::Bignum::BITSPERDIG BITSPERDIG = Bug::Bignum::BITSPERDIG
@ -135,4 +134,3 @@ class Test_Bignum < Test::Unit::TestCase
end end
end end
end

View File

@ -4,8 +4,7 @@
require 'test/unit' require 'test/unit'
require "-test-/bignum" require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase class TestBignum_Pack < Test::Unit::TestCase
class TestPack < Test::Unit::TestCase
MSWORD_FIRST = Bug::Bignum::INTEGER_PACK_MSWORD_FIRST MSWORD_FIRST = Bug::Bignum::INTEGER_PACK_MSWORD_FIRST
LSWORD_FIRST = Bug::Bignum::INTEGER_PACK_LSWORD_FIRST LSWORD_FIRST = Bug::Bignum::INTEGER_PACK_LSWORD_FIRST
@ -346,7 +345,6 @@ class Test_Bignum < Test::Unit::TestCase
"Bug::Bignum.test_unpack(#{str.dump}, #{n}, 1, 0, #{'%#x' % flags})") "Bug::Bignum.test_unpack(#{str.dump}, #{n}, 1, 0, #{'%#x' % flags})")
} }
end end
end
def test_numbits_2comp def test_numbits_2comp
assert_equal(4, Bug::Bignum.test_numbits_2comp_without_sign(-9)) assert_equal(4, Bug::Bignum.test_numbits_2comp_without_sign(-9))
@ -395,5 +393,4 @@ class Test_Bignum < Test::Unit::TestCase
assert_equal(5, Bug::Bignum.test_numbytes_2comp_with_sign(0x7fffffffff)) assert_equal(5, Bug::Bignum.test_numbytes_2comp_with_sign(0x7fffffffff))
assert_equal(6, Bug::Bignum.test_numbytes_2comp_with_sign(0x8000000000)) assert_equal(6, Bug::Bignum.test_numbytes_2comp_with_sign(0x8000000000))
end end
end end

View File

@ -2,8 +2,7 @@
require 'test/unit' require 'test/unit'
require "-test-/bignum" require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase class TestBignum_Str2big < Test::Unit::TestCase
class TestStr2big < Test::Unit::TestCase
SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT
BITSPERDIG = Bug::Bignum::BITSPERDIG BITSPERDIG = Bug::Bignum::BITSPERDIG
@ -35,4 +34,3 @@ class Test_Bignum < Test::Unit::TestCase
end end
end end
end

View File

@ -1,11 +0,0 @@
# frozen_string_literal: true
require 'test/unit'
class TestFuncall < Test::Unit::TestCase
require '-test-/funcall'
def test_funcall_extra_args
assert_equal 'TestFuncall', TestFuncall.extra_args_name,
'[ruby-core:85266] [Bug #14425]'
end
end

View File

@ -9,6 +9,11 @@ class TestFuncall < Test::Unit::TestCase
end end
require '-test-/funcall' require '-test-/funcall'
def test_funcall_extra_args
assert_equal 'TestFuncall', TestFuncall.extra_args_name,
'[ruby-core:85266] [Bug #14425]'
end
def test_with_funcall2 def test_with_funcall2
ok = nil ok = nil
Relay.with_funcall2("feature#4504") {|arg| ok = arg || true} Relay.with_funcall2("feature#4504") {|arg| ok = arg || true}

View File

@ -2,7 +2,7 @@
require 'test/unit' require 'test/unit'
require 'date' require 'date'
class TestDateParse < Test::Unit::TestCase class TestDateParseRactor < Test::Unit::TestCase
def code(klass = Date, share: false) def code(klass = Date, share: false)
<<~RUBY.gsub('Date', klass.name) <<~RUBY.gsub('Date', klass.name)
share = #{share} share = #{share}

View File

@ -4,10 +4,7 @@ require 'test/unit'
require 'tmpdir' require 'tmpdir'
require_relative 'fileasserts' require_relative 'fileasserts'
class TestFileUtils < Test::Unit::TestCase module TestFileUtilsClobber
end
module TestFileUtils::Clobber
include Test::Unit::FileAssertions include Test::Unit::FileAssertions
def my_rm_rf(path) def my_rm_rf(path)

View File

@ -8,7 +8,7 @@ require_relative 'visibility_tests'
class TestFileUtilsDryRun < Test::Unit::TestCase class TestFileUtilsDryRun < Test::Unit::TestCase
include FileUtils::DryRun include FileUtils::DryRun
include TestFileUtilsInc::Visibility include TestFileUtilsIncVisibility
def setup def setup
super super

View File

@ -8,7 +8,7 @@ require_relative 'visibility_tests'
class TestFileUtilsNoWrite < Test::Unit::TestCase class TestFileUtilsNoWrite < Test::Unit::TestCase
include FileUtils::NoWrite include FileUtils::NoWrite
include TestFileUtilsInc::Visibility include TestFileUtilsIncVisibility
def setup def setup
super super

View File

@ -8,7 +8,7 @@ require_relative 'visibility_tests'
class TestFileUtilsVerbose < Test::Unit::TestCase class TestFileUtilsVerbose < Test::Unit::TestCase
include FileUtils::Verbose include FileUtils::Verbose
include TestFileUtilsInc::Visibility include TestFileUtilsIncVisibility
def setup def setup
super super

View File

@ -2,14 +2,11 @@
require 'test/unit' require 'test/unit'
require 'fileutils' require 'fileutils'
class TestFileUtilsInc < Test::Unit::TestCase
end
## ##
# These tests are reused in the FileUtils::Verbose, FileUtils::NoWrite and # These tests are reused in the FileUtils::Verbose, FileUtils::NoWrite and
# FileUtils::DryRun tests # FileUtils::DryRun tests
module TestFileUtilsInc::Visibility module TestFileUtilsIncVisibility
FileUtils::METHODS.each do |m| FileUtils::METHODS.each do |m|
define_method "test_singleton_visibility_#{m}" do define_method "test_singleton_visibility_#{m}" do

View File

@ -20,9 +20,7 @@ $INCFLAGS << " -I."
$extout_prefix = "$(extout)$(target_prefix)/" $extout_prefix = "$(extout)$(target_prefix)/"
class TestMkmf < Test::Unit::TestCase class TestMkmf < Test::Unit::TestCase
end module Base
module TestMkmf::Base
MKMFLOG = proc {File.read("mkmf.log") rescue ""} MKMFLOG = proc {File.read("mkmf.log") rescue ""}
class Capture class Capture
@ -146,8 +144,7 @@ module TestMkmf::Base
end end
end end
class TestMkmf include Base
include TestMkmf::Base
def assert_separately(args, src, *rest, **options) def assert_separately(args, src, *rest, **options)
super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\nEND{teardown}\n#{src}", *rest, **options) super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\nEND{teardown}\n#{src}", *rest, **options)

View File

@ -4,8 +4,7 @@ $extmk = true
require 'test/unit' require 'test/unit'
require 'mkmf' require 'mkmf'
class TestMkmf < Test::Unit::TestCase class TestMkmfConfig < Test::Unit::TestCase
class TestConfig < Test::Unit::TestCase
def test_dir_config def test_dir_config
bug8074 = '[Bug #8074]' bug8074 = '[Bug #8074]'
lib = RbConfig.expand(RbConfig::MAKEFILE_CONFIG["libdir"], "exec_prefix"=>"") lib = RbConfig.expand(RbConfig::MAKEFILE_CONFIG["libdir"], "exec_prefix"=>"")
@ -14,4 +13,3 @@ class TestMkmf < Test::Unit::TestCase
} }
end end
end end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'base' require_relative 'base'
class TestMkmf class TestMkmfTryConstant < TestMkmf
class TestTryConstant < TestMkmf
def test_simple def test_simple
assert_equal( 0, mkmf {try_constant("0")}, MKMFLOG) assert_equal( 0, mkmf {try_constant("0")}, MKMFLOG)
assert_equal( 1, mkmf {try_constant("1")}, MKMFLOG) assert_equal( 1, mkmf {try_constant("1")}, MKMFLOG)
@ -35,4 +34,3 @@ class TestMkmf
assert_operator(mkmf {try_constant("1U<<(CHAR_BIT*sizeof(int)-1)")}, :>, 0, MKMFLOG) assert_operator(mkmf {try_constant("1U<<(CHAR_BIT*sizeof(int)-1)")}, :>, 0, MKMFLOG)
end end
end end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'base' require_relative 'base'
class TestMkmf class TestMkmfConvertible < TestMkmf
class TestConvertible < TestMkmf
def test_typeof_builtin def test_typeof_builtin
["", ["signed ", ""], "unsigned "].each do |signed, prefix| ["", ["signed ", ""], "unsigned "].each do |signed, prefix|
%w[short int long].each do |type| %w[short int long].each do |type|
@ -32,4 +31,3 @@ class TestMkmf
File.unlink("confdefs.h") File.unlink("confdefs.h")
end end
end end
end

View File

@ -2,8 +2,7 @@
require_relative 'base' require_relative 'base'
require 'tempfile' require 'tempfile'
class TestMkmf class TestMkmfEgrepCpp < TestMkmf
class TestEgrepCpp < TestMkmf
def test_egrep_cpp def test_egrep_cpp
assert_equal(true, egrep_cpp(/ruby_init/, ""), MKMFLOG) assert_equal(true, egrep_cpp(/ruby_init/, ""), MKMFLOG)
end end
@ -12,4 +11,3 @@ class TestMkmf
assert_equal(false, egrep_cpp(/never match/, ""), MKMFLOG) assert_equal(false, egrep_cpp(/never match/, ""), MKMFLOG)
end end
end end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'base' require_relative 'base'
class TestMkmf class TestMkmfFindExecutable < TestMkmf
class TestFindExecutable < TestMkmf
def setup def setup
super super
@path, ENV["PATH"] = ENV["PATH"], @tmpdir @path, ENV["PATH"] = ENV["PATH"], @tmpdir
@ -55,4 +54,3 @@ class TestMkmf
end end
end end
end end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'base' require_relative 'base'
class TestMkmf class TestMkmfFlags < TestMkmf
class TestFlags < TestMkmf
def test_valid_warnflags def test_valid_warnflags
val = $extmk val = $extmk
warnflags = $warnflags warnflags = $warnflags
@ -54,4 +53,3 @@ class TestMkmf
end; end;
end end
end end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'base' require_relative 'base'
class TestMkmf class TestMkmfHaveFramework < TestMkmf
class TestHaveFramework < TestMkmf
def create_framework(fw, hdrname = "#{fw}.h") def create_framework(fw, hdrname = "#{fw}.h")
Dir.mktmpdir("frameworks") do |dir| Dir.mktmpdir("frameworks") do |dir|
fwdir = "#{dir}/#{fw}.framework" fwdir = "#{dir}/#{fw}.framework"
@ -45,5 +44,4 @@ class TestMkmf
assert(have_framework([fw, hdrname]), MKMFLOG) assert(have_framework([fw, hdrname]), MKMFLOG)
end end
end end
end
end if /darwin/ =~ RUBY_PLATFORM end if /darwin/ =~ RUBY_PLATFORM

View File

@ -2,8 +2,7 @@
require_relative 'base' require_relative 'base'
require 'tempfile' require 'tempfile'
class TestMkmf class TestMkmfHaveFunc < TestMkmf
class TestHaveFunc < TestMkmf
def test_have_func def test_have_func
assert_equal(true, have_func("ruby_init"), MKMFLOG) assert_equal(true, have_func("ruby_init"), MKMFLOG)
assert_include($defs, '-DHAVE_RUBY_INIT') assert_include($defs, '-DHAVE_RUBY_INIT')
@ -14,4 +13,3 @@ class TestMkmf
assert_not_include($defs, '-DHAVE_RUBY_INIT') assert_not_include($defs, '-DHAVE_RUBY_INIT')
end end
end end
end

View File

@ -2,8 +2,7 @@
require_relative 'base' require_relative 'base'
require 'tempfile' require 'tempfile'
class TestMkmf class TestMkmfHaveLibrary < TestMkmf
class TestHaveLibrary < TestMkmf
LIBRARY_NAME = 'mkmftest' LIBRARY_NAME = 'mkmftest'
HEADER_NAME = "#{LIBRARY_NAME}.h" HEADER_NAME = "#{LIBRARY_NAME}.h"
FUNC_NAME = 'ruby_mkmftest_foo' FUNC_NAME = 'ruby_mkmftest_foo'
@ -53,4 +52,3 @@ class TestMkmf
assert_not_have_library("#{FUNC_NAME}_fake", HEADER_NAME) assert_not_have_library("#{FUNC_NAME}_fake", HEADER_NAME)
end end
end end
end

View File

@ -2,8 +2,7 @@
require_relative 'base' require_relative 'base'
require 'tempfile' require 'tempfile'
class TestMkmf class TestMkmfHaveMacro < TestMkmf
class TestHaveMacro < TestMkmf
MACRO_NAME = "RUBY_MKMFTEST_FOOBAR" MACRO_NAME = "RUBY_MKMFTEST_FOOBAR"
def test_have_macro_opt def test_have_macro_opt
@ -33,4 +32,3 @@ class TestMkmf
end end
end end
end end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'base' require_relative 'base'
class TestMkmf class TestMkmfInstall < TestMkmf
class TestInstall < TestMkmf
def test_install_dirs def test_install_dirs
Dir.mktmpdir do |dir| Dir.mktmpdir do |dir|
File.write(dir+"/extconf.rb", "require 'mkmf'; create_makefile('test')") File.write(dir+"/extconf.rb", "require 'mkmf'; create_makefile('test')")
@ -27,4 +26,3 @@ class TestMkmf
end end
end end
end end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'base' require_relative 'base'
class TestMkmf class TestMkmfLibs < TestMkmf
class TestLibs < TestMkmf
def test_split_libs def test_split_libs
assert_equal(%w[-lfoo -lbar], split_libs("-lfoo -lbar")) assert_equal(%w[-lfoo -lbar], split_libs("-lfoo -lbar"))
end end
@ -90,5 +89,4 @@ class TestMkmf
assert_in_order(array, "d", "c", bug7467) assert_in_order(array, "d", "c", bug7467)
assert_in_order(array, "c", "e", bug7467) assert_in_order(array, "c", "e", bug7467)
end end
end
end if RUBY_ENGINE == "ruby" end if RUBY_ENGINE == "ruby"

View File

@ -2,8 +2,7 @@
require 'test/unit' require 'test/unit'
require 'mkmf' require 'mkmf'
class TestMkmf < Test::Unit::TestCase class TestMkmfGlobal < Test::Unit::TestCase
class TestGlobal < TestMkmf
main = TOPLEVEL_BINDING.receiver main = TOPLEVEL_BINDING.receiver
MakeMakefile.public_instance_methods(false).each do |m| MakeMakefile.public_instance_methods(false).each do |m|
define_method(:"test_global_#{m}") do define_method(:"test_global_#{m}") do
@ -12,4 +11,3 @@ class TestMkmf < Test::Unit::TestCase
end end
end end
end end
end

View File

@ -2,8 +2,7 @@
require_relative 'base' require_relative 'base'
require 'shellwords' require 'shellwords'
class TestMkmf class TestMkmfPkgConfig < TestMkmf
class TestPkgConfig < TestMkmf
PKG_CONFIG = find_executable0("pkg-config") PKG_CONFIG = find_executable0("pkg-config")
def setup def setup
@ -65,4 +64,3 @@ class TestMkmf
assert_equal(expected, actual, MKMFLOG) assert_equal(expected, actual, MKMFLOG)
end end
end end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'base' require_relative 'base'
class TestMkmf class TestMkmfSignedness < TestMkmf
class TestSignedness < TestMkmf
def test_typeof_builtin def test_typeof_builtin
bug4144 = '[ruby-dev:42731]' bug4144 = '[ruby-dev:42731]'
[["", "-1"], ["signed ", "-1"], ["unsigned ", "+1"]].each do |signed, expect| [["", "-1"], ["signed ", "-1"], ["unsigned ", "+1"]].each do |signed, expect|
@ -27,4 +26,3 @@ class TestMkmf
File.unlink("confdefs.h") File.unlink("confdefs.h")
end end
end end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'base' require_relative 'base'
class TestMkmf class TestMkmfSizeof < TestMkmf
class TestSizeof < TestMkmf
def setup def setup
super super
@sizeof_short = config_value("SIZEOF_SHORT").to_i @sizeof_short = config_value("SIZEOF_SHORT").to_i
@ -45,4 +44,3 @@ class TestMkmf
File.unlink("confdefs.h") File.unlink("confdefs.h")
end end
end end
end

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'test_optparse' require_relative 'test_optparse'
class TestOptionParser::Acceptable < TestOptionParser class TestOptionParserAcceptable < TestOptionParser
def setup def setup
super super

View File

@ -2,9 +2,7 @@
require 'test/unit' require 'test/unit'
require 'optparse/ac' require 'optparse/ac'
class TestOptionParser < Test::Unit::TestCase; end class TestOptionParserAutoConf < Test::Unit::TestCase
class TestOptionParser::AutoConf < Test::Unit::TestCase
def setup def setup
@opt = OptionParser::AC.new @opt = OptionParser::AC.new
@foo = @bar = self.class @foo = @bar = self.class

View File

@ -2,9 +2,7 @@
require 'test/unit' require 'test/unit'
require 'optparse' require 'optparse'
class TestOptionParser < Test::Unit::TestCase class TestOptionParserBashCompletion < Test::Unit::TestCase
end
class TestOptionParser::BashCompletion < Test::Unit::TestCase
def setup def setup
@opt = OptionParser.new @opt = OptionParser.new
@opt.define("-z", "zzz") {} @opt.define("-z", "zzz") {}

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'test_optparse' require_relative 'test_optparse'
class TestOptionParser::CClass < TestOptionParser class TestOptionParserCClass < TestOptionParser
def test_no_argument def test_no_argument
flags = [] flags = []
@opt.def_option("-[a-z]") {|x| flags << x} @opt.def_option("-[a-z]") {|x| flags << x}

View File

@ -6,7 +6,7 @@ rescue LoadError
return return
end end
class TestOptionParser::DidYouMean < TestOptionParser class TestOptionParserDidYouMean < TestOptionParser
def setup def setup
super super
@opt.def_option("--foo", Integer) { |v| @foo = v } @opt.def_option("--foo", Integer) { |v| @foo = v }

View File

@ -2,9 +2,7 @@
require 'test/unit' require 'test/unit'
require 'optparse' require 'optparse'
class TestOptionParser < Test::Unit::TestCase class TestOptionParserGetopts < Test::Unit::TestCase
end
class TestOptionParser::Getopts < Test::Unit::TestCase
def setup def setup
@opt = OptionParser.new @opt = OptionParser.new
end end

View File

@ -3,9 +3,7 @@ require 'test/unit'
require 'optparse' require 'optparse'
require 'optparse/kwargs' require 'optparse/kwargs'
class TestOptionParser < Test::Unit::TestCase class TestOptionParserKwArg < Test::Unit::TestCase
end
class TestOptionParser::KwArg < Test::Unit::TestCase
class K class K
def initialize(host:, port: 8080) def initialize(host:, port: 8080)
@host = host @host = host

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'test_optparse' require_relative 'test_optparse'
module TestOptionParser::NoArg module TestOptionParserNoArg
def setup def setup
super super
@opt.def_option "--with_underscore" do |x| @flag = x end @opt.def_option "--with_underscore" do |x| @flag = x end
@ -9,7 +9,7 @@ module TestOptionParser::NoArg
end end
class Def1 < TestOptionParser class Def1 < TestOptionParser
include NoArg include TestOptionParserNoArg
def setup def setup
super super
@opt.def_option("-x") {|x| @flag = x} @opt.def_option("-x") {|x| @flag = x}
@ -17,7 +17,7 @@ module TestOptionParser::NoArg
end end
end end
class Def2 < TestOptionParser class Def2 < TestOptionParser
include NoArg include TestOptionParserNoArg
def setup def setup
super super
@opt.def_option("-x", "--option") {|x| @flag = x} @opt.def_option("-x", "--option") {|x| @flag = x}

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'test_optparse' require_relative 'test_optparse'
class TestOptionParser::OptArg < TestOptionParser class TestOptionParserOptArg < TestOptionParser
def setup def setup
super super
@opt.def_option("-x[VAL]") {|x| @flag = x} @opt.def_option("-x[VAL]") {|x| @flag = x}

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'test_optparse' require_relative 'test_optparse'
class TestOptionParser::PlaceArg < TestOptionParser class TestOptionParserPlaceArg < TestOptionParser
def setup def setup
super super
@opt.def_option("-x [VAL]") {|x| @flag = x} @opt.def_option("-x [VAL]") {|x| @flag = x}

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'test_optparse' require_relative 'test_optparse'
module TestOptionParser::ReqArg module TestOptionParserReqArg
def setup def setup
super super
@opt.def_option "--with_underscore=VAL" do |x| @flag = x end @opt.def_option "--with_underscore=VAL" do |x| @flag = x end
@ -9,7 +9,7 @@ module TestOptionParser::ReqArg
end end
class Def1 < TestOptionParser class Def1 < TestOptionParser
include ReqArg include TestOptionParserReqArg
def setup def setup
super super
@opt.def_option("-xVAL") {|x| @flag = x} @opt.def_option("-xVAL") {|x| @flag = x}
@ -19,21 +19,21 @@ module TestOptionParser::ReqArg
end end
end end
class Def2 < TestOptionParser class Def2 < TestOptionParser
include ReqArg include TestOptionParserReqArg
def setup def setup
super super
@opt.def_option("-x", "--option=VAL") {|x| @flag = x} @opt.def_option("-x", "--option=VAL") {|x| @flag = x}
end end
end end
class Def3 < TestOptionParser class Def3 < TestOptionParser
include ReqArg include TestOptionParserReqArg
def setup def setup
super super
@opt.def_option("--option=VAL", "-x") {|x| @flag = x} @opt.def_option("--option=VAL", "-x") {|x| @flag = x}
end end
end end
class Def4 < TestOptionParser class Def4 < TestOptionParser
include ReqArg include TestOptionParserReqArg
def setup def setup
super super
@opt.def_option("-xVAL", "--option=VAL") {|x| @flag = x} @opt.def_option("-xVAL", "--option=VAL") {|x| @flag = x}

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
require_relative 'test_optparse' require_relative 'test_optparse'
class TestOptionParser::SummaryTest < TestOptionParser class TestOptionParserSummaryTest < TestOptionParser
def test_short_clash def test_short_clash
r = nil r = nil
o = OptionParser.new do |opts| o = OptionParser.new do |opts|

View File

@ -2,9 +2,7 @@
require 'test/unit' require 'test/unit'
require 'optparse' require 'optparse'
class TestOptionParser < Test::Unit::TestCase class TestOptionParserZshCompletion < Test::Unit::TestCase
end
class TestOptionParser::ZshCompletion < Test::Unit::TestCase
def setup def setup
@opt = OptionParser.new @opt = OptionParser.new
@opt.define("-z", "zzz") {} @opt.define("-z", "zzz") {}

View File

@ -4,9 +4,7 @@
require "test/unit" require "test/unit"
class TestEmojiBreaks < Test::Unit::TestCase class TestEmojiBreaks < Test::Unit::TestCase
end class BreakTest
class TestEmojiBreaks::BreakTest
attr_reader :string, :comment, :filename, :line_number, :type, :shortname attr_reader :string, :comment, :filename, :line_number, :type, :shortname
def initialize(filename, line_number, data, comment='') def initialize(filename, line_number, data, comment='')
@ -31,7 +29,7 @@ class TestEmojiBreaks::BreakTest
end end
end end
class TestEmojiBreaks::BreakFile class BreakFile
attr_reader :basename, :fullname, :version attr_reader :basename, :fullname, :version
FILES = [] FILES = []
@ -47,7 +45,6 @@ class TestEmojiBreaks::BreakFile
end end
end end
class TestEmojiBreaks < Test::Unit::TestCase
UNICODE_VERSION = RbConfig::CONFIG['UNICODE_VERSION'] UNICODE_VERSION = RbConfig::CONFIG['UNICODE_VERSION']
UNICODE_DATA_PATH = File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}/ucd/emoji", __dir__) UNICODE_DATA_PATH = File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}/ucd/emoji", __dir__)
EMOJI_VERSION = RbConfig::CONFIG['UNICODE_EMOJI_VERSION'] EMOJI_VERSION = RbConfig::CONFIG['UNICODE_EMOJI_VERSION']
@ -71,9 +68,8 @@ class TestEmojiBreaks < Test::Unit::TestCase
omit "Emoji data files not available in #{EMOJI_DATA_PATH}." omit "Emoji data files not available in #{EMOJI_DATA_PATH}."
end end
end end
end
TestEmojiBreaks.data_files_available? and class TestEmojiBreaks if data_files_available?
def read_data def read_data
tests = [] tests = []
EMOJI_DATA_FILES.each do |file| EMOJI_DATA_FILES.each do |file|
@ -155,3 +151,4 @@ TestEmojiBreaks.data_files_available? and class TestEmojiBreaks
end end
end end
end end
end

View File

@ -4,9 +4,7 @@
require "test/unit" require "test/unit"
class TestGraphemeBreaksFromFile < Test::Unit::TestCase class TestGraphemeBreaksFromFile < Test::Unit::TestCase
end class BreakTest
class TestGraphemeBreaksFromFile::BreakTest
attr_reader :clusters, :string, :comment, :line_number attr_reader :clusters, :string, :comment, :line_number
def initialize(line_number, data, comment) def initialize(line_number, data, comment)
@ -28,7 +26,6 @@ class TestGraphemeBreaksFromFile::BreakTest
end end
end end
class TestGraphemeBreaksFromFile < Test::Unit::TestCase
UNICODE_VERSION = RbConfig::CONFIG['UNICODE_VERSION'] UNICODE_VERSION = RbConfig::CONFIG['UNICODE_VERSION']
path = File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}", __dir__) path = File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}", __dir__)
UNICODE_DATA_PATH = File.directory?("#{path}/ucd/auxiliary") ? "#{path}/ucd/auxiliary" : path UNICODE_DATA_PATH = File.directory?("#{path}/ucd/auxiliary") ? "#{path}/ucd/auxiliary" : path
@ -43,9 +40,8 @@ class TestGraphemeBreaksFromFile < Test::Unit::TestCase
omit "Unicode data file GraphemeBreakTest not available in #{UNICODE_DATA_PATH}." omit "Unicode data file GraphemeBreakTest not available in #{UNICODE_DATA_PATH}."
end end
end end
end
TestGraphemeBreaksFromFile.file_available? and class TestGraphemeBreaksFromFile if file_available?
def read_data def read_data
tests = [] tests = []
IO.foreach(GRAPHEME_BREAK_TEST_FILE, encoding: Encoding::UTF_8) do |line| IO.foreach(GRAPHEME_BREAK_TEST_FILE, encoding: Encoding::UTF_8) do |line|
@ -93,3 +89,4 @@ TestGraphemeBreaksFromFile.file_available? and class TestGraphemeBreaksFromFile
end end
end end
end end
end

View File

@ -3,7 +3,7 @@
require 'test/unit' require 'test/unit'
class TestMethod < Test::Unit::TestCase class TestMethodInlineCache < Test::Unit::TestCase
def test_alias def test_alias
m0 = Module.new do m0 = Module.new do
def foo; :M0 end def foo; :M0 end