aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-07-08 17:05:21 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:07 -0300
commit9961a25273bd6ff59efdef4d482269eea8c069d0 (patch)
treefd98f7e73c5793c0ca894f5487a74ba1060dc0a4 /tests
parent681f738fe473239d73172fdc979c208fdf434e2d (diff)
Fix bug#260 - "Can't modify argument name of a function added with add-function tag."
Diffstat (limited to 'tests')
-rw-r--r--tests/testaddfunction.cpp27
-rw-r--r--tests/testaddfunction.h1
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