b93eed253362ff481a6c04469d6b2e7bede7d217
[IRC.git] / Robust / src / Tests / disjoint / definite-example / test.java
1 public class Foo {
2   int z;
3 }
4
5 public class Test {
6
7   
8
9   static public void main( String args[] ) {
10
11     int m = 2;
12     int n = 3;
13
14     Foo[] a;
15     Foo b;
16
17     Foo[][] top = new Foo[m][];
18     for( int i = 0; i < m; ++i ) {
19       a = getArray( n );
20       for( int j = 0; j < n; ++j ) {
21         b = getFoo();
22         a[j] = b;
23       }
24       top[i] = a;
25     }
26
27     // every Foo is reachable from only one Foo array
28     gendefreach z0;
29     genreach z0;
30
31     // resize array...
32     //Foo[] b = getArray( n + 1 );
33     //Foo[] notused = getArray( 1 );
34     //b[0] = getFoo();
35     //for( int j = 0; j < n; ++j ) {
36     //  b[j+1] = a[j];
37     //}
38
39     // after array resize?
40     gendefreach z1;
41     genreach z1;
42
43     // use info to keep compiler from optimizing anything away
44     int total = 0;
45     for( int i = 0; i < m; ++i ) {
46       for( int j = 0; j < n; ++j ) {
47         total += top[i][j].z;
48       }
49     }
50     System.out.println( " "+total );
51   }
52
53   static public Foo[] getArray( int n ) {
54     return disjoint jupiter new Foo[n];
55   }
56
57   static public Foo getFoo() {
58     Foo f = new Foo();
59     f.z = 1;
60     return f;
61   }
62
63 }