From 2fdb6eba0a58b629db32f9eefec2f26df08d3d2e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 30 Apr 2015 13:20:43 +0200 Subject: Fix passing of locals as function arguments with side-effects Commit 75c22465cf8fe262edfe6178bb9ca19661fb710e regressed in allowing locals and arguments to be passed directly as further arguments to function calls, but that's incorrect when considering var i = 2; testFunction(i, i += 2) where it is instrumental to place the first argument into a temp (making a copy) instead of passing it directly. Change-Id: Iffcf6c6eda92a8fb665982cda1db0b96359cd092 Task-number: QTBUG-45879 Reviewed-by: Lars Knoll --- tests/auto/qml/qjsengine/tst_qjsengine.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/auto/qml/qjsengine') diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 2b7b1fc524..2690b857fa 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -176,6 +176,8 @@ private slots: void intConversion_QTBUG43309(); void toFixed(); + void argumentEvaluationOrder(); + signals: void testSignal(); }; @@ -3628,6 +3630,25 @@ void tst_QJSEngine::toFixed() QCOMPARE(result.toString(), QStringLiteral("12.1")); } +void tst_QJSEngine::argumentEvaluationOrder() +{ + QJSEngine engine; + QJSValue ok = engine.evaluate( + "function record(arg1, arg2) {\n" + " parameters = [arg1, arg2]\n" + "}\n" + "function test() {\n" + " var i = 2;\n" + " record(i, i += 2);\n" + "}\n" + "test()\n" + "parameters[0] == 2 && parameters[1] == 4"); + qDebug() << ok.toString(); + QVERIFY(ok.isBool()); + QVERIFY(ok.toBool()); + +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" -- cgit v1.2.3