summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/mock.check3
-rw-r--r--test/files/run/mock.scala29
2 files changed, 32 insertions, 0 deletions
diff --git a/test/files/run/mock.check b/test/files/run/mock.check
new file mode 100644
index 0000000000..967c4e20bb
--- /dev/null
+++ b/test/files/run/mock.check
@@ -0,0 +1,3 @@
+Hi, thanks for calling: that makes 1 times.
+Hi, thanks for calling: that makes 2 times.
+Hi, thanks for calling: that makes 3 times.
diff --git a/test/files/run/mock.scala b/test/files/run/mock.scala
new file mode 100644
index 0000000000..e414e51e2d
--- /dev/null
+++ b/test/files/run/mock.scala
@@ -0,0 +1,29 @@
+import scala.tools.reflect._
+import java.util.concurrent.Callable
+import java.io.Closeable
+
+object Test {
+ // It'd be really nice about now if functions had a common parent.
+ implicit def interfaceify(x: AnyRef): UniversalFn = UniversalFn(x)
+
+ def runner(x: Runnable) = x.run()
+ def caller[T](x: Callable[T]): T = x.call()
+ def closer(x: Closeable) = x.close()
+
+ def main(args: Array[String]): Unit = {
+ var counter = 0
+ val closure = () => {
+ counter += 1
+ println("Hi, thanks for calling: that makes " + counter + " times.")
+ counter
+ }
+
+ val int1 = closure.as[Runnable]
+ val int2 = closure.as[Callable[Int]]
+ val int3 = closure.as[Closeable]
+
+ runner(int1)
+ caller(int2)
+ closer(int3)
+ }
+}