提交 ed8836d1 编写于 作者: J James Strachan

refactor test case to work around a compiler bug that was failing a test

上级 fefcd1e5
......@@ -12,15 +12,23 @@ class TimerTest {
test fun scheduledTask() {
val counter = AtomicInteger(0)
val timer = Timer()
val task = timer.scheduleAtFixedRate(1000, 1000) {
/*
TODO this generates a compiler error!
val task = timer.scheduleAtFixedRate(1000, 1000) {
val current = counter.incrementAndGet()
println("Tiemer fired at $current")
println("Timer fired at $current")
}
*/
val task = timerTask {
val current = counter.incrementAndGet()
println("Timer fired at $current")
}
timer.scheduleAtFixedRate(task, 1000, 1000)
Thread.sleep(5000)
task.cancel()
val value = counter.get()
assertTrue(value > 2, "currnet counter is $value")
assertTrue(value > 2, "current counter is $value")
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册