/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

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