diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-04 21:36:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-04 21:36:38 +0000 |
commit | 672b8bf1c038fc12d799ad56da3ac860890fe055 (patch) | |
tree | 049e4733e014fa65e51832dec1e1a1235834f534 /test/ruby/test_module.rb | |
parent | dc5b184b1f9c5ab8212b28cee07f5b0edf7aa3c2 (diff) |
object.c: avoid inadvertent symbol creation
* object.c (rb_mod_cvar_set): fix typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_module.rb')
-rw-r--r-- | test/ruby/test_module.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 8e2d5f6333..b11a86a4da 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -581,6 +581,8 @@ class TestModule < Test::Unit::TestCase def test_const_set_invalid_name c1 = Class.new assert_raise(NameError) { c1.const_set(:foo, :foo) } + assert_raise(NameError) { c1.const_set("bar", :foo) } + assert_raise(TypeError) { c1.const_set(1, :foo) } end def test_const_get_invalid_name @@ -664,6 +666,8 @@ class TestModule < Test::Unit::TestCase assert_equal(:foo, c.class_variable_get(:@@foo)) assert_raise(NameError) { c.class_variable_get(:@@bar) } # c.f. instance_variable_get assert_raise(NameError) { c.class_variable_get(:foo) } + assert_raise(NameError) { c.class_variable_get("bar") } + assert_raise(TypeError) { c.class_variable_get(1) } end def test_class_variable_set @@ -671,6 +675,8 @@ class TestModule < Test::Unit::TestCase c.class_variable_set(:@@foo, :foo) assert_equal(:foo, c.class_eval('@@foo')) assert_raise(NameError) { c.class_variable_set(:foo, 1) } + assert_raise(NameError) { c.class_variable_set("bar", 1) } + assert_raise(TypeError) { c.class_variable_set(1, 1) } end def test_class_variable_defined @@ -679,6 +685,8 @@ class TestModule < Test::Unit::TestCase assert_equal(true, c.class_variable_defined?(:@@foo)) assert_equal(false, c.class_variable_defined?(:@@bar)) assert_raise(NameError) { c.class_variable_defined?(:foo) } + assert_raise(NameError) { c.class_variable_defined?("bar") } + assert_raise(TypeError) { c.class_variable_defined?(1) } end def test_remove_class_variable |