+ exponents are now valid: 1.212121e+18
[io/quag.git] / libs / iovm / tests / LoopBreakingTest.io
blob4ac40a9f5fbce73e6805a29ca8bf4ea5ad95a410
1 LoopBreakingTest := UnitTest clone do(
2 setUp := method(
3 List foreach2 := method(
4 slotName := call argAt(0) name
5 body := call argAt(1)
7 self foreach(v,
8 call sender setSlot(slotName, v)
9 ss := stopStatus(result := call sender doMessage(body, call sender))
10 if(ss stopLooping, break)
13 if(ss isReturn,
14 call setStopStatus(ss)
16 result
20 tearDown := method(
21 List removeSlot("foreach2")
25 testBreak := method(
26 a := list; list(1,2,3,4,5) foreach(v, a append(v); if(v >= 3, break))
27 b := list; list(1,2,3,4,5) foreach2(v, b append(v); if(v >= 3, break))
28 assertEquals(a, b)
31 testContinue := method(
32 a := list; list(1,2,3,4,5) foreach(v, a append(v); if(v >= 3, continue); a append(v))
33 b := list; list(1,2,3,4,5) foreach2(v, b append(v); if(v >= 3, continue); b append(v))
34 assertEquals(a, b)
37 testReturn := method(
38 fa := method(r := list; list(1,2,3,4,5) foreach(v, r append(v); if(v >= 3, return r); r append(v)); r append("bad"); r)
39 fb := method(r := list; list(1,2,3,4,5) foreach2(v, r append(v); if(v >= 3, return r); r append(v)); r append("bad"); r)
40 a := fa
41 b := fb
42 assertEquals(a, b)