blob: 3d41723514ff8548d51781b236a7d881c8f59c79 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package escale
import utest._
import scala.async.Async._
import scala.concurrent.ExecutionContext.Implicits.global
import syntax._
object SelectTest extends TestSuite {
val tests = Tests {
"select" - {
val ints = Channel[Int](0)
val strings = Channel[String](0)
val stop = Channel[Unit](0)
val cleaned = Channel[Int](10)
val p0 = async {
var done = false
do {
(await(Channel.select(ints, strings, stop)): @unchecked) match {
case (`ints`, value: Int) =>
cleaned !< value
case (`strings`, value: String) =>
cleaned !< value.toInt
case (`stop`, _) =>
done = true
}
} while (!done)
"done"
}
val p1 = async{
ints !< 2
}
val p2 = async{
strings !< "2"
ints !< 1
}
val p3 = async{
await(p1)
await(p2)
stop !< ()
}
p0
}
}
}
|