C++: Fix support for incremental input with \n

Also fix false positive line continuation on blank line

e.g.
"foo \

bar"

Change-Id: Ic6d345a4b578c955411d119b8438c8dc5065c072
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Orgad Shaneh
2014-01-23 22:16:43 +02:00
committed by Orgad Shaneh
parent fd31b4716c
commit e600424648
6 changed files with 76 additions and 31 deletions

View File

@@ -254,6 +254,18 @@ void tst_SimpleLexer::incremental_data()
<< _("\"foo \\\n\nbar\"")
<< (List() << T_STRING_LITERAL << T_IDENTIFIER << T_STRING_LITERAL);
QTest::newRow("escaped_string_literal_with_newline_1")
<< _("\"foo \\")
<< (List() << T_STRING_LITERAL);
QTest::newRow("escaped_string_literal_with_newline_2")
<< _("")
<< List();
QTest::newRow("escaped_string_literal_with_newline_3")
<< _("bar")
<< (List() << T_IDENTIFIER);
QTest::newRow("escaped_string_literal_with_space_and_newline_single")
<< _("\"foo \\ \n bar\"")
<< (List() << T_STRING_LITERAL);
@@ -263,8 +275,8 @@ void tst_SimpleLexer::incremental_data()
<< (List() << T_STRING_LITERAL);
QTest::newRow("escaped_string_literal_with_space_and_newline_2")
<< _("bar\"")
<< (List() << T_STRING_LITERAL);
<< _("bar")
<< (List() << T_IDENTIFIER);
QTest::newRow("token_after_escaped_string_literal_1")
<< _("\"foo \\")
@@ -310,6 +322,18 @@ void tst_SimpleLexer::incremental_data()
<< _("//foo \\\n\nbar")
<< (List() << T_CPP_COMMENT << T_IDENTIFIER);
QTest::newRow("escaped_cpp_comment_with_newline_1")
<< _("//foo \\")
<< (List() << T_CPP_COMMENT);
QTest::newRow("escaped_cpp_comment_with_newline_2")
<< _("")
<< List();
QTest::newRow("escaped_cpp_comment_with_newline_3")
<< _("bar")
<< (List() << T_IDENTIFIER);
QTest::newRow("escaped_cpp_comment_with_space_and_newline_single")
<< _("//foo \\ \n bar")
<< (List() << T_CPP_COMMENT);
@@ -320,7 +344,7 @@ void tst_SimpleLexer::incremental_data()
QTest::newRow("escaped_cpp_comment_with_space_and_newline_2")
<< _("bar")
<< (List() << T_CPP_COMMENT);
<< (List() << T_IDENTIFIER);
}
QTEST_APPLESS_MAIN(tst_SimpleLexer)