start of new file
[IRC.git] / Robust / src / RepairTest / TaskExample.java
1 class Example {
2     flag needoperation;
3     flag needprinting;
4     public Example() {}
5
6    
7     int operation;
8     int x;
9     int y;
10     int z;
11 }
12
13 /* Startup object is generated with the initialstate flag set by the
14  *  system to start the computation up */
15
16 task Startup(StartupObject s {initialstate}) {
17     for(int i=0;i<10;i++) {
18         Example e=new Example() {needoperation};
19         e.x=i;
20         e.y=2;
21         e.operation=i%2;
22     }
23     
24     taskexit(s {!initialstate}); /* Turns initial state flag off, so this task won't refire */
25 }
26
27 /* Fails for x=1 */
28
29 task DoOperation(Example e{needoperation}) {
30     e.z=10*e.y/(e.x-1);
31
32     if (e.operation==0)
33         /* Print the result */
34         taskexit(e {!needoperation, needprinting}) assert (Example(e : e));
35     else
36         /* Don't print the result */
37         taskexit(e {!needoperation}) assert (Example(e : e));
38 }
39
40 /* Note that we can write arbitrary boolean expressions for flag
41  * expressions.  For example, needprinting && ! needoperation would
42  * also be a legal flag expression */
43
44 task DoPrint(Example e{needprinting}) {
45     System.printInt(e.z);
46     System.printString("\n");
47     taskexit(e {!needprinting});
48 }