From aba824fece59d1afffa78d145a4f301f7fdc3688 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 20 Sep 2013 06:01:57 +0000 Subject: parse.y: junk sigil only names * parse.y (intern_str): sigil only names are junk, at least one identifier character is needed. [ruby-dev:47723] [Bug #8928] * parse.y (rb_enc_symname_type): fix out of bound access. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_module.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/ruby/test_module.rb') diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 9b253b3776..f6212f9349 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -688,6 +688,7 @@ class TestModule < Test::Unit::TestCase c.class_eval('@@foo = :foo') 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(:'@@') } assert_raise(NameError) { c.class_variable_get('@@') } assert_raise(NameError) { c.class_variable_get(:foo) } assert_raise(NameError) { c.class_variable_get("bar") } @@ -704,6 +705,7 @@ class TestModule < Test::Unit::TestCase c = Class.new c.class_variable_set(:@@foo, :foo) assert_equal(:foo, c.class_eval('@@foo')) + assert_raise(NameError) { c.class_variable_set(:'@@', 1) } assert_raise(NameError) { c.class_variable_set('@@', 1) } assert_raise(NameError) { c.class_variable_set(:foo, 1) } assert_raise(NameError) { c.class_variable_set("bar", 1) } @@ -722,6 +724,8 @@ class TestModule < Test::Unit::TestCase c.class_eval('@@foo = :foo') assert_equal(true, c.class_variable_defined?(:@@foo)) assert_equal(false, c.class_variable_defined?(:@@bar)) + assert_raise(NameError) { c.class_variable_defined?(:'@@') } + assert_raise(NameError) { c.class_variable_defined?('@@') } assert_raise(NameError) { c.class_variable_defined?(:foo) } assert_raise(NameError) { c.class_variable_defined?("bar") } assert_raise(TypeError) { c.class_variable_defined?(1) } -- cgit v1.2.3