New test cases
Andrew Haley
aph@cambridge.redhat.com
Tue Jul 2 10:20:00 GMT 2002
I committed these test cases that I wrote while testing the inliner.
Andrew.
2002-07-02 Andrew Haley <aph@redhat.com>
* libjava.lang/inline.java: New file.
* libjava.lang/inline.out: Likewise.
* libjava.lang/Array_3.java: Add another case.
Index: libjava.lang/inline.java
===================================================================
RCS file: libjava.lang/inline.java
diff -N libjava.lang/inline.java
--- libjava.lang/inline.java 1 Jan 1970 00:00:00 -0000
+++ libjava.lang/inline.java 2 Jul 2002 17:17:58 -0000
@@ -0,0 +1,35 @@
+public class inline
+{
+ static int factorial_1 (int n)
+ {
+ if (n > 0)
+ return n * factorial_1(n-1);
+ return 1;
+ }
+
+ static int factorial_2 (int n)
+ {
+ if (n > 0)
+ return n * factorial_3(n-1);
+ return 1;
+ }
+
+ static int factorial_3 (int n)
+ {
+ if (n > 0)
+ return n * factorial_2(n-1);
+ return 1;
+ }
+
+ public static void main(String args[])
+ {
+ if (factorial_1 (5) != 120)
+ System.out.println("This should not happen");
+ else
+ System.out.println("OK");
+ if (factorial_2 (5) != 120)
+ System.out.println("This should not happen");
+ else
+ System.out.println("OK");
+ }
+}
Index: libjava.lang/inline.out
===================================================================
RCS file: libjava.lang/inline.out
diff -N libjava.lang/inline.out
--- libjava.lang/inline.out 1 Jan 1970 00:00:00 -0000
+++ libjava.lang/inline.out 2 Jul 2002 17:17:58 -0000
@@ -0,0 +1,2 @@
+OK
+OK
Index: libjava.lang/Array_3.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/libjava.lang/Array_3.java,v
retrieving revision 1.1
diff -u -r1.1 Array_3.java
--- libjava.lang/Array_3.java 20 Dec 2001 14:09:03 -0000 1.1
+++ libjava.lang/Array_3.java 2 Jul 2002 17:17:58 -0000
@@ -27,7 +27,7 @@
ok = true;
}
if (!ok)
- throw new RuntimeException("test failed");
+ throw new RuntimeException("test failed:1");
ok = false;
try
@@ -40,7 +40,7 @@
ok = true;
}
if (!ok)
- throw new RuntimeException("test failed");
+ throw new RuntimeException("test failed:2");
ok = false;
try
@@ -54,6 +54,19 @@
}
if (!ok || nn != 0)
- throw new RuntimeException("test failed");
+ throw new RuntimeException("test failed:3");
+
+ ok = false;
+ try
+ {
+ int[] x = (int[])null;
+ nn = x.length;
+ }
+ catch (NullPointerException _)
+ {
+ ok = true;
+ }
+ if (!ok)
+ throw new RuntimeException("test failed:4");
}
}
More information about the Java
mailing list