summaryrefslogtreecommitdiff
path: root/test/ripper
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-17 05:21:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-17 05:21:18 +0000
commit12acc751e3e7fd6f8aec33abf661724ad76c862a (patch)
tree831705cd3fc725d9abb2909036867e6f13cd1df5 /test/ripper
parent0fa4a6a618295d42eb039c65f0609fdb71255355 (diff)
Numbered parameters [Feature #4475]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/test_parser_events.rb11
-rw-r--r--test/ripper/test_scanner_events.rb10
2 files changed, 20 insertions, 1 deletions
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index 0591eeb781..e4860ef533 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -812,6 +812,12 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal true, thru_next
end
+ def test_number_arg
+ thru_number_arg = false
+ parse('proc {@1}', :on_number_arg) {thru_number_arg = true}
+ assert_equal true, thru_number_arg
+ end
+
def test_opassign
thru_opassign = false
tree = parse('a += b', :on_opassign) {thru_opassign = true}
@@ -1477,8 +1483,11 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal("unterminated regexp meets end of file", compile_error('/'))
end
+ def test_invalid_numbered_parameter_name
+ assert_equal("leading zero is not allowed as a numbered parameter", compile_error('proc{@0}'))
+ end
+
def test_invalid_instance_variable_name
- assert_equal("`@1' is not allowed as an instance variable name", compile_error('@1'))
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
diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb
index 1184b23435..bb98e5d3d9 100644
--- a/test/ripper/test_scanner_events.rb
+++ b/test/ripper/test_scanner_events.rb
@@ -259,6 +259,8 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
scan('embvar', '"#@ivar"')
assert_equal ['#'],
scan('embvar', '"#@@cvar"')
+ assert_equal ['#'],
+ scan('embvar', '"#@1"')
assert_equal [],
scan('embvar', '"#lvar"')
assert_equal [],
@@ -348,6 +350,13 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
scan('ivar', 'm(lvar, @ivar, @@cvar, $gvar)')
end
+ def test_tnumparam
+ assert_equal [],
+ scan('tnumparam', '')
+ assert_equal ['@1'],
+ scan('tnumparam', 'proc {@1}')
+ end
+
def test_kw
assert_equal [],
scan('kw', '')
@@ -742,6 +751,7 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
assert_equal [" E\n\n"],
scan('tstring_content', "<<""'E'\n E\n\n"),
bug10392
+ scan('tstring_content', "tap{<<""EOS}\n""there\n""heredoc\#@1xxx\nEOS")
end
def test_heredoc_end