1 package gov.nasa.jpf.test.vm.basic;
5 import gov.nasa.jpf.test.vm.basic.AnnotationToStringTest.*;
6 import gov.nasa.jpf.util.test.TestJPF;
8 public class AnnotationHashCodeEqualsTest extends TestJPF {
10 @A0(f1 = true, f2 = false)
13 @A0(f1 = true, f2 = false)
16 @A0(f1 = false, f2 = true)
21 public void testBooleanAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
22 if(verifyNoPropertyViolation()) {
23 Class<?> klass = C0.class;
24 A0 a = klass.getDeclaredField("f1").getAnnotation(A0.class);
25 A0 b = klass.getDeclaredField("f2").getAnnotation(A0.class);
26 A0 c = klass.getDeclaredField("f3").getAnnotation(A0.class);
28 assertEquals(a.hashCode(), b.hashCode());
29 assertFalse(c.equals(b));
30 assertFalse(c.equals(a));
35 @A1(f1 = { true, false }, f2 = { false, true })
38 @A1(f1 = { true, false }, f2 = { false, true })
41 @A1(f1 = { false, true }, f2 = { true, false })
46 public void testBooleanArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
47 if(verifyNoPropertyViolation()) {
48 Class<?> klass = C1.class;
49 A1 a = klass.getDeclaredField("f1").getAnnotation(A1.class);
50 A1 b = klass.getDeclaredField("f2").getAnnotation(A1.class);
51 A1 c = klass.getDeclaredField("f3").getAnnotation(A1.class);
53 assertEquals(a.hashCode(), b.hashCode());
54 assertFalse(c.equals(b));
55 assertFalse(c.equals(a));
71 public void testByteAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
72 if(verifyNoPropertyViolation()) {
73 Class<?> klass = C2.class;
74 A2 a = klass.getDeclaredField("f1").getAnnotation(A2.class);
75 A2 b = klass.getDeclaredField("f2").getAnnotation(A2.class);
76 A2 c = klass.getDeclaredField("f3").getAnnotation(A2.class);
78 assertEquals(a.hashCode(), b.hashCode());
79 assertFalse(c.equals(b));
80 assertFalse(c.equals(a));
85 @A3(f1 = { 2, 3 }, f2 = { 3, 2 })
88 @A3(f1 = { 2, 3 }, f2 = { 3, 2 })
91 @A3(f1 = { 3, 2 }, f2 = { 2, 3 })
96 public void testByteArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
97 if(verifyNoPropertyViolation()) {
98 Class<?> klass = C3.class;
99 A3 a = klass.getDeclaredField("f1").getAnnotation(A3.class);
100 A3 b = klass.getDeclaredField("f2").getAnnotation(A3.class);
101 A3 c = klass.getDeclaredField("f3").getAnnotation(A3.class);
103 assertEquals(a.hashCode(), b.hashCode());
104 assertFalse(c.equals(b));
105 assertFalse(c.equals(a));
110 @A4(f1 = 'a', f2 = 'b')
113 @A4(f1 = 'a', f2 = 'b')
116 @A4(f1 = 'b', f2 = 'a')
121 public void testCharAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
122 if(verifyNoPropertyViolation()) {
123 Class<?> klass = C4.class;
124 A4 a = klass.getDeclaredField("f1").getAnnotation(A4.class);
125 A4 b = klass.getDeclaredField("f2").getAnnotation(A4.class);
126 A4 c = klass.getDeclaredField("f3").getAnnotation(A4.class);
128 assertEquals(a.hashCode(), b.hashCode());
129 assertFalse(c.equals(b));
130 assertFalse(c.equals(a));
135 @A5(f1 = { 'a', 'b' }, f2 = { 'b', 'a' })
138 @A5(f1 = { 'a', 'b' }, f2 = { 'b', 'a' })
141 @A5(f1 = { 'b', 'a' }, f2 = { 'a', 'b' })
146 public void testCharArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
147 if(verifyNoPropertyViolation()) {
148 Class<?> klass = C5.class;
149 A5 a = klass.getDeclaredField("f1").getAnnotation(A5.class);
150 A5 b = klass.getDeclaredField("f2").getAnnotation(A5.class);
151 A5 c = klass.getDeclaredField("f3").getAnnotation(A5.class);
153 assertEquals(a.hashCode(), b.hashCode());
154 assertFalse(c.equals(b));
155 assertFalse(c.equals(a));
171 public void testShortAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
172 if(verifyNoPropertyViolation()) {
173 Class<?> klass = C6.class;
174 A6 a = klass.getDeclaredField("f1").getAnnotation(A6.class);
175 A6 b = klass.getDeclaredField("f2").getAnnotation(A6.class);
176 A6 c = klass.getDeclaredField("f3").getAnnotation(A6.class);
178 assertEquals(a.hashCode(), b.hashCode());
179 assertFalse(c.equals(b));
180 assertFalse(c.equals(a));
185 @A7(f1 = { 0, 1 }, f2 = { 1, 0 })
188 @A7(f1 = { 0, 1 }, f2 = { 1, 0 })
191 @A7(f1 = { 1, 0 }, f2 = { 0, 1 })
196 public void testShortArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
197 if(verifyNoPropertyViolation()) {
198 Class<?> klass = C7.class;
199 A7 a = klass.getDeclaredField("f1").getAnnotation(A7.class);
200 A7 b = klass.getDeclaredField("f2").getAnnotation(A7.class);
201 A7 c = klass.getDeclaredField("f3").getAnnotation(A7.class);
203 assertEquals(a.hashCode(), b.hashCode());
204 assertFalse(c.equals(b));
205 assertFalse(c.equals(a));
221 public void testIntAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
222 if(verifyNoPropertyViolation()) {
223 Class<?> klass = C8.class;
224 A8 a = klass.getDeclaredField("f1").getAnnotation(A8.class);
225 A8 b = klass.getDeclaredField("f2").getAnnotation(A8.class);
226 A8 c = klass.getDeclaredField("f3").getAnnotation(A8.class);
228 assertEquals(a.hashCode(), b.hashCode());
229 assertFalse(c.equals(b));
230 assertFalse(c.equals(a));
235 @A9(f1 = { 4, 5 }, f2 = { 5, 4 })
238 @A9(f1 = { 4, 5 }, f2 = { 5, 4 })
241 @A9(f1 = { 5, 4 }, f2 = { 4, 5 })
246 public void testIntArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
247 if(verifyNoPropertyViolation()) {
248 Class<?> klass = C9.class;
249 A9 a = klass.getDeclaredField("f1").getAnnotation(A9.class);
250 A9 b = klass.getDeclaredField("f2").getAnnotation(A9.class);
251 A9 c = klass.getDeclaredField("f3").getAnnotation(A9.class);
253 assertEquals(a.hashCode(), b.hashCode());
254 assertFalse(c.equals(b));
255 assertFalse(c.equals(a));
260 @A10(f1 = 9L, f2 = 10L)
263 @A10(f1 = 9L, f2 = 10L)
266 @A10(f1 = 10L, f2 = 9L)
271 public void testLongAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
272 if(verifyNoPropertyViolation()) {
273 Class<?> klass = C10.class;
274 A10 a = klass.getDeclaredField("f1").getAnnotation(A10.class);
275 A10 b = klass.getDeclaredField("f2").getAnnotation(A10.class);
276 A10 c = klass.getDeclaredField("f3").getAnnotation(A10.class);
278 assertEquals(a.hashCode(), b.hashCode());
279 assertFalse(c.equals(b));
280 assertFalse(c.equals(a));
285 @A11(f1 = { 9L, 10L }, f2 = { 10L, 9L })
288 @A11(f1 = { 9L, 10L }, f2 = { 10L, 9L })
291 @A11(f1 = { 10L, 9L }, f2 = { 9L, 10L })
296 public void testLongArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
297 if(verifyNoPropertyViolation()) {
298 Class<?> klass = C11.class;
299 A11 a = klass.getDeclaredField("f1").getAnnotation(A11.class);
300 A11 b = klass.getDeclaredField("f2").getAnnotation(A11.class);
301 A11 c = klass.getDeclaredField("f3").getAnnotation(A11.class);
303 assertEquals(a.hashCode(), b.hashCode());
304 assertFalse(c.equals(b));
305 assertFalse(c.equals(a));
310 @A12(f1 = 0.5f, f2 = 2.0f)
313 @A12(f1 = 0.5f, f2 = 2.0f)
316 @A12(f1 = 2.0f, f2 = 0.5f)
321 public void testFloatAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
322 if(verifyNoPropertyViolation()) {
323 Class<?> klass = C12.class;
324 A12 a = klass.getDeclaredField("f1").getAnnotation(A12.class);
325 A12 b = klass.getDeclaredField("f2").getAnnotation(A12.class);
326 A12 c = klass.getDeclaredField("f3").getAnnotation(A12.class);
328 assertEquals(a.hashCode(), b.hashCode());
329 assertFalse(c.equals(b));
330 assertFalse(c.equals(a));
335 @A13(f1 = { 0.5f, 2.0f }, f2 = { 2.0f, 0.5f })
338 @A13(f1 = { 0.5f, 2.0f }, f2 = { 2.0f, 0.5f })
341 @A13(f1 = { 2.0f, 0.5f }, f2 = { 0.5f, 2.0f })
346 public void testFloatArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
347 if(verifyNoPropertyViolation()) {
348 Class<?> klass = C13.class;
349 A13 a = klass.getDeclaredField("f1").getAnnotation(A13.class);
350 A13 b = klass.getDeclaredField("f2").getAnnotation(A13.class);
351 A13 c = klass.getDeclaredField("f3").getAnnotation(A13.class);
353 assertEquals(a.hashCode(), b.hashCode());
354 assertFalse(c.equals(b));
355 assertFalse(c.equals(a));
360 @A14(f1 = 2.0, f2 = 3.5)
363 @A14(f1 = 2.0, f2 = 3.5)
366 @A14(f1 = 3.5, f2 = 2.0)
371 public void testDoubleAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
372 if(verifyNoPropertyViolation()) {
373 Class<?> klass = C14.class;
374 A14 a = klass.getDeclaredField("f1").getAnnotation(A14.class);
375 A14 b = klass.getDeclaredField("f2").getAnnotation(A14.class);
376 A14 c = klass.getDeclaredField("f3").getAnnotation(A14.class);
378 assertEquals(a.hashCode(), b.hashCode());
379 assertFalse(c.equals(b));
380 assertFalse(c.equals(a));
385 @A15(f1 = { 2.0, 3.5 }, f2 = { 3.5, 2.0 })
388 @A15(f1 = { 2.0, 3.5 }, f2 = { 3.5, 2.0 })
391 @A15(f1 = { 3.5, 2.0 }, f2 = { 2.0, 3.5 })
396 public void testDoubleArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
397 if(verifyNoPropertyViolation()) {
398 Class<?> klass = C15.class;
399 A15 a = klass.getDeclaredField("f1").getAnnotation(A15.class);
400 A15 b = klass.getDeclaredField("f2").getAnnotation(A15.class);
401 A15 c = klass.getDeclaredField("f3").getAnnotation(A15.class);
403 assertEquals(a.hashCode(), b.hashCode());
404 assertFalse(c.equals(b));
405 assertFalse(c.equals(a));
410 @A16(f1 = "Hello", f2 = "World")
413 @A16(f1 = "Hello", f2 = "World")
416 @A16(f1 = "World", f2 = "Hello")
421 public void testStringAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
422 if(verifyNoPropertyViolation()) {
423 Class<?> klass = C16.class;
424 A16 a = klass.getDeclaredField("f1").getAnnotation(A16.class);
425 A16 b = klass.getDeclaredField("f2").getAnnotation(A16.class);
426 A16 c = klass.getDeclaredField("f3").getAnnotation(A16.class);
428 assertEquals(a.hashCode(), b.hashCode());
429 assertFalse(c.equals(b));
430 assertFalse(c.equals(a));
435 @A17(f1 = { "Hello", "World" }, f2 = { "World", "Hello" })
438 @A17(f1 = { "Hello", "World" }, f2 = { "World", "Hello" })
441 @A17(f1 = { "World", "Hello" }, f2 = { "Hello", "World" })
446 public void testStringArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
447 if(verifyNoPropertyViolation()) {
448 Class<?> klass = C17.class;
449 A17 a = klass.getDeclaredField("f1").getAnnotation(A17.class);
450 A17 b = klass.getDeclaredField("f2").getAnnotation(A17.class);
451 A17 c = klass.getDeclaredField("f3").getAnnotation(A17.class);
453 assertEquals(a.hashCode(), b.hashCode());
454 assertFalse(c.equals(b));
455 assertFalse(c.equals(a));
460 @A18(f1 = String.class, f2 = Integer.class)
463 @A18(f1 = String.class, f2 = Integer.class)
466 @A18(f1 = Integer.class, f2 = String.class)
471 public void testClassAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
472 if(verifyNoPropertyViolation()) {
473 Class<?> klass = C18.class;
474 A18 a = klass.getDeclaredField("f1").getAnnotation(A18.class);
475 A18 b = klass.getDeclaredField("f2").getAnnotation(A18.class);
476 A18 c = klass.getDeclaredField("f3").getAnnotation(A18.class);
478 assertEquals(a.hashCode(), b.hashCode());
479 assertFalse(c.equals(b));
480 assertFalse(c.equals(a));
485 @A19(f1 = { String.class, Integer.class }, f2 = { Integer.class, String.class })
488 @A19(f1 = { String.class, Integer.class }, f2 = { Integer.class, String.class })
491 @A19(f1 = { Integer.class, String.class }, f2 = { String.class, Integer.class })
496 public void testClassArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
497 if(verifyNoPropertyViolation()) {
498 Class<?> klass = C19.class;
499 A19 a = klass.getDeclaredField("f1").getAnnotation(A19.class);
500 A19 b = klass.getDeclaredField("f2").getAnnotation(A19.class);
501 A19 c = klass.getDeclaredField("f3").getAnnotation(A19.class);
503 assertEquals(a.hashCode(), b.hashCode());
504 assertFalse(c.equals(b));
505 assertFalse(c.equals(a));
510 @A20(f1 = EnumConsts.FIRST, f2 = EnumConsts.SECOND)
513 @A20(f1 = EnumConsts.FIRST, f2 = EnumConsts.SECOND)
516 @A20(f1 = EnumConsts.SECOND, f2 = EnumConsts.FIRST)
521 public void testEnumConstsAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
522 if(verifyNoPropertyViolation()) {
523 Class<?> klass = C20.class;
524 A20 a = klass.getDeclaredField("f1").getAnnotation(A20.class);
525 A20 b = klass.getDeclaredField("f2").getAnnotation(A20.class);
526 A20 c = klass.getDeclaredField("f3").getAnnotation(A20.class);
528 assertEquals(a.hashCode(), b.hashCode());
529 assertFalse(c.equals(b));
530 assertFalse(c.equals(a));
535 @A21(f1 = { EnumConsts.FIRST, EnumConsts.SECOND }, f2 = { EnumConsts.SECOND, EnumConsts.FIRST })
538 @A21(f1 = { EnumConsts.FIRST, EnumConsts.SECOND }, f2 = { EnumConsts.SECOND, EnumConsts.FIRST })
541 @A21(f1 = { EnumConsts.SECOND, EnumConsts.FIRST }, f2 = { EnumConsts.FIRST, EnumConsts.SECOND })
546 public void testEnumConstsArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
547 if(verifyNoPropertyViolation()) {
548 Class<?> klass = C21.class;
549 A21 a = klass.getDeclaredField("f1").getAnnotation(A21.class);
550 A21 b = klass.getDeclaredField("f2").getAnnotation(A21.class);
551 A21 c = klass.getDeclaredField("f3").getAnnotation(A21.class);
553 assertEquals(a.hashCode(), b.hashCode());
554 assertFalse(c.equals(b));
555 assertFalse(c.equals(a));
560 @A22(f1 = @Nested1(fields = @A16(f1 = "Hello", f2 = "World")), f2 = @Nested2(fields = @A1(f1 = false, f2 = false)))
563 @A22(f1 = @Nested1(fields = @A16(f1 = "Hello", f2 = "World")), f2 = @Nested2(fields = @A1(f1 = false, f2 = false)))
566 @A22(f1 = @Nested1(fields = @A16(f1 = "Hola", f2 = "Mundo")), f2 = @Nested2(fields = @A1(f1 = true, f2 = true)))
571 public void testAnnotationAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
572 if(verifyNoPropertyViolation()) {
573 Class<?> klass = C22.class;
574 A22 a = klass.getDeclaredField("f1").getAnnotation(A22.class);
575 A22 b = klass.getDeclaredField("f2").getAnnotation(A22.class);
576 A22 c = klass.getDeclaredField("f3").getAnnotation(A22.class);
578 assertEquals(a.hashCode(), b.hashCode());
579 assertFalse(c.equals(b));
580 assertFalse(c.equals(a));
586 @Nested1(fields = @A16(f1 = "Hello", f2 = "World")),
587 @Nested1(fields = @A16(f1 = "Bonjour", f2 = "Monde"))
589 @Nested2(fields = @A1(f1 = false, f2 = false)),
590 @Nested2(fields = @A1(f1 = true, f2 = true))
595 @Nested1(fields = @A16(f1 = "Hello", f2 = "World")),
596 @Nested1(fields = @A16(f1 = "Bonjour", f2 = "Monde"))
598 @Nested2(fields = @A1(f1 = false, f2 = false)),
599 @Nested2(fields = @A1(f1 = true, f2 = true))
604 @Nested1(fields = @A16(f1 = "Hola", f2 = "Mundo")),
605 @Nested1(fields = @A16(f1 = "Bonjour", f2 = "Monde"))
607 @Nested2(fields = @A1(f1 = false, f2 = true)),
608 @Nested2(fields = @A1(f1 = true, f2 = false))
613 public void testAnnotationArrayAttributeHashCodeEquals() throws NoSuchFieldException, SecurityException {
614 if(verifyNoPropertyViolation()) {
615 Class<?> klass = C23.class;
616 A23 a = klass.getDeclaredField("f1").getAnnotation(A23.class);
617 A23 b = klass.getDeclaredField("f2").getAnnotation(A23.class);
618 A23 c = klass.getDeclaredField("f3").getAnnotation(A23.class);
620 assertEquals(a.hashCode(), b.hashCode());
621 assertFalse(c.equals(b));
622 assertFalse(c.equals(a));