summaryrefslogtreecommitdiff
path: root/test/files/run/duration-coarsest.scala
diff options
context:
space:
mode:
authorYaroslav Klymko <t3hnar@gmail.com>2013-06-10 17:57:47 +0300
committerYaroslav Klymko <t3hnar@gmail.com>2013-06-10 17:57:47 +0300
commite3d3e1665d150869be4be40b9ce42690e9e9d247 (patch)
tree01ba57132e72138e91c749fcbcb1f5d219a127b1 /test/files/run/duration-coarsest.scala
parent41073f8db662906ada4b779f199ea6d5f4bd5e1f (diff)
downloadscala-e3d3e1665d150869be4be40b9ce42690e9e9d247.tar.gz
scala-e3d3e1665d150869be4be40b9ce42690e9e9d247.tar.bz2
scala-e3d3e1665d150869be4be40b9ce42690e9e9d247.zip
Add Duration.toCoarsest method
Diffstat (limited to 'test/files/run/duration-coarsest.scala')
-rw-r--r--test/files/run/duration-coarsest.scala28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/files/run/duration-coarsest.scala b/test/files/run/duration-coarsest.scala
new file mode 100644
index 0000000000..51cb79287a
--- /dev/null
+++ b/test/files/run/duration-coarsest.scala
@@ -0,0 +1,28 @@
+import scala.concurrent.duration._
+import scala.language.postfixOps
+
+object Test extends App {
+ List(
+ (60 minutes, 1 hour),
+ (2000 millis, 2 seconds),
+ (2000 micros, 2 millis),
+ (2000 nanos, 2 micros),
+ (2000000 nanos, 2 millis),
+ (48 hours, 2 days),
+ (5 seconds, 5 seconds),
+ (1 second, 1 second)
+ ) foreach {
+ case (x, expected) =>
+ val actual = x.toCoarsest
+ assert(actual.unit == expected.unit, s"$actual, $expected")
+ assert(actual.length == expected.length, s"$actual, $expected")
+ }
+
+ List(
+ 45 minutes,
+ 500 millis,
+ 1500 millis,
+ 23 hours,
+ 40 days
+ ) foreach (x => assert(x == x.toCoarsest, x))
+} \ No newline at end of file