aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qjsengine/tst_qjsengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qjsengine/tst_qjsengine.cpp')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 2c5dc7af43..f9bd5c28aa 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -314,6 +314,11 @@ private slots:
void deleteDefineCycle();
void deleteFromSparseArray();
+ void generatorFunctionInTailCallPosition();
+ void generatorMethodInTailCallPosition();
+
+ void consoleLogSequence();
+
public:
Q_INVOKABLE QJSValue throwingCppMethod1();
Q_INVOKABLE void throwingCppMethod2();
@@ -6345,6 +6350,71 @@ void tst_QJSEngine::deleteFromSparseArray()
QVERIFY(result.property(20000).isUndefined());
}
+void tst_QJSEngine::generatorFunctionInTailCallPosition() {
+ QJSEngine engine;
+ QJSValue result = engine.evaluate(R"(
+ "use strict";
+ function* gen() {
+ yield 0;
+ }
+ function caller() { return gen(); }
+ caller();
+ )");
+
+ QVERIFY(!result.isError());
+ QVERIFY(!result.isUndefined());
+}
+
+void tst_QJSEngine::generatorMethodInTailCallPosition() {
+ QJSEngine engine;
+ QJSValue result = engine.evaluate(R"(
+ "use strict";
+ class Class {
+ *gen() {
+ yield 0;
+ }
+
+ caller() { return this.gen(); }
+ }
+ var c = new Class();
+ c.caller();
+ )");
+
+ QVERIFY(!result.isError());
+ QVERIFY(!result.isUndefined());
+}
+
+static unsigned stringListFetchCount = 0;
+class StringListProvider : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList strings READ strings CONSTANT)
+
+public:
+ QStringList strings() const
+ {
+ ++stringListFetchCount;
+ QStringList ret;
+ for (int i = 0; i < 10; ++i)
+ ret.append(QString::number(i));
+ return ret;
+ }
+};
+
+void tst_QJSEngine::consoleLogSequence()
+{
+ QJSEngine engine;
+ engine.installExtensions(QJSEngine::ConsoleExtension);
+
+ engine.globalObject().setProperty(
+ QStringLiteral("object"), engine.newQObject(new StringListProvider));
+
+ QTest::ignoreMessage(QtDebugMsg, "[0,1,2,3,4,5,6,7,8,9]");
+
+ engine.evaluate(QStringLiteral("console.log(object.strings)"));
+ QCOMPARE(stringListFetchCount, 1);
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"