1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/test/test_break.coffee

29 lines
446 B
CoffeeScript
Raw Normal View History

# Test with break at the top level.
2010-07-25 01:23:37 -04:00
array = [1,2,3]
callWithLambda = (l) -> null
for i in array
2010-07-25 01:23:37 -04:00
result = callWithLambda(->)
if i == 2
console.log "i = 2"
else
break
ok result is null
# Test with break *not* at the top level.
2010-07-25 01:23:37 -04:00
someFunc = (input) ->
takesLambda = (l) -> null
for i in [1,2]
2010-07-25 01:23:37 -04:00
result = takesLambda(->)
if input == 1
return 1
else
break
return 2
ok someFunc(1) is 1
ok someFunc(2) is 2