JS backend: test for toGenerator from stdlib

This commit is contained in:
Michael Nedzelsky
2014-10-29 13:41:41 +03:00
parent afeb03f383
commit 5f576c4c05
2 changed files with 23 additions and 0 deletions
@@ -189,4 +189,8 @@ public final class MiscTest extends AbstractExpressionTest {
public void testRightAssocForGeneratedConditionalOperator() throws Exception {
checkFooBoxIsOk();
}
public void testToGeneratorInStdlib() throws Exception {
checkFooBoxIsOk();
}
}
@@ -0,0 +1,19 @@
package foo
fun streamFromFunctionWithInitialValue() {
val values = stream(3) { n -> if (n > 0) n - 1 else null }
assertEquals(arrayListOf(3, 2, 1, 0), values.toList())
}
fun iterateOverFunction() {
val values = iterate<Int>(3) { n -> if (n > 0) n - 1 else null }
assertEquals(arrayList(3, 2, 1, 0), values.toList())
}
fun box(): String {
streamFromFunctionWithInitialValue()
iterateOverFunction()
return "OK"
}