diff options
| -rw-r--r-- | sources/shiboken6/ApiExtractor/tests/testremovefield.cpp | 39 | ||||
| -rw-r--r-- | sources/shiboken6/ApiExtractor/tests/testremovefield.h | 1 |
2 files changed, 40 insertions, 0 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testremovefield.cpp b/sources/shiboken6/ApiExtractor/tests/testremovefield.cpp index 8739e8dc8..2cc82071b 100644 --- a/sources/shiboken6/ApiExtractor/tests/testremovefield.cpp +++ b/sources/shiboken6/ApiExtractor/tests/testremovefield.cpp @@ -4,10 +4,15 @@ #include "testremovefield.h" #include <QtTest/QTest> #include "testutil.h" +#include <abstractmetaargument.h> #include <abstractmetafield.h> +#include <abstractmetafunction.h> +#include <abstractmetatype.h> #include <abstractmetalang.h> #include <typesystem.h> +using namespace Qt::StringLiterals; + void TestRemoveField::testRemoveField() { const char cppCode[] = "\ @@ -32,6 +37,40 @@ void TestRemoveField::testRemoveField() QCOMPARE(fieldA.name(), u"fieldA"); } +// Verify that 'static constexpr' fields are seen as static/const and +// appear fully qualified for function parameter default values. +void TestRemoveField::testConstExprField() +{ + const char cppCode[] = R"( +struct A { + static constexpr int constExprField = 44; + + void f(int iParam=constExprField); +}; +)"; + + const char xmlCode[] = R"( +<typesystem package="Foo"> + <value-type name='A'/> +</typesystem> +)"; + + QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false)); + QVERIFY(builder); + AbstractMetaClassList classes = builder->classes(); + const auto classA = AbstractMetaClass::findClass(classes, "A"); + QVERIFY(classA); + const auto &fields = classA->fields(); + QCOMPARE(fields.size(), 1); + QVERIFY(fields.constFirst().isStatic()); + QVERIFY(fields.constFirst().type().isConstant()); + const auto function = classA->findFunction("f"_L1); + QVERIFY(function); + const auto &arguments = function->arguments(); + QCOMPARE(arguments.size(), 1); + QCOMPARE(arguments.constFirst().defaultValueExpression(), "A::constExprField"_L1); +} + QTEST_APPLESS_MAIN(TestRemoveField) diff --git a/sources/shiboken6/ApiExtractor/tests/testremovefield.h b/sources/shiboken6/ApiExtractor/tests/testremovefield.h index febe672ce..05912d99e 100644 --- a/sources/shiboken6/ApiExtractor/tests/testremovefield.h +++ b/sources/shiboken6/ApiExtractor/tests/testremovefield.h @@ -11,6 +11,7 @@ class TestRemoveField : public QObject Q_OBJECT private slots: void testRemoveField(); + void testConstExprField(); }; #endif |
