File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
src/test/scala/gopher/hofasyn Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ package gopher .channels
2
+
3
+ import gopher ._
4
+ import gopher .channels ._
5
+ import gopher .tags ._
6
+
7
+ import org .scalatest ._
8
+
9
+ import scala .language ._
10
+ import scala .concurrent ._
11
+ import scala .concurrent .duration ._
12
+
13
+ class HofAsyncSuite extends FunSuite
14
+ {
15
+
16
+ import scala .concurrent .ExecutionContext .Implicits .global
17
+
18
+
19
+ test(" select emulation with macroses" ) {
20
+
21
+ val channel = gopherApi.makeChannel[Int ](100 )
22
+
23
+ go {
24
+ for ( i <- 1 to 1000 )
25
+ channel <~ i
26
+ }
27
+
28
+ var sum = 0 ;
29
+ val consumer = go {
30
+ for (s <- gopherApi.select.forever) {
31
+ s match {
32
+ case i : channel.read =>
33
+ // System.err.println("received:"+i)
34
+ sum = sum + i
35
+ if (i== 1000 )
36
+ implicitly[FlowTermination [Unit ]].doExit(())
37
+ }
38
+ }
39
+ sum
40
+ }
41
+
42
+ Await .ready(consumer, 5 .second)
43
+
44
+ val xsum = (1 to 1000 ).sum
45
+ assert(xsum == sum)
46
+
47
+ }
48
+
49
+
50
+
51
+
52
+ lazy val gopherApi = CommonTestObjects .gopherApi
53
+
54
+ }
You can’t perform that action at this time.
0 commit comments