diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-14 05:57:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-14 05:57:42 +0000 |
commit | 9c077bbed94307d67c82a6e805dd6cc486433df2 (patch) | |
tree | 21df48dcd1cb13c4fc6531a0f7d40b825ac30472 /test/ruby | |
parent | ccc933d4a6873d9be359c8ab04b1f242ed64c1e5 (diff) |
parse.y: show invalid global variable line
* parse.y (parse_gvar): show the source line erred by invalid
global variable, and indicate the variable including the wrong
punctuation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_parse.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index ea5065960a..a8389705af 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -377,9 +377,9 @@ class TestParse < Test::Unit::TestCase end def assert_disallowed_variable(type, noname, *invalid) - assert_syntax_error(noname, "`#{noname}' without identifiers is not allowed as #{type} variable name") + assert_syntax_error("a = #{noname}", "`#{noname}' without identifiers is not allowed as #{type} variable name") invalid.each do |name| - assert_syntax_error(name, "`#{name}' is not allowed as #{type} variable name") + assert_syntax_error("a = #{name}", "`#{name}' is not allowed as #{type} variable name") end end @@ -712,7 +712,9 @@ x = __ENCODING__ $test_parse_foobarbazqux = nil assert_equal(nil, $&) assert_equal(nil, eval('alias $& $preserve_last_match')) - assert_raise(SyntaxError) { eval('$#') } + assert_raise_with_message(SyntaxError, /as a global variable name\na = \$\#\n \^~$/) do + eval('a = $#') + end end def test_invalid_instance_variable |