support multi-run for ruby/test_const.rb

need to redef Constants.
This commit is contained in:
Koichi Sasada 2020-01-28 13:31:22 +09:00
Родитель 501e7f4959
Коммит 14759e6907
1 изменённых файлов: 21 добавлений и 8 удалений

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

@ -3,6 +3,13 @@
require 'test/unit'
class TestConst < Test::Unit::TestCase
setup_constants_proc = -> do
remove_const :TEST1 if defined? ::TestConst::TEST1
remove_const :TEST2 if defined? ::TestConst::TEST2
remove_const :Const if defined? ::TestConst::Const
remove_const :Const2 if defined? ::TestConst::Const2
TEST1 = 1
TEST2 = 2
@ -15,8 +22,14 @@ class TestConst < Test::Unit::TestCase
TEST3 = 6
TEST4 = 8
end
end
define_method :setup_constants do
setup_constants_proc.call
end
def test_const
setup_constants
assert defined?(TEST1)
assert_equal 1, TEST1
assert defined?(TEST2)