diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-03-26 12:44:25 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-03-27 18:44:42 +0000 |
commit | 27bf1eafbf6b3b16e0256feff4f6fce3f4fddc72 (patch) | |
tree | 4e978e8fb23deb8b829651962b80046a6da0f63f /tests | |
parent | e09a02fac0d1ecbffeebcb2012ecc659c8986a4e (diff) |
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 <michael.brasser@live.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
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() |