ruby-changes:59824
From: Koichi <ko1@a...>
Date: Tue, 28 Jan 2020 15:24:28 +0900 (JST)
Subject: [ruby-changes:59824] 14759e6907 (master): support multi-run for ruby/test_const.rb
https://git.ruby-lang.org/ruby.git/commit/?id=14759e6907 From 14759e6907eaecc86ab06a3ddf107426c00cb2c5 Mon Sep 17 00:00:00 2001 From: Koichi Sasada <ko1@a...> Date: Tue, 28 Jan 2020 13:31:22 +0900 Subject: support multi-run for ruby/test_const.rb need to redef Constants. diff --git a/test/ruby/test_const.rb b/test/ruby/test_const.rb index 1c73b66..51637a2 100644 --- a/test/ruby/test_const.rb +++ b/test/ruby/test_const.rb @@ -3,20 +3,33 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_const.rb#L3 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) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/