diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/functionLookup.qml | 6 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 17 |
3 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index c7a2a7ef0e..34c6ea3542 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -62,6 +62,7 @@ set(qml_files extendedTypes.qml failures.qml fileDialog.qml + functionLookup.qml funcWithParams.qml functionReturningVoid.qml globals.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/functionLookup.qml b/tests/auto/qml/qmlcppcodegen/data/functionLookup.qml new file mode 100644 index 0000000000..211f524088 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/functionLookup.qml @@ -0,0 +1,6 @@ +import QtQml + +QtObject { + function foo() { return "a" + 99 } + property var bar: foo +} diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 555ec27a4d..48e0bb68c9 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -119,6 +119,7 @@ private slots: void notEqualsInt(); void infinities(); void blockComments(); + void functionLookup(); }; void tst_QmlCppCodegen::simpleBinding() @@ -1788,6 +1789,22 @@ void tst_QmlCppCodegen::blockComments() QCOMPARE(o->property("implicitHeight").toDouble(), 8.0); } +void tst_QmlCppCodegen::functionLookup() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/functionLookup.qml"_qs)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(o); + const QVariant foo = o->property("bar"); + QCOMPARE(foo.metaType(), QMetaType::fromType<QJSValue>()); + const QJSManagedValue method(engine.toScriptValue(foo), &engine); + QVERIFY(method.isFunction()); + const QJSValue result = method.call(); + QVERIFY(result.isString()); + QCOMPARE(result.toString(), QStringLiteral("a99")); +} + void tst_QmlCppCodegen::runInterpreted() { if (qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER")) |