diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-01-28 13:31:22 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-01-28 15:23:51 +0900 |
commit | 14759e6907eaecc86ab06a3ddf107426c00cb2c5 (patch) | |
tree | 9b08563dd0b8232a1ff165b334fcede768a9b6cc | |
parent | 501e7f4959a1193c82adc1b661a85621952121b8 (diff) | |
download | ruby-14759e6907eaecc86ab06a3ddf107426c00cb2c5.tar.gz |
support multi-run for ruby/test_const.rb
need to redef Constants.
-rw-r--r-- | test/ruby/test_const.rb | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/test/ruby/test_const.rb b/test/ruby/test_const.rb index 1c73b66648..51637a21a5 100644 --- a/test/ruby/test_const.rb +++ b/test/ruby/test_const.rb @@ -3,20 +3,33 @@ require 'test/unit' class TestConst < Test::Unit::TestCase - TEST1 = 1 - TEST2 = 2 - module Const - TEST3 = 3 - TEST4 = 4 + 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 + + module Const + TEST3 = 3 + TEST4 = 4 + end + + module Const2 + TEST3 = 6 + TEST4 = 8 + end end - module Const2 - TEST3 = 6 - TEST4 = 8 + 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) |