diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-04 07:54:44 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-04 07:54:44 +0000 |
commit | 4e59c822a07f85c79fbcbac40cba5a591512258c (patch) | |
tree | 0bc51466bdb3e76101cd5334e7fb6a18fa74ee83 /test/-ext-/symbol/test_inadvertent_creation.rb | |
parent | 9f87297c21e2e375990166214327634b212e50fb (diff) | |
download | ruby-4e59c822a07f85c79fbcbac40cba5a591512258c.tar.gz |
object.c: avoid inadvertent symbol creation
* object.c (rb_mod_const_set): avoid inadvertent symbol creation.
(rb_obj_ivar_set): ditto.
(rb_mod_cvar_set): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/symbol/test_inadvertent_creation.rb')
-rw-r--r-- | test/-ext-/symbol/test_inadvertent_creation.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/-ext-/symbol/test_inadvertent_creation.rb b/test/-ext-/symbol/test_inadvertent_creation.rb index 247a42cab3..4b9ab1062d 100644 --- a/test/-ext-/symbol/test_inadvertent_creation.rb +++ b/test/-ext-/symbol/test_inadvertent_creation.rb @@ -193,5 +193,26 @@ module Test_Symbol assert_raise(NoMethodError) {[1, 2].inject(name)} assert_not_send([Bug::Symbol, :interned?, name]) end + + def test_module_const_set + name = noninterned_name + mod = Module.new + assert_raise(NameError) {mod.const_set(name, true)} + assert_not_send([Bug::Symbol, :interned?, name]) + end + + def test_module_cvar_set + name = noninterned_name + mod = Module.new + assert_raise(NameError) {mod.class_variable_set(name, true)} + assert_not_send([Bug::Symbol, :interned?, name]) + end + + def test_object_ivar_set + name = noninterned_name + obj = Object.new + assert_raise(NameError) {obj.instance_variable_set(name, true)} + assert_not_send([Bug::Symbol, :interned?, name]) + end end end |