aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2020-04-30 10:52:09 +0200
committerChristian Stenger <christian.stenger@qt.io>2020-05-01 22:56:34 +0200
commit126ee5c901a9675a9ab61d4c6f2961c95b8bceac (patch)
tree228d41add83e0fd19f7650e452ba3efea28def65 /tests
parentdc56e57cc52de79668ab0612534de527f5fea75a (diff)
Fix line number for follow-up lines in strings
If a string ends with a line terminator follow-up lines had a wrong line number. Change-Id: I98a8f69cbc876e07b3fe83490d517bf7771c59b5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index 10e9e49aa5..0325597e1a 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -328,6 +328,31 @@ void tst_qqmlparser::stringLiteral()
QCOMPARE(literal->firstSourceLocation().begin(), offset);
QCOMPARE(literal->firstSourceLocation().startLine, 1u);
QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
+
+ leftCode = QLatin1String("'\u000Ahello\u000Abye'");
+ code = leftCode + plusCode + rightCode;
+ lexer.setCode(code, 1);
+ QVERIFY(parser.parseExpression());
+ expression = parser.expression();
+ QVERIFY(expression);
+
+ binaryExpression = QQmlJS::AST::cast<QQmlJS::AST::BinaryExpression *>(expression);
+ QVERIFY(binaryExpression);
+
+ literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->left);
+ QVERIFY(literal);
+ QCOMPARE(literal->value, "\nhello\nbye");
+ QCOMPARE(literal->firstSourceLocation().begin(), 0u);
+ QCOMPARE(literal->firstSourceLocation().startLine, 1u);
+ QCOMPARE(literal->lastSourceLocation().end(), leftCode.size());
+
+ literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->right);
+ QVERIFY(literal);
+ QCOMPARE(literal->value, "\nbye");
+ offset = quint32(leftCode.size() + plusCode.size());
+ QCOMPARE(literal->firstSourceLocation().begin(), offset);
+ QCOMPARE(literal->lastSourceLocation().startLine, 3u);
+ QCOMPARE(literal->lastSourceLocation().end(), code.size());
}
void tst_qqmlparser::noSubstitutionTemplateLiteral()