diff options
author | jeffhao <jeffhao@google.com> | 2011-09-29 17:41:15 -0700 |
---|---|---|
committer | jeffhao <jeffhao@google.com> | 2011-09-29 17:41:15 -0700 |
commit | 5d1ac920fdaef5d4ec8f66bb734488cd9660b024 (patch) | |
tree | dd372f306ab70f4c86759869b1f74eca62ff6f2b /test/069-field-type | |
parent | c31664f3d82e6cd68275a529a8a73f067a52e8be (diff) | |
download | art-5d1ac920fdaef5d4ec8f66bb734488cd9660b024.tar.gz art-5d1ac920fdaef5d4ec8f66bb734488cd9660b024.tar.bz2 art-5d1ac920fdaef5d4ec8f66bb734488cd9660b024.zip |
Adding old unit tests to test suite.
These tests are copied straight over. They'll still run, but they're
using the old system.
Change-Id: If494519e52ddf858a9febfc55bdae830468cb3c8
Diffstat (limited to 'test/069-field-type')
-rw-r--r-- | test/069-field-type/expected.txt | 4 | ||||
-rw-r--r-- | test/069-field-type/info.txt | 4 | ||||
-rw-r--r-- | test/069-field-type/src/Blah.java | 9 | ||||
-rw-r--r-- | test/069-field-type/src/Holder.java | 7 | ||||
-rw-r--r-- | test/069-field-type/src/Main.java | 34 | ||||
-rw-r--r-- | test/069-field-type/src2/Blah.java | 10 |
6 files changed, 68 insertions, 0 deletions
diff --git a/test/069-field-type/expected.txt b/test/069-field-type/expected.txt new file mode 100644 index 0000000000..88281780f3 --- /dev/null +++ b/test/069-field-type/expected.txt @@ -0,0 +1,4 @@ +Assignment was allowed +Got expected IncompatibleClassChangeError +In compareTo +Done diff --git a/test/069-field-type/info.txt b/test/069-field-type/info.txt new file mode 100644 index 0000000000..6e3a22fd48 --- /dev/null +++ b/test/069-field-type/info.txt @@ -0,0 +1,4 @@ +This tests to see if the VM allows you to store a reference to an +inappropriate object type in an instance field. By compiling two +versions of the field-holder class we can bypass the compiler's type +safety. diff --git a/test/069-field-type/src/Blah.java b/test/069-field-type/src/Blah.java new file mode 100644 index 0000000000..fd98336461 --- /dev/null +++ b/test/069-field-type/src/Blah.java @@ -0,0 +1,9 @@ + +/** + * Trivial class; must implement an interesting interface. + */ +public class Blah implements Runnable { + public void run() { + System.out.println("run"); + } +} diff --git a/test/069-field-type/src/Holder.java b/test/069-field-type/src/Holder.java new file mode 100644 index 0000000000..e3c9f8936b --- /dev/null +++ b/test/069-field-type/src/Holder.java @@ -0,0 +1,7 @@ + +/** + * Simple class with one field. + */ +public class Holder { + public Runnable mValue; +} diff --git a/test/069-field-type/src/Main.java b/test/069-field-type/src/Main.java new file mode 100644 index 0000000000..f9885e64b2 --- /dev/null +++ b/test/069-field-type/src/Main.java @@ -0,0 +1,34 @@ + +/** + * Create some objects and store them into an instance field. + */ +public class Main { + /** + * Entry point. + */ + public static void main(String[] args) { + Holder holder = new Holder(); + + Blah blah = new Blah(); + + /* strictly speaking, this should fail */ + holder.mValue = blah; + + System.out.println("Assignment was allowed"); + + /* try to use the reference; should fail */ + try { + holder.mValue.run(); + System.err.println("ERROR: did not get expected ICCE"); + } catch (IncompatibleClassChangeError icce) { + System.out.println("Got expected IncompatibleClassChangeError"); + } + + /* for fun, verify that it's the "alternate" type */ + //Comparable cmpx = holder.mValue; /* compiler rejects */ + Comparable cmp = (Comparable) holder.mValue; + cmp.compareTo(cmp); + + System.out.println("Done"); + } +} diff --git a/test/069-field-type/src2/Blah.java b/test/069-field-type/src2/Blah.java new file mode 100644 index 0000000000..1bffff6c40 --- /dev/null +++ b/test/069-field-type/src2/Blah.java @@ -0,0 +1,10 @@ + +/** + * Trivial class; must implement an interesting interface. + */ +public class Blah implements Comparable { + public int compareTo(Object another) { + System.out.println("In compareTo"); + return 0; + } +} |