Test for blank lines between leadinig dot method chains

This commit is contained in:
Josh Cheek 2019-06-14 21:13:27 -05:00 committed by Nobuyoshi Nakada
parent b8730f1251
commit 46527e1bf4
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -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)