aboutsummaryrefslogtreecommitdiffstats
path: root/test/ripper
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-24 15:28:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-24 15:28:14 +0000
commitbe7c04e1971f84d104b74a02f4cdc22ec2c14b7a (patch)
tree309515a456efa87bb581249bad97cca6acd04881 /test/ripper
parent418c46f2844b2385cc38bb37f2538d18f04abd08 (diff)
downloadruby-be7c04e1971f84d104b74a02f4cdc22ec2c14b7a.tar.gz
parse.y: dynamic const assign_error in ripper
* parse.y (mlhs_node): dynamic constant assignment in massign should cause assign_error, like as single assign and backref assignment in massign. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/test_parser_events.rb25
1 files changed, 22 insertions, 3 deletions
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index c9b5690245..537d3fc406 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -183,29 +183,48 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
end
def test_assign_error
+ # for test_coverage
+ end
+
+ def test_assign_error_backref
thru_assign_error = false
parse('$` = 1', :on_assign_error) {thru_assign_error = true}
assert_equal true, thru_assign_error
thru_assign_error = false
parse('$`, _ = 1', :on_assign_error) {thru_assign_error = true}
assert_equal true, thru_assign_error
+ end
+ def test_assign_error_const_qualified
thru_assign_error = false
parse('self::X = 1', :on_assign_error) {thru_assign_error = true}
assert_equal false, thru_assign_error
- parse('def m\n self::X = 1\nend', :on_assign_error) {thru_assign_error = true}
+ parse("def m\n self::X = 1\nend", :on_assign_error) {thru_assign_error = true}
assert_equal true, thru_assign_error
+ thru_assign_error = false
+ parse("def m\n self::X, a = 1, 2\nend", :on_assign_error) {thru_assign_error = true}
+ assert_equal true, thru_assign_error
+ end
+ def test_assign_error_const
thru_assign_error = false
parse('X = 1', :on_assign_error) {thru_assign_error = true}
assert_equal false, thru_assign_error
- parse('def m\n X = 1\nend', :on_assign_error) {thru_assign_error = true}
+ parse("def m\n X = 1\nend", :on_assign_error) {thru_assign_error = true}
assert_equal true, thru_assign_error
+ thru_assign_error = false
+ parse("def m\n X, a = 1, 2\nend", :on_assign_error) {thru_assign_error = true}
+ assert_equal true, thru_assign_error
+ end
+ def test_assign_error_const_toplevel
thru_assign_error = false
parse('::X = 1', :on_assign_error) {thru_assign_error = true}
assert_equal false, thru_assign_error
- parse('def m\n ::X = 1\nend', :on_assign_error) {thru_assign_error = true}
+ parse("def m\n ::X = 1\nend", :on_assign_error) {thru_assign_error = true}
+ assert_equal true, thru_assign_error
+ thru_assign_error = false
+ parse("def m\n ::X, a = 1, 2\nend", :on_assign_error) {thru_assign_error = true}
assert_equal true, thru_assign_error
end