changeset 14056:6821244a6e2c

Interpreter: new test cases for arrays. Failing tests: 2
author briangoetz
date Fri, 10 Jun 2016 15:29:52 -0400
parents 5d236453e343
children 0ce7c64463e2
files interpreter/test-helpers/test/valhalla/interpreter/ConstructorTestHelper.java interpreter/test/valhalla/interpreter/InterpreterTest.java
diffstat 2 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/interpreter/test-helpers/test/valhalla/interpreter/ConstructorTestHelper.java	Fri Jun 10 12:40:30 2016 -0400
+++ b/interpreter/test-helpers/test/valhalla/interpreter/ConstructorTestHelper.java	Fri Jun 10 15:29:52 2016 -0400
@@ -54,4 +54,16 @@
             throw new AssertionError("constructor error");
         return cth;
     }
+
+    public static Object[] testArray(int x, int y) {
+        CTH cth = new CTH(x, y);
+        CTH[] array = new CTH[] { cth } ;
+        return array;
+    }
+
+    public static Object[] testArrayClone(int x, int y) {
+        CTH cth = new CTH(x, y);
+        CTH[] array = new CTH[] { cth } ;
+        return array.clone();
+    }
 }
--- a/interpreter/test/valhalla/interpreter/InterpreterTest.java	Fri Jun 10 12:40:30 2016 -0400
+++ b/interpreter/test/valhalla/interpreter/InterpreterTest.java	Fri Jun 10 15:29:52 2016 -0400
@@ -249,6 +249,18 @@
         assertEquals(f.get(o), 7);
         f = ic.getDeclaredField("y"); f.setAccessible(true);
         assertEquals(f.get(o), 9);
+
+        Object[] arr = (Object[]) interpreter.invokestatic(CONSTRUCTOR_HELPER, "testArray", "(II)[Ljava/lang/Object;", 7, 9);
+        f = ic.getDeclaredField("x"); f.setAccessible(true);
+        assertEquals(f.get(arr[0]), 7);
+        f = ic.getDeclaredField("y"); f.setAccessible(true);
+        assertEquals(f.get(arr[0]), 9);
+
+        arr = (Object[]) interpreter.invokestatic(CONSTRUCTOR_HELPER, "testArrayClone", "(II)[Ljava/lang/Object;", 7, 9);
+        f = ic.getDeclaredField("x"); f.setAccessible(true);
+        assertEquals(f.get(arr[0]), 7);
+        f = ic.getDeclaredField("y"); f.setAccessible(true);
+        assertEquals(f.get(arr[0]), 9);
     }
 }