()
| 160 | } |
| 161 | |
| 162 | @Test |
| 163 | public void testClassReference() { |
| 164 | // Setup search - References to the "Exponent" class |
| 165 | // - Should be 3 references in "Exponent" |
| 166 | // - 2 "this" variables in "calc/Exponent" |
| 167 | // - 1 type reference in "calc/Calculator" |
| 168 | SearchCollector collector = SearchBuilder.in(workspace) |
| 169 | .query(new ClassReferenceQuery("calc/Exponent")).build(); |
| 170 | // Show results |
| 171 | List<SearchResult> results = collector.getAllResults(); |
| 172 | assertEquals(3, results.size()); |
| 173 | int calc = 0, exp = 0; |
| 174 | for (SearchResult res : results) { |
| 175 | if (res.getContext() instanceof Context.InsnContext) { |
| 176 | Context.InsnContext insnContext = (Context.InsnContext) res.getContext(); |
| 177 | String owner = insnContext.getParent().getParent().getName(); |
| 178 | if (!owner.equals("calc/Calculator")) |
| 179 | fail("Unexpected result in: " + owner); |
| 180 | calc++; |
| 181 | } else if(res.getContext() instanceof Context.LocalContext) { |
| 182 | Context.LocalContext localContext = (Context.LocalContext) res.getContext(); |
| 183 | String owner = localContext.getParent().getParent().getName(); |
| 184 | if (!owner.equals("calc/Exponent")) |
| 185 | fail("Unexpected result in: " + owner); |
| 186 | exp++; |
| 187 | } |
| 188 | } |
| 189 | // - LOCAL this |
| 190 | // - LOCAL this |
| 191 | assertEquals(2, exp); |
| 192 | // - NEW Exponent |
| 193 | assertEquals(1, calc); |
| 194 | } |
| 195 | |
| 196 | @Test |
| 197 | public void testMemberReference() { |
nothing calls this directly
no test coverage detected