mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
support multi-run for test/ruby/test_struct.rb
Remove Structs to avoid redefinition warnings.
This commit is contained in:
parent
4df0819c5d
commit
9552262bb2
1 changed files with 14 additions and 2 deletions
|
|
@ -23,6 +23,10 @@ module TestStruct
|
||||||
|
|
||||||
test.bar = 47
|
test.bar = 47
|
||||||
assert_equal(47, test.bar)
|
assert_equal(47, test.bar)
|
||||||
|
|
||||||
|
@Struct.class_eval do
|
||||||
|
remove_const :Test
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# [ruby-dev:26247] more than 10 struct members causes segmentation fault
|
# [ruby-dev:26247] more than 10 struct members causes segmentation fault
|
||||||
|
|
@ -325,15 +329,19 @@ module TestStruct
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_redefinition_warning
|
def test_redefinition_warning
|
||||||
@Struct.new("RedefinitionWarning")
|
@Struct.new(name = "RedefinitionWarning")
|
||||||
e = EnvUtil.verbose_warning do
|
e = EnvUtil.verbose_warning do
|
||||||
@Struct.new("RedefinitionWarning")
|
@Struct.new("RedefinitionWarning")
|
||||||
end
|
end
|
||||||
assert_match(/redefining constant #@Struct::RedefinitionWarning/, e)
|
assert_match(/redefining constant #@Struct::RedefinitionWarning/, e)
|
||||||
|
|
||||||
|
@Struct.class_eval do
|
||||||
|
remove_const name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_nonascii
|
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]')
|
assert_equal(@Struct.const_get("R\u{e9}sum\u{e9}"), struct_test, '[ruby-core:24849]')
|
||||||
a = struct_test.new(42)
|
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]')
|
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_nothing_raised(Encoding::CompatibilityError) do
|
||||||
assert_match(/redefining constant #@Struct::R\u{e9}sum\u{e9}/, e)
|
assert_match(/redefining constant #@Struct::R\u{e9}sum\u{e9}/, e)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@Struct.class_eval do
|
||||||
|
remove_const name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_junk
|
def test_junk
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue