aboutsummaryrefslogtreecommitdiff
path: root/tests/pending/run/t3175.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-05-12 18:30:53 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-05-12 18:30:53 +0200
commit89bacb9c25a58454ff1878e67f7ea07ffc8c269f (patch)
tree51f1ff6c66aebe1b6109b1cffcc2bb8e4cf760a3 /tests/pending/run/t3175.scala
parenta0fa33deafbea1bf53edc068c5ed9db5592822f9 (diff)
downloaddotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.tar.gz
dotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.tar.bz2
dotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.zip
Run tests as they were in scala.
Diffstat (limited to 'tests/pending/run/t3175.scala')
-rw-r--r--tests/pending/run/t3175.scala58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/pending/run/t3175.scala b/tests/pending/run/t3175.scala
new file mode 100644
index 000000000..ea56ded22
--- /dev/null
+++ b/tests/pending/run/t3175.scala
@@ -0,0 +1,58 @@
+/** A bit down the road this test will examine
+ * the bytecode.
+ */
+
+import scala.language.reflectiveCalls
+
+object Test {
+ def len(x:{ def length: Int }) = x.length
+ def f1(x:{ def apply(x: Int): Long }) = x(0)
+ def f2(x:{ def apply(x: Int): Byte }) = x(0)
+ def f3(x:{ def apply(x: Int): String }) = x(0).length
+
+ def f4(x:{ def update(x: Int, y: Long): Unit }, y: Long) = x(0) = y
+ def f5(x:{ def update(x: Int, y: Byte): Unit }, y: Byte) = x(0) = y
+ def f6(x:{ def update(x: Int, y: String): Unit }, y: String) = x(0) = y
+
+ def f7(x: { def length: Any }) = x.length
+
+ def f8(x: { def apply(x: Int): Any }) = x(0)
+ def f9(x: { def apply(x: Int): Int }) = x(0)
+ def f10(x: { def apply(x: Int): Long }) = x(0)
+
+ // update has some interesting special cases
+ def f11(x:{ def update(x: Int, y: Long): Any }, y: Long) = x(0) = y
+ def f12(x:{ def update(x: Int, y: String): AnyVal }, y: String) = x(0) = y
+ def f13(x:{ def update(x: Int, y: String): AnyRef }, y: String) = x(0) = y
+
+ // doesn't work yet, see #3197
+ // def fclone(x:{ def clone(): AnyRef }) = x.clone()
+
+ def main(args: Array[String]): Unit = {
+ val longs = Array(5L)
+ val bytes = Array(5: Byte)
+ val strs = Array("abcde", "fghjij")
+
+ println(len(Array(1,2,3)) + len(Array(4.0,5.0f)) + len(Array("abc", 5)) + len("bop"))
+ println(f1(longs) + f2(bytes) + f3(strs))
+
+ f4(longs, 1)
+ f5(bytes, 1)
+ f6(strs, "a")
+
+ println(f1(longs) + f2(bytes) + f3(strs))
+
+ println(f7(Array(1,2,3)))
+ println(f7("def"))
+
+ println(f8(Array(5)))
+ println(f9(Array(5)))
+ println(f10(Array(5)))
+
+ f11(longs, 100L)
+ f12(strs, "jabooboo")
+ println(longs(0))
+ println(strs(0))
+ f13(new { def update(x: Int, y: String): List[Int] = { println("hi mom") ; Nil } }, "irrelevant")
+ }
+}