Created
November 7, 2014 21:57
-
-
Save pronebird/c6acf9e05b8f588ed8cb to your computer and use it in GitHub Desktop.
js2coffee test JS for "for" loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// if statements | |
for(var i = 0; i < 5; i++) { | |
if(i == 0) { | |
continue; // if body | |
} | |
else if(i == 1) continue; // inline else+if | |
else continue; // inline else | |
for(var j = 0; j < 2; j++) | |
for(var k = 0; k < 4; k++) | |
if(k == 0) | |
continue; | |
else | |
continue; | |
} | |
// nested closure | |
for(var i = 0; i < 5; i++) { | |
(function () { | |
// inline nested loop | |
for(var j = 0; j < 4; j++) | |
continue; | |
})(); | |
if(i == 2) continue; | |
} | |
// object | |
for(var i = 0; i < 5; i++) { | |
// continue inside of some other scope | |
var object = { | |
test: function () { | |
for(var i = 0, c = 2; i < 10; i++, c+=2) { | |
doSomething(); | |
continue; | |
} | |
} | |
}; | |
if(i == 0) { | |
object.test(); | |
continue; | |
} | |
} | |
// inline body | |
for(var i = 0; i < 10; i++) continue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# if statements | |
i = 0 | |
while i < 5 | |
if i is 0 | |
i++ | |
continue # if body | |
else if i is 1 # inline else+if | |
i++ | |
continue | |
else | |
i++ | |
continue # inline else | |
j = 0 | |
while j < 2 | |
k = 0 | |
while k < 4 | |
if k is 0 | |
k++ | |
continue | |
else | |
k++ | |
continue | |
k++ | |
j++ | |
i++ | |
# nested closure | |
i = 0 | |
while i < 5 | |
(-> | |
# inline nested loop | |
j = 0 | |
while j < 4 | |
j++ | |
continue | |
j++ | |
return | |
)() | |
if i is 2 | |
i++ | |
continue | |
i++ | |
# object | |
i = 0 | |
while i < 5 | |
# continue inside of some other scope | |
object = test: -> | |
i = 0 | |
c = 2 | |
while i < 10 | |
doSomething() | |
i++ | |
c += 2 | |
continue | |
i++ | |
c += 2 | |
return | |
if i is 0 | |
object.test() | |
i++ | |
continue | |
i++ | |
# inline body | |
i = 0 | |
while i < 10 | |
i++ | |
continue | |
i++ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment