Skip to content

Commit 89bc545

Browse files
committed
added test for fired timeout
1 parent 74ee8c3 commit 89bc545

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/test/scala/gopher/channels/MacroSelectSuite.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ class MacroSelectSuite extends FunSuite
335335
assert(x2.isInstanceOf[ChannelClosedException])
336336
}
337337

338-
test("select with constant timeout") {
338+
test("select with constant timeout which not fire") {
339339
//pending
340340
import gopherApi._
341341
val ch1 = makeChannel[Int](10)
@@ -352,6 +352,21 @@ class MacroSelectSuite extends FunSuite
352352
assert(x==1)
353353
}
354354

355+
test("select with constant timeout which fire") {
356+
import gopherApi._
357+
val ch1 = makeChannel[Int](10)
358+
val r = select.amap {
359+
case x:ch1.read =>
360+
//System.err.println(s"readed ${x}")
361+
x
362+
case x:select.timeout if (x==500.milliseconds) =>
363+
//System.err.println(s"timeout ${x}")
364+
-1
365+
}
366+
val x = Await.result(r.aread, 10 seconds)
367+
assert(x == -1)
368+
}
369+
355370
lazy val gopherApi = CommonTestObjects.gopherApi
356371

357372
}

0 commit comments

Comments
 (0)