diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-05 02:10:44 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-05 02:10:44 +0000 |
commit | 0e414175fdcc19550fe44cc1ad8cb4827d2e3da8 (patch) | |
tree | 172ab605be5bd5b23fa69dd8364739bf3cb988ae /test/-ext- | |
parent | 9e57ac56a38be03ed197dc63019626eb465c8e38 (diff) | |
download | ruby-0e414175fdcc19550fe44cc1ad8cb4827d2e3da8.tar.gz |
test_inadvertent_creation.rb: move tests
* test/-ext-/symbol/test_inadvertent_creation.rb: move symbol leak
tests, for implementation details, from test/ruby/test_symbol.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-')
-rw-r--r-- | test/-ext-/symbol/test_inadvertent_creation.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/-ext-/symbol/test_inadvertent_creation.rb b/test/-ext-/symbol/test_inadvertent_creation.rb index b180d08b04..fdd1e252ce 100644 --- a/test/-ext-/symbol/test_inadvertent_creation.rb +++ b/test/-ext-/symbol/test_inadvertent_creation.rb @@ -358,5 +358,67 @@ module Test_Symbol } assert_not_pinneddown(name) end + + def assert_no_immortal_symbol_created(name) + name = noninterned_name(name) + yield(name) + assert_not_pinneddown(name) + end + + def test_send_leak_string + assert_no_immortal_symbol_created("send should not leak - str") do |name| + assert_raise(NoMethodError) {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)} + end + end + + def test_send_leak_string_custom_method_missing + x = Object.new + def x.method_missing(*); end + assert_no_immortal_symbol_created("send should not leak - str mm") do |name| + assert_nothing_raised(NoMethodError) {x.send(name)} + end + end if false + + def test_send_leak_symbol_custom_method_missing + x = Object.new + def x.method_missing(*); end + assert_no_immortal_symbol_created("send should not leak - sym mm") do |name| + assert_nothing_raised(NoMethodError) {x.send(name.to_sym)} + end + end if false + + 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)} + 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)} + end + end + + def test_send_leak_string_custom_method_missing_no_optimization + x = Object.new + def x.method_missing(*); end + assert_no_immortal_symbol_created("send should not leak - str mm slow") do |name| + assert_nothing_raised(NoMethodError) {x.method(:send).call(name)} + end + end + + def test_send_leak_symbol_custom_method_missing_no_optimization + x = Object.new + def x.method_missing(*); end + assert_no_immortal_symbol_created("send should not leak - sym mm slow") do |name| + assert_nothing_raised(NoMethodError) {x.method(:send).call(name.to_sym)} + end + end end end |