1 LoopBreakingTest
:= UnitTest
clone do(
3 List foreach2
:= method(
4 slotName
:= call
argAt(0) name
8 call
sender setSlot(slotName
, v
)
9 ss
:= stopStatus(result
:= call
sender doMessage(body
, call
sender))
10 if(ss stopLooping
, break)
14 call
setStopStatus(ss
)
21 List removeSlot("foreach2")
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))
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
))
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
)