diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testaddfunction.cpp | 27 | ||||
-rw-r--r-- | tests/testaddfunction.h | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/testaddfunction.cpp b/tests/testaddfunction.cpp index e2be5a153..0346a6367 100644 --- a/tests/testaddfunction.cpp +++ b/tests/testaddfunction.cpp @@ -352,6 +352,33 @@ void TestAddFunction::testAddFunctionWithApiVersion() QCOMPARE(globalFuncs.count(), 1); } +void TestAddFunction::testModifyAddedFunction() +{ + const char cppCode[] = "class Foo { };"; + const char xmlCode[] = "\ + <typesystem package='Package'>\ + <primitive-type name='float'/>\ + <primitive-type name='int'/>\ + <value-type name='Foo'>\ + <add-function signature='method(float, int)'>\ + <inject-code class='target' position='beginning'>custom_code();</inject-code>\ + <modify-argument index='2'>\ + <replace-default-expression with='0' />\ + <rename to='varName' />\ + </modify-argument>\ + </add-function>\ + </value-type>\ + </typesystem>"; + TestUtil t(cppCode, xmlCode); + AbstractMetaClassList classes = t.builder()->classes(); + AbstractMetaClass* foo = classes.findClass("Foo"); + const AbstractMetaFunction* method = foo->findFunction("method"); + QCOMPARE(method->arguments().size(), 2); + AbstractMetaArgument* arg = method->arguments().at(1); + QCOMPARE(arg->defaultValueExpression(), QString("0")); + QCOMPARE(arg->name(), QString("varName")); + QCOMPARE(method->argumentName(2), QString("varName")); +} QTEST_APPLESS_MAIN(TestAddFunction) diff --git a/tests/testaddfunction.h b/tests/testaddfunction.h index 37c064cfb..09d806222 100644 --- a/tests/testaddfunction.h +++ b/tests/testaddfunction.h @@ -41,6 +41,7 @@ private slots: void testAddStaticFunction(); void testAddGlobalFunction(); void testAddFunctionWithApiVersion(); + void testModifyAddedFunction(); }; #endif |