/* test various control structures */ public class mainer { public static void main(String[]args) { foo f = new foo(); try { f.doit(); } catch (Throwable exn) { System.out.println("got an exn"); } f.more(3,30); try { f.testexn(); System.out.println("failed"); } catch (ArrayIndexOutOfBoundsException exn) { System.out.println("ok"); } System.out.println("done."); } } class bar { protected int D; public inline bar() { this.D = -1; } public inline bar(int D) { this.D = D; } } class foo extends bar { private int A; private int B; private inline int getA() { return A; } private inline void setA(int A) { this.A = A; return; } private inline int doubleIt(int A) { return A*2; } public inline foo() { super(5); B = 5; } public inline foo(int A) { this(); setA(A); } public inline foo(double x) { B = -1; } public synchronized inline void doit() throws Throwable { PrivateRegion p = new PrivateRegion(); foo f = new (p) foo(12); if (f.D != 5) System.out.println("Bad D"); if (f.A != 12) System.out.println("Bad A"); foreach (p2 in [[0]:[10]:[2]]) { System.out.println(p2[1]/2); f.setA(doubleIt(f.getA())); } if (f.A != 768) System.out.println("Bad computed A"); p.delete(); foo g = new foo(2.4); if (g.B != -1) System.out.println("Bad B"); if (g.D != -1) System.out.println("Bad D"); } public inline void more(int x, int y) { if (x > 0) System.out.println(">"); else System.out.println("<"); for (int i=0; i < y; i++) { if (i % 2 == 0) continue; if (i == 17) break; System.out.println(i); } outermost: for (int i=0; i < 5; i++) { for(int j=0; j < 10; j++) { if (i == j && j == 3) break outermost; } if (i == 4) System.out.println("error in labeled break!!!"); } int [2d] A = new int [1:5,1:5]; foreach (p in A.domain()) inline { A[p] = 10; } foreach (p in A.domain()) { A[p] = A[p] + 5; System.out.println(A[p]); } arr(A, A); try { if (true) return; // collect cleanups? testexn(); } catch (Throwable exn) { } } private inline void arr(int [2d] A, int [2d] B) overlap(A,B) { foreach (p in A.domain()) inline { A[p] = B[p]; System.out.println(A[p]); } } public inline void testexn() throws ArrayIndexOutOfBoundsException { throw new ArrayIndexOutOfBoundsException(); } }