summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-05 04:49:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-05 04:49:30 +0000
commita932a1b83de5e647e1035369dea5cd2b0b9c2876 (patch)
treeff9f9af0f3668a53a4b309d6ce47ee673bfeb83b /test
parent738ce30f99bf034468606d2e0fb56af7a217c549 (diff)
test_inadvertent_creation.rb: assert method_missing
* test/-ext-/symbol/test_inadvertent_creation.rb (assert_no_immortal_symbol_in_method_missing): assert method_missing. [Bug #10828] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/-ext-/symbol/test_inadvertent_creation.rb38
1 files changed, 22 insertions, 16 deletions
diff --git a/test/-ext-/symbol/test_inadvertent_creation.rb b/test/-ext-/symbol/test_inadvertent_creation.rb
index a9299027f0..9262fc3396 100644
--- a/test/-ext-/symbol/test_inadvertent_creation.rb
+++ b/test/-ext-/symbol/test_inadvertent_creation.rb
@@ -365,59 +365,65 @@ module Test_Symbol
assert_not_pinneddown(name)
end
+ def assert_no_immortal_symbol_in_method_missing(name)
+ assert_no_immortal_symbol_created("send should not leak - #{name}") do |name|
+ assert_raise(NoMethodError) {yield(name)}
+ end
+ end
+
def test_send_leak_string
- assert_no_immortal_symbol_created("send should not leak - str") do |name|
- assert_raise(NoMethodError) {42.send(name)}
+ assert_no_immortal_symbol_in_method_missing("str") do |name|
+ 42.send(name)
end
end
def test_send_leak_symbol
- assert_no_immortal_symbol_created("send should not leak - sym") do |name|
- assert_raise(NoMethodError) {42.send(name.to_sym)}
+ assert_no_immortal_symbol_in_method_missing("sym") do |name|
+ 42.send(name.to_sym)
end
end
def test_send_leak_string_custom_method_missing
x = Object.new
def x.method_missing(*); super; end
- assert_no_immortal_symbol_created("send should not leak - str mm") do |name|
- assert_raise(NoMethodError) {x.send(name)}
+ assert_no_immortal_symbol_in_method_missing("str mm") do |name|
+ x.send(name)
end
end
def test_send_leak_symbol_custom_method_missing
x = Object.new
def x.method_missing(*); super; end
- assert_no_immortal_symbol_created("send should not leak - sym mm") do |name|
- assert_raise(NoMethodError) {x.send(name.to_sym)}
+ assert_no_immortal_symbol_in_method_missing("sym mm") do |name|
+ x.send(name.to_sym)
end
end
def test_send_leak_string_no_optimization
- assert_no_immortal_symbol_created("send should not leak - str slow") do |name|
- assert_raise(NoMethodError) {42.method(:send).call(name)}
+ assert_no_immortal_symbol_in_method_missing("str slow") do |name|
+ 42.method(:send).call(name)
end
end
def test_send_leak_symbol_no_optimization
- assert_no_immortal_symbol_created("send should not leak - sym slow") do |name|
- assert_raise(NoMethodError) {42.method(:send).call(name.to_sym)}
+ assert_no_immortal_symbol_in_method_missing("sym slow") do |name|
+ 42.method(:send).call(name.to_sym)
end
end
def test_send_leak_string_custom_method_missing_no_optimization
x = Object.new
def x.method_missing(*); super; end
- assert_no_immortal_symbol_created("send should not leak - str mm slow") do |name|
- assert_raise(NoMethodError) {x.method(:send).call(name)}
+ assert_no_immortal_symbol_in_method_missing("str mm slow") do |name|
+ x.method(:send).call(name)
end
end
def test_send_leak_symbol_custom_method_missing_no_optimization
x = Object.new
def x.method_missing(*); super; end
- assert_no_immortal_symbol_created("send should not leak - sym mm slow") do |name|
- assert_raise(NoMethodError) {x.method(:send).call(name.to_sym)}
+ assert_no_immortal_symbol_in_method_missing("sym mm slow") do |name|
+ x.method(:send).call(name.to_sym)
end
end
end