PageRenderTime 10ms CodeModel.GetById 4ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/test/kilim/test/ex/ExLoop.java

http://github.com/kilim/kilim
Java | 30 lines | 24 code | 3 blank | 3 comment | 3 complexity | 54d647109a34472cdc518863d175062f MD5 | raw file
 1package kilim.test.ex;
 2
 3import kilim.Pausable;
 4import kilim.Task;
 5
 6public class ExLoop extends Task {
 7    public String foo[] = new String[5];
 8    String dummy() throws Pausable {
 9        Task.yield();
10        return "dummy";
11    }
12    @Override
13    public void execute() throws Pausable, Exception {
14        for (int i = 0; i < foo.length; i++) {
15            // foo and i are on the operand stack before dummy gets called. This
16            // test checks that the operand stack is correctly restored.
17            foo[i] = dummy();
18        }
19    }
20    
21    public boolean verify() {
22        // Call after ExLoop task has finished. foo[1..n] must have "dummy".
23        for (int i = 0; i < foo.length; i++) {
24            if (! "dummy".equals(foo[i])) {
25                return false;
26            }
27        }
28        return true;
29    }
30}