From 27bf1eafbf6b3b16e0256feff4f6fce3f4fddc72 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 26 Mar 2018 12:44:25 +0200 Subject: Fix QQmlExpression::hasError()/error() on syntax errors Record errors that happen during QV4::Script::parse() time in the same way as we record errors during binding evaluation, in order to correctly set the error state of QQmlExpression. This also removes dead code about setting line, description, etc. which is taken care of by ExecutionEngine::catchExceptionAsQmlError. Task-number: QTBUG-67240 Change-Id: I2d586e16803d0883cdd2d1d262b4c67202c00562 Reviewed-by: Michael Brasser --- tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp index e1ad1e8c5f..1decc04ad2 100644 --- a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp +++ b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp @@ -101,8 +101,12 @@ void tst_qqmlexpression::syntaxError() { QQmlEngine engine; QQmlExpression expression(engine.rootContext(), nullptr, "asd asd"); - QVariant v = expression.evaluate(); + bool isUndefined = false; + QVariant v = expression.evaluate(&isUndefined); QCOMPARE(v, QVariant()); + QVERIFY(expression.hasError()); + QCOMPARE(expression.error().description(), "SyntaxError: Expected token `;'"); + QVERIFY(isUndefined); } void tst_qqmlexpression::exception() -- cgit v1.2.3