diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-01-28 15:21:26 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-01-28 15:23:52 +0900 |
commit | 9552262bb2e293efa6e8f535d68623f2ecd13360 (patch) | |
tree | 706e9c6c92a88296309afb13aa51be9b5c308dc3 /test/ruby/test_struct.rb | |
parent | 4df0819c5d8b7d11e3fa1d2ba45fe7da68a0e064 (diff) |
support multi-run for test/ruby/test_struct.rb
Remove Structs to avoid redefinition warnings.
Diffstat (limited to 'test/ruby/test_struct.rb')
-rw-r--r-- | test/ruby/test_struct.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index a7deb13a08..5f073a3315 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -23,6 +23,10 @@ module TestStruct test.bar = 47 assert_equal(47, test.bar) + + @Struct.class_eval do + remove_const :Test + end end # [ruby-dev:26247] more than 10 struct members causes segmentation fault @@ -325,15 +329,19 @@ module TestStruct end def test_redefinition_warning - @Struct.new("RedefinitionWarning") + @Struct.new(name = "RedefinitionWarning") e = EnvUtil.verbose_warning do @Struct.new("RedefinitionWarning") end assert_match(/redefining constant #@Struct::RedefinitionWarning/, e) + + @Struct.class_eval do + remove_const name + end end def test_nonascii - struct_test = @Struct.new("R\u{e9}sum\u{e9}", :"r\u{e9}sum\u{e9}") + struct_test = @Struct.new(name = "R\u{e9}sum\u{e9}", :"r\u{e9}sum\u{e9}") assert_equal(@Struct.const_get("R\u{e9}sum\u{e9}"), struct_test, '[ruby-core:24849]') a = struct_test.new(42) assert_equal("#<struct #@Struct::R\u{e9}sum\u{e9} r\u{e9}sum\u{e9}=42>", a.inspect, '[ruby-core:24849]') @@ -343,6 +351,10 @@ module TestStruct assert_nothing_raised(Encoding::CompatibilityError) do assert_match(/redefining constant #@Struct::R\u{e9}sum\u{e9}/, e) end + + @Struct.class_eval do + remove_const name + end end def test_junk |