summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Cheek <josh.cheek@gmail.com>2019-06-14 21:13:27 -0500
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-15 11:25:38 +0900
commit46527e1bf4a66a42ac4729e23f12bdfec8ae953e (patch)
tree724c8d865b06cd22ecdc6bcee90fa91913c583c5
parentb8730f1251d94c0992db663f119df0a2bb31dca1 (diff)
Test for blank lines between leadinig dot method chains
-rw-r--r--test/ruby/test_syntax.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index ec2892d091..776711c8de 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -986,6 +986,27 @@ eom
assert_valid_syntax("a #\n #\n&.foo")
assert_valid_syntax("a\n\n.foo")
assert_valid_syntax("a \n \n &.foo")
+
+ src = <<~RUBY
+ def m
+ # c
+
+ x
+ end
+ RUBY
+ tokens = [
+ [:on_kw, "def", ], # EXPR_FNAME],
+ [:on_sp, " ", ], # EXPR_FNAME],
+ [:on_ident, "m", ], # EXPR_ENDFN],
+ [:on_nl, "\n", ], # EXPR_BEG],
+ [:on_comment, " # c\n", ], # EXPR_EMPTYLN],
+ [:on_sp, " ", ], # EXPR_BEG],
+ [:on_ident, "x", ], # EXPR_CMDARG],
+ [:on_nl, "\n", ], # EXPR_BEG],
+ [:on_kw, "end", ], # EXPR_END],
+ [:on_nl, "\n", ], # EXPR_BEG],
+ ]
+ assert_tokens tokens, src
end
def test_no_warning_logop_literal
@@ -1404,6 +1425,17 @@ eom
assert_equal(expected, @result, message)
end
+ def assert_tokens(expected, src, message = nil)
+ begin
+ require 'ripper'
+ actual = Ripper.lex(src).map { |_position, type, value, _state| [type, value] }
+ assert_equal(expected, actual, message)
+ rescue Exception => err
+ puts err
+ exit! 1
+ end
+ end
+
def make_tmpsrc(f, src)
f.open
f.truncate(0)