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 |
/* |
288 |
* Ensure that the deprecated flag is correctly reported |
372 |
* Ensure that the deprecated flag is correctly reported |
289 |
* (regression test fo bug 23207 Flags.isDeprecated(IMethod.getFlags()) doesn't work) |
373 |
* (regression test fo bug 23207 Flags.isDeprecated(IMethod.getFlags()) doesn't work) |
290 |
*/ |
374 |
*/ |
Lines 2290-2294
Link Here
|
2290 |
this.workingCopy.getSource()); |
2374 |
this.workingCopy.getSource()); |
2291 |
} |
2375 |
} |
2292 |
|
2376 |
|
|
|
2377 |
/* |
2378 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=248312 |
2379 |
* Ensures that negative values work while annotating local variables. |
2380 |
*/ |
2381 |
public void testBug248312() throws CoreException{ |
2382 |
createWorkingCopy( |
2383 |
"package p;\n" + |
2384 |
"public @interface Y {\n" + |
2385 |
" public int member_int() default -1;\n" + |
2386 |
" public float member_float() default -1.0f\n" + |
2387 |
" public double member_double=-1.0\n" + |
2388 |
" public long member_long=-1L\n" + |
2389 |
"}\n" + |
2390 |
"public class Test{\n" + |
2391 |
" void testMethod(){\n" + |
2392 |
" @Y(member_int=-1) @Y(member_float=-1.0f)\n" + |
2393 |
" @Y(member_double=-1.0) @Y(member_long=-1L)\n" + |
2394 |
" Object testField1\n" + |
2395 |
" }\n" + |
2396 |
"}" |
2397 |
); |
2398 |
ILocalVariable variable1 = selectLocalVariable(this.workingCopy, "testField1"); |
2399 |
IAnnotation[] annotations = variable1.getAnnotations(); |
2400 |
assertAnnotationsEqual( |
2401 |
"@Y(member_int=(int)-1)\n" + |
2402 |
"@Y(member_float=-1.0f)\n" + |
2403 |
"@Y(member_double=(double)-1.0)\n" + |
2404 |
"@Y(member_long=-1L)\n", |
2405 |
annotations); |
2406 |
} |
2293 |
|
2407 |
|
2294 |
} |
2408 |
} |