mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00
Test for blank lines between leadinig dot method chains
This commit is contained in:
parent
b8730f1251
commit
46527e1bf4
1 changed files with 32 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue