2010-03-16 05:22:41 +00:00
|
|
|
# Test with break at the top level.
|
2010-03-16 05:27:31 +00:00
|
|
|
array: [1,2,3]
|
2010-06-12 23:05:13 +00:00
|
|
|
callWithLambda: (l) -> null
|
2010-03-16 05:27:31 +00:00
|
|
|
for i in array
|
2010-06-12 23:05:13 +00:00
|
|
|
result: callWithLambda(->)
|
2010-03-14 00:29:44 +00:00
|
|
|
if i == 2
|
|
|
|
puts "i = 2"
|
|
|
|
else
|
|
|
|
break
|
|
|
|
|
2010-03-16 05:27:31 +00:00
|
|
|
ok result is null
|
2010-03-16 05:20:29 +00:00
|
|
|
|
2010-03-16 05:22:41 +00:00
|
|
|
|
|
|
|
# Test with break *not* at the top level.
|
2010-06-12 23:05:13 +00:00
|
|
|
someFunc: (input) ->
|
|
|
|
takesLambda: (l) -> null
|
2010-03-16 05:22:41 +00:00
|
|
|
for i in [1,2]
|
2010-06-12 23:05:13 +00:00
|
|
|
result: takesLambda(->)
|
2010-03-16 05:22:41 +00:00
|
|
|
if input == 1
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
break
|
|
|
|
|
|
|
|
return 2
|
|
|
|
|
2010-06-12 23:05:13 +00:00
|
|
|
ok someFunc(1) is 1
|
|
|
|
ok someFunc(2) is 2
|
2010-03-16 05:22:41 +00:00
|
|
|
|