mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
support multi-run for ruby/test_const.rb
need to redef Constants.
This commit is contained in:
parent
501e7f4959
commit
14759e6907
1 changed files with 21 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue