aboutsummaryrefslogtreecommitdiff
path: root/tests/run
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-09-14 17:07:23 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-09-14 17:07:23 +0200
commit12053fa4d55497fc4df06afd67ba3762019969c3 (patch)
tree0cbab1dee0784793d2ab09124a0103412e813072 /tests/run
parent91f992c8af3e61a76bd862ad43b9abef9a6c3403 (diff)
downloaddotty-12053fa4d55497fc4df06afd67ba3762019969c3.tar.gz
dotty-12053fa4d55497fc4df06afd67ba3762019969c3.tar.bz2
dotty-12053fa4d55497fc4df06afd67ba3762019969c3.zip
Enable more tests that pass
Diffstat (limited to 'tests/run')
-rw-r--r--tests/run/absoverride.check15
-rw-r--r--tests/run/absoverride.scala41
-rw-r--r--tests/run/caseClassHash.check9
-rw-r--r--tests/run/caseClassHash.scala37
-rw-r--r--tests/run/future-flatmap-exec-count.check6
-rw-r--r--tests/run/future-flatmap-exec-count.scala61
-rw-r--r--tests/run/getClassTest-valueClass.check2
-rw-r--r--tests/run/getClassTest-valueClass.scala10
-rw-r--r--tests/run/impconvtimes.check1
-rw-r--r--tests/run/impconvtimes.scala19
-rw-r--r--tests/run/implicits.check2
-rw-r--r--tests/run/implicits.scala50
-rw-r--r--tests/run/iterables.check5
-rw-r--r--tests/run/iterables.scala26
-rw-r--r--tests/run/lazy-traits.check160
-rw-r--r--tests/run/lazy-traits.scala170
-rw-r--r--tests/run/lift-and-unlift.scala27
-rw-r--r--tests/run/nonlocalreturn.check1
-rw-r--r--tests/run/nonlocalreturn.scala15
-rw-r--r--tests/run/patmat-finally.scala25
-rw-r--r--tests/run/retclosure.check1
-rw-r--r--tests/run/retclosure.scala23
-rw-r--r--tests/run/t0042.check1
-rw-r--r--tests/run/t0042.scala9
-rw-r--r--tests/run/t0607.check2
-rw-r--r--tests/run/t0607.scala7
-rw-r--r--tests/run/t1220.scala15
-rw-r--r--tests/run/t1373.scala6
-rw-r--r--tests/run/t2526.scala53
-rw-r--r--tests/run/t2813.2.scala39
-rw-r--r--tests/run/t2867.scala15
-rw-r--r--tests/run/t3346g.check1
-rw-r--r--tests/run/t3346g.scala9
-rw-r--r--tests/run/t3452h.scala8
-rw-r--r--tests/run/t4148.check3
-rw-r--r--tests/run/t4148.scala9
-rw-r--r--tests/run/t4897.check1
-rw-r--r--tests/run/t4897.scala10
-rw-r--r--tests/run/t5009.check5
-rw-r--r--tests/run/t5009.scala14
-rw-r--r--tests/run/t5648.check4
-rw-r--r--tests/run/t5648.flags1
-rw-r--r--tests/run/t5648.scala10
-rw-r--r--tests/run/t6089.check1
-rw-r--r--tests/run/t6089.scala13
-rw-r--r--tests/run/t6104.check1
-rw-r--r--tests/run/t6104.scala8
-rw-r--r--tests/run/t6154.check1
-rw-r--r--tests/run/t6154.scala10
-rw-r--r--tests/run/t6196.scala68
-rw-r--r--tests/run/t6200.scala68
-rw-r--r--tests/run/t6333.scala29
-rw-r--r--tests/run/t6406-regextract.check4
-rw-r--r--tests/run/t6406-regextract.scala30
-rw-r--r--tests/run/t7120.check1
-rw-r--r--tests/run/t7120/Base_1.scala10
-rw-r--r--tests/run/t7120/Derived_2.scala9
-rw-r--r--tests/run/t7120/Run_3.scala3
-rw-r--r--tests/run/t7326.scala64
-rw-r--r--tests/run/t8245.scala14
-rw-r--r--tests/run/tcpoly_monads.check1
-rw-r--r--tests/run/tcpoly_monads.scala45
-rw-r--r--tests/run/typealias_overriding.check1
-rw-r--r--tests/run/typealias_overriding.scala23
-rw-r--r--tests/run/value-class-partial-func-depmet.scala24
-rw-r--r--tests/run/view-iterator-stream.check112
-rw-r--r--tests/run/view-iterator-stream.scala70
-rw-r--r--tests/run/virtpatmat_npe.check1
-rw-r--r--tests/run/virtpatmat_npe.flags1
-rw-r--r--tests/run/virtpatmat_npe.scala10
-rw-r--r--tests/run/virtpatmat_partial_backquoted.check1
-rw-r--r--tests/run/virtpatmat_partial_backquoted.scala12
-rw-r--r--tests/run/virtpatmat_stringinterp.check1
-rw-r--r--tests/run/virtpatmat_stringinterp.flags1
-rw-r--r--tests/run/virtpatmat_stringinterp.scala16
75 files changed, 1581 insertions, 0 deletions
diff --git a/tests/run/absoverride.check b/tests/run/absoverride.check
new file mode 100644
index 000000000..0f4a2b9d5
--- /dev/null
+++ b/tests/run/absoverride.check
@@ -0,0 +1,15 @@
+<sync>
+next: j
+</sync>
+log: j
+j
+<sync>
+next: v
+</sync>
+log: v
+v
+<sync>
+next: m
+</sync>
+log: m
+m
diff --git a/tests/run/absoverride.scala b/tests/run/absoverride.scala
new file mode 100644
index 000000000..030149893
--- /dev/null
+++ b/tests/run/absoverride.scala
@@ -0,0 +1,41 @@
+abstract class AbsIterator {
+ type T
+ def hasNext: Boolean
+ def next: T
+}
+
+trait RichIterator extends AbsIterator {
+ def foreach(f: T => Unit): Unit = {
+ while (hasNext) f(next)
+ }
+}
+
+class StringIterator(s: String) extends AbsIterator {
+ type T = Char
+ private var i = 0
+ def hasNext = i < s.length()
+ def next = { val x = s.charAt(i); i += 1; println("next: " + x); x }
+}
+
+trait SyncIterator extends AbsIterator {
+ abstract override def hasNext: Boolean =
+ synchronized(super.hasNext)
+ abstract override def next: T =
+ synchronized {
+ println("<sync>"); val x = super.next; println("</sync>"); x
+ }
+}
+trait LoggedIterator extends AbsIterator {
+ abstract override def next: T = {
+ val x = super.next; println("log: " + x); x
+ }
+}
+class Iter2(s: String) extends StringIterator(s)
+ with SyncIterator with LoggedIterator;
+object Test {
+ def main(args: Array[String]): Unit = {
+ class Iter extends StringIterator(args(0)) with RichIterator with SyncIterator with LoggedIterator
+ val iter = new Iter
+ iter foreach Console.println
+ }
+}
diff --git a/tests/run/caseClassHash.check b/tests/run/caseClassHash.check
new file mode 100644
index 000000000..b5a6f08e9
--- /dev/null
+++ b/tests/run/caseClassHash.check
@@ -0,0 +1,9 @@
+Foo(true,-1,-1,d,-5,-10,500.0,500.0,List(),5.0)
+Foo(true,-1,-1,d,-5,-10,500.0,500.0,List(),5)
+1383698062
+1383698062
+true
+## method 1: 1383698062
+## method 2: 1383698062
+ Murmur 1: 1383698062
+ Murmur 2: 1383698062
diff --git a/tests/run/caseClassHash.scala b/tests/run/caseClassHash.scala
new file mode 100644
index 000000000..c5cb09c35
--- /dev/null
+++ b/tests/run/caseClassHash.scala
@@ -0,0 +1,37 @@
+case class Foo[T](a: Boolean, b: Byte, c: Short, d: Char, e: Int, f: Long, g: Double, h: Float, i: AnyRef, j: T) { }
+
+object Test {
+ def mkFoo[T](x: T) = Foo[T](true, -1, -1, 100, -5, -10, 500d, 500f, Nil, x)
+
+ def main(args: Array[String]): Unit = {
+ val foo1 = mkFoo[Double](5.0d)
+ val foo2 = mkFoo[Long](5l)
+
+ List(foo1, foo2, foo1.##, foo2.##, foo1 == foo2) foreach println
+
+ println("## method 1: " + foo1.##)
+ println("## method 2: " + foo2.##)
+ println(" Murmur 1: " + scala.util.hashing.MurmurHash3.productHash(foo1))
+ println(" Murmur 2: " + scala.util.hashing.MurmurHash3.productHash(foo2))
+ }
+}
+
+object Timing {
+ var hash = 0
+ def mkFoo(i: Int) = Foo(i % 2 == 0, i.toByte, i.toShort, i.toChar, i, i, 1.1, 1.1f, this, this)
+
+ def main(args: Array[String]): Unit = {
+ val reps = if (args.isEmpty) 100000000 else args(0).toInt
+ val start = System.nanoTime
+
+ println("Warmup.")
+ 1 to 10000 foreach mkFoo
+
+ hash = 0
+ 1 to reps foreach (i => hash += mkFoo(i).##)
+
+ val end = System.nanoTime
+ println("hash = " + hash)
+ println("Elapsed: " + ((end - start) / 1e6) + " ms.")
+ }
+}
diff --git a/tests/run/future-flatmap-exec-count.check b/tests/run/future-flatmap-exec-count.check
new file mode 100644
index 000000000..dd9dce64e
--- /dev/null
+++ b/tests/run/future-flatmap-exec-count.check
@@ -0,0 +1,6 @@
+mapping
+execute()
+flatmapping
+execute()
+recovering
+execute()
diff --git a/tests/run/future-flatmap-exec-count.scala b/tests/run/future-flatmap-exec-count.scala
new file mode 100644
index 000000000..849beb6b1
--- /dev/null
+++ b/tests/run/future-flatmap-exec-count.scala
@@ -0,0 +1,61 @@
+import scala.concurrent._
+import java.util.concurrent.atomic.AtomicInteger
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ test()
+ }
+
+ def test() = {
+ def await(f: Future[Any]) =
+ Await.result(f, duration.Duration.Inf)
+
+ val ec = new TestExecutionContext(ExecutionContext.Implicits.global)
+
+ {
+ val p = Promise[Int]()
+ val fp = p.future
+ println("mapping")
+ val mapped = fp.map(x => x)(ec)
+ p.success(0)
+ await(mapped)
+ }
+
+ {
+ println("flatmapping")
+ val p = Promise[Int]()
+ val fp = p.future
+ val flatMapped = fp.flatMap({ (x: Int) =>
+ Future.successful(2 * x)
+ })(ec)
+ p.success(0)
+ await(flatMapped)
+ }
+
+ {
+ println("recovering")
+ val recovered = Future.failed(new Throwable()).recoverWith {
+ case _ => Future.successful(2)
+ }(ec)
+ await(recovered)
+ }
+ }
+
+ class TestExecutionContext(delegate: ExecutionContext) extends ExecutionContext {
+ def execute(runnable: Runnable): Unit = ???
+
+ def reportFailure(t: Throwable): Unit = ???
+
+ override def prepare(): ExecutionContext = {
+ val preparedDelegate = delegate.prepare()
+ return new ExecutionContext {
+ def execute(runnable: Runnable): Unit = {
+ println("execute()")
+ preparedDelegate.execute(runnable)
+ }
+
+ def reportFailure(t: Throwable): Unit = ???
+ }
+ }
+ }
+}
diff --git a/tests/run/getClassTest-valueClass.check b/tests/run/getClassTest-valueClass.check
new file mode 100644
index 000000000..7608d92b4
--- /dev/null
+++ b/tests/run/getClassTest-valueClass.check
@@ -0,0 +1,2 @@
+int
+class V
diff --git a/tests/run/getClassTest-valueClass.scala b/tests/run/getClassTest-valueClass.scala
new file mode 100644
index 000000000..05a116dff
--- /dev/null
+++ b/tests/run/getClassTest-valueClass.scala
@@ -0,0 +1,10 @@
+class V(val x: Int) extends AnyVal
+
+object Test {
+ def main(args: Array[String]) = {
+ val v = new V(2)
+ val s: Any = 2
+ println(2.getClass)
+ println(v.getClass)
+ }
+}
diff --git a/tests/run/impconvtimes.check b/tests/run/impconvtimes.check
new file mode 100644
index 000000000..f08574de3
--- /dev/null
+++ b/tests/run/impconvtimes.check
@@ -0,0 +1 @@
+3.0 * Hour = Measure(3.0,Hour)
diff --git a/tests/run/impconvtimes.scala b/tests/run/impconvtimes.scala
new file mode 100644
index 000000000..0dbbf7bca
--- /dev/null
+++ b/tests/run/impconvtimes.scala
@@ -0,0 +1,19 @@
+import scala.language.implicitConversions
+
+object Test {
+ abstract class Unit
+ object NoUnit extends Unit
+ object Hour extends Unit { override def toString = "Hour" }
+
+ case class Measure(scalar: Double, unit: Unit) {
+ def *(newUnit: Unit) = Measure(scalar, newUnit)
+ }
+
+ implicit def double2Measure(scalar: Double): Test.Measure =
+ Measure(scalar, NoUnit)
+
+
+ def main(args: Array[String]): scala.Unit = {
+ Console.println("3.0 * Hour = " + (3.0 * Hour))
+ }
+}
diff --git a/tests/run/implicits.check b/tests/run/implicits.check
new file mode 100644
index 000000000..010571589
--- /dev/null
+++ b/tests/run/implicits.check
@@ -0,0 +1,2 @@
+OK
+[2]
diff --git a/tests/run/implicits.scala b/tests/run/implicits.scala
new file mode 100644
index 000000000..60a361a44
--- /dev/null
+++ b/tests/run/implicits.scala
@@ -0,0 +1,50 @@
+import scala.language.implicitConversions
+
+object A {
+ object B {
+ implicit def int2string(x: Int): String = "["+x.toString+"]"
+ }
+}
+
+class C(x: String) {
+
+ class Inner {
+ }
+
+ object Inner {
+ val s: String = x
+ implicit def Inner2String(x: Inner): String = s
+ }
+}
+
+object Test extends dotty.runtime.LegacyApp {
+ import A.B._
+ val c = new C("OK")
+ val i = new c.Inner
+ val s: String = i
+ Console.println(s)
+ Console.println(2: String)
+}
+
+object TestPriority {
+
+ class C(x: Int) { def foo: Int = x + 1 }
+
+ class D(x: Int) { def foo: Int = x + 2 }
+
+ class IMPL {
+ implicit def Int2C(x: Int): C = new C(x)
+ }
+
+ object impl extends IMPL {
+ implicit def Int2D(x: Int): D = new D(x)
+ }
+
+ import impl._
+
+ val x: C = 2
+ val y: D = 2
+ assert(x.foo == 3, x.foo)
+ assert(y.foo == 4, y.foo)
+ assert((2).foo == 4, (2).foo)
+}
diff --git a/tests/run/iterables.check b/tests/run/iterables.check
new file mode 100644
index 000000000..aac90b70a
--- /dev/null
+++ b/tests/run/iterables.check
@@ -0,0 +1,5 @@
+false
+0,1,2,3,4,5,6,7,8,9
+5,6,7,8,9
+0,2,4,6,8
+1,3,5,7,9
diff --git a/tests/run/iterables.scala b/tests/run/iterables.scala
new file mode 100644
index 000000000..251722982
--- /dev/null
+++ b/tests/run/iterables.scala
@@ -0,0 +1,26 @@
+object Test extends dotty.runtime.LegacyApp {
+ class Test(n: Int) extends Iterable[Int] {
+ private var i = 0
+ def iterator = new Iterator[Int] {
+ def hasNext = i < n
+ def next =
+ if (hasNext) { val v = i; i += 1; v }
+ else throw new IndexOutOfBoundsException("empty iterator")
+ }
+ }
+ {
+ val x = new Test(10)
+ println(x.isEmpty)
+ println(x.mkString(","))
+ }
+ {
+ val x = new Test(10)
+ println(x.filter(_ > 4).mkString(","))
+ }
+ {
+ val x = new Test(10)
+ val y = x.partition(_ % 2 == 0)
+ println(y._1.mkString(","))
+ println(y._2.mkString(","))
+ }
+}
diff --git a/tests/run/lazy-traits.check b/tests/run/lazy-traits.check
new file mode 100644
index 000000000..2f0bc1869
--- /dev/null
+++ b/tests/run/lazy-traits.check
@@ -0,0 +1,160 @@
+Cls test:
+<forced z1>
+z1 = lazy z1
+z1 = lazy z1
+z1 = lazy z1
+Cls2 test:
+<forced z1>
+<forced z2>
+z1 = lazy z1 z2 = lazy z2
+z1 = lazy z1 z2 = lazy z2
+z1 = lazy z1 z2 = lazy z2
+Cls with B test:
+<forced z1>
+<forced zb1>
+<forced zc1>
+z1 = lazy z1 zb1 = lazy zb1 zc1 = lazy zc1
+z1 = lazy z1 zb1 = lazy zb1 zc1 = lazy zc1
+z1 = lazy z1 zb1 = lazy zb1 zc1 = lazy zc1
+OverflownLazyFields with A test:
+<forced zc00>
+<forced zc01>
+<forced zc02>
+<forced zc03>
+<forced zc04>
+<forced zc05>
+<forced zc06>
+<forced zc07>
+<forced zc08>
+<forced zc09>
+<forced zc10>
+<forced zc11>
+<forced zc12>
+<forced zc13>
+<forced zc14>
+<forced zc15>
+<forced zc16>
+<forced zc17>
+<forced zc18>
+<forced zc19>
+<forced zc20>
+<forced zc21>
+<forced zc22>
+<forced zc23>
+<forced zc24>
+<forced zc25>
+<forced zc26>
+<forced zc27>
+<forced zc28>
+<forced zc29>
+<forced zc30>
+<forced zc31>
+<forced z1>
+
+zc00 = lazy zc00
+zc01 = lazy zc01
+zc02 = lazy zc02
+zc03 = lazy zc03
+zc04 = lazy zc04
+zc05 = lazy zc05
+zc06 = lazy zc06
+zc07 = lazy zc07
+zc08 = lazy zc08
+zc09 = lazy zc09
+zc10 = lazy zc10
+zc11 = lazy zc11
+zc12 = lazy zc12
+zc13 = lazy zc13
+zc14 = lazy zc14
+zc15 = lazy zc15
+zc16 = lazy zc16
+zc17 = lazy zc17
+zc18 = lazy zc18
+zc19 = lazy zc19
+zc20 = lazy zc20
+zc21 = lazy zc21
+zc22 = lazy zc22
+zc23 = lazy zc23
+zc24 = lazy zc24
+zc25 = lazy zc25
+zc26 = lazy zc26
+zc27 = lazy zc27
+zc28 = lazy zc28
+zc29 = lazy zc29
+zc30 = lazy zc30
+zc31 = lazy zc31
+z1 = lazy z1
+
+zc00 = lazy zc00
+zc01 = lazy zc01
+zc02 = lazy zc02
+zc03 = lazy zc03
+zc04 = lazy zc04
+zc05 = lazy zc05
+zc06 = lazy zc06
+zc07 = lazy zc07
+zc08 = lazy zc08
+zc09 = lazy zc09
+zc10 = lazy zc10
+zc11 = lazy zc11
+zc12 = lazy zc12
+zc13 = lazy zc13
+zc14 = lazy zc14
+zc15 = lazy zc15
+zc16 = lazy zc16
+zc17 = lazy zc17
+zc18 = lazy zc18
+zc19 = lazy zc19
+zc20 = lazy zc20
+zc21 = lazy zc21
+zc22 = lazy zc22
+zc23 = lazy zc23
+zc24 = lazy zc24
+zc25 = lazy zc25
+zc26 = lazy zc26
+zc27 = lazy zc27
+zc28 = lazy zc28
+zc29 = lazy zc29
+zc30 = lazy zc30
+zc31 = lazy zc31
+z1 = lazy z1
+
+zc00 = lazy zc00
+zc01 = lazy zc01
+zc02 = lazy zc02
+zc03 = lazy zc03
+zc04 = lazy zc04
+zc05 = lazy zc05
+zc06 = lazy zc06
+zc07 = lazy zc07
+zc08 = lazy zc08
+zc09 = lazy zc09
+zc10 = lazy zc10
+zc11 = lazy zc11
+zc12 = lazy zc12
+zc13 = lazy zc13
+zc14 = lazy zc14
+zc15 = lazy zc15
+zc16 = lazy zc16
+zc17 = lazy zc17
+zc18 = lazy zc18
+zc19 = lazy zc19
+zc20 = lazy zc20
+zc21 = lazy zc21
+zc22 = lazy zc22
+zc23 = lazy zc23
+zc24 = lazy zc24
+zc25 = lazy zc25
+zc26 = lazy zc26
+zc27 = lazy zc27
+zc28 = lazy zc28
+zc29 = lazy zc29
+zc30 = lazy zc30
+zc31 = lazy zc31
+z1 = lazy z1
+Unit lazy values test:
+UnitLazy.lz forced
+UnitLazyT.lzt forced
+MixedUnitLazy
+MixedUnitLazy
+MixedUnitLazy
diff --git a/tests/run/lazy-traits.scala b/tests/run/lazy-traits.scala
new file mode 100644
index 000000000..89e262824
--- /dev/null
+++ b/tests/run/lazy-traits.scala
@@ -0,0 +1,170 @@
+trait A {
+ lazy val z1 = {
+ println("<forced z1>")
+ "lazy z1"
+ }
+}
+
+/** Simple class which mixes in one lazy val. */
+class Cls extends AnyRef with A {
+ override def toString =
+ "z1 = " + z1
+}
+
+/** Own lazy val + one mixed in. */
+class Cls2 extends AnyRef with A {
+ lazy val z2 = {
+ println("<forced z2>")
+ "lazy z2"
+ }
+
+ override def toString =
+ "z1 = " + z1 + " z2 = " + z2
+}
+
+trait B extends A {
+ lazy val zb1 = {
+ println("<forced zb1>")
+ "lazy zb1"
+ }
+}
+
+class ClsB extends Object with B {
+ lazy val zc1 = {
+ println("<forced zc1>")
+ "lazy zc1"
+ }
+ override def toString =
+ "z1 = " + z1 + " zb1 = " + zb1 + " zc1 = " + zc1
+}
+
+/** Class with 32 lazy fields mixes in one more. */
+class OverflownLazyFields extends Object with A {
+ lazy val zc00 = { println("<forced zc00>"); "lazy zc00" }
+ lazy val zc01 = { println("<forced zc01>"); "lazy zc01" }
+ lazy val zc02 = { println("<forced zc02>"); "lazy zc02" }
+ lazy val zc03 = { println("<forced zc03>"); "lazy zc03" }
+ lazy val zc04 = { println("<forced zc04>"); "lazy zc04" }
+ lazy val zc05 = { println("<forced zc05>"); "lazy zc05" }
+ lazy val zc06 = { println("<forced zc06>"); "lazy zc06" }
+ lazy val zc07 = { println("<forced zc07>"); "lazy zc07" }
+ lazy val zc08 = { println("<forced zc08>"); "lazy zc08" }
+ lazy val zc09 = { println("<forced zc09>"); "lazy zc09" }
+ lazy val zc10 = { println("<forced zc10>"); "lazy zc10" }
+ lazy val zc11 = { println("<forced zc11>"); "lazy zc11" }
+ lazy val zc12 = { println("<forced zc12>"); "lazy zc12" }
+ lazy val zc13 = { println("<forced zc13>"); "lazy zc13" }
+ lazy val zc14 = { println("<forced zc14>"); "lazy zc14" }
+ lazy val zc15 = { println("<forced zc15>"); "lazy zc15" }
+ lazy val zc16 = { println("<forced zc16>"); "lazy zc16" }
+ lazy val zc17 = { println("<forced zc17>"); "lazy zc17" }
+ lazy val zc18 = { println("<forced zc18>"); "lazy zc18" }
+ lazy val zc19 = { println("<forced zc19>"); "lazy zc19" }
+ lazy val zc20 = { println("<forced zc20>"); "lazy zc20" }
+ lazy val zc21 = { println("<forced zc21>"); "lazy zc21" }
+ lazy val zc22 = { println("<forced zc22>"); "lazy zc22" }
+ lazy val zc23 = { println("<forced zc23>"); "lazy zc23" }
+ lazy val zc24 = { println("<forced zc24>"); "lazy zc24" }
+ lazy val zc25 = { println("<forced zc25>"); "lazy zc25" }
+ lazy val zc26 = { println("<forced zc26>"); "lazy zc26" }
+ lazy val zc27 = { println("<forced zc27>"); "lazy zc27" }
+ lazy val zc28 = { println("<forced zc28>"); "lazy zc28" }
+ lazy val zc29 = { println("<forced zc29>"); "lazy zc29" }
+ lazy val zc30 = { println("<forced zc30>"); "lazy zc30" }
+ lazy val zc31 = { println("<forced zc31>"); "lazy zc31" }
+
+ override def toString =
+ "\nzc00 = " + zc00 +
+ "\nzc01 = " + zc01 +
+ "\nzc02 = " + zc02 +
+ "\nzc03 = " + zc03 +
+ "\nzc04 = " + zc04 +
+ "\nzc05 = " + zc05 +
+ "\nzc06 = " + zc06 +
+ "\nzc07 = " + zc07 +
+ "\nzc08 = " + zc08 +
+ "\nzc09 = " + zc09 +
+ "\nzc10 = " + zc10 +
+ "\nzc11 = " + zc11 +
+ "\nzc12 = " + zc12 +
+ "\nzc13 = " + zc13 +
+ "\nzc14 = " + zc14 +
+ "\nzc15 = " + zc15 +
+ "\nzc16 = " + zc16 +
+ "\nzc17 = " + zc17 +
+ "\nzc18 = " + zc18 +
+ "\nzc19 = " + zc19 +
+ "\nzc20 = " + zc20 +
+ "\nzc21 = " + zc21 +
+ "\nzc22 = " + zc22 +
+ "\nzc23 = " + zc23 +
+ "\nzc24 = " + zc24 +
+ "\nzc25 = " + zc25 +
+ "\nzc26 = " + zc26 +
+ "\nzc27 = " + zc27 +
+ "\nzc28 = " + zc28 +
+ "\nzc29 = " + zc29 +
+ "\nzc30 = " + zc30 +
+ "\nzc31 = " + zc31 +
+ "\nz1 = " + z1
+}
+
+trait PrivateLazy {
+ private lazy val str = "z1"
+}
+
+/** Test successful compilation. */
+class InheritPrivateLazy extends AnyRef with PrivateLazy {}
+
+/** Test successful compilation, see bug #1287. */
+trait LocalLazyVal {
+ def foo = {
+ lazy val next = 10 + 1
+ next
+ }
+}
+
+/** Test successful compilation (see ticket #39) */
+package x.y {
+
+ trait Trait {
+ lazy val v = 1
+ }
+
+ class OuterClass {
+ object InnerObject extends Trait
+ }
+}
+
+/** Test successful compilation of lazy values of type Unit. */
+class UnitLazy extends A {
+ lazy val lz = Console.println("UnitLazy.lz forced")
+}
+
+trait UnitLazyT {
+ lazy val lzt = Console.println("UnitLazyT.lzt forced")
+}
+
+class MixedUnitLazy extends UnitLazy with UnitLazyT {
+ override def toString() = {
+ lz
+ lzt
+ "MixedUnitLazy"
+ }
+}
+
+object Test extends dotty.runtime.LegacyApp {
+
+ def test(name: String, v: A): Unit = {
+ println(name + " test:")
+ println(v)
+ println(v)
+ println(v)
+ }
+
+ test("Cls", new Cls)
+ test("Cls2", new Cls2)
+ test("Cls with B", new ClsB)
+ test("OverflownLazyFields with A", new OverflownLazyFields)
+ test("Unit lazy values", new MixedUnitLazy)
+}
diff --git a/tests/run/lift-and-unlift.scala b/tests/run/lift-and-unlift.scala
new file mode 100644
index 000000000..9cd85666e
--- /dev/null
+++ b/tests/run/lift-and-unlift.scala
@@ -0,0 +1,27 @@
+import Function.unlift
+
+object Test {
+ def evens1(x: Int) = if (x % 2 == 0) Some(x) else None
+ val evens2: PartialFunction[Int, Int] = {
+ case x if x % 2 == 0 => x
+ }
+
+ def main(args: Array[String]): Unit = {
+ val f1 = evens1 _
+ val f2 = evens2.lift
+
+ assert(1 to 10 forall (x => f1(x) == f2(x)))
+
+ val f3 = unlift(f1)
+ val f4 = unlift(f2)
+
+ assert(1 to 10 forall { x =>
+ if (!f3.isDefinedAt(x)) !f4.isDefinedAt(x)
+ else f3(x) == f4(x)
+ })
+
+ assert(f1 eq f3.lift)
+ assert(f4 eq unlift(f2))
+ assert(f4 eq evens2)
+ }
+}
diff --git a/tests/run/nonlocalreturn.check b/tests/run/nonlocalreturn.check
new file mode 100644
index 000000000..aeb2d5e23
--- /dev/null
+++ b/tests/run/nonlocalreturn.check
@@ -0,0 +1 @@
+Some(1)
diff --git a/tests/run/nonlocalreturn.scala b/tests/run/nonlocalreturn.scala
new file mode 100644
index 000000000..13b9045da
--- /dev/null
+++ b/tests/run/nonlocalreturn.scala
@@ -0,0 +1,15 @@
+object Test {
+ def wrap[K](body: => K): K = body
+
+ def f(): Option[Int] = {
+ wrap({ return Some(1) ; None })
+ }
+
+ def main(args: Array[String]): Unit = {
+ println(f())
+ }
+}
+// java.lang.ClassCastException: scala.Some cannot be cast to scala.None$
+// at Test$$anonfun$f$1.apply(nonlocalreturn.scala:5)
+// at Test$$anonfun$f$1.apply(nonlocalreturn.scala:5)
+// at Test$.wrap(nonlocalreturn.scala:2)
diff --git a/tests/run/patmat-finally.scala b/tests/run/patmat-finally.scala
new file mode 100644
index 000000000..895fb79f7
--- /dev/null
+++ b/tests/run/patmat-finally.scala
@@ -0,0 +1,25 @@
+/** Test pattern matching and finally, see SI-5929. */
+object Test extends dotty.runtime.LegacyApp {
+ def bar(s1: Object, s2: Object): Unit = {
+ s1 match {
+ case _ =>
+ }
+
+ try {
+ ()
+ } finally {
+ s2 match {
+ case _ =>
+ }
+ }
+ }
+
+ def x = {
+ null match { case _ => }
+
+ try { 1 } finally { while(false) { } }
+ }
+
+ bar(null, null)
+ x
+}
diff --git a/tests/run/retclosure.check b/tests/run/retclosure.check
new file mode 100644
index 000000000..94c4971e4
--- /dev/null
+++ b/tests/run/retclosure.check
@@ -0,0 +1 @@
+check failed: some problem
diff --git a/tests/run/retclosure.scala b/tests/run/retclosure.scala
new file mode 100644
index 000000000..0f4b823c3
--- /dev/null
+++ b/tests/run/retclosure.scala
@@ -0,0 +1,23 @@
+/* Test return expressions inside closures.
+ *
+ * See bug#834 */
+
+object Test {
+ def response: String = {
+ def check: Option[String] = {
+ val closure: String=>Nothing =
+ p => return Some("some problem") // should return from check
+
+ closure("whatever")
+ }
+
+ check match {
+ case Some(problem) => "check failed: " + problem
+ case None => "ok"
+ }
+ }
+
+ def main(args: Array[String]): Unit = {
+ Console.println(response)
+ }
+}
diff --git a/tests/run/t0042.check b/tests/run/t0042.check
new file mode 100644
index 000000000..aeb2d5e23
--- /dev/null
+++ b/tests/run/t0042.check
@@ -0,0 +1 @@
+Some(1)
diff --git a/tests/run/t0042.scala b/tests/run/t0042.scala
new file mode 100644
index 000000000..57c8563f0
--- /dev/null
+++ b/tests/run/t0042.scala
@@ -0,0 +1,9 @@
+object Test extends dotty.runtime.LegacyApp {
+ def getClause[T](clauses: List[T]): Option[T] = {
+ for (c <- clauses) {
+ return Some(c)
+ }
+ return None
+ }
+ println(getClause(List(1, 2, 3)))
+}
diff --git a/tests/run/t0607.check b/tests/run/t0607.check
new file mode 100644
index 000000000..a9057ea65
--- /dev/null
+++ b/tests/run/t0607.check
@@ -0,0 +1,2 @@
+A()
+B()
diff --git a/tests/run/t0607.scala b/tests/run/t0607.scala
new file mode 100644
index 000000000..8f9e29533
--- /dev/null
+++ b/tests/run/t0607.scala
@@ -0,0 +1,7 @@
+object Test extends dotty.runtime.LegacyApp {
+ case class A()
+ class B extends A() { override def toString() = "B()" }
+ println(A())
+ println(new B())
+}
+
diff --git a/tests/run/t1220.scala b/tests/run/t1220.scala
new file mode 100644
index 000000000..3f70107ce
--- /dev/null
+++ b/tests/run/t1220.scala
@@ -0,0 +1,15 @@
+object Test extends dotty.runtime.LegacyApp {
+
+ class QSRichIterable[A](self: Iterable[A]) {
+ def filterMap[R](f: PartialFunction[A,R]) =
+ self filter (f.isDefinedAt) map f
+ }
+
+ object Un {
+ def unapply(i: Int): Option[Int] = Some(i)
+ }
+
+ val richIter = new QSRichIterable(List(0, 1, 2, 3, 4))
+
+ assert((richIter filterMap {case Un(3) => 7}) == List(7))
+}
diff --git a/tests/run/t1373.scala b/tests/run/t1373.scala
new file mode 100644
index 000000000..9a873f0ed
--- /dev/null
+++ b/tests/run/t1373.scala
@@ -0,0 +1,6 @@
+// Testing whether case class params come back in the right order.
+object Test extends dotty.runtime.LegacyApp {
+ case class Foo(private val a: String, b: String, private val c: String, d: String, private val e: String)
+ val x = Foo("a", "b", "c", "d", "e")
+ assert(x.toString == """Foo(a,b,c,d,e)""")
+}
diff --git a/tests/run/t2526.scala b/tests/run/t2526.scala
new file mode 100644
index 000000000..4d567bbbf
--- /dev/null
+++ b/tests/run/t2526.scala
@@ -0,0 +1,53 @@
+/**
+ * Checks that various foreach methods overridden in mutable.HashMap as part of ticket #2526
+ * still work correctly.
+ */
+object Test {
+ import collection._
+
+ def main(args: Array[String]): Unit = {
+ val m = new mutable.HashMap[String, String]
+
+ /* Use non hash-based structure for verification */
+ val keys = List("a", "b", "c", "d", "e")
+ val valueSuffix = "value"
+ val values = keys.map(_ + valueSuffix)
+ val entries = keys.zip(values)
+
+ for (k <- keys) m(k) = k + valueSuffix
+
+ assertForeach(keys, m.keySet.iterator)
+ assertForeach(keys, m.keysIterator)
+ assertForeach(keys, m.keySet)
+
+ assertForeach(values, m.values.iterator)
+ assertForeach(values, m.valuesIterator)
+
+ assertForeach(entries, m)
+ }
+
+ /* Checks foreach of `actual` goes over all the elements in `expected` */
+ private def assertForeach[E](expected: Traversable[E], actual: Iterator[E]): Unit = {
+ val notYetFound = new mutable.ArrayBuffer[E]() ++= expected
+ actual.foreach { e =>
+ assert(notYetFound.contains(e))
+ notYetFound -= e
+ }
+ assert(notYetFound.size == 0, "mutable.HashMap.foreach should have iterated over: " + notYetFound)
+ }
+
+ /*
+ * Checks foreach of `actual` goes over all the elements in `expected`
+ * We duplicate the method above because there is no common inteface between Traversable and
+ * Iterator and we want to avoid converting between collections to ensure that we test what
+ * we mean to test.
+ */
+ private def assertForeach[E](expected: Traversable[E], actual: Traversable[E]): Unit = {
+ val notYetFound = new mutable.ArrayBuffer[E]() ++= expected
+ actual.foreach { e =>
+ assert(notYetFound.contains(e))
+ notYetFound -= e
+ }
+ assert(notYetFound.size == 0, "mutable.HashMap.foreach should have iterated over: " + notYetFound)
+ }
+}
diff --git a/tests/run/t2813.2.scala b/tests/run/t2813.2.scala
new file mode 100644
index 000000000..d228eed90
--- /dev/null
+++ b/tests/run/t2813.2.scala
@@ -0,0 +1,39 @@
+import java.util.LinkedList
+import collection.JavaConversions._
+
+object Test extends dotty.runtime.LegacyApp {
+ def assertListEquals[A](expected: List[A], actual: Seq[A]): Unit = {
+ assert(expected.sameElements(actual),
+ "Expected list to contain " + expected.mkString("[", ", ", "]") +
+ ", but was " + actual.mkString("[", ", ", "]"))
+ }
+
+ def addAllOfNonCollectionWrapperAtZeroOnEmptyLinkedList(): Unit = {
+ val l = new LinkedList[Int]
+ l.addAll(0, List(1, 2))
+ assertListEquals(List(1, 2), l)
+ }
+
+ def addAllOfNonCollectionWrapperAtZeroOnLinkedList(): Unit = {
+ val l = new LinkedList[Int] += 1 += 2
+ l.addAll(0, List(10, 11))
+ assertListEquals((List(10, 11, 1, 2)), l)
+ }
+
+ def addAllOfCollectionWrapperAtZeroOnLinkedList(): Unit = {
+ val l = new LinkedList[Int] += 1 += 2
+ l.addAll(0, new LinkedList[Int] += 10 += 11)
+ assertListEquals((List(10, 11, 1, 2)), l)
+ }
+
+ def addAllOfCollectionWrapperAtZeroOnEmptyLinkedList(): Unit = {
+ val l = new LinkedList[Int]
+ l.addAll(0, new LinkedList[Int] += 10 += 11)
+ assertListEquals((List(10, 11)), l)
+ }
+
+ addAllOfNonCollectionWrapperAtZeroOnEmptyLinkedList
+ addAllOfNonCollectionWrapperAtZeroOnLinkedList
+ addAllOfCollectionWrapperAtZeroOnEmptyLinkedList
+ addAllOfCollectionWrapperAtZeroOnLinkedList
+}
diff --git a/tests/run/t2867.scala b/tests/run/t2867.scala
new file mode 100644
index 000000000..25e55eaec
--- /dev/null
+++ b/tests/run/t2867.scala
@@ -0,0 +1,15 @@
+object Test {
+ case class A(l: List[_]*)
+
+ def main(args: Array[String]): Unit = {
+ /** Kind of sneaking a slightly different test in here as well as
+ * testing 2867. How subversive.
+ */
+ val xs1 = List(1, 2, 3)
+ val xs2 = List(1.0, 2.0, 3.0)
+ val xs3 = List[Any](1.0f, 2.0f, 3.0f)
+ val xs4 = List[Byte](1, 2, 3)
+
+ assert(A(List(xs1, xs2)) == A(List(xs3, xs4)))
+ }
+}
diff --git a/tests/run/t3346g.check b/tests/run/t3346g.check
new file mode 100644
index 000000000..ce894825e
--- /dev/null
+++ b/tests/run/t3346g.check
@@ -0,0 +1 @@
+A(3,asdf)
diff --git a/tests/run/t3346g.scala b/tests/run/t3346g.scala
new file mode 100644
index 000000000..a5b7d6bf8
--- /dev/null
+++ b/tests/run/t3346g.scala
@@ -0,0 +1,9 @@
+import scala.language.implicitConversions
+
+case class A(b: Int, c: String)
+
+object Test extends dotty.runtime.LegacyApp {
+ implicit def s2i(s: String): Int = s.length
+ implicit def toA[T](t: T)(implicit f: T => Int): A = A(f(t), t.toString)
+ println("asdf".copy(b = 3))
+}
diff --git a/tests/run/t3452h.scala b/tests/run/t3452h.scala
new file mode 100644
index 000000000..c06ae0a0b
--- /dev/null
+++ b/tests/run/t3452h.scala
@@ -0,0 +1,8 @@
+class Mix___eFoo_I_wBar__f extends Foo_I_ with Bar__f { f; }
+trait T
+abstract class Foo_I_ { class I extends T ; def f: I ; f; }
+trait Bar__f { type I>:Null<:T; def f: I = {null}; f; def gobble: I = {null}}
+
+object Test extends dotty.runtime.LegacyApp {
+ new Mix___eFoo_I_wBar__f
+}
diff --git a/tests/run/t4148.check b/tests/run/t4148.check
new file mode 100644
index 000000000..544b0d19d
--- /dev/null
+++ b/tests/run/t4148.check
@@ -0,0 +1,3 @@
+cce1
+5
+100
diff --git a/tests/run/t4148.scala b/tests/run/t4148.scala
new file mode 100644
index 000000000..d543e093a
--- /dev/null
+++ b/tests/run/t4148.scala
@@ -0,0 +1,9 @@
+object Test {
+ val x1 = try { "aaa".asInstanceOf[Int] } catch { case _: Throwable => "cce1" }
+ val x2 = try { (5: Any).asInstanceOf[Int] } catch { case _: Throwable => "cce2" }
+ val x3 = try { (new java.lang.Short(100.toShort).asInstanceOf[Int]) } catch { case _: Throwable => "cce3" }
+
+ def main(args: Array[String]): Unit = {
+ List(x1, x2, x3) foreach println
+ }
+}
diff --git a/tests/run/t4897.check b/tests/run/t4897.check
new file mode 100644
index 000000000..17dda56fe
--- /dev/null
+++ b/tests/run/t4897.check
@@ -0,0 +1 @@
+joepie
diff --git a/tests/run/t4897.scala b/tests/run/t4897.scala
new file mode 100644
index 000000000..f65c2745e
--- /dev/null
+++ b/tests/run/t4897.scala
@@ -0,0 +1,10 @@
+class CSuper {
+ object A
+}
+class C extends CSuper {
+ def f = (A: AnyRef) match { case _: A.type => "joepie" }
+}
+
+object Test extends C with App {
+ println(f)
+}
diff --git a/tests/run/t5009.check b/tests/run/t5009.check
new file mode 100644
index 000000000..6c567227b
--- /dev/null
+++ b/tests/run/t5009.check
@@ -0,0 +1,5 @@
+C(1,true)
+10
+C(7283,20)
+C(66,-3)
+100
diff --git a/tests/run/t5009.scala b/tests/run/t5009.scala
new file mode 100644
index 000000000..9e4700c07
--- /dev/null
+++ b/tests/run/t5009.scala
@@ -0,0 +1,14 @@
+object Test extends dotty.runtime.LegacyApp {
+
+ case class C[T, U <: String, O >: Object](x: Int, y: T)(z: U, b: Boolean)(s: O, val l: Int)
+
+ val c = C(1, true)("dlkfj", true)("dlkfjlk", 10)
+ println(c)
+ println(c.l)
+
+ println(c.copy(y = 20, x = 7283)("enwa", b = false)(l = -1, s = new Object))
+
+ val res = c.copy[Int, String, Object](y = -3, x = 66)("lkdjen", false)(new Object, 100)
+ println(res)
+ println(res.l)
+}
diff --git a/tests/run/t5648.check b/tests/run/t5648.check
new file mode 100644
index 000000000..1140ff52e
--- /dev/null
+++ b/tests/run/t5648.check
@@ -0,0 +1,4 @@
+true
+true
+true
+true
diff --git a/tests/run/t5648.flags b/tests/run/t5648.flags
new file mode 100644
index 000000000..e8fb65d50
--- /dev/null
+++ b/tests/run/t5648.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/tests/run/t5648.scala b/tests/run/t5648.scala
new file mode 100644
index 000000000..c5cea9e1c
--- /dev/null
+++ b/tests/run/t5648.scala
@@ -0,0 +1,10 @@
+case class C(val s: Int*)
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ println(new C(1, 3, 7) == new C(1, 3, 7))
+ println(new C(1, 3, 7) == C(1, 3, 7))
+ println(C(1, 3, 7) == new C(1, 3, 7))
+ println(C(1, 3, 7) == C(1, 3, 7))
+ }
+}
diff --git a/tests/run/t6089.check b/tests/run/t6089.check
new file mode 100644
index 000000000..a8d442410
--- /dev/null
+++ b/tests/run/t6089.check
@@ -0,0 +1 @@
+scala.MatchError: Foo(0) (of class Foo)
diff --git a/tests/run/t6089.scala b/tests/run/t6089.scala
new file mode 100644
index 000000000..8fb4082b7
--- /dev/null
+++ b/tests/run/t6089.scala
@@ -0,0 +1,13 @@
+case class Foo(x: Int)
+
+object Test {
+ def bippo(result: Boolean): Boolean = result
+ def bungus(m: Foo): Boolean =
+ bippo(m match { case Foo(2) => bungus(m) })
+
+ def main(args: Array[String]): Unit = try {
+ bungus(Foo(0))
+ } catch {
+ case x: MatchError => println(x)
+ }
+}
diff --git a/tests/run/t6104.check b/tests/run/t6104.check
new file mode 100644
index 000000000..9766475a4
--- /dev/null
+++ b/tests/run/t6104.check
@@ -0,0 +1 @@
+ok
diff --git a/tests/run/t6104.scala b/tests/run/t6104.scala
new file mode 100644
index 000000000..ac6d4c77e
--- /dev/null
+++ b/tests/run/t6104.scala
@@ -0,0 +1,8 @@
+class A { Self =>
+ val ok = "ok"
+ this match {
+ case me@Self => println(me.ok)
+ }
+}
+
+object Test extends A with App
diff --git a/tests/run/t6154.check b/tests/run/t6154.check
new file mode 100644
index 000000000..9766475a4
--- /dev/null
+++ b/tests/run/t6154.check
@@ -0,0 +1 @@
+ok
diff --git a/tests/run/t6154.scala b/tests/run/t6154.scala
new file mode 100644
index 000000000..47773490a
--- /dev/null
+++ b/tests/run/t6154.scala
@@ -0,0 +1,10 @@
+object Test {
+ def foo(a: Int): Unit = {
+ var bar: Int = 0
+ bar = try { 0 } catch { case ex: Throwable => 0 }
+ new { foo(bar) }
+ }
+
+ def main(args: Array[String]): Unit =
+ try foo(0) catch { case _: java.lang.StackOverflowError => println("ok") }
+}
diff --git a/tests/run/t6196.scala b/tests/run/t6196.scala
new file mode 100644
index 000000000..9ded3b9c0
--- /dev/null
+++ b/tests/run/t6196.scala
@@ -0,0 +1,68 @@
+import scala.collection.immutable.HashSet
+
+object Test extends dotty.runtime.LegacyApp {
+
+ case class Collision(value: Int) extends Ordered[Collision] {
+ def compare(that:Collision) = value compare that.value
+
+ override def hashCode = value / 5
+ }
+
+ def testCorrectness[T : Ordering](n: Int, mkKey: Int => T): Unit = {
+ val o = implicitly[Ordering[T]]
+ val s = HashSet.empty[T] ++ (0 until n).map(mkKey)
+ for (i <- 0 until n) {
+ val ki = mkKey(i)
+ val a = s.filter(o.lt(_,ki))
+ val b = s.filterNot(o.lt(_,ki))
+ require(a.size == i && (0 until i).forall(i => a.contains(mkKey(i))))
+ require(b.size == n - i && (i until n).forall(i => b.contains(mkKey(i))))
+ }
+ }
+
+ // this tests the structural sharing of the new filter
+ // I could not come up with a simple test that tests structural sharing when only parts are reused, but
+ // at least this fails with the old and passes with the new implementation
+ def testSharing(): Unit = {
+ val s = HashSet.empty[Int] ++ (0 until 100)
+ require(s.filter(_ => true) eq s)
+ require(s.filterNot(_ => false) eq s)
+ }
+
+ // this tests that neither hashCode nor equals are called during filter
+ def testNoHashing(): Unit = {
+ var hashCount = 0
+ var equalsCount = 0
+ case class HashCounter(value:Int) extends Ordered[HashCounter] {
+ def compare(that:HashCounter) = value compare that.value
+
+ override def hashCode = {
+ hashCount += 1
+ value
+ }
+
+ override def equals(that:Any) = {
+ equalsCount += 1
+ that match {
+ case HashCounter(value) => this.value == value
+ case _ => false
+ }
+ }
+ }
+
+ val s = HashSet.empty[HashCounter] ++ (0 until 100).map(HashCounter)
+ val hashCount0 = hashCount
+ val equalsCount0 = equalsCount
+ val t = s.filter(_<HashCounter(50))
+ require(hashCount == hashCount0)
+ require(equalsCount == equalsCount0)
+ }
+
+ // this tests correctness of filter and filterNot for integer keys
+ testCorrectness[Int](100, identity _)
+ // this tests correctness of filter and filterNot for keys with lots of collisions
+ // this is necessary because usually collisions are rare so the collision-related code is not thoroughly tested
+ testCorrectness[Collision](100, Collision.apply _)
+ testSharing()
+ testNoHashing()
+}
diff --git a/tests/run/t6200.scala b/tests/run/t6200.scala
new file mode 100644
index 000000000..af348f563
--- /dev/null
+++ b/tests/run/t6200.scala
@@ -0,0 +1,68 @@
+import scala.collection.immutable.HashMap
+
+object Test extends dotty.runtime.LegacyApp {
+
+ case class Collision(value: Int) extends Ordered[Collision] {
+ def compare(that: Collision) = value compare that.value
+
+ override def hashCode = value / 5
+ }
+
+ def testCorrectness[T: Ordering](n: Int, mkKey: Int => T): Unit = {
+ val o = implicitly[Ordering[T]]
+ val s = HashMap.empty[T, Unit] ++ (0 until n).map(x => mkKey(x) -> (()))
+ for (i <- 0 until n) {
+ val ki = mkKey(i)
+ val a = s.filter(kv => o.lt(kv._1, ki))
+ val b = s.filterNot(kv => o.lt(kv._1, ki))
+ require(a.size == i && (0 until i).forall(i => a.contains(mkKey(i))))
+ require(b.size == n - i && (i until n).forall(i => b.contains(mkKey(i))))
+ }
+ }
+
+ // this tests the structural sharing of the new filter
+ // I could not come up with a simple test that tests structural sharing when only parts are reused, but
+ // at least this fails with the old and passes with the new implementation
+ def testSharing(): Unit = {
+ val s = HashMap.empty[Int, Unit] ++ (0 until 100).map(_ -> (()))
+ require(s.filter(_ => true) eq s)
+ require(s.filterNot(_ => false) eq s)
+ }
+
+ // this tests that neither hashCode nor equals are called during filter
+ def testNoHashing(): Unit = {
+ var hashCount = 0
+ var equalsCount = 0
+ case class HashCounter(value: Int) extends Ordered[HashCounter] {
+ def compare(that: HashCounter) = value compare that.value
+
+ override def hashCode = {
+ hashCount += 1
+ value
+ }
+
+ override def equals(that: Any) = {
+ equalsCount += 1
+ that match {
+ case HashCounter(value) => this.value == value
+ case _ => false
+ }
+ }
+ }
+
+ val s = HashMap.empty[HashCounter, Unit] ++ (0 until 100).map(k => HashCounter(k) -> (()))
+ val hashCount0 = hashCount
+ val equalsCount0 = equalsCount
+ val t = s.filter(_._1 < HashCounter(50))
+ require(hashCount == hashCount0)
+ require(equalsCount == equalsCount0)
+ }
+
+ // this tests correctness of filter and filterNot for integer keys
+ testCorrectness[Int](100, identity _)
+ // this tests correctness of filter and filterNot for keys with lots of collisions
+ // this is necessary because usually collisions are rare so the collision-related code is not thoroughly tested
+ testCorrectness[Collision](100, Collision.apply _)
+ testSharing()
+ testNoHashing()
+}
diff --git a/tests/run/t6333.scala b/tests/run/t6333.scala
new file mode 100644
index 000000000..0c8986c9e
--- /dev/null
+++ b/tests/run/t6333.scala
@@ -0,0 +1,29 @@
+object Test extends dotty.runtime.LegacyApp {
+ import util.Try
+
+ val a = "apple"
+ def fail: String = throw new Exception("Fail!")
+ def argh: Try[String] = throw new Exception("Argh!")
+
+ // No throw tests
+ def tryMethods(expr: => String): Unit = {
+ Try(expr) orElse argh
+ Try(expr).transform(_ => argh, _ => argh)
+ Try(expr).recoverWith { case e if (a == fail) => Try(a) }
+ Try(expr).recoverWith { case _ => argh }
+ Try(expr).getOrElse(a)
+ // TODO - Fail getOrElse?
+ Try(expr) orElse argh
+ Try(expr) orElse Try(a)
+ Try(expr) map (_ => fail)
+ Try(expr) map (_ => a)
+ Try(expr) flatMap (_ => argh)
+ Try(expr) flatMap (_ => Try(a))
+ Try(expr) filter (_ => throw new Exception("O NOES"))
+ Try(expr) filter (_ => true)
+ Try(expr) recover { case _ => fail }
+ Try(expr).failed
+ }
+ tryMethods(a)
+ tryMethods(fail)
+}
diff --git a/tests/run/t6406-regextract.check b/tests/run/t6406-regextract.check
new file mode 100644
index 000000000..88c5a52eb
--- /dev/null
+++ b/tests/run/t6406-regextract.check
@@ -0,0 +1,4 @@
+List(1, 3)
+List(1, 3)
+List(1, 3)
+Some(2011) Some(2011)
diff --git a/tests/run/t6406-regextract.scala b/tests/run/t6406-regextract.scala
new file mode 100644
index 000000000..26d0baedc
--- /dev/null
+++ b/tests/run/t6406-regextract.scala
@@ -0,0 +1,30 @@
+
+object Test extends dotty.runtime.LegacyApp {
+ import util.matching._
+ import Regex._
+
+ val r = "(\\d+)".r
+ val q = """(\d)""".r
+ val ns = List("1,2","x","3,4")
+ val u = r.unanchored
+
+ val is = ns collect { case u(x) => x } map { case r(x) => x }
+ println(is)
+ // Match from same pattern
+ val js = (ns map { u findFirstMatchIn _ }).flatten map { case r(x) => x }
+ println(js)
+ // Match not from same pattern
+ val ks = (ns map { q findFirstMatchIn _ }).flatten map { case r(x) => x }
+ println(ks)
+
+ val t = "Last modified 2011-07-15"
+ val p1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r
+ val y1: Option[String] = for {
+ p1(year, month, day) <- p1 findFirstIn t
+ } yield year
+ val y2: Option[String] = for {
+ p1(year, month, day) <- p1 findFirstMatchIn t
+ } yield year
+ println(s"$y1 $y2")
+
+}
diff --git a/tests/run/t7120.check b/tests/run/t7120.check
new file mode 100644
index 000000000..45a4fb75d
--- /dev/null
+++ b/tests/run/t7120.check
@@ -0,0 +1 @@
+8
diff --git a/tests/run/t7120/Base_1.scala b/tests/run/t7120/Base_1.scala
new file mode 100644
index 000000000..be07b4f34
--- /dev/null
+++ b/tests/run/t7120/Base_1.scala
@@ -0,0 +1,10 @@
+// This bug doesn't depend on separate compilation,
+// in the interests of minimizing the log output during
+// debugging this problem, I've split the compilation.
+
+case class Container( v: String )
+
+trait Base[ T <: AnyRef ] {
+ type UserType = T
+ protected def defect: PartialFunction[ UserType, String ]
+}
diff --git a/tests/run/t7120/Derived_2.scala b/tests/run/t7120/Derived_2.scala
new file mode 100644
index 000000000..e0de629f8
--- /dev/null
+++ b/tests/run/t7120/Derived_2.scala
@@ -0,0 +1,9 @@
+trait Derived extends Base[ Container ] {
+ protected def defect = { case c: Container => c.v.toString }
+}
+
+// Erasure was ignoring the prefix `Derived#7001.this` when erasing
+// A1, and consequently used `Object` rather than `Container`, which
+// was only seen because that signature clashed with the bridge method.
+//
+// applyOrElse[A1 <: Derived#7001.this.UserType#7318, B1 >: String](x1: A1)
diff --git a/tests/run/t7120/Run_3.scala b/tests/run/t7120/Run_3.scala
new file mode 100644
index 000000000..95e7f994f
--- /dev/null
+++ b/tests/run/t7120/Run_3.scala
@@ -0,0 +1,3 @@
+object Test extends Derived with App {
+ println( defect( Container( "8" ) ) )
+}
diff --git a/tests/run/t7326.scala b/tests/run/t7326.scala
new file mode 100644
index 000000000..3d6a711e5
--- /dev/null
+++ b/tests/run/t7326.scala
@@ -0,0 +1,64 @@
+import scala.collection.immutable.ListSet
+import scala.collection.immutable.HashSet
+
+object Test extends dotty.runtime.LegacyApp {
+
+ def testCorrectness(): Unit = {
+ // a key that has many hashCode collisions
+ case class Collision(i: Int) { override def hashCode = i / 5 }
+
+ def subsetTest[T](emptyA:Set[T], emptyB:Set[T], mkKey:Int => T, n:Int): Unit = {
+ val outside = mkKey(n + 1)
+ for(i <- 0 to n) {
+ val a = emptyA ++ (0 until i).map(mkKey)
+ // every set must be a subset of itself
+ require(a.subsetOf(a), "A set must be the subset of itself")
+ for(k <- 0 to i) {
+ // k <= i, so b is definitely a subset
+ val b = emptyB ++ (0 until k).map(mkKey)
+ // c has less elements than a, but contains a value that is not in a
+ // so it is not a subset, but that is not immediately obvious due to size
+ val c = b + outside
+ require(b.subsetOf(a), s"$b must be a subset of $a")
+ require(!c.subsetOf(a), s"$c must not be a subset of $a")
+ }
+ }
+ }
+
+ // test the HashSet/HashSet case
+ subsetTest(HashSet.empty[Int], HashSet.empty[Int], identity, 100)
+
+ // test the HashSet/other set case
+ subsetTest(HashSet.empty[Int], ListSet.empty[Int], identity, 100)
+
+ // test the HashSet/HashSet case for Collision keys
+ subsetTest(HashSet.empty[Collision], HashSet.empty[Collision], Collision, 100)
+
+ // test the HashSet/other set case for Collision keys
+ subsetTest(HashSet.empty[Collision], ListSet.empty[Collision], Collision, 100)
+ }
+
+ /**
+ * A main performance benefit of the new subsetOf is that we do not have to call hashCode during subsetOf
+ * since we already have the hash codes in the HashSet1 nodes.
+ */
+ def testNoHashCodeInvocationsDuringSubsetOf() = {
+ var count = 0
+
+ case class HashCodeCounter(i:Int) {
+ override def hashCode = {
+ count += 1
+ i
+ }
+ }
+
+ val a = HashSet.empty ++ (0 until 100).map(HashCodeCounter)
+ val b = HashSet.empty ++ (0 until 50).map(HashCodeCounter)
+ val count0 = count
+ val result = b.subsetOf(a)
+ require(count == count0, "key.hashCode must not be called during subsetOf of two HashSets")
+ result
+ }
+ testCorrectness()
+ testNoHashCodeInvocationsDuringSubsetOf()
+}
diff --git a/tests/run/t8245.scala b/tests/run/t8245.scala
new file mode 100644
index 000000000..5a6fb9ff7
--- /dev/null
+++ b/tests/run/t8245.scala
@@ -0,0 +1,14 @@
+object Test {
+ def foo(o: Option[Int]): Int = {
+ lazy val i: Int = {
+ def local: Int = {if ("".isEmpty) return 42; -42}
+ assert(local == 42)
+ o.getOrElse(return -1)
+ }
+ i + 1
+ }
+
+ def main(args: Array[String]): Unit = {
+ assert(foo(None) == -1)
+ }
+}
diff --git a/tests/run/tcpoly_monads.check b/tests/run/tcpoly_monads.check
new file mode 100644
index 000000000..d81cc0710
--- /dev/null
+++ b/tests/run/tcpoly_monads.check
@@ -0,0 +1 @@
+42
diff --git a/tests/run/tcpoly_monads.scala b/tests/run/tcpoly_monads.scala
new file mode 100644
index 000000000..978f88959
--- /dev/null
+++ b/tests/run/tcpoly_monads.scala
@@ -0,0 +1,45 @@
+
+import scala.language.{ higherKinds, implicitConversions }
+
+trait Monads {
+ /**
+ * class Monad m where
+ * (>>=) :: m a -> (a -> m b) -> m b
+ * return :: a -> m a
+ *
+ * MonadTC encodes the above Haskell type class,
+ * an instance of MonadTC corresponds to a method dictionary.
+ * (see http://lampwww.epfl.ch/~odersky/talks/wg2.8-boston06.pdf)
+ *
+ * Note that the identity (`this') of the method dictionary does not really correspond
+ * to the instance of m[x] (`self') that is `wrapped': e.g., unit does not use `self' (which
+ * corresponds to the argument of the implicit conversion that encodes an instance of this type class)
+ */
+ trait MonadTC[m[x], a] {
+ def unit[a](orig: a): m[a]
+
+ // >>='s first argument comes from the implicit definition constructing this "method dictionary"
+ def >>=[b](fun: a => m[b]): m[b]
+ }
+}
+
+/**
+ * instance Monad Maybe where
+ * (Just x) >>= k = k x
+ * Nothing >>= _ = Nothing
+ */
+trait OptionMonad extends Monads {
+ // this implicit method encodes the Monad type class instance for Option
+ implicit def OptionInstOfMonad[a](self: Option[a]): MonadTC[Option, a]
+ = new MonadTC[Option, a] {
+ def unit[a](orig: a) = Some(orig)
+ def >>=[b](fun: a => Option[b]): Option[b] = self match {
+ case Some(x) => fun(x)
+ case None => None
+ }
+ }
+}
+
+object Test extends OptionMonad with App {
+ Console.println((Some("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") >>= (x => Some(x.length))).get)
+}
diff --git a/tests/run/typealias_overriding.check b/tests/run/typealias_overriding.check
new file mode 100644
index 000000000..2dc752a8c
--- /dev/null
+++ b/tests/run/typealias_overriding.check
@@ -0,0 +1 @@
+LinkedNode
diff --git a/tests/run/typealias_overriding.scala b/tests/run/typealias_overriding.scala
new file mode 100644
index 000000000..e19ae0bed
--- /dev/null
+++ b/tests/run/typealias_overriding.scala
@@ -0,0 +1,23 @@
+// this bug (http://scala-webapps.epfl.ch/bugtracking/bugs/displayItem.do?id=1065)
+// was caused by Uncurry not normalizing all the types
+// (more specifically the argument/return types of an anonymous Function)
+object Test extends dotty.runtime.LegacyApp {
+ trait AddRemove {
+ type TNode <: NodeImpl;
+ trait NodeImpl;
+
+ object removing {
+ type TNode = AddRemove.this.TNode;
+ def printNode(node: TNode, f: TNode => String) = Console.println(f(node))
+ }
+ }
+
+ class Linked extends AddRemove {
+ type TNode = Node // can also directly write `class Node extends super.NodeImpl' -- doesn't change the bug
+ class Node extends super.NodeImpl { override def toString = "LinkedNode" }
+
+ removing.printNode(new Node, (x: removing.TNode) => x.toString) // make inference explicit, doesn't affect the bug
+ }
+
+ new Linked
+}
diff --git a/tests/run/value-class-partial-func-depmet.scala b/tests/run/value-class-partial-func-depmet.scala
new file mode 100644
index 000000000..f8d2a16e7
--- /dev/null
+++ b/tests/run/value-class-partial-func-depmet.scala
@@ -0,0 +1,24 @@
+class C
+class A { class C }
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val a = new A
+
+ new VC("").foo(a)
+ }
+}
+
+class VC(val a: Any) extends AnyVal {
+ def foo(a: A) = {
+ val pf: PartialFunction[a.C, Any] = { case x => x }
+ (pf: PartialFunction[Null, Any]).isDefinedAt(null)
+ }
+}
+
+// 2.11.0-M6
+// test/files/run/value-class-partial-func-depmet.scala:14: error: overriding method applyOrElse in trait PartialFunction of type [A1 <: a.C, B1 >: Any](x: A1, default: A1 => B1)B1;
+// method applyOrElse has incompatible type
+// val pf: PartialFunction[a.C, Any] = { case x => x }
+// ^
+// one error found
diff --git a/tests/run/view-iterator-stream.check b/tests/run/view-iterator-stream.check
new file mode 100644
index 000000000..2da02c865
--- /dev/null
+++ b/tests/run/view-iterator-stream.check
@@ -0,0 +1,112 @@
+
+** drop 20 -> take 10 -> slice(1, 5) **
+
+-------------------
+toIndexedSeq -> toIterator -> toStream Stream(22, ?) 22 23 24 25
+toIndexedSeq -> toIterator -> view StreamView(...) 22 23 24 25
+toIndexedSeq -> toStream -> toIterator non-empty iterator 22 23 24 25
+toIndexedSeq -> toStream -> view StreamView(...) 22 23 24 25
+toIndexedSeq -> view -> toIterator non-empty iterator 22 23 24 25
+toIndexedSeq -> view -> toStream Stream(22, ?) 22 23 24 25
+toIterator -> toIndexedSeq -> toStream Stream(22, ?) 22 23 24 25
+toIterator -> toIndexedSeq -> view SeqView(...) 22 23 24 25
+toIterator -> toStream -> toIndexedSeq Vector(22, 23, 24, 25) 22 23 24 25
+toIterator -> toStream -> view StreamView(...) 22 23 24 25
+toIterator -> view -> toIndexedSeq Vector(22, 23, 24, 25) 22 23 24 25
+toIterator -> view -> toStream Stream(22, ?) 22 23 24 25
+toStream -> toIndexedSeq -> toIterator non-empty iterator 22 23 24 25
+toStream -> toIndexedSeq -> view SeqView(...) 22 23 24 25
+toStream -> toIterator -> toIndexedSeq Vector(22, 23, 24, 25) 22 23 24 25
+toStream -> toIterator -> view StreamView(...) 22 23 24 25
+toStream -> view -> toIndexedSeq Vector(22, 23, 24, 25) 22 23 24 25
+toStream -> view -> toIterator non-empty iterator 22 23 24 25
+view -> toIndexedSeq -> toIterator non-empty iterator 22 23 24 25
+view -> toIndexedSeq -> toStream Stream(22, ?) 22 23 24 25
+view -> toIterator -> toIndexedSeq Vector(22, 23, 24, 25) 22 23 24 25
+view -> toIterator -> toStream Stream(22, ?) 22 23 24 25
+view -> toStream -> toIndexedSeq Vector(22, 23, 24, 25) 22 23 24 25
+view -> toStream -> toIterator non-empty iterator 22 23 24 25
+
+** take 20 -> drop 10 -> slice(1, 5) **
+
+-------------------
+toIndexedSeq -> toIterator -> toStream Stream(12, ?) 12 13 14 15
+toIndexedSeq -> toIterator -> view StreamView(...) 12 13 14 15
+toIndexedSeq -> toStream -> toIterator non-empty iterator 12 13 14 15
+toIndexedSeq -> toStream -> view StreamView(...) 12 13 14 15
+toIndexedSeq -> view -> toIterator non-empty iterator 12 13 14 15
+toIndexedSeq -> view -> toStream Stream(12, ?) 12 13 14 15
+toIterator -> toIndexedSeq -> toStream Stream(12, ?) 12 13 14 15
+toIterator -> toIndexedSeq -> view SeqView(...) 12 13 14 15
+toIterator -> toStream -> toIndexedSeq Vector(12, 13, 14, 15) 12 13 14 15
+toIterator -> toStream -> view StreamView(...) 12 13 14 15
+toIterator -> view -> toIndexedSeq Vector(12, 13, 14, 15) 12 13 14 15
+toIterator -> view -> toStream Stream(12, ?) 12 13 14 15
+toStream -> toIndexedSeq -> toIterator non-empty iterator 12 13 14 15
+toStream -> toIndexedSeq -> view SeqView(...) 12 13 14 15
+toStream -> toIterator -> toIndexedSeq Vector(12, 13, 14, 15) 12 13 14 15
+toStream -> toIterator -> view StreamView(...) 12 13 14 15
+toStream -> view -> toIndexedSeq Vector(12, 13, 14, 15) 12 13 14 15
+toStream -> view -> toIterator non-empty iterator 12 13 14 15
+view -> toIndexedSeq -> toIterator non-empty iterator 12 13 14 15
+view -> toIndexedSeq -> toStream Stream(12, ?) 12 13 14 15
+view -> toIterator -> toIndexedSeq Vector(12, 13, 14, 15) 12 13 14 15
+view -> toIterator -> toStream Stream(12, ?) 12 13 14 15
+view -> toStream -> toIndexedSeq Vector(12, 13, 14, 15) 12 13 14 15
+view -> toStream -> toIterator non-empty iterator 12 13 14 15
+
+** slice(20, 40) -> drop 10 -> take 5 **
+
+-------------------
+toIndexedSeq -> toIterator -> toStream Stream(31, ?) 31 32 33 34 35
+toIndexedSeq -> toIterator -> view StreamView(...) 31 32 33 34 35
+toIndexedSeq -> toStream -> toIterator non-empty iterator 31 32 33 34 35
+toIndexedSeq -> toStream -> view StreamView(...) 31 32 33 34 35
+toIndexedSeq -> view -> toIterator non-empty iterator 31 32 33 34 35
+toIndexedSeq -> view -> toStream Stream(31, ?) 31 32 33 34 35
+toIterator -> toIndexedSeq -> toStream Stream(31, ?) 31 32 33 34 35
+toIterator -> toIndexedSeq -> view SeqView(...) 31 32 33 34 35
+toIterator -> toStream -> toIndexedSeq Vector(31, 32, 33, 34, 35) 31 32 33 34 35
+toIterator -> toStream -> view StreamView(...) 31 32 33 34 35
+toIterator -> view -> toIndexedSeq Vector(31, 32, 33, 34, 35) 31 32 33 34 35
+toIterator -> view -> toStream Stream(31, ?) 31 32 33 34 35
+toStream -> toIndexedSeq -> toIterator non-empty iterator 31 32 33 34 35
+toStream -> toIndexedSeq -> view SeqView(...) 31 32 33 34 35
+toStream -> toIterator -> toIndexedSeq Vector(31, 32, 33, 34, 35) 31 32 33 34 35
+toStream -> toIterator -> view StreamView(...) 31 32 33 34 35
+toStream -> view -> toIndexedSeq Vector(31, 32, 33, 34, 35) 31 32 33 34 35
+toStream -> view -> toIterator non-empty iterator 31 32 33 34 35
+view -> toIndexedSeq -> toIterator non-empty iterator 31 32 33 34 35
+view -> toIndexedSeq -> toStream Stream(31, ?) 31 32 33 34 35
+view -> toIterator -> toIndexedSeq Vector(31, 32, 33, 34, 35) 31 32 33 34 35
+view -> toIterator -> toStream Stream(31, ?) 31 32 33 34 35
+view -> toStream -> toIndexedSeq Vector(31, 32, 33, 34, 35) 31 32 33 34 35
+view -> toStream -> toIterator non-empty iterator 31 32 33 34 35
+
+** slice(20, 40) -> take 10 -> drop 5 **
+
+-------------------
+toIndexedSeq -> toIterator -> toStream Stream(26, ?) 26 27 28 29 30
+toIndexedSeq -> toIterator -> view StreamView(...) 26 27 28 29 30
+toIndexedSeq -> toStream -> toIterator non-empty iterator 26 27 28 29 30
+toIndexedSeq -> toStream -> view StreamView(...) 26 27 28 29 30
+toIndexedSeq -> view -> toIterator non-empty iterator 26 27 28 29 30
+toIndexedSeq -> view -> toStream Stream(26, ?) 26 27 28 29 30
+toIterator -> toIndexedSeq -> toStream Stream(26, ?) 26 27 28 29 30
+toIterator -> toIndexedSeq -> view SeqView(...) 26 27 28 29 30
+toIterator -> toStream -> toIndexedSeq Vector(26, 27, 28, 29, 30) 26 27 28 29 30
+toIterator -> toStream -> view StreamView(...) 26 27 28 29 30
+toIterator -> view -> toIndexedSeq Vector(26, 27, 28, 29, 30) 26 27 28 29 30
+toIterator -> view -> toStream Stream(26, ?) 26 27 28 29 30
+toStream -> toIndexedSeq -> toIterator non-empty iterator 26 27 28 29 30
+toStream -> toIndexedSeq -> view SeqView(...) 26 27 28 29 30
+toStream -> toIterator -> toIndexedSeq Vector(26, 27, 28, 29, 30) 26 27 28 29 30
+toStream -> toIterator -> view StreamView(...) 26 27 28 29 30
+toStream -> view -> toIndexedSeq Vector(26, 27, 28, 29, 30) 26 27 28 29 30
+toStream -> view -> toIterator non-empty iterator 26 27 28 29 30
+view -> toIndexedSeq -> toIterator non-empty iterator 26 27 28 29 30
+view -> toIndexedSeq -> toStream Stream(26, ?) 26 27 28 29 30
+view -> toIterator -> toIndexedSeq Vector(26, 27, 28, 29, 30) 26 27 28 29 30
+view -> toIterator -> toStream Stream(26, ?) 26 27 28 29 30
+view -> toStream -> toIndexedSeq Vector(26, 27, 28, 29, 30) 26 27 28 29 30
+view -> toStream -> toIterator non-empty iterator 26 27 28 29 30
diff --git a/tests/run/view-iterator-stream.scala b/tests/run/view-iterator-stream.scala
new file mode 100644
index 000000000..0e0c42d7d
--- /dev/null
+++ b/tests/run/view-iterator-stream.scala
@@ -0,0 +1,70 @@
+
+import scala.language.postfixOps
+
+import scala.collection.{ mutable, immutable, generic }
+import collection.TraversableView
+
+object Test {
+ type PerturberFn[T] = TraversableOnce[T] => TraversableOnce[T]
+ lazy val Id = new Perturber(Nil, identity[TraversableOnce[Int]] _) { }
+ class Perturber(val labels: List[String], val f: PerturberFn[Int]) extends PerturberFn[Int] {
+ def apply(xs: TraversableOnce[Int]): TraversableOnce[Int] = f(xs)
+ def show(xs: TraversableOnce[Int]): String = {
+ val res = f(xs)
+ val resString = "" + res
+ val rest = res.toTraversable
+ val failed = (rest take 100).size == 100
+
+ "%-45s %-30s %s".format(toString, resString,
+ if (failed) "<failed>" else rest.mkString(" ")
+ )
+ }
+ def and(g: Perturber): Perturber =
+ new Perturber(this.labels ++ g.labels, f andThen g.f)
+
+ override def toString = labels mkString " -> "
+ }
+ object Perturber {
+ def apply(label: String, f: PerturberFn[Int]) = new Perturber(List(label), f)
+ }
+
+ def naturals = Stream from 1
+ val toV : Perturber = Perturber("view", _.toTraversable.view)
+ val toI : Perturber = Perturber("toIterator", _.toIterator)
+ val toS : Perturber = Perturber("toStream", _.toStream)
+ val toIS : Perturber = Perturber("toIndexedSeq", _.toIndexedSeq)
+
+ def p(ps: Perturber*): Perturber = if (ps.isEmpty) Id else ps.reduceLeft(_ and _)
+ def drop(n: Int): Perturber = Perturber("drop " + n, _.toIterator drop n)
+ def take(n: Int): Perturber = Perturber("take " + n, _.toIterator take n)
+ def slice(from: Int, until: Int): Perturber =
+ Perturber(
+ "slice(%d, %d)".format(from, until),
+ _.toTraversable.slice(from, until)
+ )
+
+ val fns = List[Perturber](toV, toI, toS, toIS)
+
+ def tds(n: Int): Perturber = p(drop(n), take(n / 2), slice(1, n / 4))
+ def dts(n: Int): Perturber = p(take(n), drop(n / 2), slice(1, n / 4))
+ def sdt(n: Int): Perturber = p(slice(n, n * 2), drop(n / 2), take(n / 4))
+ def std(n: Int): Perturber = p(slice(n, n * 2), take(n / 2), drop(n / 4))
+
+ val transforms = (fns.permutations map (xs => p(xs take 3: _*))).toList.distinct
+ def mkOps(n: Int) = List[Perturber](tds(n), dts(n), sdt(n), std(n))
+ def runOps(n: Int) = {
+ val xs: List[(String, List[String])] = mkOps(n) map { op =>
+ ("" + op, transforms map (_ show op(naturals)) sorted)
+ }
+ for ((k, v) <- xs) {
+ println("\n** " + k + " **\n")
+ println("-------------------")
+ v foreach println
+ }
+ ()
+ }
+
+ def main(args: Array[String]): Unit = {
+ runOps(20)
+ }
+}
diff --git a/tests/run/virtpatmat_npe.check b/tests/run/virtpatmat_npe.check
new file mode 100644
index 000000000..a0aba9318
--- /dev/null
+++ b/tests/run/virtpatmat_npe.check
@@ -0,0 +1 @@
+OK \ No newline at end of file
diff --git a/tests/run/virtpatmat_npe.flags b/tests/run/virtpatmat_npe.flags
new file mode 100644
index 000000000..3f5a3100e
--- /dev/null
+++ b/tests/run/virtpatmat_npe.flags
@@ -0,0 +1 @@
+ -Xexperimental
diff --git a/tests/run/virtpatmat_npe.scala b/tests/run/virtpatmat_npe.scala
new file mode 100644
index 000000000..efa66f328
--- /dev/null
+++ b/tests/run/virtpatmat_npe.scala
@@ -0,0 +1,10 @@
+class C {
+ class D
+ val values = new Array[AnyRef](10)
+ values(0) match {
+ case name: D => println("NOK: "+ name) // the outer check on D's outer should not cause a NPE
+ case null => println("OK")
+ }
+}
+
+object Test extends C with App
diff --git a/tests/run/virtpatmat_partial_backquoted.check b/tests/run/virtpatmat_partial_backquoted.check
new file mode 100644
index 000000000..8ab8f2967
--- /dev/null
+++ b/tests/run/virtpatmat_partial_backquoted.check
@@ -0,0 +1 @@
+Set(You got me!)
diff --git a/tests/run/virtpatmat_partial_backquoted.scala b/tests/run/virtpatmat_partial_backquoted.scala
new file mode 100644
index 000000000..21f686dcf
--- /dev/null
+++ b/tests/run/virtpatmat_partial_backquoted.scala
@@ -0,0 +1,12 @@
+object Test extends dotty.runtime.LegacyApp {
+ class Region { override def toString = "You got me!" }
+ class SymbolType
+ case class SymbolInfo(tp: SymbolType, regions: List[Region], x: Any)
+
+ def findRegionsWithSymbolType(rawSymbolInfos: Seq[SymbolInfo], symbolType: SymbolType): Set[Region] =
+ rawSymbolInfos.collect { case SymbolInfo(`symbolType`, regions, _) => regions }.flatten.toSet
+
+ val stp = new SymbolType
+ val stp2 = new SymbolType
+ println(findRegionsWithSymbolType(List(SymbolInfo(stp2, List(), null), SymbolInfo(stp, List(new Region), null)), stp))
+}
diff --git a/tests/run/virtpatmat_stringinterp.check b/tests/run/virtpatmat_stringinterp.check
new file mode 100644
index 000000000..7927f4f2d
--- /dev/null
+++ b/tests/run/virtpatmat_stringinterp.check
@@ -0,0 +1 @@
+Node(1)
diff --git a/tests/run/virtpatmat_stringinterp.flags b/tests/run/virtpatmat_stringinterp.flags
new file mode 100644
index 000000000..e1b37447c
--- /dev/null
+++ b/tests/run/virtpatmat_stringinterp.flags
@@ -0,0 +1 @@
+-Xexperimental \ No newline at end of file
diff --git a/tests/run/virtpatmat_stringinterp.scala b/tests/run/virtpatmat_stringinterp.scala
new file mode 100644
index 000000000..6ce1bf9c5
--- /dev/null
+++ b/tests/run/virtpatmat_stringinterp.scala
@@ -0,0 +1,16 @@
+
+import scala.language.{ implicitConversions }
+
+object Test extends dotty.runtime.LegacyApp {
+ case class Node(x: Int)
+
+ implicit def sc2xml(sc: StringContext): XMLContext = new XMLContext(sc)
+ class XMLContext(sc: StringContext) {
+ object xml {
+ def unapplySeq(xml: Node): Option[Seq[Node]] = Some(List(Node(1)))
+ }
+ }
+
+ val x: Node = Node(0)
+ x match { case xml"""<foo arg=$a/>""" => println(a) }
+}