JS backend: test for toGenerator from stdlib
This commit is contained in:
@@ -189,4 +189,8 @@ public final class MiscTest extends AbstractExpressionTest {
|
|||||||
public void testRightAssocForGeneratedConditionalOperator() throws Exception {
|
public void testRightAssocForGeneratedConditionalOperator() throws Exception {
|
||||||
checkFooBoxIsOk();
|
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"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user