This commit is contained in:
sergeych committed 2025-08-08 19:33:17 +03:00
1 parent 1a90b25b1e
commit 9aae33d564
3 files changed
+17 -20

No files matched your search

@@ -23,10 +23,7 @@ class ObjFlowBuilder(val output: SendChannel<Obj>) : Obj() {
val type = object : ObjClass("FlowBuilder") {}.apply {
addFn("emit") {
val data = requireOnlyArg<Obj>()
println("well well $data")
try {
println("builder ${thisAs<ObjFlowBuilder>().hashCode()}")
println("channel ${thisAs<ObjFlowBuilder>().output.hashCode()}")
val channel = thisAs<ObjFlowBuilder>().output
if( !channel.isClosedForSend )
channel.send(data)
@@ -74,7 +71,6 @@ class ObjFlow(val producer: Statement) : Obj() {
}
}.apply {
addFn("iterator") {
println("called iterator!")
ObjFlowIterator(thisAs<ObjFlow>().producer)
}
}
@@ -90,28 +90,20 @@ class TestCoroutines {
fun testFlow2() = runTest {
eval("""
val f = flow {
println("Starting generator")
emit("start")
emit("start2")
println("Emitting")
(1..4).forEach {
// println("you hoo "+it)
emit(it)
}
println("Done emitting")
}
// let's collect flow:
val result = []
// for( x in f ) result += x
println(result)
for( x in f ) result += x
println(result)
// let's collect it once again:
println(f.toList())
println(f.toList())
// for( x in f ) println(x)
// for( x in f ) println(x)
//assertEquals( result, f.toList() )
assertEquals( result, f.toList())
assertEquals( result, f.toList())
""".trimIndent())
}
}