[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdevelop/languages/cpp/parser/tests
From: Hamish Rodda <rodda () kde ! org>
Date: 2006-07-11 19:32:22
Message-ID: 1152646342.816334.13774.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 561285 by rodda:
More work on the tests - can now easily declare more tests to perform
and check the output against
M +52 -10 test_duchain.cpp
--- trunk/KDE/kdevelop/languages/cpp/parser/tests/test_duchain.cpp #561284:561285
@@ -203,11 +203,59 @@
topContext->deleteChildContextsRecursively();
}
- void testParsing()
+ void testDeclareInt()
{
- QByteArray method("int i;");//void A::t() { for (int i = 0; i < 10; i++) { ; }}");
+ QByteArray method("int i;");
+
+ DUContext* top = parse(method);
+
+ QCOMPARE(top->childContexts().count(), 0);
+ QCOMPARE(top->localDefinitions().count(), 1);
+
+ Definition* def = top->localDefinitions().first();
+ QCOMPARE(def->identifier(), QString("i"));
+
+ //delete top;
+ }
+
+
+ void testDeclareFor()
+ {
+ QByteArray method("for (int i = 0; i < 10; i++) {}");
+
+ DUContext* top = parse(method);
+
+ /*QCOMPARE(top->childContexts(), 0);
+ QCOMPARE(top->localDefinitions(), 1);
+
+ Definition* def = top->localDefinitions().first();
+ QCOMPARE(def->identifier(), QString("i"));*/
+
+ //delete top;
+ }
+
+ void testDeclareFunction()
+ {
+ QByteArray method("void A::t() { }");
+
+ DUContext* top = parse(method);
+
+ /*QCOMPARE(top->childContexts(), 0);
+ QCOMPARE(top->localDefinitions(), 1);
+
+ Definition* def = top->localDefinitions().first();
+ QCOMPARE(def->identifier(), QString("i"));*/
+
+ //delete top;
+ }
+
+private:
+ DUContext* parse(const QByteArray& unit)
+ {
pool mem_pool;
- TranslationUnitAST* ast = parse(method, &mem_pool);
+
+ TranslationUnitAST* ast = parser.parse(unit.constData(), unit.size() + 1, &mem_pool);
+
EditorIntegrator::addParsedSource(&parser.lexer, &parser.token_stream);
dumper.dump(ast, &parser.token_stream);
@@ -216,14 +264,8 @@
DUContext* top = dubuilder.build(KUrl("file:///internal"), ast);
dumper.dump(top);
- delete top;
+ return top;
}
-
-private:
- TranslationUnitAST* parse(const QByteArray& unit, pool* mem_pool)
- {
- return parser.parse(unit.constData(), unit.size() + 1, mem_pool);
- }
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic