2010-03-16 01:22:41 -04:00
|
|
|
# Test with break at the top level.
|
2010-03-16 01:27:31 -04:00
|
|
|
array: [1,2,3]
|
2010-03-13 19:29:44 -05:00
|
|
|
call_with_lambda: (l) -> null
|
2010-03-16 01:27:31 -04:00
|
|
|
for i in array
|
|
|
|
result: call_with_lambda(->)
|
2010-03-13 19:29:44 -05:00
|
|
|
if i == 2
|
|
|
|
puts "i = 2"
|
|
|
|
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.
|
|
|
|
some_func: (input) ->
|
|
|
|
takes_lambda: (l) -> null
|
|
|
|
for i in [1,2]
|
2010-03-16 01:27:31 -04:00
|
|
|
result: takes_lambda(->)
|
2010-03-16 01:22:41 -04:00
|
|
|
if input == 1
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
break
|
|
|
|
|
|
|
|
return 2
|
|
|
|
|
|
|
|
ok some_func(1) is 1
|
|
|
|
ok some_func(2) is 2
|
|
|
|
|