aboutsummaryrefslogtreecommitdiffstats
path: root/dcevm/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'dcevm/src/test')
-rw-r--r--dcevm/src/test/java7/com/github/dcevm/test/fields/EnumTest.java86
-rw-r--r--dcevm/src/test/java7/com/github/dcevm/test/methods/AnnotationTest.java3
2 files changed, 57 insertions, 32 deletions
diff --git a/dcevm/src/test/java7/com/github/dcevm/test/fields/EnumTest.java b/dcevm/src/test/java7/com/github/dcevm/test/fields/EnumTest.java
index 24836c4d..eb23ba2e 100644
--- a/dcevm/src/test/java7/com/github/dcevm/test/fields/EnumTest.java
+++ b/dcevm/src/test/java7/com/github/dcevm/test/fields/EnumTest.java
@@ -29,42 +29,64 @@ import org.junit.Ignore;
import org.junit.Test;
import static com.github.dcevm.test.util.HotSwapTestHelper.__toVersion__;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
/**
* @author Ivan Dubrov
*/
public class EnumTest {
- @Before
- public void setUp() throws Exception {
- __toVersion__(0);
- }
-
- static enum A {
- FIRST,
- SECOND;
- }
-
- static enum A___1 {
- SECOND,
- THIRD,
- FOURTH;
- }
-
- @Test
- @Ignore
- public void testEnumFields() throws Exception {
- assertEquals(2, A.values().length);
- assertNotNull(A.values()[0]);
- assertNotNull(A.values()[1]);
-
- __toVersion__(1);
-
- assertEquals(3, A.values().length);
- assertNotNull(A.values()[0]);
- assertNotNull(A.values()[1]);
- assertNotNull(A.values()[2]);
- }
+ @Before
+ public void setUp() throws Exception {
+ __toVersion__(0);
+ }
+
+ enum A {
+ FIRST,
+ SECOND {
+ },
+ OTHER,
+ ANOTHER;
+
+
+ private final static A THIRD = FIRST;
+ private final static A FOURTH = null;
+ }
+
+ enum A___1 {
+ SECOND {
+ },
+ THIRD,
+ FOURTH;
+
+ public final static A___1 FIRST = FOURTH;
+ public final static A___1 OTHER = null;
+ }
+
+ @Test
+ public void testEnumFields() throws Exception {
+ A second = A.SECOND;
+ assertEquals(4, A.values().length);
+ assertNotNull(A.values()[0]);
+ assertNotNull(A.values()[1]);
+
+ __toVersion__(1);
+
+ assertEquals(3, A.values().length);
+ assertNotNull(A.values()[0]);
+ assertNotNull(A.values()[1]);
+ assertNotNull(A.values()[2]);
+
+ assertSame("literal instance is the same", second, A.SECOND);
+ assertEquals("THIRD static non-literal field should not be copied", "THIRD", A.values()[1].name());
+ assertEquals("FOURTH static non-literal field should not be copied", "FOURTH", A.values()[2].name());
+ assertSame("literal should not be copied to a non-literal static field", A.FIRST, A.valueOf("FOURTH"));
+ assertNull("literal should not be copied to a non-literal static field", A.OTHER);
+
+ // Ordinal was transferred
+ assertEquals(0, second.ordinal());
+
+ // Array was updated
+ assertSame(second, A.values()[0]);
+ }
}
diff --git a/dcevm/src/test/java7/com/github/dcevm/test/methods/AnnotationTest.java b/dcevm/src/test/java7/com/github/dcevm/test/methods/AnnotationTest.java
index 3c4d6697..b709eb00 100644
--- a/dcevm/src/test/java7/com/github/dcevm/test/methods/AnnotationTest.java
+++ b/dcevm/src/test/java7/com/github/dcevm/test/methods/AnnotationTest.java
@@ -82,6 +82,9 @@ public class AnnotationTest {
@TestAnnotation2
public int testField;
+ public void addedMethod() {
+ }
+
@TestAnnotation2
public void testMethod() {
}