aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-03-15 01:00:09 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-03-15 11:20:40 +0100
commit67cc0be410e0325ff5c8757684cacd02eea91572 (patch)
treed41a8a73b6792e6ebd70b94cd439d6b33bdcadda /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
parent662c53dc583188d0278c86f59ab6b80056dbd419 (diff)
parentf10ac43ebb839b61315bd3b370b77683b625e4c4 (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts: src/qml/compiler/qv4codegen.cpp Change-Id: I604517d0948fb5056ce36cc104f13ac956fbcc24
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index dd73acc815..48cbf02751 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -361,6 +361,9 @@ private slots:
void importLexicalVariables();
void hugeObject();
void templateStringTerminator();
+ void arrayAndException();
+ void numberToStringWithRadix();
+ void tailCallWithArguments();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -8876,6 +8879,41 @@ 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());
+}
+
+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"));
+ }
+}
+
+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"