summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-30 03:57:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-30 03:57:46 +0000
commitd617fce9ab4e955f9548073bb3a2320a44b07c75 (patch)
treed5f1d2a4acb883013fef09d63146e09c61d436a6
parentd492043fba2dfc0f524cf981519fb7fa69bfbec2 (diff)
more checks for prompt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/irb/test_ruby-lex.rb63
1 files changed, 32 insertions, 31 deletions
diff --git a/test/irb/test_ruby-lex.rb b/test/irb/test_ruby-lex.rb
index d1355549b7a..ec02c6fafea 100644
--- a/test/irb/test_ruby-lex.rb
+++ b/test/irb/test_ruby-lex.rb
@@ -52,39 +52,40 @@ module TestIRB
prompts << a
end
}
- src = "#{<<-"begin;"}#{<<~"end;"}"
+ src = "#{<<-"begin;"}#{<<~'end;'}"
begin;
- if false or
- true
- "
- "
- '
- '
- else
- nil
- nil
- end
+ # #;# LTYPE:INDENT:CONTINUE
+ x #;# -:0:* # FIXME: a comment should not `continue'
+ x( #;# -:0:-
+ ) #;# -:1:*
+ a \ #;# -:0:-
+ #;# -:0:*
+ a; #;# -:0:-
+ a #;# -:0:* # FIXME: a semicolon should not `continue'
+ #;# -:0:-
+ 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;
- assert_equal([[src, 1]], top_level_statement(src))
- expected = [
- [nil, 0, false],
- [nil, 1, true],
- [nil, 1, false],
- ['"', 1, false],
- [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]}")
- }
+ top_level_statement(src.gsub(/[ \t]*#;#.*/, ''))
+ src.each_line.with_index(1) do |line, i|
+ p = prompts.shift
+ next unless /#;#\s*(?:-|(\S)):(\d+):(?:(\*)|-)/ =~ line
+ assert_equal([$1, $2.to_i, true&$3, i], p[0..3], "#{i}:#{p[4]}: #{line}")
+ end
end
def top_level_statement(lines)