Lines 285-290
Link Here
|
285 |
} |
285 |
} |
286 |
|
286 |
|
287 |
/* |
287 |
/* |
|
|
288 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=248312 |
289 |
* Ensures that the default value (a negative int) for an annotation method is correct. |
290 |
*/ |
291 |
public void testDefaultValue7() throws CoreException { |
292 |
try { |
293 |
String cuSource = |
294 |
"package p;\n" + |
295 |
"public @interface Y {\n" + |
296 |
" public int member() default -1;\n" + |
297 |
"}"; |
298 |
createFile("/P/src/p/Y.java", cuSource); |
299 |
IMethod method = getCompilationUnit("/P/src/p/Y.java").getType("Y").getMethod("member", new String[0]); |
300 |
assertMemberValuePairEquals( |
301 |
"member=(int)-1", |
302 |
method.getDefaultValue()); |
303 |
} finally { |
304 |
deleteFile("/P/src/p/Y.java"); |
305 |
} |
306 |
} |
307 |
|
308 |
/* |
309 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=248312 |
310 |
* Ensures that the default value (a negative float) for an annotation method is correct. |
311 |
*/ |
312 |
public void testDefaultValue8() throws CoreException { |
313 |
try { |
314 |
String cuSource = |
315 |
"package p;\n" + |
316 |
"public @interface Y {\n" + |
317 |
" public float member() default -1.0f;\n" + |
318 |
"}"; |
319 |
createFile("/P/src/p/Y.java", cuSource); |
320 |
IMethod method = getCompilationUnit("/P/src/p/Y.java").getType("Y").getMethod("member", new String[0]); |
321 |
assertMemberValuePairEquals( |
322 |
"member=-1.0f", |
323 |
method.getDefaultValue()); |
324 |
} finally { |
325 |
deleteFile("/P/src/p/Y.java"); |
326 |
} |
327 |
} |
328 |
|
329 |
/* |
330 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=248312 |
331 |
* Ensures that the default value (a negative double) for an annotation method is correct. |
332 |
*/ |
333 |
public void testDefaultValue9() throws CoreException { |
334 |
try { |
335 |
String cuSource = |
336 |
"package p;\n" + |
337 |
"public @interface Y {\n" + |
338 |
" public double member() default -1.0;\n" + |
339 |
"}"; |
340 |
createFile("/P/src/p/Y.java", cuSource); |
341 |
IMethod method = getCompilationUnit("/P/src/p/Y.java").getType("Y").getMethod("member", new String[0]); |
342 |
assertMemberValuePairEquals( |
343 |
"member=(double)-1.0", |
344 |
method.getDefaultValue()); |
345 |
} finally { |
346 |
deleteFile("/P/src/p/Y.java"); |
347 |
} |
348 |
} |
349 |
|
350 |
/* |
351 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=248312 |
352 |
* Ensures that the default value (a negative long) for an annotation method is correct. |
353 |
*/ |
354 |
public void testDefaultValue10() throws CoreException { |
355 |
try { |
356 |
String cuSource = |
357 |
"package p;\n" + |
358 |
"public @interface Y {\n" + |
359 |
" public long member() default -1L;\n" + |
360 |
"}"; |
361 |
createFile("/P/src/p/Y.java", cuSource); |
362 |
IMethod method = getCompilationUnit("/P/src/p/Y.java").getType("Y").getMethod("member", new String[0]); |
363 |
assertMemberValuePairEquals( |
364 |
"member=-1L", |
365 |
method.getDefaultValue()); |
366 |
} finally { |
367 |
deleteFile("/P/src/p/Y.java"); |
368 |
} |
369 |
} |
370 |
|
371 |
/* |
372 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=248312 |
373 |
* Ensures that the default value (a sign appended Qualified Name Reference) for an annotation method is correct. |
374 |
*/ |
375 |
public void testDefaultValue11() throws CoreException { |
376 |
try { |
377 |
String cuSource = |
378 |
"package p;\n" + |
379 |
"interface A {\n" + |
380 |
" static int VAL = 1;\n" + |
381 |
"}\n" + |
382 |
"public @interface Y {\n" + |
383 |
" public int member() default -A.VAL;\n" + |
384 |
"}"; |
385 |
createFile("/P/src/p/Y.java", cuSource); |
386 |
IMethod method = getCompilationUnit("/P/src/p/Y.java").getType("Y").getMethod("member", new String[0]); |
387 |
assertMemberValuePairEquals( |
388 |
"member=-A.VAL", |
389 |
method.getDefaultValue()); |
390 |
} finally { |
391 |
deleteFile("/P/src/p/Y.java"); |
392 |
} |
393 |
} |
394 |
|
395 |
/* |
288 |
* Ensure that the deprecated flag is correctly reported |
396 |
* Ensure that the deprecated flag is correctly reported |
289 |
* (regression test fo bug 23207 Flags.isDeprecated(IMethod.getFlags()) doesn't work) |
397 |
* (regression test fo bug 23207 Flags.isDeprecated(IMethod.getFlags()) doesn't work) |
290 |
*/ |
398 |
*/ |
Lines 2290-2294
Link Here
|
2290 |
this.workingCopy.getSource()); |
2398 |
this.workingCopy.getSource()); |
2291 |
} |
2399 |
} |
2292 |
|
2400 |
|
|
|
2401 |
/* |
2402 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=248312 |
2403 |
* Ensures that negative values work while annotating local variables. |
2404 |
*/ |
2405 |
public void testBug248312() throws CoreException{ |
2406 |
createWorkingCopy( |
2407 |
"package p;\n" + |
2408 |
"interface A {\n" + |
2409 |
" static int VAL = 2;\n" + |
2410 |
"}\n" + |
2411 |
"public @interface Y {\n" + |
2412 |
" public int member_int() default -1;\n" + |
2413 |
" public int member_int2() default -1;\n" + |
2414 |
" public float member_float() default -1.0f\n" + |
2415 |
" public double member_double=-1.0\n" + |
2416 |
" public long member_long=-1L\n" + |
2417 |
"}\n" + |
2418 |
"public class Test{\n" + |
2419 |
" void testMethod(){\n" + |
2420 |
" @Y(member_int=-2) @Y(member_float=-2.0f)\n" + |
2421 |
" @Y(member_double=-2.0) @Y(member_long=-2L)\n" + |
2422 |
" @Y(member_int2=-A.VAL)\n" + |
2423 |
" Object testField1\n" + |
2424 |
" }\n" + |
2425 |
"}" |
2426 |
); |
2427 |
ILocalVariable variable1 = selectLocalVariable(this.workingCopy, "testField1"); |
2428 |
IAnnotation[] annotations = variable1.getAnnotations(); |
2429 |
assertAnnotationsEqual( |
2430 |
"@Y(member_int=(int)-2)\n" + |
2431 |
"@Y(member_float=-2.0f)\n" + |
2432 |
"@Y(member_double=(double)-2.0)\n" + |
2433 |
"@Y(member_long=-2L)\n" + |
2434 |
"@Y(member_int2=-A.VAL)\n", |
2435 |
annotations); |
2436 |
} |
2293 |
|
2437 |
|
2294 |
} |
2438 |
} |