1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

more checks for prompt

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-01-30 03:57:46 +00:00
parent d492043fba
commit d617fce9ab

View file

@ -52,39 +52,40 @@ module TestIRB
prompts << a prompts << a
end end
} }
src = "#{<<-"begin;"}#{<<~"end;"}" src = "#{<<-"begin;"}#{<<~'end;'}"
begin; begin;
if false or # #;# LTYPE:INDENT:CONTINUE
true x #;# -:0:* # FIXME: a comment should not `continue'
" x( #;# -:0:-
" ) #;# -:1:*
' a \ #;# -:0:-
' #;# -:0:*
else a; #;# -:0:-
nil a #;# -:0:* # FIXME: a semicolon should not `continue'
nil #;# -:0:-
end a #;# -:0:* # FIXME: an empty line should not `continue'
a = #;# -:0:-
' #;# -:0:*
' #;# ':0:*
if false or #;# -:0:-
true #;# -:1:*
a #;# -:1:-
" #;# -:1:-
" #;# ":1:-
begin #;# -:1:-
a #;# -:2:* # FIXME: the first line should not be `continue'd
a #;# -:2:-
end #;# -:2:-
else #;# -:1:-
nil #;# -:1:* # FIXME: just after `else' should not be `continue'd
end #;# -:1:-
end; end;
assert_equal([[src, 1]], top_level_statement(src)) top_level_statement(src.gsub(/[ \t]*#;#.*/, ''))
expected = [ src.each_line.with_index(1) do |line, i|
[nil, 0, false], p = prompts.shift
[nil, 1, true], next unless /#;#\s*(?:-|(\S)):(\d+):(?:(\*)|-)/ =~ line
[nil, 1, false], assert_equal([$1, $2.to_i, true&$3, i], p[0..3], "#{i}:#{p[4]}: #{line}")
['"', 1, false], end
[nil, 1, false],
["'", 1, false],
[nil, 1, false],
[nil, 1, true], # FIXME: just after `else' should be `false'
[nil, 1, false],
[nil, 1, false],
[nil, 0, false],
]
srcs = src.lines
assert_equal(expected.size, prompts.size)
expected.each_with_index {|e, i|
assert_equal(i + 1, prompts[i][3])
assert_equal(e, prompts[i][0..2], "#{i+1}: #{srcs[i]} # #{prompts[i]}")
}
end end
def top_level_statement(lines) def top_level_statement(lines)