aboutsummaryrefslogtreecommitdiff
path: root/tests/pickling/desugar.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-03-08 22:02:22 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:16:37 +0100
commit5962a931c83622ce065bc1ce9add049ade89bfcf (patch)
tree24851bbc76f1ca537456715c44a9f866a5c00668 /tests/pickling/desugar.scala
parent19bfc0c6c9be9c4c3fdca55480e01e980a493b42 (diff)
downloaddotty-5962a931c83622ce065bc1ce9add049ade89bfcf.tar.gz
dotty-5962a931c83622ce065bc1ce9add049ade89bfcf.tar.bz2
dotty-5962a931c83622ce065bc1ce9add049ade89bfcf.zip
Pickling test reorg
Move pickling tests into separate top-level test directory. That way they are not needlessly pos-tested before. Also, disable core tests for now - after rebasing we get a stale symbol error. Need to investigate that.
Diffstat (limited to 'tests/pickling/desugar.scala')
-rw-r--r--tests/pickling/desugar.scala88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/pickling/desugar.scala b/tests/pickling/desugar.scala
new file mode 100644
index 000000000..0d3b6d8ca
--- /dev/null
+++ b/tests/pickling/desugar.scala
@@ -0,0 +1,88 @@
+object desugar {
+
+ // variables
+ var x: Int = 2
+ var y = x * x
+ val list = List(1, 2, 3)
+
+ { var z: Int = y }
+
+ def foo0(first: Int, second: Int = 2, third: Int = 3) = first + second
+ def foo1(first: Int, second: Int = 2)(third: Int = 3) = first + second
+ def foo2(first: Int)(second: Int = 2)(third: Int = 3) = first + second
+
+ object caseClasses { self =>
+ trait List[+T] {
+ def head: T
+ def tail: List[T]
+ }
+
+ case class Cons[+T](val head: T, val tail: List[T]) extends List[T]
+
+ object Cons {
+ def apply[T](head: T): Cons[T] = apply(head, Nil)
+ }
+
+ case object Nil extends List[Nothing] {
+ def head = throw new Error()
+ def tail = throw new Error()
+ }
+ }
+
+ object patDefs {
+
+ import caseClasses._
+
+ val xs: List[Int] = Cons(1, Cons(2, Nil))
+
+ val Cons(y, ys) = xs
+ val Cons(z, _) = xs
+ val Cons(_, _) = xs
+
+ val (cons: Cons[Int]) = xs
+
+ val x1, y1, z1: Int = 1
+ }
+
+ object Binops {
+
+ x :: y :: Nil
+
+ val x :: y :: Nil = list
+
+ }
+
+ object fors {
+
+ for (x <- List(1, 2, 3)) yield 2
+ for (x <- List(1, 2, 3) if x % 2 == 0) yield x * x
+ for (x <- List(1, 2, 3); y <- 0 to x) yield x * y
+ for (x <- List(1, 2, 3); y <- 0 to x; if x + y % 2 == 0) yield x * y
+ for (x <- List(1, 2, 3); y = x * x; if x + y % 2 == 0) yield x * y
+ for (x <- List(1, 2, 3); y = x * x; z = x * y; u <- 0 to y) yield x * y * z * u
+
+ for (x <- List(1, 2, 3)) println(x)
+ for (x <- List(1, 2, 3) if x % 2 == 0) println(x * x)
+ for (x <- List(1, 2, 3); y <- 0 to x) println(x * y)
+ for (x <- List(1, 2, 3); y <- 0 to x; if x + y % 2 == 0) println(x * y)
+ for (x <- List(1, 2, 3); y = x * x; if x + y % 2 == 0) println(x * y)
+ for (x <- List(1, 2, 3); y = x * x; z = x * y; u <- 0 to y) println(x * y * z * u)
+ }
+
+ object misc {
+ 'hello
+ s"this is a $x + ${x + y} string"
+ type ~ = Tuple2
+ val pair: Int ~ String = 1 -> "abc"
+ def foo(xs: Int*) = xs.length
+ foo(list: _*)
+ println(list: _*)
+ (list length)
+ - desugar.x
+ def bar(x: => Int) = x
+ (x + y) + 1
+ while (x < 10) x += 1
+ do x -= 1 while (x > 0)
+ }
+
+}