diff options
author | Martin Odersky <odersky@gmail.com> | 2012-02-07 13:58:27 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-02-07 17:55:38 +0100 |
commit | aee074e69ea8295c018040b606ed8f13ac08d2ab (patch) | |
tree | 3712ccb4c28259d5af97af4483b88a01d4280c28 /test/files/run/Meter.scala | |
parent | 7f9c2636cf560b066783e0745a08393ce17531cd (diff) | |
download | scala-aee074e69ea8295c018040b606ed8f13ac08d2ab.tar.gz scala-aee074e69ea8295c018040b606ed8f13ac08d2ab.tar.bz2 scala-aee074e69ea8295c018040b606ed8f13ac08d2ab.zip |
Added test case.
Diffstat (limited to 'test/files/run/Meter.scala')
-rw-r--r-- | test/files/run/Meter.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/files/run/Meter.scala b/test/files/run/Meter.scala new file mode 100644 index 0000000000..0c30ddd41e --- /dev/null +++ b/test/files/run/Meter.scala @@ -0,0 +1,19 @@ +class Meter(val underlying: Double) extends AnyVal with Printable { + def + (other: Meter): Meter = + new Meter(this.underlying + other.underlying) + def / (other: Meter): Double = this.underlying / other.underlying + def / (factor: Double): Meter = new Meter(this.underlying / factor) + def < (other: Meter): Boolean = this.underlying < other.underlying + override def toString: String = underlying.toString+"m" +} +trait Printable extends Any { def print: Unit = Console.print(this) } + +object Test extends App { + + val x = new Meter(1) + println((x + x) / x) + println((x + x) / 0.5) + println((x < x).toString) + + +} |