From cdb8eb988e572411030486ad2834ae54e4567bf3 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 6 Feb 2019 10:32:31 +0100 Subject: V4: Rotate loop in ArrayPattern and eliminate "done" label This prevents jumping over the resetting of the unwind handler when an exception occurs. (cherry-picked from commit 0282b89ec672e25a465a8e51bc74c7fd58a624b1) Fixes: QTBUG-73985 Change-Id: I4a4da815f54c13980d239e0492f9b013991cfbd5 Reviewed-by: Lars Knoll --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/auto/qml/qqmlecmascript') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 788ecce1c5..aaaaf09925 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -361,6 +361,7 @@ private slots: void importLexicalVariables(); void hugeObject(); void templateStringTerminator(); + void arrayAndException(); private: // static void propertyVarWeakRefCallback(v8::Persistent object, void* parameter); @@ -8869,6 +8870,14 @@ void tst_qqmlecmascript::templateStringTerminator() QCOMPARE(value.toString(), QLatin1String("x123\ny^")); } +void tst_qqmlecmascript::arrayAndException() +{ + QJSEngine engine; + const QJSValue value = engine.evaluate("[...[],[,,$]]"); + // Should not crash + QVERIFY(value.isError()); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" -- cgit v1.2.3 From b959074afb43d25c1a8818e0528004f8cf073ae2 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 22 Feb 2019 17:13:36 +0100 Subject: Unify and fix number to string conversion with radix Previously, the loop that generated the string could fail to terminate with certain numbers as input. Also, the algorithm was duplicated in two places. Change-Id: Ie2075148d931e7cfcedb5bcd23af61e2e8afc232 Fixes: QTBUG-73999 Reviewed-by: Robert Loehning Reviewed-by: Lars Knoll --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/auto/qml/qqmlecmascript') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index aaaaf09925..f849403cd8 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -362,6 +362,7 @@ private slots: void hugeObject(); void templateStringTerminator(); void arrayAndException(); + void numberToStringWithRadix(); private: // static void propertyVarWeakRefCallback(v8::Persistent object, void* parameter); @@ -8878,6 +8879,21 @@ void tst_qqmlecmascript::arrayAndException() QVERIFY(value.isError()); } +void tst_qqmlecmascript::numberToStringWithRadix() +{ + QJSEngine engine; + { + const QJSValue value = engine.evaluate(".5.toString(5)"); + QVERIFY(!value.isError()); + QVERIFY(value.toString().startsWith("0.2222222222")); + } + { + const QJSValue value = engine.evaluate(".05.toString(5)"); + QVERIFY(!value.isError()); + QVERIFY(value.toString().startsWith("0.01111111111")); + } +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" -- cgit v1.2.3 From 783ec60774a565f3a16c25af076b720de0e6acbd Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 1 Mar 2019 14:57:21 +0100 Subject: Disable tail calls for function called with more arguments than formals We cannot easily find the required stack space to store the extra arguments without adding a new stack frame. In principle it would be possible, but heavily recursing on such functions should be a rare problem. Change-Id: I1a53a6d29e37ce67aa7bd64acb7b1f41197e84c0 Fixes: QTBUG-72807 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto/qml/qqmlecmascript') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index f849403cd8..eb9b05e764 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -363,6 +363,7 @@ private slots: void templateStringTerminator(); void arrayAndException(); void numberToStringWithRadix(); + void tailCallWithArguments(); private: // static void propertyVarWeakRefCallback(v8::Persistent object, void* parameter); @@ -8894,6 +8895,18 @@ void tst_qqmlecmascript::numberToStringWithRadix() } } +void tst_qqmlecmascript::tailCallWithArguments() +{ + QJSEngine engine; + const QJSValue value = engine.evaluate( + "'use strict';\n" + "[[1, 2]].map(function (a) {\n" + " return (function() { return Math.min.apply(this, arguments); })(a[0], a[1]);\n" + "})[0];"); + QVERIFY(!value.isError()); + QCOMPARE(value.toInt(), 1); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" -- cgit v1.2.3