diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 1999-04-07 14:42:40 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 1999-04-07 14:42:40 +0000 |
commit | ee9dd3721be68b9fa63dea9aa5a1d86e66958cde (patch) | |
tree | d96801a16fdf03a5682ef98730fe333a46eef944 /libjava/testsuite/libjava.lang | |
parent | 140fa895c6b859f827fc4437b91775a82cd105fb (diff) | |
download | gcc-ee9dd3721be68b9fa63dea9aa5a1d86e66958cde.zip gcc-ee9dd3721be68b9fa63dea9aa5a1d86e66958cde.tar.gz gcc-ee9dd3721be68b9fa63dea9aa5a1d86e66958cde.tar.bz2 |
Initial revision
From-SVN: r26263
Diffstat (limited to 'libjava/testsuite/libjava.lang')
-rw-r--r-- | libjava/testsuite/libjava.lang/Array_1.java | 18 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Array_1.out | 4 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Finalize_1.java | 28 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Finalize_1.out | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Float_1.java | 52 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Float_1.out | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Invoke_1.java | 27 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Invoke_1.out | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Synch.java | 17 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Synch.out | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_1.java | 182 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_1.out | 10 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Throw_1.java | 25 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Throw_1.out | 0 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/test.exp | 34 |
15 files changed, 401 insertions, 0 deletions
diff --git a/libjava/testsuite/libjava.lang/Array_1.java b/libjava/testsuite/libjava.lang/Array_1.java new file mode 100644 index 0000000..1fcf04e --- /dev/null +++ b/libjava/testsuite/libjava.lang/Array_1.java @@ -0,0 +1,18 @@ +// Test of array stuff. Technically this probably isn't in java.lang. + +public class Array_1 +{ + public static void main (String[] args) + { + int x[][] = { { 1, 2}, null }; + + System.out.println(Cloneable.class.isInstance(x)); + + // This example is from the Java Spec book. + int y[][] = (int[][]) x.clone(); + System.out.println(x == y); + System.out.println(x[0] == y[0] && x[1] == y[1]); + + System.out.println(x.getClass().getSuperclass()); + } +} diff --git a/libjava/testsuite/libjava.lang/Array_1.out b/libjava/testsuite/libjava.lang/Array_1.out new file mode 100644 index 0000000..3cc754d --- /dev/null +++ b/libjava/testsuite/libjava.lang/Array_1.out @@ -0,0 +1,4 @@ +true +false +true +class java.lang.Object diff --git a/libjava/testsuite/libjava.lang/Finalize_1.java b/libjava/testsuite/libjava.lang/Finalize_1.java new file mode 100644 index 0000000..b1a4d95 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Finalize_1.java @@ -0,0 +1,28 @@ +// Finalize.java - Test code for finalizers. + +import java.io.*; +import java.util.*; +import java.lang.Runtime; + +public final class Finalize_1 +{ + public static void main (String[] args) + { + Finalize_1 f; + Runtime t; + + t = Runtime.getRuntime (); + + for (int i = 0; i < 3; ++i) + f = new Finalize_1 (); + f = null; + + t.gc (); + t.runFinalization (); + } + + public void finalize () throws Throwable + { + System.out.print ("Finalize "); + } +} diff --git a/libjava/testsuite/libjava.lang/Finalize_1.out b/libjava/testsuite/libjava.lang/Finalize_1.out new file mode 100644 index 0000000..45b1f96 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Finalize_1.out @@ -0,0 +1 @@ +Finalize Finalize Finalize diff --git a/libjava/testsuite/libjava.lang/Float_1.java b/libjava/testsuite/libjava.lang/Float_1.java new file mode 100644 index 0000000..cb147ee --- /dev/null +++ b/libjava/testsuite/libjava.lang/Float_1.java @@ -0,0 +1,52 @@ +/* + +Date: 25 Aug 1998 16:04:00 -0000 +From: Andrew Haley <aph@pasanda.cygnus.co.uk> +To: java-project@cygnus.com +Subject: Help: vtable problem? + +My little program: + +----------------------------------------------------------------------- +import java.lang.*; + + public class widget + { + public static void main (String argv[]) + { + int test = Float.floatToIntBits((float)2.0); + String s = Integer.toHexString(test); + + System.out.print (s+"\n"); + } + + } +----------------------------------------------------------------------- +prints out + +40000000 + +with Sun's interpreter, but prints out + +true + +when compiled with gcj; PrintStream dispatches a string arg as a +boolean rather than as a String. I've tried to rebuild everything. + +? + +Thanks, +Andrew. + +*/ + +public class Float_1 +{ + public static void main (String argv[]) + { + int test = Float.floatToIntBits((float)2.0); + String s = Integer.toHexString(test); + + System.out.print (s+"\n"); + } +} diff --git a/libjava/testsuite/libjava.lang/Float_1.out b/libjava/testsuite/libjava.lang/Float_1.out new file mode 100644 index 0000000..52f3f6a --- /dev/null +++ b/libjava/testsuite/libjava.lang/Float_1.out @@ -0,0 +1 @@ +40000000 diff --git a/libjava/testsuite/libjava.lang/Invoke_1.java b/libjava/testsuite/libjava.lang/Invoke_1.java new file mode 100644 index 0000000..bc467830 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Invoke_1.java @@ -0,0 +1,27 @@ +// Test of failing method invocation. + +public class Invoke_1 +{ + public void call_me () + { + System.out.println ("no"); + } + + public static Invoke_1 get_i () + { + return null; + } + + public static void main (String[] args) + { + Invoke_1 i = get_i (); + try + { + i.call_me (); + } + catch (NullPointerException ok) + { + System.out.println ("ok"); + } + } +} diff --git a/libjava/testsuite/libjava.lang/Invoke_1.out b/libjava/testsuite/libjava.lang/Invoke_1.out new file mode 100644 index 0000000..9766475 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Invoke_1.out @@ -0,0 +1 @@ +ok diff --git a/libjava/testsuite/libjava.lang/Synch.java b/libjava/testsuite/libjava.lang/Synch.java new file mode 100644 index 0000000..15e2d26 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Synch.java @@ -0,0 +1,17 @@ +public class Synch +{ + public synchronized void s() + { + // This call to notify() isn't supposed to cause a + // java.lang.IllegalMonitorStateException. + notify (); + } + + public static void main (String[] args) + { + (new Synch()).s(); + System.out.println ("Ok"); + } +} + + diff --git a/libjava/testsuite/libjava.lang/Synch.out b/libjava/testsuite/libjava.lang/Synch.out new file mode 100644 index 0000000..7326d96 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Synch.out @@ -0,0 +1 @@ +Ok diff --git a/libjava/testsuite/libjava.lang/Thread_1.java b/libjava/testsuite/libjava.lang/Thread_1.java new file mode 100644 index 0000000..932afa5 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Thread_1.java @@ -0,0 +1,182 @@ +// Various thread tests. + +public class Thread_1 extends Thread +{ + // The group for the workers. + static ThreadGroup subgroup; + + // Which piece of test code to try. + static int test_case; + + // Names of the tests. + static final int JOIN_GOOD = 0; + static final int JOIN_TIMEOUT = 1; + static final int JOIN_INTERRUPTED = 2; + static final int THREAD_EXIT = 3; + + // True if this is normal; false if daemon. + boolean normal; + // The other thread in the test. + Thread_1 other; + // True when the thread has entered run(). + boolean started; + + public void run () + { + try + { + if (normal) + { + System.out.println ("test " + test_case); + // Tell the main thread to start the daemon thread. + synchronized (this) + { + started = true; + notify (); + } + // Now wait for daemon to start. + synchronized (other) + { + while (! other.started) + other.wait (); + } + switch (test_case) + { + case JOIN_GOOD: + other.join (); + System.out.println ("joined"); + break; + case JOIN_TIMEOUT: + other.join (10); + System.out.println (other.isAlive()); + other.join (); + break; + case JOIN_INTERRUPTED: + other.join (); + System.out.println ("joined"); + break; + case THREAD_EXIT: + // Nothing. + break; + + default: + System.out.println ("failure"); + break; + } + } + else + { + // Let the normal thread start first. + synchronized (other) + { + while (! other.started) + other.wait(); + } + // Tell normal thread that we've started. + synchronized (this) + { + started = true; + notify (); + } + switch (test_case) + { + case JOIN_GOOD: + System.out.println ("daemon done"); + break; + case JOIN_TIMEOUT: + sleep (50); + break; + case JOIN_INTERRUPTED: + other.interrupt (); + break; + case THREAD_EXIT: + // Wait for a while. However, don't wait indefinitely + // -- we want this thread to terminate so that the + // process won't hang if there is a bug. + sleep (10000); + System.out.println ("daemon still alive"); + break; + + default: + System.out.println ("failure"); + break; + } + } + } + catch (InterruptedException e) + { + System.out.println ("interrupted"); + } + } + + public void setOther (Thread_1 x) + { + other = x; + } + + Thread_1 (String name, boolean x) + { + super (subgroup, name); + normal = x; + started = false; + setDaemon (! normal); + } + + // Run a single test. + static Thread_1 doit (int what) + { + // FIXME: we used to just use the same threads each time. That + // didn't work -- must debug. + Thread_1 dt = new Thread_1 ("daemon", false); + Thread_1 nt = new Thread_1 ("normal", true); + + dt.setOther(nt); + nt.setOther(dt); + + test_case = what; + try + { + nt.start(); + dt.start(); + + // Don't wait for the threads if we're doing the exit test. + if (what != THREAD_EXIT) + { + nt.join (); + dt.join (); + } + } + catch (InterruptedException e) + { + System.out.println ("caught bad exception"); + } + + return dt; + } + + public static void main (String[] args) + { + subgroup = new ThreadGroup ("sub"); + + doit (JOIN_GOOD); + + System.out.println ("active count = " + subgroup.activeCount ()); + + Thread_1 dt = doit (JOIN_TIMEOUT); + // Make sure that joining a dead thread works. + System.out.println ("still alive: " + dt.isAlive ()); + try + { + dt.join (); + } + catch (InterruptedException e) + { + System.out.println ("exception caught"); + } + + doit (JOIN_INTERRUPTED); + + // This test must come last. + doit (THREAD_EXIT); + } +} diff --git a/libjava/testsuite/libjava.lang/Thread_1.out b/libjava/testsuite/libjava.lang/Thread_1.out new file mode 100644 index 0000000..1bd7a01 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Thread_1.out @@ -0,0 +1,10 @@ +test 0 +daemon done +joined +active count = 2 +test 1 +true +still alive: false +test 2 +interrupted +test 3 diff --git a/libjava/testsuite/libjava.lang/Throw_1.java b/libjava/testsuite/libjava.lang/Throw_1.java new file mode 100644 index 0000000..4a0780a --- /dev/null +++ b/libjava/testsuite/libjava.lang/Throw_1.java @@ -0,0 +1,25 @@ +// Some tests of `throw'. + +public class Throw_1 +{ + public static Throwable get () + { + return null; + } + + public static void main (String[] args) + { + Throwable t = get (); + try + { + throw t; + } + catch (NullPointerException y) + { + } + catch (Throwable x) + { + System.out.println ("no"); + } + } +} diff --git a/libjava/testsuite/libjava.lang/Throw_1.out b/libjava/testsuite/libjava.lang/Throw_1.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Throw_1.out diff --git a/libjava/testsuite/libjava.lang/test.exp b/libjava/testsuite/libjava.lang/test.exp new file mode 100644 index 0000000..cfe9cf5 --- /dev/null +++ b/libjava/testsuite/libjava.lang/test.exp @@ -0,0 +1,34 @@ +global srcdir subdir + +catch "glob -nocomplain ${srcdir}/${subdir}/*.out" srcfiles +verbose "srcfiles are $srcfiles" + +set prefix "" +foreach x $srcfiles { + regsub "\\.out$" $x "" prefix + set bname [file tail $prefix] + set args "" + if [file exists $srcdir/$subdir/${bname}.arg] { + set id [open "$srcdir/$subdir/${bname}.arg" r]; + set args [read -nonewline $id]; + close $id; + } + if [file exists $srcdir/$subdir/${bname}.xpo] { + set resfile "$srcdir/$subdir/${bname}.xpo" + set options "regexp_match" + } else { + set resfile "${prefix}.out" + set options "" + } + + if [file exists ${prefix}.inp] { + set inpfile ${prefix}.inp + } else { + set inpfile "" + } + + verbose "inpfile is $inpfile" + + test_libjava $options "${prefix}.java" "" $inpfile $resfile $args + test_libjava $options "${prefix}.java" "-O" $inpfile $resfile $args +} |