Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/uses.cpp
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 89 | { | |||
---|---|---|---|---|---|
94 | TopDUContext* top = parse(method, DumpNone, QUrl(QStringLiteral("file:///internal/usestest/memberFunctionCall.php"))); | 94 | TopDUContext* top = parse(method, DumpNone, QUrl(QStringLiteral("file:///internal/usestest/memberFunctionCall.php"))); | ||
95 | DUChainReleaser releaseTop(top); | 95 | DUChainReleaser releaseTop(top); | ||
96 | DUChainWriteLocker lock(DUChain::lock()); | 96 | DUChainWriteLocker lock(DUChain::lock()); | ||
97 | Declaration* fun = top->childContexts().first()->localDeclarations().first(); | 97 | Declaration* fun = top->childContexts().first()->localDeclarations().first(); | ||
98 | compareUses(fun, RangeInRevision(0, 51, 0, 54)); | 98 | compareUses(fun, RangeInRevision(0, 51, 0, 54)); | ||
99 | QCOMPARE(fun->uses().keys().first(), IndexedString(QUrl("file:///internal/usestest/memberFunctionCall.php"))); | 99 | QCOMPARE(fun->uses().keys().first(), IndexedString(QUrl("file:///internal/usestest/memberFunctionCall.php"))); | ||
100 | } | 100 | } | ||
101 | 101 | | |||
102 | void TestUses::unsureMemberFunctionCall() { | ||||
103 | //First try with a single unsure structure type | ||||
104 | | ||||
105 | { | ||||
106 | // 0 1 2 3 4 5 6 7 8 | ||||
107 | // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 | ||||
108 | QByteArray method("<? class A { function foo() {} } if (true) { $a = new A(); } else { $a = null; } $a->foo();"); | ||||
109 | TopDUContext* top = parse(method, DumpNone); | ||||
110 | DUChainReleaser releaseTop(top); | ||||
111 | DUChainWriteLocker lock(DUChain::lock()); | ||||
112 | Declaration* fun = top->childContexts().first()->localDeclarations().first(); | ||||
113 | compareUses(fun, RangeInRevision(0, 85, 0, 88)); | ||||
114 | } | ||||
115 | | ||||
116 | //Now try with two unsure structure types | ||||
117 | | ||||
118 | { | ||||
119 | // 0 1 2 3 4 5 6 7 8 | ||||
120 | // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 | ||||
121 | QByteArray method("<? class A { function foo() {} } class B {} if (true) { $a = new A(); } else { $a = new B(); } $a->foo();"); | ||||
122 | TopDUContext* top = parse(method, DumpNone); | ||||
123 | DUChainReleaser releaseTop(top); | ||||
124 | DUChainWriteLocker lock(DUChain::lock()); | ||||
125 | Declaration* fun = top->childContexts().first()->localDeclarations().first(); | ||||
126 | QCOMPARE(fun->uses().keys().count(), 0); | ||||
127 | } | ||||
128 | } | ||||
129 | | ||||
102 | void TestUses::memberVariable() | 130 | void TestUses::memberVariable() | ||
103 | { | 131 | { | ||
104 | 132 | | |||
105 | // 0 1 2 3 4 5 6 7 | 133 | // 0 1 2 3 4 5 6 7 | ||
106 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | 134 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | ||
107 | QByteArray method("<? class A { public $foo; } $a = new A(); $a->foo; "); | 135 | QByteArray method("<? class A { public $foo; } $a = new A(); $a->foo; "); | ||
108 | TopDUContext* top = parse(method, DumpNone, QUrl(QStringLiteral("file:///internal/usestest/memberVariable.php"))); | 136 | TopDUContext* top = parse(method, DumpNone, QUrl(QStringLiteral("file:///internal/usestest/memberVariable.php"))); | ||
109 | DUChainReleaser releaseTop(top); | 137 | DUChainReleaser releaseTop(top); | ||
▲ Show 20 Lines • Show All 1165 Lines • Show Last 20 Lines |