Signed-off-by: Vegard Nossum <[email protected]>
---
Makefile | 1 +
regression/jvm/CloneTest.java | 64 +++++++++++++++++++++++++++++++++++++++++
regression/run-suite.sh | 1 +
3 files changed, 66 insertions(+), 0 deletions(-)
create mode 100644 regression/jvm/CloneTest.java
diff --git a/Makefile b/Makefile
index 3db3210..1dd388f 100644
--- a/Makefile
+++ b/Makefile
@@ -216,6 +216,7 @@ REGRESSION_TEST_SUITE_CLASSES = \
regression/jvm/ArrayTest.class \
regression/jvm/BranchTest.class \
regression/jvm/ClassExceptionsTest.class \
+ regression/jvm/CloneTest.class \
regression/jvm/ControlTransferTest.class \
regression/jvm/ConversionTest.class \
regression/jvm/ExceptionsTest.class \
diff --git a/regression/jvm/CloneTest.java b/regression/jvm/CloneTest.java
new file mode 100644
index 0000000..53ce002
--- /dev/null
+++ b/regression/jvm/CloneTest.java
@@ -0,0 +1,64 @@
+package jvm;
+
+public class CloneTest extends TestCase {
+ public static class X implements Cloneable {
+ int x;
+ int y;
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+ }
+
+ private static void cloneObjectTest() throws Exception {
+ X x = new X();
+ x.x = 1;
+ x.y = 2;
+
+ X y = (X) x.clone();
+ assertEquals(y.x, 1);
+ assertEquals(y.y, 2);
+ }
+
+ private static void clonePrimitiveArrayTest() throws Exception {
+ int[] x = new int[10];
+
+ for (int i = 0; i < x.length; ++i)
+ x[i] = i;
+
+ int[] y = (int[]) x.clone();
+
+ for (int i = 0; i < x.length; ++i)
+ assertEquals(y[i], i);
+
+ y[0]++;
+ assertFalse(x[0] == y[0]);
+ }
+
+ private static void cloneObjectArrayTest() throws Exception {
+ X[] x = new X[10];
+
+ for (int i = 0; i < x.length; ++i) {
+ x[i] = new X();
+ x[i].x = i;
+ x[i].y = 2 * i;
+ }
+
+ X[] y = (X[]) x.clone();
+
+ for (int i = 0; i < x.length; ++i) {
+ assertEquals(y[i].x, i);
+ assertEquals(y[i].y, 2 * i);
+ }
+
+ y[0] = new X();
+ assertFalse(x[0] == y[0]);
+ }
+
+ public static void main(String[] args) throws Exception {
+ cloneObjectTest();
+ clonePrimitiveArrayTest();
+ cloneObjectArrayTest();
+ exit();
+ }
+}
diff --git a/regression/run-suite.sh b/regression/run-suite.sh
index ad9d886..ce10cde 100755
--- a/regression/run-suite.sh
+++ b/regression/run-suite.sh
@@ -56,6 +56,7 @@ if [ -z "$CLASS_LIST" ]; then
run_java jvm.ArrayTest 0
run_java jvm.BranchTest 0
run_java jvm.ClassExceptionsTest 0
+ run_java jvm.CloneTest 0
run_java jvm.ControlTransferTest 0
run_java jvm.ConversionTest 0
run_java jvm.ExceptionsTest 0
--
1.6.0.4
------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel