aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-14 08:13:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-14 08:13:46 +0000
commit9800fc26b0367c63ada516b932b13268bb79524b (patch)
tree1d645a9c5f00e5ea2e7ae2532d511a15e97aca58 /test
parent277af37b427c635688d9ca7cba0b2fa8d1fb459d (diff)
downloadruby-9800fc26b0367c63ada516b932b13268bb79524b.tar.gz
parse.y: no punctuation instance/class variables
* parse.y (parse_atmark): exclude punctuation follows @ marks, whereas it is inclusive after $ mark as some punctuation global variables exist. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ripper/test_parser_events.rb4
-rw-r--r--test/ruby/test_parse.rb12
2 files changed, 9 insertions, 7 deletions
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index 3c78daf16e..0591eeb781 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -1479,13 +1479,13 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
def test_invalid_instance_variable_name
assert_equal("`@1' is not allowed as an instance variable name", compile_error('@1'))
- assert_equal("`@%' is not allowed as an instance variable name", compile_error('@%'))
+ assert_equal("`@' without identifiers is not allowed as an instance variable name", compile_error('@%'))
assert_equal("`@' without identifiers is not allowed as an instance variable name", compile_error('@'))
end
def test_invalid_class_variable_name
assert_equal("`@@1' is not allowed as a class variable name", compile_error('@@1'))
- assert_equal("`@@%' is not allowed as a class variable name", compile_error('@@%'))
+ assert_equal("`@@' without identifiers is not allowed as a class variable name", compile_error('@@%'))
assert_equal("`@@' without identifiers is not allowed as a class variable name", compile_error('@@'))
end
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index a8389705af..0b3657f8a0 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -376,23 +376,25 @@ class TestParse < Test::Unit::TestCase
assert_nothing_raised { eval(':""') }
end
- def assert_disallowed_variable(type, noname, *invalid)
- assert_syntax_error("a = #{noname}", "`#{noname}' without identifiers is not allowed as #{type} variable name")
+ def assert_disallowed_variable(type, noname, invalid)
+ noname.each do |name|
+ assert_syntax_error("a = #{name}", "`#{noname[0]}' without identifiers is not allowed as #{type} variable name")
+ end
invalid.each do |name|
assert_syntax_error("a = #{name}", "`#{name}' is not allowed as #{type} variable name")
end
end
def test_disallowed_instance_variable
- assert_disallowed_variable("an instance", *%w[@ @1 @.])
+ assert_disallowed_variable("an instance", %w[@ @.], %w[@1])
end
def test_disallowed_class_variable
- assert_disallowed_variable("a class", *%w[@@ @@1 @@.])
+ assert_disallowed_variable("a class", %w[@@ @@.], %w[@@1])
end
def test_disallowed_gloal_variable
- assert_disallowed_variable("a global", *%w[$ $%])
+ assert_disallowed_variable("a global", %w[$], %w[$%])
end
def test_arg2