2010-03-15 22:22:41 -07:00
|
|
|
# Test with break at the top level.
|
2010-07-24 22:23:37 -07:00
|
|
|
array = [1,2,3]
|
|
|
|
callWithLambda = (l) -> null
|
2010-03-15 22:27:31 -07:00
|
|
|
for i in array
|
2010-07-24 22:23:37 -07:00
|
|
|
result = callWithLambda(->)
|
2010-03-14 11:29:44 +11:00
|
|
|
if i == 2
|
|
|
|
puts "i = 2"
|
|
|
|
else
|
|
|
|
break
|
|
|
|
|
2010-03-15 22:27:31 -07:00
|
|
|
ok result is null
|
2010-03-15 22:20:29 -07:00
|
|
|
|
2010-03-15 22:22:41 -07:00
|
|
|
|
|
|
|
# Test with break *not* at the top level.
|
2010-07-24 22:23:37 -07:00
|
|
|
someFunc = (input) ->
|
|
|
|
takesLambda = (l) -> null
|
2010-03-15 22:22:41 -07:00
|
|
|
for i in [1,2]
|
2010-07-24 22:23:37 -07:00
|
|
|
result = takesLambda(->)
|
2010-03-15 22:22:41 -07: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-15 22:22:41 -07:00
|
|
|
|