From ed8836d170580cc148501509660a7624ac9109f6 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 5 Apr 2012 12:54:51 +0100 Subject: [PATCH] refactor test case to work around a compiler bug that was failing a test --- libraries/stdlib/test/concurrent/TimerTest.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libraries/stdlib/test/concurrent/TimerTest.kt b/libraries/stdlib/test/concurrent/TimerTest.kt index 50a40cb7bb4..b2ee976c901 100644 --- a/libraries/stdlib/test/concurrent/TimerTest.kt +++ b/libraries/stdlib/test/concurrent/TimerTest.kt @@ -12,15 +12,23 @@ class TimerTest { test fun scheduledTask() { val counter = AtomicInteger(0) val timer = Timer() - val task = timer.scheduleAtFixedRate(1000, 1000) { - val current = counter.incrementAndGet() - println("Tiemer fired at $current") - } + /* + TODO this generates a compiler error! + val task = timer.scheduleAtFixedRate(1000, 1000) { + val current = counter.incrementAndGet() + 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