diff options
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 4415e6cf74..71bb357a43 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -345,6 +345,8 @@ private slots: void qtbug_60547(); void delayLoadingArgs(); void manyArguments(); + void forInIterator(); + void localForInIterator(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -8394,6 +8396,37 @@ void tst_qqmlecmascript::manyArguments() engine.evaluate(testCase); } +void tst_qqmlecmascript::forInIterator() +{ + auto testCase = + "(function(){\n" + "var x = 'yoyo'\n" + "var i\n" + "for (i in x) {\n" + "}\n" + "return i\n" + "})()"; + QJSEngine engine; + QJSValue ret = engine.evaluate(testCase); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QStringLiteral("3")); +} + +void tst_qqmlecmascript::localForInIterator() +{ + auto testCase = + "(function(){\n" + "var x = 'yoyo'\n" + "for (var i in x) {\n" + "}\n" + "return i\n" + "})()"; + QJSEngine engine; + QJSValue ret = engine.evaluate(testCase); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QStringLiteral("3")); +} + QTEST_MAIN(tst_qqmlecmascript) |