Commit ee16a1e8 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Added testcase for find usages of inline method parameters.

parent 4df9b375
...@@ -48,6 +48,8 @@ class tst_FindUsages: public QObject ...@@ -48,6 +48,8 @@ class tst_FindUsages: public QObject
Q_OBJECT Q_OBJECT
private Q_SLOTS: private Q_SLOTS:
void inlineMethod();
// Objective-C // Objective-C
void objc_args(); void objc_args();
// void objc_methods(); // void objc_methods();
...@@ -55,6 +57,42 @@ private Q_SLOTS: ...@@ -55,6 +57,42 @@ private Q_SLOTS:
// void objc_classes(); // void objc_classes();
}; };
void tst_FindUsages::inlineMethod()
{
const QByteArray src = "\n"
"class Tst {\n"
" int method(int arg) {\n"
" return arg;\n"
" }\n"
"};\n";
Document::Ptr doc = Document::create("inlineMethod");
doc->setSource(src);
doc->parse();
doc->check();
QVERIFY(doc->diagnosticMessages().isEmpty());
QCOMPARE(doc->globalSymbolCount(), 1U);
Snapshot snapshot;
snapshot.insert(doc);
Class *tst = doc->globalSymbolAt(0)->asClass();
QVERIFY(tst);
QCOMPARE(tst->memberCount(), 1U);
Function *method = tst->memberAt(0)->asFunction();
QVERIFY(method);
QCOMPARE(method->argumentCount(), 1U);
Argument *arg = method->argumentAt(0)->asArgument();
QVERIFY(arg);
QCOMPARE(arg->identifier()->chars(), "arg");
FindUsages findUsages(doc, snapshot);
findUsages.setGlobalNamespaceBinding(bind(doc, snapshot));
findUsages(arg);
QCOMPARE(findUsages.usages().size(), 2);
QCOMPARE(findUsages.references().size(), 2);
}
#if 0 #if 0
@interface Clazz {} +(void)method:(int)arg; @end @interface Clazz {} +(void)method:(int)arg; @end
@implementation Clazz +(void)method:(int)arg { @implementation Clazz +(void)method:(int)arg {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment