2010-03-16 01:22:41 -04:00
|
|
|
# Test with break at the top level.
|
2010-07-25 01:23:37 -04:00
|
|
|
array = [1,2,3]
|
|
|
|
callWithLambda = (l) -> null
|
2010-03-16 01:27:31 -04:00
|
|
|
for i in array
|
2010-07-25 01:23:37 -04:00
|
|
|
result = callWithLambda(->)
|
2010-03-13 19:29:44 -05:00
|
|
|
if i == 2
|
2010-10-24 12:48:42 -04:00
|
|
|
console.log "i = 2"
|
2010-03-13 19:29:44 -05:00
|
|
|
else
|
|
|
|
break
|
|
|
|
|
2010-03-16 01:27:31 -04:00
|
|
|
ok result is null
|
2010-03-16 01:20:29 -04:00
|
|
|
|
2010-03-16 01:22:41 -04:00
|
|
|
|
|
|
|
# Test with break *not* at the top level.
|
2010-07-25 01:23:37 -04:00
|
|
|
someFunc = (input) ->
|
|
|
|
takesLambda = (l) -> null
|
2010-03-16 01:22:41 -04:00
|
|
|
for i in [1,2]
|
2010-07-25 01:23:37 -04:00
|
|
|
result = takesLambda(->)
|
2010-03-16 01:22:41 -04:00
|
|
|
if input == 1
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
break
|
|
|
|
|
|
|
|
return 2
|
|
|
|
|
2010-06-12 19:05:13 -04:00
|
|
|
ok someFunc(1) is 1
|
|
|
|
ok someFunc(2) is 2
|
2010-03-16 01:22:41 -04:00
|
|
|
|