aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-02-04 17:12:41 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:14 -0300
commit7ee3543fd19e49fffaf6f3213cc553ebb3ee636e (patch)
tree35d067052f993ef4df4def43f8a3045617cf17a1 /tests
parent517993907bb165daafda75c9c5165985ea454794 (diff)
Global functions can now be renamed.
This is accomplished via the "rename" attribute on the "function" tag. An unit test was added and the documentation updated. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/testfunctiontag.cpp25
-rw-r--r--tests/testfunctiontag.h1
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/testfunctiontag.cpp b/tests/testfunctiontag.cpp
index 79e3142a5..378baf479 100644
--- a/tests/testfunctiontag.cpp
+++ b/tests/testfunctiontag.cpp
@@ -58,6 +58,31 @@ void TestFunctionTag::testFunctionTagForAllSignatures()
QCOMPARE(t.builder()->globalFunctions().size(), 2);
}
+void TestFunctionTag::testRenameGlobalFunction()
+{
+ const char* cppCode ="void global_function_with_ugly_name();";
+ const char* xmlCode = "\
+ <typesystem package='Foo'> \
+ <function signature='global_function_with_ugly_name()' rename='smooth' />\
+ </typesystem>";
+ TestUtil t(cppCode, xmlCode, false);
+
+ FunctionTypeEntry* func = (FunctionTypeEntry*) TypeDatabase::instance()->findType("global_function_with_ugly_name");
+ QVERIFY(func);
+
+ QCOMPARE(t.builder()->globalFunctions().size(), 1);
+ const AbstractMetaFunction* metaFunc = t.builder()->globalFunctions().first();
+
+ QVERIFY(metaFunc);
+ QCOMPARE(metaFunc->modifications().size(), 1);
+ QVERIFY(metaFunc->modifications().first().isRenameModifier());
+ QCOMPARE(metaFunc->modifications().first().renamedTo(), QString("smooth"));
+
+ QCOMPARE(metaFunc->name(), QString("smooth"));
+ QCOMPARE(metaFunc->originalName(), QString("global_function_with_ugly_name"));
+ QCOMPARE(metaFunc->minimalSignature(), QString("global_function_with_ugly_name()"));
+}
+
QTEST_APPLESS_MAIN(TestFunctionTag)
#include "testfunctiontag.moc"
diff --git a/tests/testfunctiontag.h b/tests/testfunctiontag.h
index 8f42774c6..2edd1c4de 100644
--- a/tests/testfunctiontag.h
+++ b/tests/testfunctiontag.h
@@ -31,6 +31,7 @@ class TestFunctionTag : public QObject
private slots:
void testFunctionTagForSpecificSignature();
void testFunctionTagForAllSignatures();
+ void testRenameGlobalFunction();
};
#endif