diff options
698 files changed, 18952 insertions, 0 deletions
diff --git a/tests/run/Course-2002-03.check b/tests/run/Course-2002-03.check new file mode 100644 index 000000000..01b9977d3 --- /dev/null +++ b/tests/run/Course-2002-03.check @@ -0,0 +1,67 @@ +1 +2 +1/2 +5/6 + +1/3 +5/7 +3/2 +66/42 + +1/3 +5/7 +3/2 +11/7 + +11/7 +7/11 +11/7 +11/7 + +13/36 + +false +true +true +false + +set0 = [] +set1 = [1] +set2 = [1,2] +set3 = [1,2,3] +set4 = [1,2,3,4] + +set2 contains the following elements: +1 +2 + +set3 contains the following elements: +1 +2 +3 + +set4 contains the following elements: +1 +2 +3 +4 + +2 <- set2: true +3 <- set2: false + +setx = [-10,-1,0,3,5,21] +setx * 2 = [-20,-2,0,6,10,42] + +setx = [-10,-1,0,3,5,21] +sety = [-9,-5,-1,0,3,7,8] +setx & sety = [-1,0,3] +sety & setx = [-1,0,3] +setx > 0 = [3,5,21] +sety > 0 = [3,7,8] +setx & sety = [-1,0,3] +sety & setx = [-1,0,3] + +1/1 +1/1 +1/1 + diff --git a/tests/run/Course-2002-03.scala b/tests/run/Course-2002-03.scala new file mode 100644 index 000000000..44cc75aaa --- /dev/null +++ b/tests/run/Course-2002-03.scala @@ -0,0 +1,392 @@ +//############################################################################ +// Programmation IV - 2002 - Week 03 +//############################################################################ + + +object M0 { + class Rational(x: Int, y: Int) { + def numer = x; + def denom = y; + } + + def addRational(r: Rational, s: Rational): Rational = + new Rational( + r.numer * s.denom + s.numer * r.denom, + r.denom * s.denom); + + def makeString(r: Rational) = + r.numer + "/" + r.denom; + + val x = new Rational(1, 2); + val y = new Rational(1, 3); + Console.println(x.numer); + Console.println(x.denom); + Console.println(makeString(x)); + Console.println(makeString(addRational(x,y))); + Console.println; +} + +//############################################################################ + +object M1 { + class Rational(x: Int, y: Int) { + def numer = x; + def denom = y; + def add(r: Rational) = + new Rational( + numer * r.denom + r.numer * denom, + denom * r.denom); + def mul(r: Rational) = + new Rational( + numer * r.numer, + denom * r.denom); + override def toString() = numer + "/" + denom; + } + + val x = new Rational(1, 3); + val y = new Rational(5, 7); + val z = new Rational(3, 2); + Console.println(x); + Console.println(y); + Console.println(z); + Console.println(x.add(y).mul(z)); + Console.println; +} + +//############################################################################ + +object M2 { + class Rational(x: Int, y: Int) { + private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); + private val g = gcd(x, y); + def numer = x / g; + def denom = y / g; + def add(r: Rational) = + new Rational( + numer * r.denom + r.numer * denom, + denom * r.denom); + def sub(r: Rational) = + new Rational( + numer * r.denom - r.numer * denom, + denom * r.denom); + def mul(r: Rational) = + new Rational( + numer * r.numer, + denom * r.denom); + def div(r: Rational) = + new Rational( + numer * r.denom, + denom * r.numer); + override def toString() = numer + "/" + denom; + } + + val x = new Rational(1, 3); + val y = new Rational(5, 7); + val z = new Rational(3, 2); + Console.println(x); + Console.println(y); + Console.println(z); + Console.println(x.add(y).mul(z)); + Console.println; +} + +//############################################################################ + +object M3 { + class Rational(x: Int, y: Int) { + private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); + def numer = x / gcd(x, y); + def denom = y / gcd(x, y); + def less(that: Rational) = + this.numer * that.denom < that.numer * this.denom; + def max(that: Rational) = if (this.less(that)) that else this; + override def toString() = numer + "/" + denom; + } + + val x = new Rational(66, 42); + val y = new Rational(42, 66); + Console.println(x); + Console.println(y); + Console.println(x.max(y)); + Console.println(y.max(x)); + Console.println; +} + +//############################################################################ + +object M4 { + class Rational(x: Int, y: Int) { + private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); + private val g = gcd(x, y); + def numer = x / g; + def denom = y / g; + def + (r: Rational) = + new Rational( + numer * r.denom + r.numer * denom, + denom * r.denom); + def - (r: Rational) = + new Rational( + numer * r.denom - r.numer * denom, + denom * r.denom); + def * (r: Rational) = + new Rational( + numer * r.numer, + denom * r.denom); + def / (r: Rational) = + new Rational( + numer * r.denom, + denom * r.numer); + override def toString() = numer + "/" + denom; + } + + val x = new Rational(1, 2); + val y = new Rational(1, 3); + Console.println(x * x + y * y); + Console.println; +} + +//############################################################################ + +object M5 { + trait IntSet { + def incl(x: Int): IntSet; + def contains(x: Int): Boolean; + } + + class Empty extends IntSet { + def contains(x: Int): Boolean = false; + def incl(x: Int): IntSet = new NonEmpty(x, new Empty, new Empty); + } + + class NonEmpty(elem: Int, left: IntSet, right: IntSet) extends IntSet { + def contains(x: Int): Boolean = + if (x < elem) left contains x + else if (x > elem) right contains x + else true; + def incl(x: Int): IntSet = + if (x < elem) new NonEmpty(elem, left incl x, right) + else if (x > elem) new NonEmpty(elem, left, right incl x) + else this; + } + + val x = new Empty incl 1 incl 2; + Console.println(x contains 0); + Console.println(x contains 1); + Console.println(x contains 2); + Console.println(x contains 3); + Console.println; +} + +//############################################################################ + +object M6 { + trait Boolean { + def ifThenElse[a](t: => a)(e: => a): a; + + def ! : Boolean = ifThenElse[Boolean](new False())(new True()); + + def && (x: => Boolean): Boolean = ifThenElse[Boolean](x)(new False()); + def || (x: => Boolean): Boolean = ifThenElse[Boolean](new True())(x); + + // !!! def == (x: Boolean): Boolean = ifThenElse[Boolean](x)(x.!); + // !!! def != (x: Boolean): Boolean = ifThenElse[Boolean](x.!)(x); + def < (x: Boolean): Boolean = ifThenElse[Boolean](new False())(x); + def > (x: Boolean): Boolean = ifThenElse[Boolean](x.!)(new False()); + def <= (x: Boolean): Boolean = ifThenElse[Boolean](x)(new True()); + def >= (x: Boolean): Boolean = ifThenElse[Boolean](new True())(x.!); + } + class True() extends Boolean { // !!! class -> object + def ifThenElse[a](t: => a)(e: => a): a = t } + class False() extends Boolean { // !!! class -> object + def ifThenElse[a](t: => a)(e: => a): a = e } +} + +//############################################################################ + +object M7 { + trait Nat { + def isZero(): Boolean; + def predecessor: Nat; + def successor: Nat; + def + (that: Nat): Nat; + def - (that: Nat): Nat; + } +} + +//############################################################################ + +object M8 { + + trait IntSet { + def incl(x: Int): IntSet; + def contains(x: Int): Boolean; + def map(f: Int => Int): IntSet; + + def foreach(f: Int => Unit): Unit; + def intersect0(that: IntSet, accu: IntSet): IntSet; + def filter0(f: Int => Boolean, accu: IntSet): IntSet; + + def intersect(that: IntSet): IntSet = intersect0(that, new Empty); + def intersect2(that: IntSet): IntSet = filter(x => that.contains(x)); + def filter(f: Int => Boolean): IntSet = filter0(f, new Empty); + + def print() = foreach(Console.println); + + override def toString(): String = { + val buffer: StringBuilder = new StringBuilder(); + buffer.append('['); + foreach(i => { + if (buffer.length > 1) {buffer.append(','); ()}; // !!! ; () + buffer.append(i); + ()}); + buffer.append(']'); + buffer.toString(); + } + } + + class Empty extends IntSet { // !!! class Empty() -> object Empty + def contains(x: Int): Boolean = false; + def incl(x: Int): IntSet = new NonEmpty(x, new Empty, new Empty); + def map(f: Int => Int): IntSet = this; + + def foreach(f: Int => Unit): Unit = (); + def intersect0(that: IntSet, accu: IntSet): IntSet = accu; + def filter0(f: Int => Boolean, accu: IntSet): IntSet = accu; + } + + class NonEmpty(elem: Int, left: IntSet, right: IntSet) extends IntSet { + def contains(x: Int): Boolean = + if (x < elem) left contains x + else if (x > elem) right contains x + else true; + + def incl(x: Int): IntSet = + if (x < elem) new NonEmpty(elem, left incl x, right) + else if (x > elem) new NonEmpty(elem, left, right incl x) + else this; + + + def map(f: Int => Int): IntSet = { + val lset = left.map(f); + val rset = right.map(f); + new NonEmpty(f(elem), lset, rset) + } + + def foreach(f: Int => Unit): Unit = { + left.foreach(f); + f(elem); + right.foreach(f); + } + + def intersect0(that: IntSet, accu: IntSet): IntSet = + right.intersect0(that, left.intersect0(that, + if (that.contains(elem)) accu.incl(elem) else accu)); + + def filter0(f: Int => Boolean, accu: IntSet): IntSet = + right.filter0(f, left.filter0(f, + if (f(elem)) accu.incl(elem) else accu)); + } + + def test = { + val set0: IntSet = new Empty; + val set1: IntSet = new Empty incl 1; + val set2: IntSet = new Empty incl 1 incl 2; + val set3: IntSet = new Empty incl 1 incl 2 incl 3; + val set4: IntSet = new Empty incl 1 incl 2 incl 3 incl 4; + val setx: IntSet = set0 incl -10 incl 5 incl 21 incl -1 incl 0 incl 3; + val sety: IntSet = set0 incl 3 incl 7 incl -5 incl 0 incl-9 incl 8 incl-1; + + Console.println("set0 = " + set0); + Console.println("set1 = " + (set1.toString())); + Console.println("set2 = " + set2); + Console.println("set3 = " + (set3.toString())); + Console.println("set4 = " + set4); + Console.println; + + Console.println("set2 contains the following elements:"); + set2.foreach(Console.println); + Console.println; + + Console.println("set3 contains the following elements:"); + set3 foreach Console.println; + Console.println; + + Console.println("set4 contains the following elements:"); + set4.print(); + Console.println; + + Console.println("2 <- set2: " + (set2 contains 2)); + Console.println("3 <- set2: " + set2.contains(3)); + Console.println; + + Console.println("setx = " + setx); + Console.println("setx * 2 = " + (setx.map(x => 2 * x))); + Console.println; + + Console.println("setx = " + setx); + Console.println("sety = " + sety); + Console.println("setx & sety = " + (setx.intersect(sety))); + Console.println("sety & setx = " + (sety.intersect(setx))); + Console.println("setx > 0 = " + (setx.filter(x => x > 0))); + Console.println("sety > 0 = " + (sety.filter(x => x > 0))); + Console.println("setx & sety = " + (setx.intersect2(sety))); + Console.println("sety & setx = " + (sety.intersect2(setx))); + Console.println; + } +} + +//############################################################################ + +object M9 { + class Rational(x: Int, y: Int) { + private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); + private val g = gcd(x, y); + def numer = x / g; + def denom = y / g; + def add(r: Rational) = + new Rational( + numer * r.denom + r.numer * denom, + denom * r.denom); + def sub(r: Rational) = + new Rational( + numer * r.denom - r.numer * denom, + denom * r.denom); + def mul(r: Rational) = + new Rational( + numer * r.numer, + denom * r.denom); + def equal(r: Rational) = + new Rational( + numer * r.denom, + denom * r.numer); + def asString = numer.toString().concat("/").concat(denom.toString()); + override def toString() = asString; + } + + def test = { + Console.println(new Rational(2,2).asString); + Console.println(new Rational(2,2).toString()); + Console.println(new Rational(2,2)); + Console.println; + } +} + +//############################################################################ + +object Test { + def main(args: Array[String]): Unit = { + M0; + M1; + M2; + M3; + M4; + M5; + M6; + M7; + M8.test; + M9.test; + () + } +} + +//############################################################################ diff --git a/tests/run/Course-2002-04.check b/tests/run/Course-2002-04.check new file mode 100644 index 000000000..1110fd05a --- /dev/null +++ b/tests/run/Course-2002-04.check @@ -0,0 +1,64 @@ +list0 = List(6, 3, 1, 8, 7, 1, 2, 5, 8, 4, 3, 4, 8) +list1 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8) +list2 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8) +list3 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8) +list4 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8) +list5 = List(8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2, 1, 1) +list6 = List(8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2, 1, 1) + +list0: List() -> List() +list1: List(0) -> List(0) +list2: List(0, 1) -> List(0, 1) +list3: List(1, 0) -> List(0, 1) +list4: List(0, 1, 2) -> List(0, 1, 2) +list5: List(1, 0, 2) -> List(0, 1, 2) +list6: List(0, 1, 2) -> List(0, 1, 2) +list7: List(1, 0, 2) -> List(0, 1, 2) +list8: List(2, 0, 1) -> List(0, 1, 2) +list9: List(2, 1, 0) -> List(0, 1, 2) +listA: List(6, 3, 1, 8, 7, 1, 2, 5, 8, 4) -> List(1, 1, 2, 3, 4, 5, 6, 7, 8, 8) + +f(x) = 5x^3+7x^2+5x+9 +f(0) = 9.0 +f(1) = 26.0 +f(2) = 87.0 +f(3) = 222.0 + +v1 = List(2.0, 3.0, 4.0) +v2 = List(6.0, 7.0, 8.0) + +id = List(List(1.0, 0.0, 0.0), List(0.0, 1.0, 0.0), List(0.0, 0.0, 1.0)) +m1 = List(List(2.0, 0.0, 0.0), List(0.0, 2.0, 0.0), List(0.0, 0.0, 2.0)) +m2 = List(List(1.0, 2.0, 3.0), List(4.0, 5.0, 6.0), List(7.0, 8.0, 9.0)) + +v1 * v1 = 29.0 +v1 * v2 = 65.0 +v2 * v1 = 65.0 +v1 * v2 = 65.0 + +id * v1 = List(2.0, 3.0, 4.0) +m1 * v1 = List(4.0, 6.0, 8.0) +m2 * v1 = List(20.0, 47.0, 74.0) + +trn(id) = List(List(1.0, 0.0, 0.0), List(0.0, 1.0, 0.0), List(0.0, 0.0, 1.0)) +trn(m1) = List(List(2.0, 0.0, 0.0), List(0.0, 2.0, 0.0), List(0.0, 0.0, 2.0)) +trn(m2) = List(List(1.0, 4.0, 7.0), List(2.0, 5.0, 8.0), List(3.0, 6.0, 9.0)) + +List(v1) * id = List(List(2.0, 3.0, 4.0)) +List(v1) * m1 = List(List(4.0, 6.0, 8.0)) +List(v1) * m2 = List(List(42.0, 51.0, 60.0)) + +id * List(v1) = List(List(2.0, 3.0, 4.0), List(0.0, 0.0, 0.0), List(0.0, 0.0, 0.0)) +m1 * List(v1) = List(List(4.0, 6.0, 8.0), List(0.0, 0.0, 0.0), List(0.0, 0.0, 0.0)) +m2 * List(v1) = List(List(2.0, 3.0, 4.0), List(8.0, 12.0, 16.0), List(14.0, 21.0, 28.0)) + +id * id = List(List(1.0, 0.0, 0.0), List(0.0, 1.0, 0.0), List(0.0, 0.0, 1.0)) +id * m1 = List(List(2.0, 0.0, 0.0), List(0.0, 2.0, 0.0), List(0.0, 0.0, 2.0)) +m1 * id = List(List(2.0, 0.0, 0.0), List(0.0, 2.0, 0.0), List(0.0, 0.0, 2.0)) +m1 * m1 = List(List(4.0, 0.0, 0.0), List(0.0, 4.0, 0.0), List(0.0, 0.0, 4.0)) +id * m2 = List(List(1.0, 2.0, 3.0), List(4.0, 5.0, 6.0), List(7.0, 8.0, 9.0)) +m2 * id = List(List(1.0, 2.0, 3.0), List(4.0, 5.0, 6.0), List(7.0, 8.0, 9.0)) +m1 * m2 = List(List(2.0, 4.0, 6.0), List(8.0, 10.0, 12.0), List(14.0, 16.0, 18.0)) +m2 * m1 = List(List(2.0, 4.0, 6.0), List(8.0, 10.0, 12.0), List(14.0, 16.0, 18.0)) +m2 * m2 = List(List(30.0, 36.0, 42.0), List(66.0, 81.0, 96.0), List(102.0, 126.0, 150.0)) + diff --git a/tests/run/Course-2002-04.scala b/tests/run/Course-2002-04.scala new file mode 100644 index 000000000..368e29db4 --- /dev/null +++ b/tests/run/Course-2002-04.scala @@ -0,0 +1,244 @@ +//############################################################################ +// Programmation IV - 2002 - Week 04 +//############################################################################ + +object M0 { + + def quicksort[a] (less : (a,a) => Boolean) (xs : List[a]) : List[a] = { + if (xs.isEmpty) + xs + else { + val pivot : a = xs.head; + val smaller : List[a] = + quicksort(less)(xs.tail.filter(elem => less(elem, pivot))); + val greaterOrEqual : List[a] = + quicksort(less)(xs.tail.filter(elem => !less(elem, pivot))); + smaller ::: List(pivot) ::: greaterOrEqual + } + } + + def test = { + val isort: List[Int] => List[Int] = quicksort[Int]((x,y) => x < y); + val list0 = List(6,3,1,8,7,1,2,5,8,4,3,4,8); + val list1 = quicksort[Int]((x,y) => x < y)(list0); + val list2 = quicksort[Int]((x,y) => x < y)(list1); + val list3 = isort(list0); + val list4 = isort(list1); + val list5 = quicksort[Int]((x,y) => x >= y)(list0); + val list6 = quicksort[Int]((x,y) => x >= y)(list1); + + Console.println("list0 = " + list0); + Console.println("list1 = " + list1); + Console.println("list2 = " + list2); + Console.println("list3 = " + list3); + Console.println("list4 = " + list4); + Console.println("list5 = " + list5); + Console.println("list6 = " + list6); + Console.println; + } +} + +//############################################################################ + +object M1 { + + def mergesort[a] (less : (a,a) => Boolean) (xs: Array[a]): Unit = { + + def While(c: => Boolean)(b: => Unit): Unit = + if (c) { b ; While(c)(b) } else (); + + def swap(i: Int, j: Int): Unit = { + val t = xs(i); + val u = xs(j); + xs(i) = u; + xs(j) = t; + } + + def sort1(l: Int, r: Int): Unit = { + val pivot = xs((l + r) / 2); + var i = l; + var j = r; + While (i <= j) { + While (less(xs(i), pivot)) { i = i + 1 } + While (less(pivot, xs(j))) { j = j - 1 } + if (i <= j) { + swap(i, j); + i = i + 1; + j = j - 1; + } + } + if (l < j) sort1(l, j); + if (j < r) sort1(i, r); + } + + if (xs.length > 0) sort1(0, xs.length - 1); + } + + def list2array(list: List[Int]): Array[Int] = { + val array = new Array[Int](list.length); + list.copyToArray(array, 0); + array; + } + + def array2list(array: Array[Int]): List[Int] = { + var list = List[Int](); + List.range(0, array.length).map(i => list = array(i) :: list); + list.reverse; + } + + def isort(list: List[Int]): List[Int] = { + val array = list2array(list); + mergesort[Int]((x,y) => x < y)(array); + array2list(array); + } + + def test = { + val list0 = List(); + val list1 = List(0); + val list2 = List(0,1); + val list3 = List(1,0); + val list4 = List(0,1,2); + val list5 = List(1,0,2); + val list6 = List(0,1,2); + val list7 = List(1,0,2); + val list8 = List(2,0,1); + val list9 = List(2,1,0); + val listA = List(6,3,1,8,7,1,2,5,8,4); + + Console.println("list0: " + list0 + " -> " + isort(list0)); + Console.println("list1: " + list1 + " -> " + isort(list1)); + Console.println("list2: " + list2 + " -> " + isort(list2)); + Console.println("list3: " + list3 + " -> " + isort(list3)); + Console.println("list4: " + list4 + " -> " + isort(list4)); + Console.println("list5: " + list5 + " -> " + isort(list5)); + Console.println("list6: " + list6 + " -> " + isort(list6)); + Console.println("list7: " + list7 + " -> " + isort(list7)); + Console.println("list8: " + list8 + " -> " + isort(list8)); + Console.println("list9: " + list9 + " -> " + isort(list9)); + Console.println("listA: " + listA + " -> " + isort(listA)); + Console.println; + } + +} + +//############################################################################ + +object M2 { + + def horner (x : Double, coefs : List[Double]) : Double = { + if (coefs.isEmpty) + 0 + else + horner(x, coefs.tail) * x + coefs.head + } + + def test = { + val poly = List(9.0,5.0,7.0,5.0); + Console.println("f(x) = 5x^3+7x^2+5x+9"); + Console.println("f(0) = " + horner(0, poly)); + Console.println("f(1) = " + horner(1, poly)); + Console.println("f(2) = " + horner(2, poly)); + Console.println("f(3) = " + horner(3, poly)); + Console.println; + } +} + +//############################################################################ + +object M3 { + + def dotproduct (v : List[Double], w : List[Double]) : Double = { + if (v.isEmpty) + 0 + else + (v.head * w.head) + dotproduct(v.tail, w.tail) + } + + def matrixTimesVector (m : List[List[Double]], v : List[Double]) + : List[Double] = { + m.map(row => dotproduct(row, v)) + } + + def transpose(m : List[List[Double]]) : List[List[Double]] = { + if (m.isEmpty || m.head.isEmpty) + List() + else + m.map(row => row.head) :: transpose (m.map (row => row.tail)) + } + + def matrixTimesMatrix(m1 : List[List[Double]], m2 : List[List[Double]]) + : List[List[Double]] = { + val columns = transpose(m2); + m1.map(row => matrixTimesVector(columns, row)) + } + + def test = { + val v1 = List(2.0,3.0,4.0); + val v2 = List(6.0,7.0,8.0); + def id = List(List(1.0,0.0,0.0),List(0.0,1.0,0.0),List(0.0,0.0,1.0)); + def m1 = List(List(2.0,0.0,0.0),List(0.0,2.0,0.0),List(0.0,0.0,2.0)); + def m2 = List(List(1.0,2.0,3.0),List(4.0,5.0,6.0),List(7.0,8.0,9.0)); + + def v = List(2.0,3.0,4.0); + + Console.println("v1 = " + v1); + Console.println("v2 = " + v2); + Console.println; + + Console.println("id = " + id); + Console.println("m1 = " + m1); + Console.println("m2 = " + m2); + Console.println; + + Console.println("v1 * v1 = " + dotproduct(v1,v1)); + Console.println("v1 * v2 = " + dotproduct(v1,v2)); + Console.println("v2 * v1 = " + dotproduct(v2,v1)); + Console.println("v1 * v2 = " + dotproduct(v1,v2)); + Console.println; + + Console.println("id * v1 = " + matrixTimesVector(id,v1)); + Console.println("m1 * v1 = " + matrixTimesVector(m1,v1)); + Console.println("m2 * v1 = " + matrixTimesVector(m2,v1)); + Console.println; + + Console.println("trn(id) = " + transpose(id)); + Console.println("trn(m1) = " + transpose(m1)); + Console.println("trn(m2) = " + transpose(m2)); + Console.println; + + Console.println("List(v1) * id = " + matrixTimesMatrix(List(v1),id)); + Console.println("List(v1) * m1 = " + matrixTimesMatrix(List(v1),m1)); + Console.println("List(v1) * m2 = " + matrixTimesMatrix(List(v1),m2)); + Console.println; + + Console.println("id * List(v1) = " + matrixTimesMatrix(id,List(v1))); + Console.println("m1 * List(v1) = " + matrixTimesMatrix(m1,List(v1))); + Console.println("m2 * List(v1) = " + matrixTimesMatrix(m2,List(v1))); + Console.println; + + Console.println("id * id = " + matrixTimesMatrix(id,id)); + Console.println("id * m1 = " + matrixTimesMatrix(id,m1)); + Console.println("m1 * id = " + matrixTimesMatrix(m1,id)); + Console.println("m1 * m1 = " + matrixTimesMatrix(m1,m1)); + Console.println("id * m2 = " + matrixTimesMatrix(id,m2)); + Console.println("m2 * id = " + matrixTimesMatrix(m2,id)); + Console.println("m1 * m2 = " + matrixTimesMatrix(m1,m2)); + Console.println("m2 * m1 = " + matrixTimesMatrix(m2,m1)); + Console.println("m2 * m2 = " + matrixTimesMatrix(m2,m2)); + Console.println; + } +} + +//############################################################################ + +object Test { + def main(args: Array[String]): Unit = { + M0.test; + M1.test; + M2.test; + M3.test; + () + } +} + +//############################################################################ diff --git a/tests/run/Course-2002-05.check b/tests/run/Course-2002-05.check new file mode 100644 index 000000000..d41120ad4 --- /dev/null +++ b/tests/run/Course-2002-05.check @@ -0,0 +1,44 @@ +(List(),List(1, 2, 3, 4, 5, 6, 7, 8)) +(List(1, 2, 3, 4),List(5, 6, 7, 8)) +(List(1, 2, 3, 4, 5, 6, 7, 8),List()) + +(List(),List(8, 7, 6, 5, 4, 3, 2, 1)) +(List(4, 3, 2, 1),List(8, 7, 6, 5)) +(List(8, 7, 6, 5, 4, 3, 2, 1),List()) + +(List(),List(7, 2, 1, 5, 4, 3, 8, 6)) +(List(2, 1, 4, 3),List(7, 5, 8, 6)) +(List(7, 2, 1, 5, 4, 3, 8, 6),List()) + +List(1, 2, 3, 4, 5, 6, 7, 8) + +(List(),List(1, 2, 3, 4, 5, 6, 7, 8)) +(List(1, 2, 3, 4),List(5, 6, 7, 8)) +(List(1, 2, 3, 4, 5, 6, 7, 8),List()) + +(List(),List(8, 7, 6, 5, 4, 3, 2, 1)) +(List(4, 3, 2, 1),List(8, 7, 6, 5)) +(List(8, 7, 6, 5, 4, 3, 2, 1),List()) + +(List(),List(7, 2, 1, 5, 4, 3, 8, 6)) +(List(2, 1, 4, 3),List(7, 5, 8, 6)) +(List(7, 2, 1, 5, 4, 3, 8, 6),List()) + +List(1, 2, 3, 4, 5, 6, 7, 8) + +List(List()) +List(List(), List(1)) +List(List(), List(2), List(1), List(1, 2)) +List(List(), List(3), List(2), List(2, 3), List(1), List(1, 3), List(1, 2), List(1, 2, 3)) +List(List(), List(4), List(3), List(3, 4), List(2), List(2, 4), List(2, 3), List(2, 3, 4), List(1), List(1, 4), List(1, 3), List(1, 3, 4), List(1, 2), List(1, 2, 4), List(1, 2, 3), List(1, 2, 3, 4)) + +queens(1) = List(List((1,1))) +queens(2) = List() +queens(3) = List() +queens(4) = List(List((4,3), (3,1), (2,4), (1,2)), List((4,2), (3,4), (2,1), (1,3))) + +queens(1) = List(List(1)) +queens(2) = List() +queens(3) = List() +queens(4) = List(List(3, 1, 4, 2), List(2, 4, 1, 3)) + diff --git a/tests/run/Course-2002-05.scala b/tests/run/Course-2002-05.scala new file mode 100644 index 000000000..c1e6b07c0 --- /dev/null +++ b/tests/run/Course-2002-05.scala @@ -0,0 +1,214 @@ +//############################################################################ +// Programmation IV - 2002 - Week 05 +//############################################################################ + +object M0 { + def partition[a](xs: List[a], pred: a => Boolean): Tuple2[List[a], List[a]] = { + if (xs.isEmpty) + (List(),List()) + else { + val tailPartition = partition(xs.tail, pred); + if (pred(xs.head)) + (xs.head :: tailPartition._1, tailPartition._2) + else + (tailPartition._1, xs.head :: tailPartition._2) + } + } + + def quicksort[a] (less : (a,a) => Boolean) (xs : List[a]) : List[a] = { + if (xs.isEmpty) + xs + else { + val pivot = xs.head; + val sub = partition(xs.tail, { elem : a => less(elem, pivot) }); + quicksort(less)(sub._1) ::: List(pivot) ::: quicksort(less)(sub._2) + } + } + + def test = { + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 0))); + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 5))); + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 9))); + Console.println; + + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 0))); + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 5))); + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 9))); + Console.println; + + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 0))); + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 5))); + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 9))); + Console.println; + + Console.println(quicksort[Int]((x,y) => x < y)(List(7,2,1,5,4,3,8,6))); + Console.println; + } +} + +//############################################################################ + +object M1 { + def partition[a](xs: List[a], pred: a => Boolean): Tuple2[List[a], List[a]] = { + xs.foldRight[Tuple2[List[a], List[a]]]((List(), List())) { + (x, p) => if (pred (x)) (x :: p._1, p._2) else (p._1, x :: p._2) + } + } + + def quicksort[a] (less : (a,a) => Boolean) (xs : List[a]) : List[a] = { + if (xs.isEmpty) + xs + else { + val pivot = xs.head; + val sub = partition(xs.tail, (elem : a) => less(elem, pivot)); + quicksort(less)(sub._1) ::: List(pivot) ::: quicksort(less)(sub._2) + } + } + + def test = { + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 0))); + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 5))); + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 9))); + Console.println; + + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 0))); + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 5))); + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 9))); + Console.println; + + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 0))); + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 5))); + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 9))); + Console.println; + + Console.println(quicksort[Int]((x,y) => x < y)(List(7,2,1,5,4,3,8,6))); + Console.println; + } +} + +//############################################################################ + +object M2 { + + def powerset[a] (s: List[a]): List[List[a]] = { + if (s.isEmpty) + List(List()) + else { + val x = s.head; + val withoutX = powerset(s.tail); + withoutX ::: withoutX.map { s1 : List[a] => x::s1 } + } + } + + def test = { + Console.println(powerset(List())); + Console.println(powerset(List(1))); + Console.println(powerset(List(1,2))); + Console.println(powerset(List(1,2,3))); + Console.println(powerset(List(1,2,3,4))); + Console.println; + } +} + +//############################################################################ + +object M3 { + + def abs(x: Int) = if (x < 0) 0 - x else x; + + def range(lo: Int, hi: Int): List[Int] = + if (lo > hi) List() + else lo :: range(lo + 1, hi); + + type Placement = List[(Int, Int)]; + + def queens(n: Int): List[Placement] = { + def placeQueens(row: Int): List[Placement] = { + if (row == 0) + List(List()) + else { + def isSafe(column: Int, placement: Placement): Boolean = + placement forall { + pos => (pos._2 != column && + abs(pos._2 - column) != row - pos._1) + } + + def adjoinRow(placement: Placement): List[Placement] = + range(1, n) + .filter (column => isSafe(column, placement)) + .map (column => (row, column) :: placement); + + placeQueens(row - 1) flatMap adjoinRow + } + } + placeQueens(n) + } + + def test: Unit = { + Console.println("queens(1) = " + queens(1)); + Console.println("queens(2) = " + queens(2)); + Console.println("queens(3) = " + queens(3)); + Console.println("queens(4) = " + queens(4)); + Console.println; + } +} + +//############################################################################ + +object M4 { + + def abs(x: Int) = if (x < 0) 0 - x else x; + + def range(lo: Int, hi: Int): List[Int] = + if (lo > hi) List() + else lo :: range(lo + 1, hi); + + type Placement = List[Int]; + + def queens(n: Int): List[Placement] = { + val columns = range(1, n); + def placeQueens(row: Int): List[Placement] = { + if (row == 0) + List(List()) + else { + def isSafe(col: Int, p: Placement, delta: Int): Boolean = + (p.isEmpty || + (col != p.head && + abs(col - p.head) != delta && + isSafe(col, p.tail, delta + 1))); + + for ( + placement <- placeQueens(row - 1); + col <- columns; + if isSafe(col, placement, 1) + ) yield { + col :: placement + } + } + } + placeQueens(n); + } + + def test: Unit = { + Console.println("queens(1) = " + queens(1)); + Console.println("queens(2) = " + queens(2)); + Console.println("queens(3) = " + queens(3)); + Console.println("queens(4) = " + queens(4)); + Console.println; + } +} + +//############################################################################ + +object Test { + def main(args: Array[String]): Unit = { + M0.test; + M1.test; + M2.test; + M3.test; + M4.test; + () + } +} + +//############################################################################ diff --git a/tests/run/Course-2002-06.check b/tests/run/Course-2002-06.check new file mode 100644 index 000000000..bd354594a --- /dev/null +++ b/tests/run/Course-2002-06.check @@ -0,0 +1,38 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: ProgrammationIV +%%Creator: LAMP +%%BoundingBox: 0 0 595.28 841.89 +%%EndComments + +/m {moveto} bind def +/l {lineto} bind def + +0.14 setlinewidth +newpath +42.52 165.83 m 297.64 165.83 l +297.64 165.83 m 297.64 505.99 l +297.64 505.99 m 42.52 505.99 l +42.52 505.99 m 170.08 676.07 l +170.08 676.07 m 297.64 505.99 l +297.64 505.99 m 42.52 165.83 l +42.52 165.83 m 42.52 505.99 l +42.52 505.99 m 297.64 165.83 l +297.64 165.83 m 425.2 165.83 l +425.2 165.83 m 425.2 505.99 l +425.2 505.99 m 297.64 505.99 l +297.64 505.99 m 361.42 676.07 l +361.42 676.07 m 425.2 505.99 l +425.2 505.99 m 297.64 165.83 l +297.64 165.83 m 297.64 505.99 l +297.64 505.99 m 425.2 165.83 l +425.2 676.07 m 552.76 676.07 l +552.76 676.07 m 552.76 335.91 l +552.76 335.91 m 425.2 335.91 l +425.2 335.91 m 488.98 165.83 l +488.98 165.83 m 552.76 335.91 l +552.76 335.91 m 425.2 676.07 l +425.2 676.07 m 425.2 335.91 l +425.2 335.91 m 552.76 676.07 l +stroke +showpage +%%EOF diff --git a/tests/run/Course-2002-06.scala b/tests/run/Course-2002-06.scala new file mode 100644 index 000000000..908a93404 --- /dev/null +++ b/tests/run/Course-2002-06.scala @@ -0,0 +1,261 @@ +//############################################################################ +// Programmation IV - 2002 - Week 06 +//############################################################################ + +/** Two-dimensional vector. */ +class Vector (_x: Double, _y: Double) { + def x: Double = _x; + def y: Double = _y; + def +(that: Vector): Vector = new Vector(x + that.x, y + that.y); + def *(scalar: Double): Vector = new Vector(x * scalar, y * scalar); + def -(that: Vector): Vector = new Vector(x - that.x, y - that.y); + def /(scalar: Double): Vector = new Vector(x / scalar, y / scalar); + def norm: Double = Math.sqrt(x * x + y * y); +} + +//############################################################################ + +/** Frame. */ +class Frame (_origin: Vector, _edgeX: Vector, _edgeY: Vector) { + def origin: Vector = _origin; + def edgeX: Vector = _edgeX; + def edgeY: Vector = _edgeY; + /** The vector v in the absolute (drawing) coordinate system */ + def coordMap(v: Vector): Vector = origin + (edgeX * v.x) + (edgeY * v.y); +} + +//############################################################################ + +/** Space on which we can draw lines. */ +abstract class Graphics(_width: Double, _height: Double) { + /** Width of the picture.*/ + def width: Double = _width; + + /** Height of the picture.*/ + def height: Double = _height; + + /** Frame that represents the drawable area of the output device*/ + val frame: Frame; + + /** Draw a line in device coordinates*/ + def plotLine(x1: Double, y1: Double, x2: Double, y2: Double): Unit; + + /** Draw a line in logical coordinates*/ + def drawLine(v1: Vector, v2: Vector): Unit = { + val _v1 = frame.coordMap(v1); + val _v2 = frame.coordMap(v2); + plotLine(_v1.x, _v1.y, _v2.x, _v2.y); + } + + /** Draw a segment of the picture.*/ + def drawSegment(frm: Frame)(v1: Vector, v2: Vector): Unit = { + val _v1 = frm.coordMap(v1); + val _v2 = frm.coordMap(v2); + drawLine(_v1, _v2); + } + + /** Draw a list of segments on the picture.*/ + def drawSegments(frm: Frame)(segments: List[Tuple2[Vector, Vector]]): Unit = + if (segments.isEmpty) () + else { + drawSegment(frm)(segments.head._1, segments.head._2); + drawSegments(frm)(segments.tail) + } + + /** Draw a list of continuous segments on the picture.*/ + def drawPolySegment(frm: Frame)(points: List[Vector]) : Unit = + if (!points.tail.isEmpty) { + drawSegment(frm)(points.head, points.tail.head); + drawPolySegment(frm)(points.tail); + } + + /** updates the contents of the output device*/ + def repaint = (); + + /** Add the last touch to the picture.*/ + def close : Unit; +} + +//############################################################################ + +/** Provides PostScript output. The name of the file is the first parameter + * of the constructor. The width and height determine the aspect ratio + */ +class PostScript (filename: String, _width: Double, _height: Double) + extends Graphics(_width, _height) { + /** Convert mm into 72th of inch.*/ + def mm2ps(x: Double) : Double = round(x * 72.0 / 25.4); + + def round(x: Double): Double = + Math.floor(x * 100.0 + 0.5) / 100.0; + + def scaleAndCenter(frm: Frame, ratio:Double): Frame = { + val currentRatio = frm.edgeX.norm / frm.edgeY.norm; + if (currentRatio < ratio) { + val newEdgeX = frm.edgeX; + val newEdgeY = frm.edgeY * (currentRatio /ratio); + val newOrigin = frm.origin + ((frm.edgeY - newEdgeY) / 2); + new Frame(newOrigin, newEdgeX, newEdgeY) + } + else { + val newEdgeX = frm.edgeX * (ratio / currentRatio); + val newEdgeY = frm.edgeY; + val newOrigin = frm.origin + ((frm.edgeX - newEdgeX) / 2); + new Frame(newOrigin, newEdgeX, newEdgeY) + } + } + + /** Line thickness in millimeters.*/ + val line_thickness : Double = 0.05; + + /** Width, height, left and right margins in mm.*/ + val psWidth: Double = 210.0; + val psHeight: Double = 297.0; + val psWidthMargin: Double = 15.0; + val psHeightMargin: Double = 15.0; + + val frame: Frame = { + val origin = new Vector(mm2ps(psWidthMargin), mm2ps(psHeightMargin)); + val edgeX = new Vector(mm2ps(psWidth) - 2 * mm2ps(psWidthMargin), 0); + val edgeY = new Vector(0, mm2ps(psHeight) - 2 * mm2ps(psHeightMargin)); + scaleAndCenter(new Frame(origin, edgeX, edgeY), width / height) + } + + def plotLine(x1: Double, y1: Double, x2: Double, y2: Double): Unit = { + Console.println(round(x1) + " " + round(y1) + " m " + + round(x2) + " " + round(y2) + " l"); + } + + /** Print the PS header.*/ + Console.println("%!PS-Adobe-3.0 EPSF-3.0\n%%Title: ProgrammationIV"); + Console.println("%%Creator: LAMP"); + Console.println("%%BoundingBox: 0 0 " + mm2ps(psWidth) + " " + mm2ps(psHeight)); + Console.println("%%EndComments\n"); + Console.println("/m {moveto} bind def\n/l {lineto} bind def\n"); + Console.println(mm2ps(line_thickness) + " setlinewidth\nnewpath"); + + /** Terminate the PS document and close the file stream. */ + def close : Unit = { + Console.println("stroke\nshowpage\n%%EOF"); + Console.flush; + } +} + +//############################################################################ + +object M0 { + + /** Define the type of a painter as a function that takes a frame, + * draws itself onto it and returns nothing + */ + type Painter = (Frame) => Unit; + + + /** Transform the frame in which the painter is to be drawn, hence + * changing the appearance of the painter + */ + def transformPainter(origin: Vector, newX: Vector, newY: Vector)(painter: Painter): Painter = { + frame: Frame => { + val newOrigin = frame.coordMap(origin); + val newFrame = new Frame(newOrigin, + frame.coordMap(newX) - newOrigin, + frame.coordMap(newY) - newOrigin); + painter(newFrame) + } + } + + + /** Flip the painter vertically + */ + def flipVert: Painter => Painter = + transformPainter(new Vector(0.0, 1.0), + new Vector(1.0, 1.0), + new Vector(0.0, 0.0)); + + /** Flip the painter horizontally + */ + def flipHoriz: Painter => Painter = + transformPainter(new Vector(1.0, 0.0), + new Vector(0.0, 0.0), + new Vector(1.0, 1.0)); + + /** Compose a painter that draws p1 on the left of p2 + */ + def beside(p1: Painter, p2: Painter) : Painter = { + frame: Frame => { + transformPainter(new Vector(0.0, 0.0), + new Vector(0.5, 0.0), + new Vector(0.0, 1.0))(p1)(frame); + transformPainter(new Vector(0.5, 0.0), + new Vector(1.0, 0.0), + new Vector(0.5, 1.0))(p2)(frame) + } + } + + /** Compose a painter that draws p1 below p2 + */ + def below(p1: Painter, p2: Painter): Painter = { + frame: Frame => { + transformPainter(new Vector(0.0, 0.0), + new Vector(1.0, 0.0), + new Vector(0.0, 0.5))(p1)(frame); + transformPainter(new Vector(0.0, 0.5), + new Vector(1.0, 0.5), + new Vector(0.0, 1.0))(p2)(frame) + } + } + + def rightSplit(painter: Painter, n: Int): Painter = { + if (n == 0) painter + else { + val smaller = rightSplit(painter, n-1); + beside(painter, below(smaller, smaller)) + } + } + + // A small test painter. + def house(canvas: Graphics)(frame: Frame): Unit = { + canvas.drawPolySegment(frame)(List(new Vector(0.0, 0.0), + new Vector(1.0, 0.0), + new Vector(1.0, 2.0/3.0), + new Vector(0.0, 2.0/3.0), + new Vector(0.5, 1.0), + new Vector(1.0, 2.0/3.0), + new Vector(0.0, 0.0), + new Vector(0.0, 2.0/3.0), + new Vector(1.0, 0.0))); + canvas.repaint + } + + def test = { + val psfile = "-"; + val canvas: Graphics = new PostScript(psfile, 2, 2); + + // the identity frame + val identFrame = new Frame(new Vector(0.0,0.0), + new Vector(1.0,0.0), + new Vector(0.0,1.0)); + + // Create a basic painter... + val p: Painter = house(canvas); + // ...then compose it with itself. + val threeHouses = beside(p, beside(p, flipVert(p))); + + // Use the painter to draw the final image. + threeHouses(identFrame); + + // Don't forget to close the canvas! + canvas.close + } +} + +//############################################################################ + +object Test { + def main(args: Array[String]): Unit = { + M0.test; + () + } +} + +//############################################################################ diff --git a/tests/run/Course-2002-08.check b/tests/run/Course-2002-08.check new file mode 100644 index 000000000..e2a780ecb --- /dev/null +++ b/tests/run/Course-2002-08.check @@ -0,0 +1,171 @@ +x = abc +count = 111 +x = hello +count = 112 + +account deposit 50 -> () +account withdraw 20 -> 30 +account withdraw 20 -> 10 +account withdraw 15 -> + +x deposit 30 -> () +y withdraw 20 -> + +x deposit 30 -> () +x withdraw 20 -> 10 + +x deposit 30 -> () +y withdraw 20 -> 10 + +2^0 = 1.0 +2^1 = 2.0 +2^2 = 4.0 +2^3 = 8.0 + +2^0 = 1.0 +2^1 = 2.0 +2^2 = 4.0 +2^3 = 8.0 + +1 2 3 +List(1, 2, 3) + +out 0 new-value = false +*** simulation started *** +out 1 new-value = true +!0 = 1 + +*** simulation started *** +out 2 new-value = false +!1 = 0 + +out 2 new-value = false + +*** simulation started *** +0 & 0 = 0 + +*** simulation started *** +0 & 1 = 0 + +*** simulation started *** +out 11 new-value = true +out 11 new-value = false +1 & 0 = 0 + +*** simulation started *** +out 14 new-value = true +1 & 1 = 1 + +out 14 new-value = false + +*** simulation started *** +0 | 0 = 0 + +*** simulation started *** +out 24 new-value = true +0 | 1 = 1 + +*** simulation started *** +1 | 0 = 1 + +*** simulation started *** +1 | 1 = 1 + +sum 34 new-value = false +carry 34 new-value = false + +*** simulation started *** +0 + 0 = 0 + +*** simulation started *** +sum 47 new-value = true +0 + 1 = 1 + +*** simulation started *** +carry 50 new-value = true +carry 50 new-value = false +sum 54 new-value = false +sum 54 new-value = true +1 + 0 = 1 + +*** simulation started *** +carry 57 new-value = true +sum 61 new-value = false +1 + 1 = 2 + +sum 61 new-value = false +carry 61 new-value = false + +*** simulation started *** +0 + 0 + 0 = 0 + +*** simulation started *** +sum 82 new-value = true +0 + 0 + 1 = 1 + +*** simulation started *** +sum 89 new-value = false +carry 90 new-value = true +sum 97 new-value = true +carry 98 new-value = false +0 + 1 + 0 = 1 + +*** simulation started *** +sum 113 new-value = false +carry 114 new-value = true +0 + 1 + 1 = 2 + +*** simulation started *** +sum 121 new-value = true +carry 122 new-value = false +sum 129 new-value = false +sum 129 new-value = true +1 + 0 + 0 = 1 + +*** simulation started *** +carry 137 new-value = true +sum 144 new-value = false +1 + 0 + 1 = 2 + +*** simulation started *** +carry 152 new-value = false +sum 152 new-value = true +sum 158 new-value = false +carry 159 new-value = true +1 + 1 + 0 = 2 + +*** simulation started *** +sum 173 new-value = true +1 + 1 + 1 = 3 + +in 0 new-value = false +ctrl0 0 new-value = false +ctrl1 0 new-value = false +ctrl2 0 new-value = false +out0 0 new-value = false +out1 0 new-value = false +out2 0 new-value = false +out3 0 new-value = false +out4 0 new-value = false +out5 0 new-value = false +out6 0 new-value = false +out7 0 new-value = false +in 0 new-value = true +*** simulation started *** +out0 10 new-value = true +ctrl0 10 new-value = true +*** simulation started *** +out1 13 new-value = true +out0 14 new-value = false +ctrl1 14 new-value = true +*** simulation started *** +out3 20 new-value = true +out1 21 new-value = false +ctrl2 21 new-value = true +*** simulation started *** +out7 30 new-value = true +out3 31 new-value = false +ctrl0 31 new-value = false +*** simulation started *** +out7 34 new-value = false +out6 35 new-value = true diff --git a/tests/run/Course-2002-08.scala b/tests/run/Course-2002-08.scala new file mode 100644 index 000000000..5e21edaba --- /dev/null +++ b/tests/run/Course-2002-08.scala @@ -0,0 +1,601 @@ +//############################################################################ +// Programmation IV - 2002 - Week 08 +//############################################################################ + +import List._; + +object M0 { + + var x: String = "abc"; + var count = 111; + + def test = { + Console.println("x = " + x); + Console.println("count = " + count); + x = "hello"; + count = count + 1; + Console.println("x = " + x); + Console.println("count = " + count); + Console.println; + } +} + +//############################################################################ + +object M1 { + + class BankAccount() { + private var balance = 0; + def deposit(amount: Int): Unit = + if (amount > 0) balance = balance + amount; + + def withdraw(amount: Int): Int = + if (0 < amount && amount <= balance) { + balance = balance - amount; + balance + } else sys.error("insufficient funds"); + } + + def test0 = { + val account = new BankAccount(); + Console.print("account deposit 50 -> "); + Console.println((account deposit 50).toString()); // !!! .toString + Console.print("account withdraw 20 -> "); + Console.println(account withdraw 20); + Console.print("account withdraw 20 -> "); + Console.println(account withdraw 20); + Console.print("account withdraw 15 -> "); + Console.println; + } + + def test1 = { + val x = new BankAccount(); + val y = new BankAccount(); + Console.print("x deposit 30 -> "); + Console.println((x deposit 30).toString()); // !!! .toString + Console.print("y withdraw 20 -> "); + Console.println; + } + + def test2 = { + val x = new BankAccount(); + val y = new BankAccount(); + Console.print("x deposit 30 -> "); + Console.println((x deposit 30).toString()); // !!! .toString + Console.print("x withdraw 20 -> "); + Console.println(x withdraw 20); + } + + def test3 = { + val x = new BankAccount(); + val y = x; + Console.print("x deposit 30 -> "); + Console.println((x deposit 30).toString()); // !!! .toString + Console.print("y withdraw 20 -> "); + Console.println(y withdraw 20); + } + + def test = { + test0; Console.println; + test1; Console.println; + test2; Console.println; + test3; Console.println; + } +} + + +//############################################################################ + +object M2 { + + def While(condition: => Boolean)(command: => Unit): Unit = + if (condition) { + command; While(condition)(command) + } else { + } + + def power (x: Double, exp: Int): Double = { + var r = 1.0; + var i = exp; + While (i > 0) { r = r * x; i = i - 1 } + r + } + + def test = { + Console.println("2^0 = " + power(2,0)); + Console.println("2^1 = " + power(2,1)); + Console.println("2^2 = " + power(2,2)); + Console.println("2^3 = " + power(2,3)); + Console.println; + } +} + +//############################################################################ + +object M3 { + + def power (x: Double, exp: Int): Double = { + var r = 1.0; + var i = exp; + while (i > 0) { r = r * x; i = i - 1 } + r + } + + def test = { + Console.println("2^0 = " + power(2,0)); + Console.println("2^1 = " + power(2,1)); + Console.println("2^2 = " + power(2,2)); + Console.println("2^3 = " + power(2,3)); + Console.println; + } +} + +//############################################################################ + +object M4 { + + def test = { + for (i <- range(1, 4)) { Console.print(i + " ") }; + Console.println; + Console.println(for (i <- range(1, 4)) yield i); + Console.println; + } +} + +//############################################################################ + +object M5 { + + type Action = () => Unit; + + class Wire() { + private var sigVal = false; + private var actions: List[Action] = List(); + def getSignal = sigVal; + def setSignal(s: Boolean) = + if (s != sigVal) { + sigVal = s; + actions.foreach(action => action()); + } + def addAction(a: Action) = { + actions = a :: actions; a() + } + } + + abstract class Simulation() { + private type Agenda = List[Tuple2[Int, Action]]; + private var agenda: Agenda = List(); + private var curtime = 0; + def currentTime: Int = curtime; + + def afterDelay(delay: Int)(action: Action): Unit = { + def insert(ag: Agenda, time: Int): Agenda = ag match { + case List() => + List((time, action)) + case (t, act) :: ag1 => + if (time < t) (time, action) :: ag + else (t, act) :: insert(ag1, time) + } + agenda = insert(agenda, curtime + delay) + } + + private def next: Unit = agenda match { + case List() => () + case (time, action) :: ag1 => { + agenda = ag1; + curtime = time; + action(); + } + } + + def run: Unit = { + afterDelay(0){() => Console.println("*** simulation started ***"); } + while (!agenda.isEmpty) { next } + } + } + + abstract class BasicCircuitSimulation() extends Simulation() { + + val InverterDelay: Int; + val AndGateDelay: Int; + val OrGateDelay: Int; + + def inverter(input: Wire, output: Wire): Unit = { + def invertAction() = { + val inputSig = input.getSignal; + afterDelay(InverterDelay) {() => output.setSignal(!inputSig) }; + } + input addAction invertAction + } + + def andGate(a1: Wire, a2: Wire, output: Wire): Unit = { + def andAction() = { + val a1Sig = a1.getSignal; + val a2Sig = a2.getSignal; + afterDelay(AndGateDelay) {() => output.setSignal(a1Sig & a2Sig) }; + } + a1 addAction andAction; + a2 addAction andAction; + } + + def orGate(o1: Wire, o2: Wire, output: Wire): Unit = { + def orAction() = { + val o1Sig = o1.getSignal; + val o2Sig = o2.getSignal; + afterDelay(OrGateDelay) {() => output.setSignal(o1Sig | o2Sig) }; + } + o1 addAction orAction; + o2 addAction orAction; + } + + def probe(name: String, wire: Wire): Unit = { + wire addAction {() => + Console.println( + name + " " + currentTime + " new-value = " + wire.getSignal); + } + } + } + + abstract class CircuitSimulation() extends BasicCircuitSimulation() { + + def halfAdder(a: Wire, b: Wire, s: Wire, c: Wire): Unit = { + val d = new Wire(); + val e = new Wire(); + orGate(a, b, d); + andGate(a, b, c); + inverter(c, e); + andGate(d, e, s); + } + + def fullAdder(a: Wire, b: Wire, cin: Wire, sum: Wire, cout: Wire): Unit = { + val s = new Wire(); + val c1 = new Wire(); + val c2 = new Wire(); + halfAdder(a, cin, s, c1); + halfAdder(b, s, sum, c2); + orGate(c1, c2, cout); + } + } + + class Test() extends CircuitSimulation() { + + val InverterDelay = 1; + val AndGateDelay = 3; + val OrGateDelay = 5; + + def invert = { + val ain = new Wire(); + val cout = new Wire(); + inverter(ain, cout); + + def result = if (cout.getSignal) 1 else 0; + + def test(a: Int) = { + ain setSignal (if (a == 0) false else true); + run; + Console.println("!" + a + " = " + result); + Console.println; + } + + probe("out ", cout); + + test(0); + test(1); + } + + def and = { + val ain = new Wire(); + val bin = new Wire(); + val cout = new Wire(); + andGate(ain, bin, cout); + + def result = if (cout.getSignal) 1 else 0; + + def test(a: Int, b: Int) = { + ain setSignal (if (a == 0) false else true); + bin setSignal (if (b == 0) false else true); + run; + Console.println(a + " & " + b + " = " + result); + Console.println; + } + + probe("out ", cout); + Console.println; + + test(0,0); + test(0,1); + test(1,0); + test(1,1); + } + + def or = { + val ain = new Wire(); + val bin = new Wire(); + val cout = new Wire(); + orGate(ain, bin, cout); + + def result = if (cout.getSignal) 1 else 0; + + def test(a: Int, b: Int) = { + ain setSignal (if (a == 0) false else true); + bin setSignal (if (b == 0) false else true); + run; + Console.println(a + " | " + b + " = " + result); + Console.println; + } + + probe("out ", cout); + Console.println; + + test(0,0); + test(0,1); + test(1,0); + test(1,1); + } + + def half = { + val ain = new Wire(); + val bin = new Wire(); + val sout = new Wire(); + val cout = new Wire(); + halfAdder(ain, bin, sout, cout); + + def result = + ((if (sout.getSignal) 1 else 0) + + (if (cout.getSignal) 2 else 0)); + + def test(a: Int, b: Int) = { + ain setSignal (if (a == 0) false else true); + bin setSignal (if (b == 0) false else true); + run; + Console.println(a + " + " + b + " = " + result); + Console.println; + } + + probe("sum ", sout); + probe("carry", cout); + Console.println; + + test(0,0); + test(0,1); + test(1,0); + test(1,1); + } + + def full = { + val ain = new Wire(); + val bin = new Wire(); + val cin = new Wire(); + val sout = new Wire(); + val cout = new Wire(); + fullAdder(ain, bin, cin, sout, cout); + + def result = + ((if (sout.getSignal) 1 else 0) + + (if (cout.getSignal) 2 else 0)); + + def test(a: Int, b: Int, c: Int) = { + ain setSignal (if (a == 0) false else true); + bin setSignal (if (b == 0) false else true); + cin setSignal (if (c == 0) false else true); + run; + Console.println(a + " + " + b + " + " + c + " = " + result); + Console.println; + } + + probe("sum ", sout); + probe("carry", cout); + Console.println; + + test(0,0,0); + test(0,0,1); + test(0,1,0); + test(0,1,1); + test(1,0,0); + test(1,0,1); + test(1,1,0); + test(1,1,1); + } + } + + def test = { + val sim = new Test(); + sim.invert; + sim.and; + sim.or; + sim.half; + sim.full; + } +} + +//############################################################################ + +class Simulator() { + + type Action = () => Unit; + type Agenda = List[Tuple2[Int, Action]]; + + private var agenda: Agenda = List(); + private var curtime = 0; + + def afterDelay(delay: Int)(action: Action) = { + def insert(ag: Agenda, time: Int): Agenda = ag match { + case List() => + List((time, action)) + case (t, act) :: ag1 => + if (time < t) (time, action) :: ag + else (t, act) :: insert(ag1, time) + } + agenda = insert(agenda, curtime + delay) + } + + def next: Unit = agenda match { + case List() => () + case (time, action) :: rest => { + agenda = rest; + curtime = time; + action(); + } + } + + protected def currentTime: Int = curtime; + + def run = { + afterDelay(0){() => Console.println("*** simulation started ***"); } + while (!agenda.isEmpty) { next } + } +} + +class Wire() { + private var sigVal = false; + private var actions: List[() => Unit] = List(); + def getSignal = sigVal; + def setSignal(s: Boolean) = + if (s != sigVal) { + sigVal = s; + actions.foreach(action => action()); + } + def addAction(a: () => Unit) = { + actions = a :: actions; + a() + } +} + +abstract class BasicCircuitSimulator() extends Simulator() { + + def probe(name: String, wire: Wire): Unit = { + wire addAction {() => + Console.println( + name + " " + currentTime + " new-value = " + wire.getSignal); + } + } + + val InverterDelay: Int; + val AndGateDelay: Int; + val OrGateDelay: Int; + + def inverter(input: Wire, output: Wire) = { + def invertAction() = { + val inputSig = input.getSignal; + afterDelay(InverterDelay) {() => output.setSignal(!inputSig) }; + } + input addAction invertAction + } + + def andGate(a1: Wire, a2: Wire, output: Wire) = { + def andAction() = { + val a1Sig = a1.getSignal; + val a2Sig = a2.getSignal; + afterDelay(AndGateDelay) {() => output.setSignal(a1Sig & a2Sig) }; + } + a1 addAction andAction; + a2 addAction andAction + } + + def orGate(a1: Wire, a2: Wire, output: Wire) = { + def orAction() = { + val a1Sig = a1.getSignal; + val a2Sig = a2.getSignal; + afterDelay(OrGateDelay) {() => output.setSignal(a1Sig | a2Sig) }; + } + a1 addAction orAction; + a2 addAction orAction + } + + def orGate2(a1: Wire, a2: Wire, output: Wire) = { + val w1 = new Wire(); + val w2 = new Wire(); + val w3 = new Wire(); + inverter(a1, w1); + inverter(a2, w2); + andGate(w1, w2, w3); + inverter(w3, output); + } +} + +abstract class CircuitSimulator() extends BasicCircuitSimulator() { + def demux2(in: Wire, ctrl: List[Wire], out: List[Wire]) : Unit = { + val ctrlN = ctrl.map(w => { val iw = new Wire(); inverter(w,iw); iw}); + val w0 = new Wire(); + val w1 = new Wire(); + val w2 = new Wire(); + val w3 = new Wire(); + + andGate(in, ctrl(1), w3); + andGate(in, ctrl(1), w2); + andGate(in, ctrlN(1), w1); + andGate(in, ctrlN(1), w0); + + andGate(w3, ctrl(0), out(3)); + andGate(w2, ctrlN(0), out(2)); + andGate(w1, ctrl(0), out(1)); + andGate(w0, ctrlN(0), out(0)); + } + + def connect(in: Wire, out: Wire) = { + in addAction {() => out.setSignal(in.getSignal); } + } + + def demux(in: Wire, ctrl: List[Wire], out: List[Wire]): Unit = ctrl match { + case List() => connect(in, out.head); + case c :: rest => + val c_ = new Wire(); + val w1 = new Wire(); + val w2 = new Wire(); + inverter(c, c_); + andGate(in, c_, w1); + andGate(in, c, w2); + demux(w1, rest, out.drop(out.length / 2)); + demux(w2, rest, out.take(out.length / 2)); + } +} + +class Main() extends CircuitSimulator() { + + val InverterDelay = 1; + val AndGateDelay = 3; + val OrGateDelay = 5; + + def main = { + val n = 3; + val outNum = 1 << n; + + val in = new Wire(); + val ctrl = for (x <- range(0,n)) yield { new Wire() }; + val out = for (x <- range(0,outNum)) yield { new Wire() }; + + demux(in, ctrl.reverse, out.reverse); + + probe("in", in); + for ((x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) } + for ((x,o) <- range(0,outNum) zip out) { probe("out" + x, o) } + + in.setSignal(true); + run; + ctrl(0).setSignal(true); + run; + ctrl(1).setSignal(true); + run; + ctrl(2).setSignal(true); + run; + ctrl(0).setSignal(false); + run; + } +} + +//############################################################################ + +object Test { + def main(args: Array[String]): Unit = { + M0.test; + M1.test; + M2.test; + M3.test; + M4.test; + M5.test; + new Main().main; + () + } +} + +//############################################################################ diff --git a/tests/run/Course-2002-09.check b/tests/run/Course-2002-09.check new file mode 100644 index 000000000..765962aad --- /dev/null +++ b/tests/run/Course-2002-09.check @@ -0,0 +1,50 @@ +Probe: f = 32.0 +Probe: c = 0.0 +Probe: f = ? +Probe: c = ? + +Probe: f = 212.0 +Probe: c = 100.0 +Probe: f = ? +Probe: c = ? + +Probe: c = 0.0 +Probe: f = 32.0 +Probe: c = ? +Probe: f = ? + +Probe: c = 100.0 +Probe: f = 212.0 +Probe: c = ? +Probe: f = ? + +0.0 Celsius -> 32.0 Fahrenheits +100.0 Celsius -> 212.0 Fahrenheits +32.0 Fahrenheits -> 0.0 Celsius +212.0 Fahrenheits -> 100.0 Celsius + +a = ?, b = ?, c = ? => ? * ? = ? +a = 2, b = ?, c = ? => 2.0 * ? = ? +a = ?, b = 3, c = ? => ? * 3.0 = ? +a = ?, b = ?, c = 6 => ? * ? = 6.0 +a = 2, b = 3, c = ? => 2.0 * 3.0 = 6.0 +a = 2, b = ?, c = 6 => 2.0 * 3.0 = 6.0 +a = ?, b = 3, c = 6 => 2.0 * 3.0 = 6.0 +a = 2, b = 3, c = 6 => 2.0 * 3.0 = 6.0 + +a = 0, b = ?, c = ? => 0.0 * ? = 0.0 +a = ?, b = 0, c = ? => ? * 0.0 = 0.0 +a = ?, b = ?, c = 0 => ? * ? = 0.0 +a = 0, b = 7, c = ? => 0.0 * 7.0 = 0.0 +a = 7, b = 0, c = ? => 7.0 * 0.0 = 0.0 +a = 0, b = 0, c = ? => 0.0 * 0.0 = 0.0 +a = 0, b = ?, c = 0 => 0.0 * ? = 0.0 +a = ?, b = 0, c = 0 => ? * 0.0 = 0.0 +a = 0, b = 7, c = 0 => 0.0 * 7.0 = 0.0 +a = 7, b = 0, c = 0 => 7.0 * 0.0 = 0.0 +a = 0, b = 0, c = 0 => 0.0 * 0.0 = 0.0 + +a = 3, b = 4 => c = 5.0 +a = 3, c = 5 => b = 4.0 +b = 4, c = 5 => a = 3.0 + diff --git a/tests/run/Course-2002-09.scala b/tests/run/Course-2002-09.scala new file mode 100644 index 000000000..588703ddc --- /dev/null +++ b/tests/run/Course-2002-09.scala @@ -0,0 +1,332 @@ +//############################################################################ +// Programmation IV - 2002 - Week 09 +//############################################################################ + +trait Constraint { + def newValue: Unit; + def dropValue: Unit +} + +object NoConstraint extends Constraint { + def newValue: Unit = sys.error("NoConstraint.newValue"); + def dropValue: Unit = sys.error("NoConstraint.dropValue"); +} + +class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint { + def newValue = (a1.getValue, a2.getValue, sum.getValue) match { + case (Some(x1), Some(x2), _ ) => sum.setValue(x1 + x2, this) + case (Some(x1), _ , Some(r)) => a2.setValue(r - x1, this) + case (_ , Some(x2), Some(r)) => a1.setValue(r - x2, this) + case _ => + } + def dropValue: Unit = { + a1.forgetValue(this); a2.forgetValue(this); sum.forgetValue(this); + } + a1 connect this; + a2 connect this; + sum connect this; +} + +class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity) + extends Constraint { + def newValue = (m1.getValue, m2.getValue, prod.getValue) match { + case (Some(0d), _ , _ ) => prod.setValue(0, this); + case (_ , Some(0d), _ ) => prod.setValue(0, this); + case (Some(x1), Some(x2), _ ) => prod.setValue(x1 * x2, this) + case (Some(x1), _ , Some(r)) => m2.setValue(r / x1, this) + case (_, Some(x2), Some(r)) => m1.setValue(r / x2, this) + case _ => + } + def dropValue: Unit = { + m1.forgetValue(this); m2.forgetValue(this); prod.forgetValue(this); + } + m1 connect this; + m2 connect this; + prod connect this; +} + +class Squarer(square: Quantity, root: Quantity) extends Constraint { + def newValue: Unit = (square.getValue, root.getValue) match { + case (Some(x), _ )if (x < 0) => sys.error("Square of negative number") + case (Some(x), _ ) => root.setValue(Math.sqrt(x), this) + case (_ , Some(x)) => square.setValue(x*x, this) + case _ => + } + def dropValue: Unit = { + square.forgetValue(this); root.forgetValue(this); + } + square connect this; + root connect this; +} + +class Eq(a: Quantity, b: Quantity) extends Constraint { + def newValue = ((a.getValue, b.getValue): @unchecked) match { + case (Some(x), _ ) => b.setValue(x, this); + case (_ , Some(y)) => a.setValue(y, this); + } + def dropValue: Unit = { + a.forgetValue(this); b.forgetValue(this); + } + a connect this; + b connect this; +} + +class Constant(q: Quantity, v: Double) extends Constraint { + def newValue: Unit = sys.error("Constant.newValue"); + def dropValue: Unit = sys.error("Constant.dropValue"); + q connect this; + q.setValue(v, this); +} + +class Probe(name: String, q: Quantity) extends Constraint { + def newValue: Unit = printProbe(q.getValue); + def dropValue: Unit = printProbe(None); + private def printProbe(v: Option[Double]): Unit = { + val vstr = v match { + case Some(x) => x.toString() + case None => "?" + } + Console.println("Probe: " + name + " = " + vstr); + } + q connect this +} + +class Quantity() { + private var value: Option[Double] = None; + private var constraints: List[Constraint] = List(); + private var informant: Constraint = null; + + def getValue: Option[Double] = value; + + def setValue(v: Double, setter: Constraint) = value match { + case Some(v1) => + if (v != v1) sys.error("Error! contradiction: " + v + " and " + v1); + case None => + informant = setter; value = Some(v); + for (c <- constraints; if !(c == informant)) { + c.newValue; + } + } + def setValue(v: Double): Unit = setValue(v, NoConstraint); + + def forgetValue(retractor: Constraint): Unit = { + if (retractor == informant) { + value = None; + for (c <- constraints; if !(c == informant)) c.dropValue; + } + } + def forgetValue: Unit = forgetValue(NoConstraint); + + def connect(c: Constraint) = { + constraints = c :: constraints; + value match { + case Some(_) => c.newValue + case None => + } + } + + def +(that: Quantity): Quantity = { + val sum = new Quantity(); + new Adder(this, that, sum); + sum; + } + + def *(that: Quantity): Quantity = { + val prod = new Quantity(); + new Multiplier(this, that, prod); + prod; + } + + def square: Quantity = { + val square = new Quantity(); + new Squarer(square, this); + square; + } + + def sqrt: Quantity = { + val root = new Quantity(); + new Squarer(this, root); + root; + } + + def ===(that: Quantity): Constraint = { + new Eq(this, that); + } + + override def toString(): String = value match { + case None => " ?" + case Some(v) => v.toString() + } + + def str: String = toString(); +} + +//############################################################################ + +object M0 { + + def CFconverter(c: Quantity, f: Quantity) = { + val u = new Quantity(); + val v = new Quantity(); + val w = new Quantity(); + val x = new Quantity(); + val y = new Quantity(); + new Multiplier(c, w, u); + new Multiplier(v, x, u); + new Adder(v, y, f); + new Constant(w, 9); + new Constant(x, 5); + new Constant(y, 32); + } + + def test = { + val c = new Quantity(); new Probe("c", c); + val f = new Quantity(); new Probe("f", f); + CFconverter(c, f); + + c.setValue(0); + c.forgetValue; + Console.println; + + c.setValue(100); + c.forgetValue; + Console.println; + + f.setValue(32); + f.forgetValue; + Console.println; + + f.setValue(212); + f.forgetValue; + Console.println; + } +} + +//############################################################################ + +object M1 { + + def constant(x: Double): Quantity = { + val q = new Quantity(); + new Constant(q, x); + q + } + + def CFconverter(c: Quantity, f: Quantity) = { + val v = new Quantity(); + constant(9) * c === constant(5) * v; + v + constant(32) === f; + } + + def show_c2f(c: Quantity, f: Quantity, v: Int) = { + c.setValue(v); + Console.println(c.str + " Celsius -> " + f.str + " Fahrenheits"); + c.forgetValue; + } + + def show_f2c(c: Quantity, f: Quantity, v: Int) = { + f.setValue(v); + Console.println(f.str + " Fahrenheits -> " + c.str + " Celsius"); + f.forgetValue; + } + + def test = { + val c = new Quantity(); + val f = new Quantity(); + CFconverter(c, f); + + show_c2f(c, f, 0); + show_c2f(c, f, 100); + show_f2c(c, f, 32); + show_f2c(c, f, 212); + Console.println; + } +} + +//############################################################################ + +object M2 { + + val a = new Quantity(); + val b = new Quantity(); + val c = a * b; + + def set(q: Quantity, o: Option[Int]): String = { + o match { + case None => "?" + case Some(v) => q.setValue(v); v.toString() + }; + } + + def show(x: Option[Int], y: Option[Int], z: Option[Int]) = { + Console.print("a = " +set(a,x)+ ", b = " +set(b,y)+ ", c = " +set(c,z)); + Console.println(" => " + a.str + " * " + b.str + " = " + c.str); + a.forgetValue; b.forgetValue; c.forgetValue; + } + + def test = { + show(None , None , None ); + show(Some(2), None , None ); + show(None , Some(3), None ); + show(None , None , Some(6)); + show(Some(2), Some(3), None ); + show(Some(2), None , Some(6)); + show(None , Some(3), Some(6)); + show(Some(2), Some(3), Some(6)); + Console.println; + + show(Some(0), None , None ); + show(None , Some(0), None ); + show(None , None , Some(0)); + show(Some(0), Some(7), None ); + show(Some(7), Some(0), None ); + show(Some(0), Some(0), None ); + show(Some(0), None , Some(0)); + show(None , Some(0), Some(0)); + show(Some(0), Some(7), Some(0)); + show(Some(7), Some(0), Some(0)); + show(Some(0), Some(0), Some(0)); + Console.println; + } +} + + +//############################################################################ + +object M3 { + + def test = { + val a = new Quantity(); + val b = new Quantity(); + val c = new Quantity(); + c === (a.square + b.square).sqrt; + + a.setValue(3); b.setValue(4); + Console.println("a = 3, b = 4 => c = " + c.str); + a.forgetValue; b.forgetValue; + + a.setValue(3); c.setValue(5); + Console.println("a = 3, c = 5 => b = " + b.str); + a.forgetValue; c.forgetValue; + + b.setValue(4); c.setValue(5); + Console.println("b = 4, c = 5 => a = " + a.str); + b.forgetValue; c.forgetValue; + + Console.println; + } +} + +//############################################################################ + +object Test { + def main(args: Array[String]): Unit = { + M0.test; + M1.test; + M2.test; + M3.test; + () + } +} + +//############################################################################ diff --git a/tests/run/MutableListTest.scala b/tests/run/MutableListTest.scala new file mode 100644 index 000000000..8efb8281d --- /dev/null +++ b/tests/run/MutableListTest.scala @@ -0,0 +1,126 @@ + + + +import scala.collection.mutable.MutableList + + + +class ExtList[T] extends MutableList[T] { + def printState: Unit = { + println("Length: " + len) + println("Last elem: " + last0.elem) + println("First elem: " + first0.elem) + println("After first elem: " + first0.next.elem) + println("After first: " + first0.next) + println("Last: " + last0) + } +} + +object Test { + + def main(args: Array[String]): Unit = { + testEmpty + testAddElement + testAddFewElements + testAddMoreElements + testTraversables + } + + def testEmpty: Unit = { + val mlist = new MutableList[Int] + assert(mlist.isEmpty) + assert(mlist.get(0) == None) + } + + def testAddElement: Unit = { + val mlist = new MutableList[Int] + mlist += 17 + assert(mlist.nonEmpty) + assert(mlist.length == 1) + assert(mlist.head == 17) + assert(mlist.last == 17) + assert(mlist(0) == 17) + assert(mlist.tail.isEmpty) + assert(mlist.tail.length == 0) + mlist(0) = 101 + assert(mlist(0) == 101) + assert(mlist.toList == List(101)) + assert(mlist.tail.get(0) == None) + assert((mlist.tail += 19).head == 19) + assert(mlist.tail.length == 0) + } + + def testAddFewElements: Unit = { + val mlist = new MutableList[Int] + for (i <- 0 until 2) mlist += i +// mlist.printState + for (i <- 0 until 2) assert(mlist(i) == i) + assert(mlist.length == 2) + assert(mlist.nonEmpty) + assert(mlist.tail.length == 1) + assert(mlist.tail.tail.length == 0) + assert(mlist.tail.tail.isEmpty) + } + + def testAddMoreElements: Unit = { + val mlist = new MutableList[Int] + for (i <- 0 until 10) mlist += i * i + assert(mlist.nonEmpty) + assert(mlist.length == 10) + for (i <- 0 until 10) assert(mlist(i) == i * i) + assert(mlist(5) == 5 * 5) + assert(mlist(9) == 9 * 9) + var sometail = mlist + for (i <- 0 until 10) { + assert(sometail.head == i * i) + sometail = sometail.tail + } + mlist(5) = -25 + assert(mlist(5) == -25) + mlist(0) = -1 + assert(mlist(0) == -1) + mlist(9) = -81 + assert(mlist(9) == -81) + assert(mlist(5) == -25) + assert(mlist(0) == -1) + assert(mlist.last == -81) + mlist.clear + assert(mlist.isEmpty) + mlist += 1001 + assert(mlist.head == 1001) + mlist += 9999 + assert(mlist.tail.head == 9999) + assert(mlist.last == 9999) + } + + def testTraversables: Unit = { + val mlist = new MutableList[Int] + for (i <- 0 until 10) mlist += i * i + var lst = mlist.drop(5) + for (i <- 0 until 5) assert(lst(i) == (i + 5) * (i + 5)) + lst = lst.take(3) + for (i <- 0 until 3) assert(lst(i) == (i + 5) * (i + 5)) + lst += 129 + assert(lst(3) == 129) + assert(lst.last == 129) + assert(lst.length == 4) + lst += 7 + assert(lst.init.last == 129) + assert(lst.length == 5) + lst.clear + assert(lst.length == 0) + for (i <- 0 until 5) lst += i + assert(lst.reduceLeft(_ + _) == 10) + } + +} + + + + + + + + + + diff --git a/tests/run/OrderingTest.scala b/tests/run/OrderingTest.scala new file mode 100644 index 000000000..ad5acfa0c --- /dev/null +++ b/tests/run/OrderingTest.scala @@ -0,0 +1,36 @@ +object Test extends dotty.runtime.LegacyApp { + def test[T](t1 : T, t2 : T)(implicit ord : Ordering[T]) = { + val cmp = ord.compare(t1, t2); + val cmp2 = ord.compare(t2, t1); + + assert((cmp == 0) == (cmp2 == 0)) + assert((cmp > 0) == (cmp2 < 0)) + assert((cmp < 0) == (cmp2 > 0)) + } + + def testAll[T](t1 : T, t2 : T)(implicit ord : Ordering[T]) = { + assert(ord.compare(t1, t2) < 0) + test(t1, t2); + test(t1, t1); + test(t2, t2); + } + + assert(Ordering[String].compare("australopithecus", "brontausaurus") < 0) + // assert(Ordering[Unit].compare((), ()) == 0) + + testAll("bar", "foo"); + testAll[Byte](0, 1); + testAll(false, true) + testAll(1, 2); + testAll(1.0, 2.0); + testAll(None, Some(1)); + testAll[Iterable[Int]](List(1), List(1, 2)); + testAll[Iterable[Int]](List(1, 2), List(2)); + testAll((1, "bar"), (1, "foo")) + testAll((1, "foo"), (2, "bar")) + + // sortBy + val words = "The quick brown fox jumped over the lazy dog".split(' ') + val result = words.sortBy(x => (x.length, x.head)) + assert(result sameElements Array[String]("The", "dog", "fox", "the", "lazy", "over", "brown", "quick", "jumped")) +} diff --git a/tests/run/Predef.readLine.check b/tests/run/Predef.readLine.check new file mode 100644 index 000000000..4fb2bc4c6 --- /dev/null +++ b/tests/run/Predef.readLine.check @@ -0,0 +1,3 @@ +prompt +fancy prompt +immensely fancy prompt
\ No newline at end of file diff --git a/tests/run/Predef.readLine.scala b/tests/run/Predef.readLine.scala new file mode 100644 index 000000000..f751949e8 --- /dev/null +++ b/tests/run/Predef.readLine.scala @@ -0,0 +1,11 @@ +import java.io.StringReader +import scala.io.StdIn.readLine + +object Test extends dotty.runtime.LegacyApp { + Console.withIn(new StringReader("")) { + readLine() + readLine("prompt\n") + readLine("%s prompt\n", "fancy") + readLine("%s %s prompt\n", "immensely", "fancy") + } +} diff --git a/tests/run/QueueTest.scala b/tests/run/QueueTest.scala new file mode 100644 index 000000000..8c35e39cb --- /dev/null +++ b/tests/run/QueueTest.scala @@ -0,0 +1,297 @@ + + +import scala.collection.mutable.Queue + + + + +class ExtQueue[T] extends Queue[T] { + def printState: Unit = { + println("-------------------") + println("Length: " + len) + println("First: " + first0) + println("First elem: " + first0.elem) + println("After first: " + first0.next) + } +} + +object Test { + + def main(args: Array[String]): Unit = { + testEmpty + testEnqueue + testTwoEnqueues + testFewEnqueues + testMoreEnqueues + } + + def testEmpty: Unit = { + val queue = new Queue[Int] + + assert(queue.isEmpty) + assert(queue.size == 0) + assert(queue.length == 0) + assert(queue.dequeueFirst(_ > 500) == None) + assert(queue.dequeueAll(_ > 500).isEmpty) + + queue.clear + assert(queue.isEmpty) + assert(queue.size == 0) + assert(queue.length == 0) + assert(queue.dequeueFirst(_ > 500) == None) + assert(queue.dequeueAll(_ > 500).isEmpty) + } + + def testEnqueue: Unit = { + val queue = new Queue[Int] + + queue.enqueue(10) + assert(queue.nonEmpty) + assert(queue.size == 1) + assert(queue.length == 1) + assert(queue.head == 10) + assert(queue(0) == 10) + assert(queue.init.isEmpty) + assert(queue.tail.isEmpty) + + queue.clear + assert(queue.isEmpty) + assert(queue.length == 0) + + queue.enqueue(11) + assert(queue.nonEmpty) + assert(queue.length == 1) + assert(queue.head == 11) + assert(queue.front == 11) + + val deq = queue.dequeue + assert(deq == 11) + assert(queue.isEmpty) + assert(queue.length == 0) + + queue.enqueue(12) + val pdopt = queue.dequeueFirst(_ > 999) + assert(pdopt == None) + assert(queue.nonEmpty && queue.length == 1) + + val somepd = queue.dequeueFirst(_ >= 1) + assert(somepd == Some(12)) + assert(queue.isEmpty && queue.length == 0) + } + + def testTwoEnqueues: Unit = { + val queue = new ExtQueue[Int] + queue.enqueue(30) + queue.enqueue(40) + + assert(queue.length == 2) + assert(queue.size == 2) + assert(queue.nonEmpty) + assert(queue.front == 30) +// queue.printState + + val all = queue.dequeueAll(_ > 20) + assert(all.size == 2) + assert(all.contains(30)) + assert(all.contains(40)) + assert(queue.size == 0) + assert(queue.isEmpty) + } + + def testFewEnqueues: Unit = { + val queue = new ExtQueue[Int] + queue.enqueue(10) + queue.enqueue(20) + + assert(queue.length == 2) + assert(queue.nonEmpty) + assert(queue.head == 10) + assert(queue.last == 20) + assert(queue.front == 10) +// queue.printState + + val ten = queue.dequeue + assert(ten == 10) + assert(queue.length == 1) +// queue.printState + + queue.enqueue(30) +// queue.printState + val gt25 = queue.dequeueFirst(_ > 25) + assert(gt25 == Some(30)) + assert(queue.nonEmpty) + assert(queue.length == 1) + assert(queue.head == 20) + assert(queue.front == 20) +// queue.printState + + queue.enqueue(30) +// queue.printState + val lt25 = queue.dequeueFirst(_ < 25) + assert(lt25 == Some(20)) + assert(queue.nonEmpty) + assert(queue.length == 1) +// queue.printState + + queue.enqueue(40) +// queue.printState + val all = queue.dequeueAll(_ > 20) +// queue.printState + assert(all.size == 2) + assert(all.contains(30)) + assert(all.contains(40)) + assert(queue.isEmpty) + assert(queue.length == 0) + + queue.enqueue(50) + queue.enqueue(60) +// queue.printState + val allgt55 = queue.dequeueAll(_ > 55) +// println(allgt55) +// queue.printState + assert(allgt55.size == 1) + assert(allgt55.contains(60)) + assert(queue.length == 1) + + queue.enqueue(70) + queue.enqueue(80) +// queue.printState + val alllt75 = queue.dequeueAll(_ < 75) +// queue.printState + assert(alllt75.size == 2) + assert(alllt75.contains(70)) + assert(alllt75.contains(50)) + assert(queue.length == 1) + assert(queue.head == 80) + assert(queue.last == 80) + assert(queue.front == 80) + } + + def testMoreEnqueues: Unit = { + val queue = new ExtQueue[Int] + for (i <- 0 until 10) queue.enqueue(i * 2) + + for (i <- 0 until 10) { + val top = queue.dequeue + assert(top == i * 2) + assert(queue.length == 10 - i - 1) + } + assert(queue.isEmpty) + assert(queue.length == 0) + + for (i <- 0 until 10) queue.enqueue(i * i) + assert(queue.length == 10) + assert(queue.nonEmpty) + + //queue.printState + val gt5 = queue.dequeueAll(_ > 4) + //queue.printState + //println(gt5) + assert(gt5.size == 7) + assert(queue.length == 3) + assert(queue.nonEmpty) + + queue.clear + assert(queue.length == 0) + assert(queue.isEmpty) + + for (i <- 0 until 10) queue.enqueue(i) + assert(queue.length == 10) + + val even = queue.dequeueAll(_ % 2 == 0) + assert(even.size == 5) + assert(even.sameElements(List(0, 2, 4, 6, 8))) + assert(queue.length == 5) + assert(queue.head == 1) + assert(queue.last == 9) + + val odd = queue.dequeueAll(_ %2 == 1) + assert(odd.size == 5) + assert(queue.length == 0) + assert(queue.isEmpty) + assert(odd.sameElements(List(1, 3, 5, 7, 9))) + + for (i <- 0 until 10) queue.enqueue(i * i) + assert(queue.last == 81) + assert(queue.head == 0) + assert(queue.length == 10) + + val foddgt25 = queue.dequeueFirst(num => num > 25 && num % 2 == 1) + assert(foddgt25 == Some(49)) + assert(queue.length == 9) + assert(queue.nonEmpty) + + //queue.printState + val lt30 = queue.dequeueAll(_ < 30) + //println(lt30) + //queue.printState + assert(lt30.size == 6) + assert(queue.length == 3) + + val fgt60 = queue.dequeueFirst(_ > 60) + assert(fgt60 == Some(64)) + assert(queue.length == 2) + assert(queue.head == 36) + assert(queue.last == 81) + + val sgt60 = queue.dequeueFirst(_ > 60) + assert(sgt60 == Some(81)) + assert(queue.length == 1) + assert(queue.head == 36) + assert(queue.last == 36) + + val nogt60 = queue.dequeueFirst(_ > 60) + assert(nogt60 == None) + assert(queue.length == 1) + assert(queue.nonEmpty) + assert(queue.head == 36) + + val gt0 = queue.dequeueFirst(_ > 0) + assert(gt0 == Some(36)) + assert(queue.length == 0) + assert(queue.isEmpty) + + for (i <- 0 until 4) queue.enqueue(i) + val interv = queue.dequeueAll(n => n > 0 && n < 3) + assert(interv.sameElements(List(1, 2))) + assert(queue.length == 2) + assert(queue.head == 0) + assert(queue.last == 3) + + queue.dequeue + assert(queue.head == 3) + + queue.enqueue(9) + val three = queue.dequeueFirst(_ < 5) + assert(three == Some(3)) + assert(queue.length == 1) + assert(queue.head == 9) + + queue.clear + for (i <- -100 until 100) queue.enqueue(i * i + i % 7 + 5) + assert(queue.length == 200) + + val manyodds = queue.dequeueAll(_ % 2 == 1) + assert((manyodds.size + queue.length) == 200) + + queue.dequeueAll(_ > -10000) + assert(queue.isEmpty) + + for (i <- 0 until 100) queue.enqueue(i) + val multof3 = queue.dequeueAll(_ % 3 == 0) + assert(multof3.size == 34) + assert(queue.size == 66) + + val n98 = queue.dequeueFirst(_ == 98) + assert(n98 == Some(98)) + assert(queue.size == 65) + assert(queue.last == 97) + assert(queue.head == 1) + // well... seems to work + } + +} + + + + diff --git a/tests/run/ReplacementMatching.scala b/tests/run/ReplacementMatching.scala new file mode 100644 index 000000000..370f7dc25 --- /dev/null +++ b/tests/run/ReplacementMatching.scala @@ -0,0 +1,47 @@ + + + +import util.matching._ + + + + +object Test { + + def main(args: Array[String]): Unit = { + replacementMatching + groupsMatching + } + + def replacementMatching: Unit = { + val regex = """\$\{(.+?)\}""".r + val replaced = regex.replaceAllIn("Replacing: ${main}. And another method: ${foo}.", + (m: util.matching.Regex.Match) => { + val identifier = m.group(1) + identifier + }) + assert(replaced == "Replacing: main. And another method: foo.") + + val regex3 = """\$\{(.+?)\}""".r + val replaced3 = regex3.replaceSomeIn("Replacing: ${main}. And another: ${foo}.", (m: util.matching.Regex.Match) => { + val id = m.group(1) + if (id.startsWith("m")) Some(id) else None + }) + assert(replaced3 == "Replacing: main. And another: ${foo}.") + } + + def groupsMatching: Unit = { + val Date = """(\d+)/(\d+)/(\d+)""".r + for (Regex.Groups(a, b, c) <- Date findFirstMatchIn "1/1/2001 marks the start of the millenium. 31/12/2000 doesn't.") { + assert(a == "1") + assert(b == "1") + assert(c == "2001") + } + for (Regex.Groups(a, b, c) <- (Date findAllIn "1/1/2001 marks the start of the millenium. 31/12/2000 doesn't.").matchData) { + assert(a == "1" || a == "31") + assert(b == "1" || b == "12") + assert(c == "2001" || c == "2000") + } + } + +} diff --git a/tests/run/ReverseSeqView.scala b/tests/run/ReverseSeqView.scala new file mode 100644 index 000000000..edb2e8c28 --- /dev/null +++ b/tests/run/ReverseSeqView.scala @@ -0,0 +1,25 @@ + + + + + + +object Test extends dotty.runtime.LegacyApp { + + val lstv = List(1, 2, 3).view + val lstvr = lstv.reverse + assert(lstvr.iterator.toList == List(3, 2, 1)) + assert(lstvr.reverse == List(1, 2, 3)) + assert(lstvr.reverseIterator.toList == List(1, 2, 3)) + assert(lstvr.reverseMap(_ + 1) == List(2, 3, 4)) + +} + + + + + + + + + diff --git a/tests/run/UnrolledBuffer.scala b/tests/run/UnrolledBuffer.scala new file mode 100644 index 000000000..76201bb7c --- /dev/null +++ b/tests/run/UnrolledBuffer.scala @@ -0,0 +1,125 @@ + + + + +import collection.mutable.UnrolledBuffer + + + +object Test { + + def main(args: Array[String]): Unit = { + val u1 = new UnrolledBuffer[Int] + assert(u1.isEmpty) + assert(u1.size == 0) + + u1 += 1 + u1 += 2 + u1 += 3 + assert(u1 == UnrolledBuffer(1, 2, 3)) + assert(u1.toList == List(1, 2, 3)) + assert(u1.nonEmpty) + assert(u1.size == 3) + + u1.clear + assert(u1.isEmpty) + assert(u1.size == 0) + + u1 += 1 + u1 += 2 + u1 += 3 + u1.remove(1) + assert(u1.nonEmpty) + assert(u1.size == 2) + assert(u1 == UnrolledBuffer(1, 3)) + assert(u1.toList == List(1, 3)) + + u1 concat UnrolledBuffer(5, 7, 9) + assert(u1 == UnrolledBuffer(1, 3, 5, 7, 9)) + + val u2 = u1 map { x => (x - 1) / 2 } + assert(u2 == UnrolledBuffer(0, 1, 2, 3, 4)) + + u1.clear + u2.clear + assert(u1.size == 0) + assert(u2.size == 0) + + for (i <- 0 until 500) u1 += i + for (i <- 500 until 1000) u2 += i + assert(u1.size == 500) + assert(u2.size == 500) + assert(u1.iterator.toList == (0 until 500).toList) + assert((for (elem <- u1) yield elem) sameElements (0 until 500)) + + u1 concat u2 + assert(u1.size == 1000) + assert(u2.size == 0) + assertCorrect(u1) + + u1 concat UnrolledBuffer() + assertCorrect(u1) + + val u3 = u1 map { x => x } + var i = 0 + for (elem <- u1) { + assert(elem == u3(i)) + i += 1 + } + + u1.remove(999) + assert(u1.size == 999) + assertCorrect(u1) + + u1.remove(500) + assert(u1.size == 998) + assertCorrect(u1) + + u1.remove(5) + assert(u1.size == 997) + assertCorrect(u1) + + u1.remove(0) + assert(u1.size == 996) + assertCorrect(u1) + + u1.insert(0, 0) + assert(u1.size == 997) + assertCorrect(u1) + + u1.insert(5, 5) + assert(u1.size == 998) + assertCorrect(u1) + + u1.insert(500, 500) + assert(u1.size == 999) + assertCorrect(u1) + + u1.insert(999, 999) + assert(u1.size == 1000) + assertCorrect(u1) + + for (i <- -100 until 0) { + i +=: u1 + assertCorrect(u1) + } + assert(u1.size == 1100) + assertCorrect(u1) + } + + def assertCorrect(u1: UnrolledBuffer[Int]): Unit = { + val sz = u1.size + val store = new Array[Int](sz) + for (i <- 0 until sz) { + store(i) = u1(i) + u1(i) = sz - i + } + for (i <- 0 until sz) assert(u1(i) == (sz - i)) + for (i <- 0 until sz) u1(i) = store(i) + for (i <- 0 until sz) assert(store(i) == u1(i)) + + assert((u1 map { x => x }) == u1) + assert(u1.iterator.toSeq.size == u1.size) + } + +} diff --git a/tests/run/adding-growing-set.scala b/tests/run/adding-growing-set.scala new file mode 100644 index 000000000..ab94b893b --- /dev/null +++ b/tests/run/adding-growing-set.scala @@ -0,0 +1,11 @@ +/** This will run a loooong time if Set's builder copies a + * complete new Set for every element. + */ +object Test { + def main(args: Array[String]): Unit = { + val a = new Array[Long](1000000) + (1 to 10000) foreach (i => a(i) = i) + val s = collection.mutable.Set(a: _*) + assert(s.sum > 0) + } +} diff --git a/tests/run/array-charSeq.check b/tests/run/array-charSeq.check new file mode 100644 index 000000000..f1f374f63 --- /dev/null +++ b/tests/run/array-charSeq.check @@ -0,0 +1,248 @@ + +[check 'abcdefghi'] len = 9 +sub(0, 9) == 'abcdefghi' +sub(0, 0) == '' +sub(1, 9) == 'bcdefghi' +sub(0, 1) == 'a' +sub(2, 9) == 'cdefghi' +sub(0, 2) == 'ab' +sub(3, 9) == 'defghi' +sub(0, 3) == 'abc' +sub(4, 9) == 'efghi' +sub(0, 4) == 'abcd' +sub(5, 9) == 'fghi' +sub(0, 5) == 'abcde' +sub(6, 9) == 'ghi' +sub(0, 6) == 'abcdef' +sub(7, 9) == 'hi' +sub(0, 7) == 'abcdefg' +sub(8, 9) == 'i' +sub(0, 8) == 'abcdefgh' + +[check 'bcdefgh'] len = 7 +sub(0, 7) == 'bcdefgh' +sub(0, 0) == '' +sub(1, 7) == 'cdefgh' +sub(0, 1) == 'b' +sub(2, 7) == 'defgh' +sub(0, 2) == 'bc' +sub(3, 7) == 'efgh' +sub(0, 3) == 'bcd' +sub(4, 7) == 'fgh' +sub(0, 4) == 'bcde' +sub(5, 7) == 'gh' +sub(0, 5) == 'bcdef' +sub(6, 7) == 'h' +sub(0, 6) == 'bcdefg' + +[check 'cdefg'] len = 5 +sub(0, 5) == 'cdefg' +sub(0, 0) == '' +sub(1, 5) == 'defg' +sub(0, 1) == 'c' +sub(2, 5) == 'efg' +sub(0, 2) == 'cd' +sub(3, 5) == 'fg' +sub(0, 3) == 'cde' +sub(4, 5) == 'g' +sub(0, 4) == 'cdef' + +[check 'def'] len = 3 +sub(0, 3) == 'def' +sub(0, 0) == '' +sub(1, 3) == 'ef' +sub(0, 1) == 'd' +sub(2, 3) == 'f' +sub(0, 2) == 'de' + +[check 'e'] len = 1 +sub(0, 1) == 'e' +sub(0, 0) == '' + +[check 'abcdefgh'] len = 8 +sub(0, 8) == 'abcdefgh' +sub(0, 0) == '' +sub(1, 8) == 'bcdefgh' +sub(0, 1) == 'a' +sub(2, 8) == 'cdefgh' +sub(0, 2) == 'ab' +sub(3, 8) == 'defgh' +sub(0, 3) == 'abc' +sub(4, 8) == 'efgh' +sub(0, 4) == 'abcd' +sub(5, 8) == 'fgh' +sub(0, 5) == 'abcde' +sub(6, 8) == 'gh' +sub(0, 6) == 'abcdef' +sub(7, 8) == 'h' +sub(0, 7) == 'abcdefg' + +[check 'bcdefg'] len = 6 +sub(0, 6) == 'bcdefg' +sub(0, 0) == '' +sub(1, 6) == 'cdefg' +sub(0, 1) == 'b' +sub(2, 6) == 'defg' +sub(0, 2) == 'bc' +sub(3, 6) == 'efg' +sub(0, 3) == 'bcd' +sub(4, 6) == 'fg' +sub(0, 4) == 'bcde' +sub(5, 6) == 'g' +sub(0, 5) == 'bcdef' + +[check 'cdef'] len = 4 +sub(0, 4) == 'cdef' +sub(0, 0) == '' +sub(1, 4) == 'def' +sub(0, 1) == 'c' +sub(2, 4) == 'ef' +sub(0, 2) == 'cd' +sub(3, 4) == 'f' +sub(0, 3) == 'cde' + +[check 'de'] len = 2 +sub(0, 2) == 'de' +sub(0, 0) == '' +sub(1, 2) == 'e' +sub(0, 1) == 'd' + +[check ''] len = 0 + +[check 'abcdefg'] len = 7 +sub(0, 7) == 'abcdefg' +sub(0, 0) == '' +sub(1, 7) == 'bcdefg' +sub(0, 1) == 'a' +sub(2, 7) == 'cdefg' +sub(0, 2) == 'ab' +sub(3, 7) == 'defg' +sub(0, 3) == 'abc' +sub(4, 7) == 'efg' +sub(0, 4) == 'abcd' +sub(5, 7) == 'fg' +sub(0, 5) == 'abcde' +sub(6, 7) == 'g' +sub(0, 6) == 'abcdef' + +[check 'bcdef'] len = 5 +sub(0, 5) == 'bcdef' +sub(0, 0) == '' +sub(1, 5) == 'cdef' +sub(0, 1) == 'b' +sub(2, 5) == 'def' +sub(0, 2) == 'bc' +sub(3, 5) == 'ef' +sub(0, 3) == 'bcd' +sub(4, 5) == 'f' +sub(0, 4) == 'bcde' + +[check 'cde'] len = 3 +sub(0, 3) == 'cde' +sub(0, 0) == '' +sub(1, 3) == 'de' +sub(0, 1) == 'c' +sub(2, 3) == 'e' +sub(0, 2) == 'cd' + +[check 'd'] len = 1 +sub(0, 1) == 'd' +sub(0, 0) == '' + +[check 'abcdef'] len = 6 +sub(0, 6) == 'abcdef' +sub(0, 0) == '' +sub(1, 6) == 'bcdef' +sub(0, 1) == 'a' +sub(2, 6) == 'cdef' +sub(0, 2) == 'ab' +sub(3, 6) == 'def' +sub(0, 3) == 'abc' +sub(4, 6) == 'ef' +sub(0, 4) == 'abcd' +sub(5, 6) == 'f' +sub(0, 5) == 'abcde' + +[check 'bcde'] len = 4 +sub(0, 4) == 'bcde' +sub(0, 0) == '' +sub(1, 4) == 'cde' +sub(0, 1) == 'b' +sub(2, 4) == 'de' +sub(0, 2) == 'bc' +sub(3, 4) == 'e' +sub(0, 3) == 'bcd' + +[check 'cd'] len = 2 +sub(0, 2) == 'cd' +sub(0, 0) == '' +sub(1, 2) == 'd' +sub(0, 1) == 'c' + +[check ''] len = 0 + +[check 'abcde'] len = 5 +sub(0, 5) == 'abcde' +sub(0, 0) == '' +sub(1, 5) == 'bcde' +sub(0, 1) == 'a' +sub(2, 5) == 'cde' +sub(0, 2) == 'ab' +sub(3, 5) == 'de' +sub(0, 3) == 'abc' +sub(4, 5) == 'e' +sub(0, 4) == 'abcd' + +[check 'bcd'] len = 3 +sub(0, 3) == 'bcd' +sub(0, 0) == '' +sub(1, 3) == 'cd' +sub(0, 1) == 'b' +sub(2, 3) == 'd' +sub(0, 2) == 'bc' + +[check 'c'] len = 1 +sub(0, 1) == 'c' +sub(0, 0) == '' + +[check 'abcd'] len = 4 +sub(0, 4) == 'abcd' +sub(0, 0) == '' +sub(1, 4) == 'bcd' +sub(0, 1) == 'a' +sub(2, 4) == 'cd' +sub(0, 2) == 'ab' +sub(3, 4) == 'd' +sub(0, 3) == 'abc' + +[check 'bc'] len = 2 +sub(0, 2) == 'bc' +sub(0, 0) == '' +sub(1, 2) == 'c' +sub(0, 1) == 'b' + +[check ''] len = 0 + +[check 'abc'] len = 3 +sub(0, 3) == 'abc' +sub(0, 0) == '' +sub(1, 3) == 'bc' +sub(0, 1) == 'a' +sub(2, 3) == 'c' +sub(0, 2) == 'ab' + +[check 'b'] len = 1 +sub(0, 1) == 'b' +sub(0, 0) == '' + +[check 'ab'] len = 2 +sub(0, 2) == 'ab' +sub(0, 0) == '' +sub(1, 2) == 'b' +sub(0, 1) == 'a' + +[check ''] len = 0 + +[check 'a'] len = 1 +sub(0, 1) == 'a' +sub(0, 0) == '' diff --git a/tests/run/array-charSeq.scala b/tests/run/array-charSeq.scala new file mode 100644 index 000000000..64055c640 --- /dev/null +++ b/tests/run/array-charSeq.scala @@ -0,0 +1,28 @@ +object Test { + val arr = Array[Char]('a' to 'i': _*) + var xs: CharSequence = arr + val hash = xs.hashCode + + def check(chars: CharSequence): Unit = { + println("\n[check '" + chars + "'] len = " + chars.length) + chars match { + case x: Predef.ArrayCharSequence => assert(x.__arrayOfChars eq arr, ((x.__arrayOfChars, arr))) + case x: runtime.ArrayCharSequence => assert(x.xs eq arr, ((x.xs, arr))) + case x => assert(false, x) + } + + 0 until chars.length foreach { i => + println("sub(%s, %s) == '%s'".format(i, chars.length, chars.subSequence(i, chars.length))) + println("sub(%s, %s) == '%s'".format(0, i, chars.subSequence(0, i))) + } + if (chars.length >= 2) + check(chars.subSequence(1, chars.length - 1)) + } + + def main(args: Array[String]): Unit = { + while (xs.length > 0) { + check(xs) + xs = xs.subSequence(0, xs.length - 1) + } + } +} diff --git a/tests/run/array-existential-bound.check b/tests/run/array-existential-bound.check new file mode 100644 index 000000000..f5cca843e --- /dev/null +++ b/tests/run/array-existential-bound.check @@ -0,0 +1,4 @@ +2 +1000 +1000 +26 diff --git a/tests/run/array-existential-bound.scala b/tests/run/array-existential-bound.scala new file mode 100644 index 000000000..cc105d8fc --- /dev/null +++ b/tests/run/array-existential-bound.scala @@ -0,0 +1,17 @@ +trait Fooz[Q <: Array[_]] { + def f0(x: Q) = x.length +} + +object Test extends Fooz[Array[Int]] { + val f1 = new Fooz[Array[String]] { } + val f2 = new Fooz[Array[Int]] { } + val f3 = new Fooz[Array[Any]] { } + val f4 = new Fooz[Array[_]] { } + + def main(args: Array[String]): Unit = { + println(f1.f0(Array[String]("a", "b"))) + println(f2.f0((1 to 1000).toArray)) + println(f3.f0((1 to 1000).toArray[Any])) + println(f4.f0(('a' to 'z').toArray)) + } +} diff --git a/tests/run/arraycopy.scala b/tests/run/arraycopy.scala new file mode 100644 index 000000000..77a8809a1 --- /dev/null +++ b/tests/run/arraycopy.scala @@ -0,0 +1,31 @@ + + +object Test { + def main(args: Array[String]): Unit = { + val a = new Array[Int](10) + val b = new Array[Any](10) + for (i <- 0 until 10) b(i) = i + + Array.copy(b, 3, a, 3, 7) + assert(a.toSeq == List(0, 0, 0, 3, 4, 5, 6, 7, 8, 9)) + } +} + + + + + + + + + + + + + + + + + + + diff --git a/tests/run/arybufgrow.check b/tests/run/arybufgrow.check new file mode 100644 index 000000000..ce71841c7 --- /dev/null +++ b/tests/run/arybufgrow.check @@ -0,0 +1 @@ +1000 = 1000 diff --git a/tests/run/arybufgrow.scala b/tests/run/arybufgrow.scala new file mode 100644 index 000000000..b0e06166b --- /dev/null +++ b/tests/run/arybufgrow.scala @@ -0,0 +1,10 @@ +import scala.collection.mutable._; + +object Test extends dotty.runtime.LegacyApp { + val buf = new ArrayBuffer[String]; + for (i <- List.range(0,1000)) { + buf += "hello"; + } + + Console.println("1000 = " + buf.length); +} diff --git a/tests/run/bigDecimalCache.scala b/tests/run/bigDecimalCache.scala new file mode 100644 index 000000000..c0c709a50 --- /dev/null +++ b/tests/run/bigDecimalCache.scala @@ -0,0 +1,9 @@ +object Test { + def main(args: Array[String]): Unit = { + val bd5a = BigDecimal(5) + val mc = java.math.MathContext.DECIMAL32 + val bd5b = BigDecimal(5,mc) + + assert(bd5b.mc == mc) + } +} diff --git a/tests/run/bigDecimalTest.check b/tests/run/bigDecimalTest.check new file mode 100644 index 000000000..36db6aaaf --- /dev/null +++ b/tests/run/bigDecimalTest.check @@ -0,0 +1,6 @@ +34 +83 +0 +0 +0 +15 diff --git a/tests/run/bigDecimalTest.scala b/tests/run/bigDecimalTest.scala new file mode 100644 index 000000000..480305d7d --- /dev/null +++ b/tests/run/bigDecimalTest.scala @@ -0,0 +1,35 @@ +object Test { + def main(args: Array[String]): Unit = { + + // SI-4981: avoid being limited by math context when not needed + val big = BigDecimal("32432875832753287583275382753288325325328532875325") + val f = big % BigDecimal(scala.math.Pi) + + // SI-1812: use math context to limit decimal expansion + val a = BigDecimal(1) / BigDecimal(3) + val b = BigDecimal(1) / big + + // SI-2199: implicit conversions from java.math.BigDecimal to BigDecimal + val c = BigDecimal(1) + (new java.math.BigDecimal(3)) + + // SI-2024: correctly use BigDecimal.valueOf + assert(BigDecimal(123) + 1.1 == BigDecimal("124.1")) + + // SI-3206: BigDecimal cache errors + val d = BigDecimal(2, new java.math.MathContext(33)) + val e = BigDecimal(2, new java.math.MathContext(34)) + assert(d.mc != e.mc) + + // SI-921 + assert(BigDecimal(2) / BigDecimal(0.5) == BigDecimal(4)) + + // SI-2304: enforce equals/hashCode contract + assert(BigDecimal("2").hashCode == BigDecimal("2.00").hashCode) + + // SI-4547: implicit conversion + assert(5 + BigDecimal(3) == BigDecimal(8)) + + // meaningless sanity check + List[BigDecimal](a, b, c, d, e, f) map (_.scale) foreach println + } +} diff --git a/tests/run/blame_eye_triple_eee-double.check b/tests/run/blame_eye_triple_eee-double.check new file mode 100644 index 000000000..5e46d91a8 --- /dev/null +++ b/tests/run/blame_eye_triple_eee-double.check @@ -0,0 +1,9 @@ +if (NaN == NaN) is good +if (x == x) is good +if (x == NaN) is good +if (NaN != NaN) is good +if (x != x) is good +if (NaN != x) is good +x matching was good +NaN matching was good +loop with NaN was goood diff --git a/tests/run/blame_eye_triple_eee-double.flags b/tests/run/blame_eye_triple_eee-double.flags new file mode 100644 index 000000000..c9b68d70d --- /dev/null +++ b/tests/run/blame_eye_triple_eee-double.flags @@ -0,0 +1 @@ +-optimise diff --git a/tests/run/blame_eye_triple_eee-double.scala b/tests/run/blame_eye_triple_eee-double.scala new file mode 100644 index 000000000..406fc960a --- /dev/null +++ b/tests/run/blame_eye_triple_eee-double.scala @@ -0,0 +1,61 @@ +object Test extends dotty.runtime.LegacyApp { + import Double.NaN + + // NaN must not equal NaN no matter what optimizations are applied + // All the following will seem redundant, but to an optimizer + // they can appear different + + val x = NaN + + if (NaN == NaN) + println("if (NaN == NaN) is broken") + else + println("if (NaN == NaN) is good") + + if (x == x) + println("if (x == x) is broken") + else + println("if (x == x) is good") + + if (x == NaN) + println("if (x == NaN) is broken") + else + println("if (x == NaN) is good") + + if (NaN != NaN) + println("if (NaN != NaN) is good") + else + println("if (NaN != NaN) broken") + + if (x != x) + println("if (x != x) is good") + else + println("if (x != x) broken") + + if (NaN != x) + println("if (NaN != x) is good") + else + println("if (NaN != x) is broken") + + x match { + case 0.0d => println("x matched 0!") + case NaN => println("x matched NaN!") + case _ => println("x matching was good") + } + + NaN match { + case 0.0d => println("NaN matched 0!") + case NaN => println("NaN matched NaN!") + case _ => println("NaN matching was good") + } + + var z = 0.0d + var i = 0 + while (i < 10) { + if (i % 2 == 0) z = NaN + else z = NaN + i += 1 + } + if (z.isNaN && i == 10) println("loop with NaN was goood") + else println("loop with NaN was broken") +} diff --git a/tests/run/blame_eye_triple_eee-float.check b/tests/run/blame_eye_triple_eee-float.check new file mode 100644 index 000000000..5e46d91a8 --- /dev/null +++ b/tests/run/blame_eye_triple_eee-float.check @@ -0,0 +1,9 @@ +if (NaN == NaN) is good +if (x == x) is good +if (x == NaN) is good +if (NaN != NaN) is good +if (x != x) is good +if (NaN != x) is good +x matching was good +NaN matching was good +loop with NaN was goood diff --git a/tests/run/blame_eye_triple_eee-float.flags b/tests/run/blame_eye_triple_eee-float.flags new file mode 100644 index 000000000..c9b68d70d --- /dev/null +++ b/tests/run/blame_eye_triple_eee-float.flags @@ -0,0 +1 @@ +-optimise diff --git a/tests/run/blame_eye_triple_eee-float.scala b/tests/run/blame_eye_triple_eee-float.scala new file mode 100644 index 000000000..e62461828 --- /dev/null +++ b/tests/run/blame_eye_triple_eee-float.scala @@ -0,0 +1,61 @@ +object Test extends dotty.runtime.LegacyApp { + import Float.NaN + + // NaN must not equal NaN no matter what optimizations are applied + // All the following will seem redundant, but to an optimizer + // they can appear different + + val x = NaN + + if (NaN == NaN) + println("if (NaN == NaN) is broken") + else + println("if (NaN == NaN) is good") + + if (x == x) + println("if (x == x) is broken") + else + println("if (x == x) is good") + + if (x == NaN) + println("if (x == NaN) is broken") + else + println("if (x == NaN) is good") + + if (NaN != NaN) + println("if (NaN != NaN) is good") + else + println("if (NaN != NaN) broken") + + if (x != x) + println("if (x != x) is good") + else + println("if (x != x) broken") + + if (NaN != x) + println("if (NaN != x) is good") + else + println("if (NaN != x) is broken") + + x match { + case 0.0f => println("x matched 0!") + case NaN => println("x matched NaN!") + case _ => println("x matching was good") + } + + NaN match { + case 0.0f => println("NaN matched 0!") + case NaN => println("NaN matched NaN!") + case _ => println("NaN matching was good") + } + + var z = 0.0f + var i = 0 + while (i < 10) { + if (i % 2 == 0) z = NaN + else z = NaN + i += 1 + } + if (z.isNaN && i == 10) println("loop with NaN was goood") + else println("loop with NaN was broken") +} diff --git a/tests/run/boolexprs.check b/tests/run/boolexprs.check new file mode 100644 index 000000000..cd2c73589 --- /dev/null +++ b/tests/run/boolexprs.check @@ -0,0 +1,3 @@ +test Test1 was successful +test Test2 was successful + diff --git a/tests/run/boolexprs.scala b/tests/run/boolexprs.scala new file mode 100644 index 000000000..94313d9c8 --- /dev/null +++ b/tests/run/boolexprs.scala @@ -0,0 +1,59 @@ +//############################################################################ +// Boolean Expressions +//############################################################################ + +class Counter { + private var n: Int = 0; + def incrThen(b: Boolean) = if (b) n += 1; + def value = n; +} + +object Test1 { + var flag = false; + def flip: Boolean = { val tmp = flag; flag = !flag; tmp } + def run: Int = { + val c = new Counter; + c.incrThen(flip || flip); + c.value + } +} + +object Test2 { + val a = Array(false); + + def run: Int = { + val c = new Counter; + c.incrThen(true && a(0)); + c.incrThen(false || Nil.length > 0); + c.value + } +} + +//############################################################################ +// Test code + +object Test { + def check_success(name: String, closure: => Int, expected: Int): Unit = { + Console.print("test " + name); + try { + val actual: Int = closure; + if (actual == expected) { + Console.print(" was successful"); + } else { + Console.print(" failed: expected "+ expected +", found "+ actual); + } + } catch { + case exception: Throwable => + Console.print(" raised exception " + exception); + } + Console.println; + } + + def main(args: Array[String]): Unit = { + check_success("Test1", Test1.run, 1); + check_success("Test2", Test2.run, 0); + Console.println; + } +} + +//############################################################################ diff --git a/tests/run/boolord.check b/tests/run/boolord.check new file mode 100644 index 000000000..d1b11c0cd --- /dev/null +++ b/tests/run/boolord.check @@ -0,0 +1,4 @@ +false < false = false +false < true = true +true < false = false +true < true = false diff --git a/tests/run/boolord.scala b/tests/run/boolord.scala new file mode 100644 index 000000000..7a827ffc3 --- /dev/null +++ b/tests/run/boolord.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]): Unit = { + Console.println("false < false = " + (false < false)) + Console.println("false < true = " + (false < true)) + Console.println("true < false = " + (true < false)) + Console.println("true < true = " + (true < true)) + } +} diff --git a/tests/run/breakout.check b/tests/run/breakout.check new file mode 100644 index 000000000..7971496d1 --- /dev/null +++ b/tests/run/breakout.check @@ -0,0 +1 @@ +2, 3, 4 diff --git a/tests/run/breakout.scala b/tests/run/breakout.scala new file mode 100644 index 000000000..a58191046 --- /dev/null +++ b/tests/run/breakout.scala @@ -0,0 +1,9 @@ +import scala.collection.generic._ +import scala.collection._ +import scala.collection.mutable._ + +object Test extends dotty.runtime.LegacyApp { + val l = List(1, 2, 3) + val a: Array[Int] = l.map(_ + 1)(breakOut) + println(a.mkString(", ")) +} diff --git a/tests/run/buffer-slice.check b/tests/run/buffer-slice.check new file mode 100644 index 000000000..5287aa9d7 --- /dev/null +++ b/tests/run/buffer-slice.check @@ -0,0 +1 @@ +ArrayBuffer() diff --git a/tests/run/buffer-slice.scala b/tests/run/buffer-slice.scala new file mode 100644 index 000000000..ddd82e075 --- /dev/null +++ b/tests/run/buffer-slice.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + println(scala.collection.mutable.ArrayBuffer().slice(102450392, -2045033354)) + } +} diff --git a/tests/run/byNameVarargs/i499.scala b/tests/run/byNameVarargs/i499.scala new file mode 100644 index 000000000..e1550b6ec --- /dev/null +++ b/tests/run/byNameVarargs/i499.scala @@ -0,0 +1,27 @@ +object Test extends dotty.runtime.LegacyApp{ + def foo(a: => Any*) = () + def bar(a: => Any*) = foo(a : _*) + def baz(a: => Seq[Any]) = foo(a : _*) + bar(???, ???) + baz(Seq(???, ???)) + + def foo1(a: => Any, b: => Any*) = () + foo1(???) + foo1(???, ???, ???) + + def assertFails(a: => Any) = { + var failed = false + try { + a + } catch { + case e => failed = true + } + assert(failed) + } + + def forceLength(b: => Any*) = b.length + assertFails(forceLength(???)) + + def forceHead(b: => Any*) = b(0) + assertFails(forceHead(1, ???)) +} diff --git a/tests/run/classTags.scala b/tests/run/classTags.scala new file mode 100644 index 000000000..9af6747f3 --- /dev/null +++ b/tests/run/classTags.scala @@ -0,0 +1,24 @@ +object Test { + type T = String + type U + +/* val a /* : Class[T] */ = classOf[T] // [Ljava/lang/String; + println(a) +*/ val b /* : ClassTag[T] */ = reflect.classTag[T] // ClassTag(classOf[java.lang.String]) +/* println(b) + + val d /* : ClassTag[T with U] */ = reflect.classTag[T with U] // ClassTag(classOf[java.lang.String]) + println(d) + val e /* : Class[Array[T with U]] */ = classOf[Array[T with U]] // [Ljava/lang/String; + println(e) + val f /* : ClassTag[Array[T with U]] */ = reflect.classTag[Array[T with U]] // ClassTag(arrayClass(classOf[java.lang.String])) + println(f) + val g /* : Class[Meter] */ = classOf[Meter] // [LMeter; + println(g) + val h /* : ClassTag[Meter] */ = reflect.classTag[Meter] // ClassTag(classOf[Meter]) + println(h) +*/ + def main(args: Array[String]): Unit = () +} + +//class Meter(val i: Int) extends AnyVal diff --git a/tests/run/classmanifests_new_alias.check b/tests/run/classmanifests_new_alias.check new file mode 100644 index 000000000..032521a92 --- /dev/null +++ b/tests/run/classmanifests_new_alias.check @@ -0,0 +1,2 @@ +Int +true diff --git a/tests/run/classmanifests_new_alias.scala b/tests/run/classmanifests_new_alias.scala new file mode 100644 index 000000000..38af0ede3 --- /dev/null +++ b/tests/run/classmanifests_new_alias.scala @@ -0,0 +1,7 @@ + +@deprecated("Suppress warnings", since="2.11") +object Test extends dotty.runtime.LegacyApp { + type CM[T] = ClassManifest[T] + println(implicitly[CM[Int]]) + println(implicitly[CM[Int]] eq Manifest.Int) +} diff --git a/tests/run/classmanifests_new_core.check b/tests/run/classmanifests_new_core.check new file mode 100644 index 000000000..032521a92 --- /dev/null +++ b/tests/run/classmanifests_new_core.check @@ -0,0 +1,2 @@ +Int +true diff --git a/tests/run/classmanifests_new_core.scala b/tests/run/classmanifests_new_core.scala new file mode 100644 index 000000000..a916b750c --- /dev/null +++ b/tests/run/classmanifests_new_core.scala @@ -0,0 +1,5 @@ +@deprecated("Suppress warnings", since="2.11") +object Test extends dotty.runtime.LegacyApp { + println(classManifest[Int]) + println(classManifest[Int] eq Manifest.Int) +} diff --git a/tests/run/collections-toSelf.scala b/tests/run/collections-toSelf.scala new file mode 100644 index 000000000..02f1dd6a9 --- /dev/null +++ b/tests/run/collections-toSelf.scala @@ -0,0 +1,11 @@ +object Test { + val map = Map(1 -> 2) + val set = Set(1, 2) + val seq = collection.immutable.Seq(1, 2) + + def main(args: Array[String]): Unit = { + assert(map.toMap eq map) + assert(set.toSet eq set) + assert(seq.toSeq eq seq) + } +} diff --git a/tests/run/comparable-comparator.scala b/tests/run/comparable-comparator.scala new file mode 100644 index 000000000..f059cc52f --- /dev/null +++ b/tests/run/comparable-comparator.scala @@ -0,0 +1,29 @@ + +object Test { + import java.util.Comparator + + class C1(val s: String) extends Comparable[C1] { + def compareTo(other: C1) = s compareTo other.s + override def toString = s + } + class C2(val s: String) { + def compareTo(other: C2) = s compareTo other.s + override def toString = s + } + + implicit val cmp: Comparator[C2] = new Comparator[C2] { + def compare(p1: C2, p2: C2) = p2.s compareTo p1.s + } + + val words = "zip foo bar baz aggle bing bong" split ' ' + val strs = words.toList + val c1s = strs map (x => new C1(x)) + val c2s = strs map (x => new C2(x)) + + val sorted1 = c1s.sorted map (_.s) + val sorted2 = c2s.sorted map (_.s) + + def main(args: Array[String]): Unit = { + assert(sorted1 == sorted2.reverse) + } +} diff --git a/tests/run/complicatedmatch.check b/tests/run/complicatedmatch.check new file mode 100644 index 000000000..501b7a32d --- /dev/null +++ b/tests/run/complicatedmatch.check @@ -0,0 +1,6 @@ +1 +42 +42 +11 +7 +13 diff --git a/tests/run/complicatedmatch.scala b/tests/run/complicatedmatch.scala new file mode 100644 index 000000000..7a7438445 --- /dev/null +++ b/tests/run/complicatedmatch.scala @@ -0,0 +1,31 @@ +object Bar{ + def unapply(x : String) = x == "bar"; +} + +object Even{ + def unapply(x : Int) = if (x % 2 == 0) Some(x / 2) else None; +} + +object Test extends dotty.runtime.LegacyApp{ + val LongWord = "supercalifragilisticexpialadocious"; + + def foo(x : Int, y : String) : Int = (x, y) match { + case (Even(i), "bar") => 1 + case (1 | 2 | 3, "foo") => 42; + case (x, y) if y.length < x => 11; + case (1 | 2 | 3, Bar()) => 7; + case (1 | 2 | 3, "bar") => 8 + case (Even(Even(3)), Bar()) => 13; + case (Even(Even(3)), LongWord) => 13; + case _ => 0; + } + + List( + 2 -> "bar", + 2 -> "foo", + 3 -> "foo", + 7 -> "flob", + 3 -> "bar", + 12 -> LongWord + ).foreach({case (x, y) => println(foo(x, y))}); +} diff --git a/tests/run/concat-two-strings.scala b/tests/run/concat-two-strings.scala new file mode 100644 index 000000000..c8881aa14 --- /dev/null +++ b/tests/run/concat-two-strings.scala @@ -0,0 +1,15 @@ +/** This doesn't test that the optimization is working, only that + * nothing is exploding. + */ +object Test { + def f1(x: AnyRef) = "" + x + def f2(x: Int) = "" + x + def f3(x: Array[Char]) = "" + x + def f4(x: List[Int]) = "" + x + def f5(x: Any) = "" + x + def f6(x: AnyVal) = "" + x + + def main(args: Array[String]): Unit = { + List(f1("a"), f2(5), f3(null), f3(Array('a')), f4(List(1)), f5(null), f6(55d)) mkString "" + } +} diff --git a/tests/run/concurrent-map-conversions.scala b/tests/run/concurrent-map-conversions.scala new file mode 100644 index 000000000..225efe1da --- /dev/null +++ b/tests/run/concurrent-map-conversions.scala @@ -0,0 +1,36 @@ + + + + + +object Test { + + def main(args: Array[String]): Unit = { + testConversions() + testConverters() + } + + def needPackageConcurrentMap(map: collection.concurrent.Map[Int, Int]): Unit = { + } + def needJavaConcurrent(map: java.util.concurrent.ConcurrentMap[Int, Int]): Unit = { + } + + def testConversions(): Unit = { + import collection.JavaConversions._ + val skiplist = new java.util.concurrent.ConcurrentSkipListMap[Int, Int] + val ctrie = new collection.concurrent.TrieMap[Int, Int] + + needPackageConcurrentMap(skiplist) + needJavaConcurrent(ctrie) + } + + def testConverters(): Unit = { + import collection.JavaConverters._ + val skiplist = new java.util.concurrent.ConcurrentSkipListMap[Int, Int] + val ctrie = new collection.concurrent.TrieMap[Int, Int] + + needPackageConcurrentMap(skiplist.asScala) + needJavaConcurrent(ctrie.asJava) + } + +} diff --git a/tests/run/constant-optimization.check b/tests/run/constant-optimization.check new file mode 100644 index 000000000..957ffc5a8 --- /dev/null +++ b/tests/run/constant-optimization.check @@ -0,0 +1,5 @@ +testBothReachable: good +testOneReachable: good +testAllReachable: good +testOneUnreachable: good +testDefaultUnreachable: good diff --git a/tests/run/constant-optimization.flags b/tests/run/constant-optimization.flags new file mode 100644 index 000000000..c9b68d70d --- /dev/null +++ b/tests/run/constant-optimization.flags @@ -0,0 +1 @@ +-optimise diff --git a/tests/run/constant-optimization.scala b/tests/run/constant-optimization.scala new file mode 100644 index 000000000..83cabf856 --- /dev/null +++ b/tests/run/constant-optimization.scala @@ -0,0 +1,61 @@ +object Test extends dotty.runtime.LegacyApp { + def testBothReachable(): Unit = { + val i = util.Random.nextInt + val x = if (i % 2 == 0) null else "good" + val y = if (x == null) "good" else x + "" + println(s"testBothReachable: $y") + } + + def testOneReachable(): Unit = { + val i = 1 + val x = if (i != 1) null else "good" + val y = if (x == null) "good" else x + "" + println(s"testOneReachable: $y") + } + + def testAllReachable(): Unit = { + val i = util.Random.nextInt + val y = (i % 2) match { + case 0 => "good" + case 1 => "good" + case _ => "good" + } + println(s"testAllReachable: $y") + } + + def testOneUnreachable(): Unit = { + val i = util.Random.nextInt + val x = if (i % 2 == 0) { + 1 + } else { + 2 + } + val y = x match { + case 0 => "good" + case 1 => "good" + case _ => "good" + } + println(s"testOneUnreachable: $y") + } + + def testDefaultUnreachable(): Unit = { + val i = util.Random.nextInt + val x = if (i % 2 == 0) { + 1 + } else { + 2 + } + val y = x match { + case 1 => "good" + case 2 => "good" + case _ => "good" + } + println(s"testDefaultUnreachable: $y") + } + + testBothReachable() + testOneReachable() + testAllReachable() + testOneUnreachable() + testDefaultUnreachable() +} diff --git a/tests/run/deeps.check b/tests/run/deeps.check new file mode 100644 index 000000000..a68e474f6 --- /dev/null +++ b/tests/run/deeps.check @@ -0,0 +1,87 @@ +testEquals1 +false +false +true + +testEquals2 +false +false +true + +testEquals3 +x=Array(1) +y=Array(1) +false +false +true + +x=Array(Array(1), Array(1)) +y=Array(Array(1), Array(1)) +false +false +true + +x=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1))) +y=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1))) +false +false +true + +testEquals4 +false +false +true +false +false +true +Array(true, false) +Array(true, false) +[true;false] +true;false + +Array(Array(true, false), Array(true, false)) +Array(Array(true, false), Array(true, false)) +[Array(true, false);Array(true, false)] +Array(true, false);Array(true, false) + +Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false))) +Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false))) +[Array(Array(true, false), Array(true, false));Array(Array(true, false), Array(true, false))] +Array(Array(true, false), Array(true, false));Array(Array(true, false), Array(true, false)) + +Array(1.0, 0.0) +Array(1.0, 0.0) +[1.0;0.0] +1.0;0.0 + +Array(Array(1.0, 0.0), Array(1.0, 0.0)) +Array(Array(1.0, 0.0), Array(1.0, 0.0)) +[Array(1.0, 0.0);Array(1.0, 0.0)] +Array(1.0, 0.0);Array(1.0, 0.0) + +Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0))) +Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0))) +[Array(Array(1.0, 0.0), Array(1.0, 0.0));Array(Array(1.0, 0.0), Array(1.0, 0.0))] +Array(Array(1.0, 0.0), Array(1.0, 0.0));Array(Array(1.0, 0.0), Array(1.0, 0.0)) + +Array(a, b) +Array(a, b) +[a;b] +a;b + +Array(Array(a, b), Array(a, b)) +Array(Array(a, b), Array(a, b)) +[Array(a, b);Array(a, b)] +Array(a, b);Array(a, b) + +Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b))) +Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b))) +[Array(Array(a, b), Array(a, b));Array(Array(a, b), Array(a, b))] +Array(Array(a, b), Array(a, b));Array(Array(a, b), Array(a, b)) + +[Array(true, false); Array(false)] +[Array(1, 2); Array(3)] +[Array(1, 2); Array(3)] + +Array(boo, and, foo) +Array(a) diff --git a/tests/run/deeps.scala b/tests/run/deeps.scala new file mode 100644 index 000000000..0cb6d6231 --- /dev/null +++ b/tests/run/deeps.scala @@ -0,0 +1,114 @@ +//############################################################################ +// deepEquals / deep.toString +//############################################################################ + +//############################################################################ +// need to revisit array equqality +object Test { + + def testEquals1: Unit = { + println(Array(1) == Array(1)) + println(Array(1) equals Array(1)) + println(Array(1).deep == Array(1).deep) + println + } + + def testEquals2: Unit = { + println(Array(Array(1), Array(2)) == Array(Array(1), Array(2))) + println(Array(Array(1), Array(2)) equals Array(Array(1), Array(2))) + println(Array(Array(1), Array(2)).deep equals Array(Array(1), Array(2)).deep) + println + } + + def testEquals3: Unit = { + val a1 = Array(1) + val b1 = Array(1) + val a2 = Array(a1, b1) + val b2 = Array(a1, b1) + val a3 = Array(a2, b2) + val b3 = Array(a2, b2) + def test[T](x: Array[T], y: Array[T]): Unit = { + println("x=" + x.deep.toString) + println("y=" + y.deep.toString) + println(x == y) + println(x equals y) + println(x.deep == y.deep) + println + } + test(a1, b1) + test(a2, b2) + test(a3, b3) + } + + def testEquals4: Unit = { + println("boo:and:foo".split(':') == "boo:and:foo".split(':')) + println("boo:and:foo".split(':') equals "boo:and:foo".split(':')) + println("boo:and:foo".split(':').deep == "boo:and:foo".split(':').deep) + + val xs = new java.util.ArrayList[String](); xs.add("a") + val ys = new java.util.ArrayList[String](); ys.add("a") + println(xs.toArray == ys.toArray) + println(xs.toArray equals ys.toArray) + println(xs.toArray.deep == ys.toArray.deep) + } + + def testToString1: Unit = { + def sweep(s: String) = ( + s.replaceAll("D@[0-9a-fA-F]+", "D@0000000") + .replaceAll("Z@[0-9a-fA-F]+", "Z@0000000") + .replaceAll(";@[0-9a-fA-F]+", ";@0000000") + ) + def test[T](a: Array[T]): Unit = { + println(sweep(a.deep.toString)) + println(a.deep.toString) + println(a.deep.mkString("[", ";", "]")) + println(a.deep.mkString(";")) + println + } + + val ba1 = Array(true, false) + val ba2 = Array(ba1, ba1) + val ba3 = Array(ba2, ba2) + test(ba1) + test(ba2) + test(ba3) + + val da1 = Array(1.0d, 0.0d) + val da2 = Array(da1, da1) + val da3 = Array(da2, da2) + test(da1) + test(da2) + test(da3) + + val sa1 = Array("a", "b") + val sa2 = Array(sa1, sa1) + val sa3 = Array(sa2, sa2) + test(sa1) + test(sa2) + test(sa3) + } + + def testToString2: Unit = { + println(Array(Array(true, false), Array(false)).deep.mkString("[", "; ", "]")) + println(Array(Array('1', '2'), Array('3')).deep.mkString("[", "; ", "]")) + println(Array(Array(1, 2), Array(3)).deep.mkString("[", "; ", "]")) + println + } + + def testToString3: Unit = { + println("boo:and:foo".split(':').deep.toString) + + val xs = new java.util.ArrayList[String](); xs.add("a") + println(xs.toArray.deep.toString) + } + + def main(args: Array[String]): Unit = { + println("testEquals1") ; testEquals1 + println("testEquals2") ; testEquals2 + println("testEquals3") ; testEquals3 + println("testEquals4") ; testEquals4 + testToString1 + testToString2 + testToString3 + } +} diff --git a/tests/run/delambdafy-dependent-on-param-subst-2.scala b/tests/run/delambdafy-dependent-on-param-subst-2.scala new file mode 100644 index 000000000..4f7b2dc6e --- /dev/null +++ b/tests/run/delambdafy-dependent-on-param-subst-2.scala @@ -0,0 +1,20 @@ +trait M[-X] { + def m(x: X): Boolean +} + +class C +class A { class C } + +object Test { + def main(args: Array[String]): Unit = { + val a = new A + + // class O extends M[a.C] { def m(x: a.C) = true } + // (new O: M[Null]).m(null) // Okay + + ((a: A) => { + class N extends M[a.C] { def m(x: a.C) = true } + new N: M[Null] + }).apply(a).m(null) // NPE, missing bridge + } +} diff --git a/tests/run/delambdafy-dependent-on-param-subst.flags b/tests/run/delambdafy-dependent-on-param-subst.flags new file mode 100644 index 000000000..2b27e1983 --- /dev/null +++ b/tests/run/delambdafy-dependent-on-param-subst.flags @@ -0,0 +1 @@ +-Ydelambdafy:method
\ No newline at end of file diff --git a/tests/run/delambdafy-dependent-on-param-subst.scala b/tests/run/delambdafy-dependent-on-param-subst.scala new file mode 100644 index 000000000..4f7b2dc6e --- /dev/null +++ b/tests/run/delambdafy-dependent-on-param-subst.scala @@ -0,0 +1,20 @@ +trait M[-X] { + def m(x: X): Boolean +} + +class C +class A { class C } + +object Test { + def main(args: Array[String]): Unit = { + val a = new A + + // class O extends M[a.C] { def m(x: a.C) = true } + // (new O: M[Null]).m(null) // Okay + + ((a: A) => { + class N extends M[a.C] { def m(x: a.C) = true } + new N: M[Null] + }).apply(a).m(null) // NPE, missing bridge + } +} diff --git a/tests/run/delambdafy-nested-by-name.check b/tests/run/delambdafy-nested-by-name.check new file mode 100644 index 000000000..94954abda --- /dev/null +++ b/tests/run/delambdafy-nested-by-name.check @@ -0,0 +1,2 @@ +hello +world diff --git a/tests/run/delambdafy-nested-by-name.scala b/tests/run/delambdafy-nested-by-name.scala new file mode 100644 index 000000000..37aa86a04 --- /dev/null +++ b/tests/run/delambdafy-nested-by-name.scala @@ -0,0 +1,11 @@ +// during development of delayed delambdafication I created a bug where calling a by-name method with a by-name argument that +// itself contained a by-name argument would cause a class cast exception. That bug wasn't found in the existing test suite +// so this test covers that case +object Test { + def meth1(arg1: => String) = arg1 + def meth2(arg2: => String) = meth1({println("hello"); arg2}) + + def main(args: Array[String]): Unit = { + println(meth2("world")) + } +} diff --git a/tests/run/delambdafy-two-lambdas.check b/tests/run/delambdafy-two-lambdas.check new file mode 100644 index 000000000..ed9ea404d --- /dev/null +++ b/tests/run/delambdafy-two-lambdas.check @@ -0,0 +1,2 @@ +13 +24 diff --git a/tests/run/delambdafy-two-lambdas.scala b/tests/run/delambdafy-two-lambdas.scala new file mode 100644 index 000000000..decede74a --- /dev/null +++ b/tests/run/delambdafy-two-lambdas.scala @@ -0,0 +1,12 @@ +/* + * Tests if two lambdas defined in the same class do not lead to + * name clashes. + */ +object Test { + def takeLambda(f: Int => Int ): Int = f(12) + + def main(args: Array[String]): Unit = { + println(takeLambda(x => x+1)) + println(takeLambda(x => x*2)) + } +} diff --git a/tests/run/duplicate-meth.check b/tests/run/duplicate-meth.check new file mode 100644 index 000000000..099250280 --- /dev/null +++ b/tests/run/duplicate-meth.check @@ -0,0 +1 @@ +verified! diff --git a/tests/run/duplicate-meth.scala b/tests/run/duplicate-meth.scala new file mode 100644 index 000000000..481c869d9 --- /dev/null +++ b/tests/run/duplicate-meth.scala @@ -0,0 +1,23 @@ + +trait Base { + private val secure_# = 10l +} + +class TestUser extends Base { + def clsMeth(x: Int) = x + private def foo(x: Int) = x +} + +object TestUser extends TestUser { + def objMeth = "a" + + private def foo(x: Int) = x +} + +object Test { + def main(args: Array[String]): Unit = { + TestUser.objMeth + // no-op, just check that it passes verification + println("verified!") + } +} diff --git a/tests/run/duration-coarsest.scala b/tests/run/duration-coarsest.scala new file mode 100644 index 000000000..229b7960b --- /dev/null +++ b/tests/run/duration-coarsest.scala @@ -0,0 +1,28 @@ +import scala.concurrent.duration._ +import scala.language.postfixOps + +object Test extends dotty.runtime.LegacyApp { + List( + (60 minutes, 1 hour), + (2000 millis, 2 seconds), + (2000 micros, 2 millis), + (2000 nanos, 2 micros), + (2000000 nanos, 2 millis), + (48 hours, 2 days), + (5 seconds, 5 seconds), + (1 second, 1 second) + ) foreach { + case (x, expected) => + val actual = x.toCoarsest + assert(actual.unit == expected.unit, s"$actual, $expected") + assert(actual.length == expected.length, s"$actual, $expected") + } + + List( + 45 minutes, + 500 millis, + 1500 millis, + 23 hours, + 40 days + ) foreach (x => assert(x == x.toCoarsest, x)) +} diff --git a/tests/run/elidable-noflags.check b/tests/run/elidable-noflags.check new file mode 100644 index 000000000..23be9ab4e --- /dev/null +++ b/tests/run/elidable-noflags.check @@ -0,0 +1,7 @@ +Good for me, I was not elided. +Good for me, I was not elided. +Good for me, I was not elided. +Good for me, I was not elided. +Good for me, I was not elided. +Good for me, I was not elided. +ESPECIALLY good for me, I was not elided. diff --git a/tests/run/elidable-noflags.scala b/tests/run/elidable-noflags.scala new file mode 100644 index 000000000..1b9c5118b --- /dev/null +++ b/tests/run/elidable-noflags.scala @@ -0,0 +1,22 @@ +import annotation._ +import elidable._ + +object Test { + @elidable(FINEST) def f1() = println("Good for me, I was not elided.") + @elidable(INFO) def f2() = println("Good for me, I was not elided.") + @elidable(SEVERE) def f3() = println("Good for me, I was not elided.") + @elidable(INFO) def f4() = println("Good for me, I was not elided.") + @elidable(100000) def f5() = println("Good for me, I was not elided.") + @elidable(OFF) def f6() = println("Good for me, I was not elided.") + @elidable(ALL) def f7() = println("ESPECIALLY good for me, I was not elided.") + + def main(args: Array[String]): Unit = { + f1() + f2() + f3() + f4() + f5() + f6() + f7() + } +} diff --git a/tests/run/empty-array.check b/tests/run/empty-array.check new file mode 100644 index 000000000..bb0b1cf65 --- /dev/null +++ b/tests/run/empty-array.check @@ -0,0 +1,3 @@ +0 +0 +0 diff --git a/tests/run/empty-array.scala b/tests/run/empty-array.scala new file mode 100644 index 000000000..6e37dca37 --- /dev/null +++ b/tests/run/empty-array.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]): Unit = { + println(Array.emptyByteArray.length) + println(Array.emptyDoubleArray.length) + println(Array.emptyBooleanArray.length) + // okay okay okay + } +} diff --git a/tests/run/equality.scala b/tests/run/equality.scala new file mode 100644 index 000000000..ff5989882 --- /dev/null +++ b/tests/run/equality.scala @@ -0,0 +1,40 @@ +// a quickly assembled test of equality. Needs work. +object Test +{ + import scala.runtime.ScalaRunTime.hash + + def makeFromInt(x: Int) = List( + x.toByte, x.toShort, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x) + ) ::: ( + if (x < 0) Nil else List(x.toChar) + ) + def makeFromDouble(x: Double) = List( + x.toShort, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x.toInt), BigDecimal(x) + ) + + def main(args: Array[String]): Unit = { + var xs = makeFromInt(5) + for (x <- xs ; y <- xs) { + assert(x == y, x + " == " + y) + assert(hash(x) == hash(y), "hash(%s) == hash(%s)".format(x, y)) + } + + xs = makeFromInt(-5) + for (x <- xs ; y <- xs) { + assert(x == y, x + " == " + y) + assert(hash(x) == hash(y), "hash(%s) == hash(%s)".format(x, y)) + } + + xs = makeFromDouble(500.0) + for (x <- xs ; y <- xs) { + assert(x == y, x + " == " + y) + assert(hash(x) == hash(y), "hash(%s) == hash(%s)".format(x, y)) + } + + // negatives + val bigLong = new java.util.concurrent.atomic.AtomicLong(Long.MaxValue) + assert(-1 != bigLong && bigLong != -1) // bigLong.intValue() == -1 + assert(BigDecimal(1.1) != 1L) + assert(1L != BigDecimal(1.1)) + } +} diff --git a/tests/run/exc.scala b/tests/run/exc.scala new file mode 100644 index 000000000..be999794a --- /dev/null +++ b/tests/run/exc.scala @@ -0,0 +1,10 @@ +object Test extends dotty.runtime.LegacyApp { + def foo() = { + while (true) { + try { + } catch { + case ex: Exception => + } + } + } +} diff --git a/tests/run/exc1.scala b/tests/run/exc1.scala new file mode 100644 index 000000000..c48b4c156 --- /dev/null +++ b/tests/run/exc1.scala @@ -0,0 +1,10 @@ +object Test extends dotty.runtime.LegacyApp { + def foo(): Unit = { + while (true) { + try { + } catch { + case ex: Exception => + } + } + } +} diff --git a/tests/run/exc2.scala b/tests/run/exc2.scala new file mode 100644 index 000000000..4075cb26f --- /dev/null +++ b/tests/run/exc2.scala @@ -0,0 +1,12 @@ +object Test extends dotty.runtime.LegacyApp { + def foo() = { + while (true) { + try { + Console.println("foo") + } catch { + case ex: Exception => + Console.println("bar") + } + } + } +} diff --git a/tests/run/exceptions-nest.check b/tests/run/exceptions-nest.check new file mode 100644 index 000000000..48725e4d2 --- /dev/null +++ b/tests/run/exceptions-nest.check @@ -0,0 +1,13 @@ +2 +23 +2 +5 +2 +4 +OK +4 +OK +10 +1 +() +10 diff --git a/tests/run/exceptions-nest.scala b/tests/run/exceptions-nest.scala new file mode 100644 index 000000000..87586485c --- /dev/null +++ b/tests/run/exceptions-nest.scala @@ -0,0 +1,157 @@ +object Test extends dotty.runtime.LegacyApp { + + println(test1) + println(test2) + println(test3) + println(test4) + println(test5) + try { println(test6) } catch { case _: Throwable => println("OK") } + println(test7) + try { println(test8) } catch { case _: Throwable => println("OK") } + println(test9) + println(test10) + println(test11) + println(test12) + + def test1 = { + var x = 1 + try { + x = 2 + } catch { + case _: NullPointerException => x = 3 + case _: Throwable => x = 4 + } + x + } + + def test2 = { + var x = 1 + try { + x = 2 + try { + x = 21 + } catch { + case _: Throwable => x = 22 + } + x = 23 + } catch { + case _: NullPointerException => x = 3 + case _: Throwable => x = 4 + } + x + } + + def test3 = { + var x = 1 + try { + try{x = 2} catch { case _: Throwable => x = 4 } + } catch { + case _: NullPointerException => x = 3 + case _: Throwable => x = 4 + } + x + } + + def test4 = { + var x = 1 + try { + x = 2 + } catch { + case _: NullPointerException => x = 3 + case _: Throwable => x = 4 + } + try { + x = 5 + } catch { + case _: NullPointerException => x = 6 + } + x + } + + def test5 = { + var x = 1 + try { + x = 2 + } catch { + case _: NullPointerException => try { x = 3 } catch { case f: Throwable => throw f } + case _: Throwable => x = 4; try { x = 41 } catch { case _: Exception => x = 42 }; x = 43 + } + x + } + + def test6: Int = { + var x = 1 + try { + x = 2 + (null: String).toString + } catch { + case e: NullPointerException => + throw e + case _: Throwable => + x = 3 + return 1000 + } finally { + x = 4 + println(x) + } + x + } + + def test7 = { + var x = 1 + try { + x = 2 + } finally { + try { + x = 4 + } catch { + case _: Throwable => x = 5 + } + } + x + } + + def test8 = { + var x = 1 + try { + throw new NullPointerException + } catch { + case e: Throwable => throw e + } + x + } + + def test9 = { + try { "" match { + case s: String => 10 + }} catch { case _: Throwable => 20 } + } + + var x10 = 1 + def test10: Int = { + try { 1 } + catch { case e if (x10 == 1) => 1 } + } + + def test11: Unit = { + try { () } + catch { case e: Throwable => () } + } + + class E1 extends Exception + class E2 extends Exception + class E3 extends Exception + + def test12_impl(op: => Int) = try { + op + } catch { + case e: E1 => 2 + case e: E2 => 3 + case e: E3 => 4 + } + def test12 = + test12_impl(1) + + test12_impl(throw new E1) + + test12_impl(throw new E2) + + test12_impl(throw new E3) +} diff --git a/tests/run/exoticnames.scala b/tests/run/exoticnames.scala new file mode 100644 index 000000000..beaea15b1 --- /dev/null +++ b/tests/run/exoticnames.scala @@ -0,0 +1,7 @@ +// this is a run-test because the compiler should emit bytecode that'll pass the JVM's verifier +object Test extends dotty.runtime.LegacyApp { + def `(` = sys.error("bla") + def `.` = sys.error("bla") + def `)` = sys.error("bla") + def `,` = sys.error("bla") +} diff --git a/tests/run/finally.check b/tests/run/finally.check new file mode 100644 index 000000000..901a79742 --- /dev/null +++ b/tests/run/finally.check @@ -0,0 +1,35 @@ +Running throwCatchFinally +hi +In Finally +java.lang.RuntimeException: ouch +---------------------------------------- +Running retCatch +java.lang.Exception +in finally +---------------------------------------- +Running throwCatch +java.lang.Exception +in finally +COUGHT: java.lang.Exception +---------------------------------------- +Running retBody +in finally +---------------------------------------- +Running throwBody +java.lang.Exception +in finally +---------------------------------------- +Running retFinally +body +in finally 1 +in finally 2 +---------------------------------------- +Running throwFinally +body +in finally +java.lang.Exception +---------------------------------------- +Running nestedFinalies +in finally 1 +in finally 2 +---------------------------------------- diff --git a/tests/run/finally.scala b/tests/run/finally.scala new file mode 100644 index 000000000..64324abc4 --- /dev/null +++ b/tests/run/finally.scala @@ -0,0 +1,127 @@ + +object Test extends dotty.runtime.LegacyApp { + + + // test that finally is not covered by any exception handlers. + def throwCatchFinally: Unit = { + try { + bar + } catch { + case e: Throwable => println(e) + } + } + + // test that finally is not covered by any exception handlers. + def bar: Unit = { + try { + println("hi") + } + catch { + case e: Throwable => println("SHOULD NOT GET HERE") + } + finally { + println("In Finally") + throw new RuntimeException("ouch") + } + } + + // return in catch (finally is executed) + def retCatch: Unit = { + try { + throw new Exception + } catch { + case e: Throwable => + println(e); + return + } finally println("in finally") + } + + // throw in catch (finally is executed, exception propagated) + def throwCatch: Unit = { + try { + throw new Exception + } catch { + case e: Throwable => + println(e); + throw e + } finally println("in finally") + } + + // return inside body (finally is executed) + def retBody: Unit = { + try { + return + } catch { + case e: Throwable => + println(e); + throw e + } finally println("in finally") + } + + // throw inside body (finally and catch are executed) + def throwBody: Unit = { + try { + throw new Exception + } catch { + case e: Throwable => + println(e); + } finally println("in finally") + } + + // return inside finally (each finally is executed once) + def retFinally: Unit = { + try { + try println("body") + finally { + println("in finally 1") + return + } + } finally println("in finally 2") + } + + + // throw inside finally (finally is executed once, exception is propagated) + def throwFinally: Unit = { + try { + try println("body") + finally { + println("in finally") + throw new Exception + } + } catch { + case e: Throwable => println(e) + } + } + + // nested finallies with return value + def nestedFinalies: Int = + try { + try { + return 10 + } finally { + try { () } catch { case _: Throwable => () } + println("in finally 1") + } + } finally { + println("in finally 2") + } + + def test[A](m: => A, name: String): Unit = { + println("Running %s".format(name)) + try { + m + } catch { + case e: Throwable => println("COUGHT: " + e) + } + println("-" * 40) + } + + test(throwCatchFinally, "throwCatchFinally") + test(retCatch, "retCatch") + test(throwCatch, "throwCatch") + test(retBody, "retBody") + test(throwBody, "throwBody") + test(retFinally, "retFinally") + test(throwFinally, "throwFinally") + test(nestedFinalies, "nestedFinalies") +} diff --git a/tests/run/flat-flat-flat.scala b/tests/run/flat-flat-flat.scala new file mode 100644 index 000000000..80868b9c5 --- /dev/null +++ b/tests/run/flat-flat-flat.scala @@ -0,0 +1,11 @@ +object Test { + def f1 = List(Iterator(Some(1), None, Some(2)), Iterator(Some(3), None)) + def f2 = Iterator(List(Some(1), None, Some(2)), List(Some(3), None), Nil) + def f3 = List(Some(Iterator(1)), None, Some(Iterator(2, 3))) + + def main(args: Array[String]): Unit = { + assert(f1.flatten.flatten.toList == List(1, 2, 3)) + assert(f2.flatten.flatten.toList == List(1, 2, 3)) + assert(f3.flatten.flatten.toList == List(1, 2, 3)) + } +} diff --git a/tests/run/fors.check b/tests/run/fors.check new file mode 100644 index 000000000..b459f00b4 --- /dev/null +++ b/tests/run/fors.check @@ -0,0 +1,28 @@ + +testOld +1 2 3 +2 +2 +3 +1 2 3 +1 2 3 +0 1 2 3 4 5 6 7 8 9 +0 2 4 6 8 +0 2 4 6 8 +a b c +b c +b c + +testNew +3 +1 2 3 +1 2 3 +0 1 2 3 4 5 6 7 8 9 +0 2 4 6 8 +0 2 4 6 8 +0 2 4 6 8 +0 2 4 6 8 +0 2 4 6 8 +0 2 4 6 8 +0 2 4 6 8 +a b c diff --git a/tests/run/fors.scala b/tests/run/fors.scala new file mode 100644 index 000000000..1de164029 --- /dev/null +++ b/tests/run/fors.scala @@ -0,0 +1,84 @@ +//############################################################################ +// for-comprehensions (old and new syntax) +//############################################################################ + +//############################################################################ + +object Test extends dotty.runtime.LegacyApp { + val xs = List(1, 2, 3) + val ys = List('a, 'b, 'c) + + def it = 0 until 10 + + val ar = "abc".toCharArray + + /////////////////// old syntax /////////////////// + + def testOld: Unit = { + println("\ntestOld") + + // lists + for (x <- xs) print(x + " "); println + for (x <- xs; + if x % 2 == 0) print(x + " "); println + for {x <- xs + if x % 2 == 0} print(x + " "); println + var n = 0 + for (_ <- xs) n += 1; println(n) + for ((x, y) <- xs zip ys) print(x + " "); println + for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println + + // iterators + for (x <- it) print(x + " "); println + for (x <- it; + if x % 2 == 0) print(x + " "); println + for {x <- it + if x % 2 == 0} print(x + " "); println + + // arrays + for (x <- ar) print(x + " "); println + for (x <- ar; + if x.toInt > 97) print(x + " "); println + for {x <- ar + if x.toInt > 97} print(x + " "); println + + } + + /////////////////// new syntax /////////////////// + + def testNew: Unit = { + println("\ntestNew") + + // lists + var n = 0 + for (_ <- xs) n += 1; println(n) + for ((x, y) <- xs zip ys) print(x + " "); println + for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println + + // iterators + for (x <- it) print(x + " "); println + for (x <- it if x % 2 == 0) print(x + " "); println + for (x <- it; if x % 2 == 0) print(x + " "); println + for (x <- it; + if x % 2 == 0) print(x + " "); println + for (x <- it + if x % 2 == 0) print(x + " "); println + for {x <- it + if x % 2 == 0} print(x + " "); println + for (x <- it; + y = 2 + if x % y == 0) print(x + " "); println + for {x <- it + y = 2 + if x % y == 0} print(x + " "); println + + // arrays + for (x <- ar) print(x + " "); println + + } + + //////////////////////////////////////////////////// + + testOld + testNew +} diff --git a/tests/run/forvaleq.check b/tests/run/forvaleq.check new file mode 100644 index 000000000..ec57719cb --- /dev/null +++ b/tests/run/forvaleq.check @@ -0,0 +1,5 @@ +List(2, 6, 10, 14, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38) +List(2, 6, 10, 14, 18, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2) +List(2, 6, 10, 14, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38) +List(2, 6, 10, 14, 18, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2) +called 20 times diff --git a/tests/run/forvaleq.scala b/tests/run/forvaleq.scala new file mode 100644 index 000000000..dac3234a6 --- /dev/null +++ b/tests/run/forvaleq.scala @@ -0,0 +1,91 @@ +// test "foo = expr" clauses in for comprehensions + +import scala.collection.immutable.Queue +import scala.{List=>L} + +object Test { + // redefine some symbols to make it extra hard + class List + class Tuple2 + def List[A](as: A*) = 5 + + def firstDigit(x: Int): Int = + x match { + case 0 => 0 + case _ if (x<0) => firstDigit(-x) + case _ if (x<10) => x + case _ => firstDigit(x / 10) + } + + + { + // a basic test case + + val input = L.range(0,20) + val oddFirstTimesTwo = + for {x <- input + xf = firstDigit(x) + if xf % 2 == 1} + yield x*2 + println(oddFirstTimesTwo) + } + + { + // a test case with patterns + + val input = L.range(0, 20) + val oddFirstTimesTwo = + for {x <- input + xf = firstDigit(x) + yf = x - firstDigit(x) / 10 + (a, b) = (xf - yf, xf + yf) + if xf % 2 == 1} + yield a + b + println(oddFirstTimesTwo) + } + + { + // make sure it works on non-Ls + + // val input: Queue = Queue.Empty[int].incl(L.range(0,20)) + val input = L.range(0, 20).iterator + val oddFirstTimesTwo = + for {x <- input + xf = firstDigit(x) + if xf % 2 == 1} + yield x*2 + println(oddFirstTimesTwo.toList) + } + + { + // yield the computed value + + val input = L.range(0,20) + val oddFirstTimesTwo = + for {x <- input + xf = firstDigit(x) + if xf % 2 == 1} + yield xf*2 + println(oddFirstTimesTwo) + } + + { + // make sure the function is only called once + var count: Int = 0 + + def fdct(x: Int) = { + count += 1 + firstDigit(x) + } + + val input = L.range(0,20) + for {x <- input + xf = fdct(x) + if xf % 2 == 1} + yield xf + + println("called " + count + " times") + } + + def main(args: Array[String]): Unit = {} +} diff --git a/tests/run/groupby.scala b/tests/run/groupby.scala new file mode 100644 index 000000000..9a33ae289 --- /dev/null +++ b/tests/run/groupby.scala @@ -0,0 +1,18 @@ + + + +// Fixes #3422 +object Test { + + def main(args: Array[String]): Unit = { + val arr = Array.range(0,10) + val map = arr groupBy (_%2) + val v1 = map(0) + val v2 = map(0) + // this should hold, of course, assuming also that group by returns a regular + // map implementation, and does nothing fancy - and it should return just a + // hash map by default. + assert(v1 eq v2) + } + +} diff --git a/tests/run/hashset.check b/tests/run/hashset.check new file mode 100644 index 000000000..9542a1ff4 --- /dev/null +++ b/tests/run/hashset.check @@ -0,0 +1,26 @@ +*** HashSet primitives +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 + +*** HashSet Strings with null +null true +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,10,11,12,13,14,15,16,17,18,19,2,3,4,5,6,7,8,9,null +null false +0 false,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true + +*** ParHashSet primitives +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 + +*** ParHashSet Strings with null +null true +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,10,11,12,13,14,15,16,17,18,19,2,3,4,5,6,7,8,9,null +null false +0 false,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true + diff --git a/tests/run/hashset.scala b/tests/run/hashset.scala new file mode 100644 index 000000000..0c305142b --- /dev/null +++ b/tests/run/hashset.scala @@ -0,0 +1,48 @@ +import scala.collection.generic.{Growable, Shrinkable} +import scala.collection.GenSet +import scala.collection.mutable.FlatHashTable +import scala.collection.mutable.HashSet +import scala.collection.parallel.mutable.ParHashSet + +object Test extends dotty.runtime.LegacyApp { + test(new Creator{ + def create[A] = new HashSet[A] + def hashSetType = "HashSet" + }) + + test(new Creator{ + def create[A] = new ParHashSet[A] + def hashSetType = "ParHashSet" + }) + + + def test(creator : Creator): Unit = { + println("*** " + creator.hashSetType + " primitives") + val h1 = creator.create[Int] + for (i <- 0 until 20) h1 += i + println((for (i <- 0 until 20) yield i + " " + (h1 contains i)).toList.sorted mkString(",")) + println((for (i <- 20 until 40) yield i + " " + (h1 contains i)).toList.sorted mkString(",")) + println(h1.toList.sorted mkString ",") + println + + println("*** " + creator.hashSetType + " Strings with null") + val h2 = creator.create[String] + h2 += null + for (i <- 0 until 20) h2 += "" + i + println("null " + (h2 contains null)) + println((for (i <- 0 until 20) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println((for (i <- 20 until 40) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println((h2.toList map {x => "" + x}).sorted mkString ",") + + h2 -= null + h2 -= "" + 0 + println("null " + (h2 contains null)) + println((for (i <- 0 until 20) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println + } + + trait Creator { + def create[A] : GenSet[A] with Cloneable with FlatHashTable[A] with Growable[A] with Shrinkable[A] + def hashSetType : String + } +} diff --git a/tests/run/hashsetremove.check b/tests/run/hashsetremove.check new file mode 100644 index 000000000..8de982689 --- /dev/null +++ b/tests/run/hashsetremove.check @@ -0,0 +1,6 @@ +remove 0 should be false, was false +contains 1 should be true, was true +remove 1 should be true, was true +contains 1 should be false, was false +remove 1 should be false, was false +contains 1 should be false, was false diff --git a/tests/run/hashsetremove.scala b/tests/run/hashsetremove.scala new file mode 100644 index 000000000..e47269a96 --- /dev/null +++ b/tests/run/hashsetremove.scala @@ -0,0 +1,13 @@ +import scala.collection.mutable.HashSet + + +object Test extends dotty.runtime.LegacyApp { + val h = new HashSet[Int] + h += 1 + println(s"remove 0 should be false, was ${h remove 0}") + println(s"contains 1 should be true, was ${h contains 1}") + println(s"remove 1 should be true, was ${h remove 1}") + println(s"contains 1 should be false, was ${h contains 1}") + println(s"remove 1 should be false, was ${h remove 1}") + println(s"contains 1 should be false, was ${h contains 1}") + } diff --git a/tests/run/implicitclasses.scala b/tests/run/implicitclasses.scala new file mode 100644 index 000000000..fefb69591 --- /dev/null +++ b/tests/run/implicitclasses.scala @@ -0,0 +1,10 @@ +object Test extends dotty.runtime.LegacyApp { + + implicit class C(s: String) { + def nElems = s.length + } + + assert("abc".nElems == 3) + +} + diff --git a/tests/run/imports.check b/tests/run/imports.check new file mode 100644 index 000000000..56f5e23d4 --- /dev/null +++ b/tests/run/imports.check @@ -0,0 +1,12 @@ +In C_ico, v_ico .toString() returns C_ico -> ok +In C_ico, field .toString() returns C_ico -> ok +In C_ico, method.toString() returns C_ico -> ok + +In C_ioc, v_ioc .toString() returns C_ioc -> ok +In C_ioc, field .toString() returns C_ioc -> ok +In C_ioc, method.toString() returns C_ioc -> ok + +In C_oic, v_oic .toString() returns C_oic -> ok +In C_oic, field .toString() returns C_oic -> ok +In C_oic, method.toString() returns C_oic -> ok + diff --git a/tests/run/imports.scala b/tests/run/imports.scala new file mode 100644 index 000000000..4bdbef9f9 --- /dev/null +++ b/tests/run/imports.scala @@ -0,0 +1,96 @@ +//############################################################################ +// Import statements +//############################################################################ + +//############################################################################ + +object checker { + def check(location: String, what: String, value: Any): Unit = { + Console.print("In " + location + ", " + what + ".toString() returns "); + Console.flush; + val string: String = if (value == null) "null" else value.toString(); + val test = if (string == location) "ok" else "KO"; + Console.println(string + " -> " + test); + Console.flush; + } +} + +import checker.check; + +//############################################################################ + +//import o_ico.v_ico; + +class C_ico() { + o_ico.v_ico = this; + import o_ico.v_ico; + override def toString(): String = "C_ico"; + def method: C_ico = v_ico; + val field: C_ico = v_ico; + + check("C_ico", "v_ico ", v_ico); + check("C_ico", "field ", field); + check("C_ico", "method", method); + Console.println; +} + +object o_ico { + var v_ico: C_ico = null; + new C_ico(); +} + +//############################################################################ + +object o_ioc { + var v_ioc: C_ioc = null; + new C_ioc(); +} + +import o_ioc.v_ioc; + + +class C_ioc() { + o_ioc.v_ioc = this; + override def toString(): String = "C_ioc"; + def method: C_ioc = v_ioc; + val field: C_ioc = v_ioc; + + check("C_ioc", "v_ioc ", v_ioc); + check("C_ioc", "field ", field); + check("C_ioc", "method", method); + Console.println; +} + +//############################################################################ + +object o_oic { + var v_oic: C_oic = null; + new C_oic(); +} + +import o_oic.v_oic; + +class C_oic() { + o_oic.v_oic = this; + override def toString(): String = "C_oic"; + def method: C_oic = v_oic; + val field: C_oic = v_oic; + + check("C_oic", "v_oic ", v_oic); + check("C_oic", "field ", field); + check("C_oic", "method", method); + Console.println; +} + +//############################################################################ + +object Test { + def main(args: Array[String]): Unit = { + o_ico; + o_ioc; + o_oic; + () + } +} + +//############################################################################ diff --git a/tests/run/indexedSeq-apply.check b/tests/run/indexedSeq-apply.check new file mode 100644 index 000000000..d86bac9de --- /dev/null +++ b/tests/run/indexedSeq-apply.check @@ -0,0 +1 @@ +OK diff --git a/tests/run/indexedSeq-apply.scala b/tests/run/indexedSeq-apply.scala new file mode 100644 index 000000000..455218d2c --- /dev/null +++ b/tests/run/indexedSeq-apply.scala @@ -0,0 +1,15 @@ +object Test extends dotty.runtime.LegacyApp { + val empty = IndexedSeq() + assert(empty.isEmpty) + + val single = IndexedSeq(1) + assert(List(1) == single.toList) + + val two = IndexedSeq("a", "b") + assert("a" == two.head) + assert("b" == two.apply(1)) + + println("OK") +} + +// vim: set ts=2 sw=2 et: diff --git a/tests/run/indexedSeq.scala b/tests/run/indexedSeq.scala new file mode 100644 index 000000000..b1a2b1bc6 --- /dev/null +++ b/tests/run/indexedSeq.scala @@ -0,0 +1,11 @@ +object Test { + import scala.collection.immutable + + def checkIdentity[A](xs: immutable.IndexedSeq[A]) = assert(xs.toIndexedSeq eq xs) + + def main(args: Array[String]): Unit = { + def r = 1 to 10 + checkIdentity(immutable.Vector(r: _*)) + checkIdentity(r.toIndexedSeq) + } +} diff --git a/tests/run/infiniteloop.check b/tests/run/infiniteloop.check new file mode 100644 index 000000000..6f8cf6e4d --- /dev/null +++ b/tests/run/infiniteloop.check @@ -0,0 +1 @@ +Stream(512, 256, 128, 64, 32, 16, 8, 4, 2, 1) diff --git a/tests/run/infiniteloop.scala b/tests/run/infiniteloop.scala new file mode 100644 index 000000000..2668d5b00 --- /dev/null +++ b/tests/run/infiniteloop.scala @@ -0,0 +1,13 @@ +/** Tests the optimiser (not to loop on 'reverse'). */ + +object Test extends dotty.runtime.LegacyApp { + def foo: Unit = { + val s3 = Stream.range(1, 1000) //100000 (ticket #153: Stackoverflow) + + // ticket #153 + def powers(x: Int) = if ((x&(x-1)) == 0) Some(x) else None + println(s3.flatMap(powers).reverse) + } + + foo +} diff --git a/tests/run/inliner-infer.check b/tests/run/inliner-infer.check new file mode 100644 index 000000000..d702bd602 --- /dev/null +++ b/tests/run/inliner-infer.check @@ -0,0 +1,2 @@ +non-empty +empty diff --git a/tests/run/inliner-infer.scala b/tests/run/inliner-infer.scala new file mode 100644 index 000000000..6a2e47194 --- /dev/null +++ b/tests/run/inliner-infer.scala @@ -0,0 +1,28 @@ + + +/** Test that the inliner is not inferring that `xs' is + * always Nil, removing the call to isEmpty. + */ +object Test extends dotty.runtime.LegacyApp { + + @annotation.tailrec + def walk(xs: MyList): Unit = { + if (xs.isEmpty) + println("empty") + else { + println("non-empty") + walk(MyNil) + } + } + + walk(new MyList) +} + +class MyList { + def isEmpty = false +} + +object MyNil extends MyList { + override def isEmpty = true +} + diff --git a/tests/run/interop_classtags_are_classmanifests.check b/tests/run/interop_classtags_are_classmanifests.check new file mode 100644 index 000000000..5a8fc2b78 --- /dev/null +++ b/tests/run/interop_classtags_are_classmanifests.check @@ -0,0 +1,3 @@ +Int +java.lang.String +Array[int] diff --git a/tests/run/interop_classtags_are_classmanifests.scala b/tests/run/interop_classtags_are_classmanifests.scala new file mode 100644 index 000000000..77b6bbbab --- /dev/null +++ b/tests/run/interop_classtags_are_classmanifests.scala @@ -0,0 +1,12 @@ +import scala.reflect.ClassTag + +@deprecated("Suppress warnings", since="2.11") +object Test extends dotty.runtime.LegacyApp { + def classTagIsClassManifest[T: ClassTag] = { + println(classManifest[T]) + } + + classTagIsClassManifest[Int] + classTagIsClassManifest[String] + classTagIsClassManifest[Array[Int]] +} diff --git a/tests/run/interpolationArgs.check b/tests/run/interpolationArgs.check new file mode 100644 index 000000000..983214cbe --- /dev/null +++ b/tests/run/interpolationArgs.check @@ -0,0 +1,2 @@ +java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 3 parts +java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 1 parts diff --git a/tests/run/interpolationArgs.scala b/tests/run/interpolationArgs.scala new file mode 100644 index 000000000..f4e41557a --- /dev/null +++ b/tests/run/interpolationArgs.scala @@ -0,0 +1,5 @@ +object Test extends dotty.runtime.LegacyApp { + try { scala.StringContext("p1", "p2", "p3").s("e1") } catch { case ex: Throwable => println(ex) } + try { scala.StringContext("p1").s("e1") } catch { case ex: Throwable => println(ex) } +} + diff --git a/tests/run/intmap.scala b/tests/run/intmap.scala new file mode 100644 index 000000000..593714e2f --- /dev/null +++ b/tests/run/intmap.scala @@ -0,0 +1,8 @@ +object Test extends dotty.runtime.LegacyApp{ + import scala.collection.immutable.IntMap; + + val it = IntMap(8 -> 2, 11 -> 3, 1 -> 2, 7 -> 13); + + assert(it.firstKey == 1); + assert(it.lastKey == 11); +} diff --git a/tests/run/iq.check b/tests/run/iq.check new file mode 100644 index 000000000..311bf83ed --- /dev/null +++ b/tests/run/iq.check @@ -0,0 +1,16 @@ +Empty +q2: Queue(42, 0) +qa: Queue(42, 0) +qb: Queue(42, 0) +qc: Queue(42, 0) +Head: 42 +q5: Queue(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) +q5[5]: 5 +q5 == q5c: true +q5c == q5: true +q8: Queue(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) +q8 == q9: true +Elements: 1 2 3 4 5 6 7 8 9 +String: <1-2-3-4-5-6-7-8-9> +Length: 9 +Front: 1 diff --git a/tests/run/iq.scala b/tests/run/iq.scala new file mode 100644 index 000000000..e70b6e4f8 --- /dev/null +++ b/tests/run/iq.scala @@ -0,0 +1,111 @@ +/* + * Test file for immutable queues. + */ + +import scala.collection.immutable.Queue + +object iq { + def main: Unit = { + /* Create an empty queue. */ + val q: Queue[Int] = Queue.empty + + /* Test isEmpty. + * Expected: Empty + */ + if (q.isEmpty) { + Console.println("Empty") + } + + /* Test enqueing. */ + val q2 = q.enqueue(42).enqueue(0) + val qa = q :+ 42 :+ 0 + assert(q2 == qa) + + val qb = 42 +: 0 +: q + assert(q2 == qb) + val qc = 42 +: q :+ 0 + assert(q2 == qc) + + Console.println("q2: " + q2) + Console.println("qa: " + qa) + Console.println("qb: " + qb) + Console.println("qc: " + qc) + + /* Test is empty and dequeue. + * Expected: Head: 42 + */ + val q4 = + if (q2.isEmpty) { + Console.println("Empty") + q2 + } + else { + val (head, q3) = q2.dequeue + Console.println("Head: " + head) + q3 + } + + /* Test sequence enqueing. */ + val q5: Queue[Any] = q4.enqueue(List(1,2,3,4,5,6,7,8,9)) + /* Test toString. + * Expected: q5: Queue(0,1,2,3,4,5,6,7,8,9) + */ + Console.println("q5: " + q5) + /* Test apply + * Expected: q5[5]: 5 + */ + Console.println("q5[5]: " + q5(5)) + + val q5c: Queue[Int] = Queue.empty.enqueue(List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)) + + /* Testing == + * Expected: q5 == q9: true + * q9 == q5: true + */ + Console.println("q5 == q5c: " + (q5 == q5c)) + Console.println("q5c == q5: " + (q5c == q5)) + + val (_, q6) = q5.dequeue + val (_, q7) = q6.dequeue + //val q8 = q7 + 10 + 11 //deprecated + val q8 = q7.enqueue(10).enqueue(11) + /* Test dequeu + * Expected: q8: Queue(2,3,4,5,6,7,8,9,10,11) + */ + Console.println("q8: " + q8) + val q9 = Queue(2,3,4,5,6,7,8,9,10,11) + + /* Testing == + * Expected: q8 == q9: true + */ + Console.println("q8 == q9: " + (q8 == q9)) + + /* Testing elements + * Expected: Elements: 1 2 3 4 5 6 7 8 9 + */ + Console.print("Elements: "); + q6.iterator.foreach(e => Console.print(" "+ e + " ")) + Console.println; + + /* Testing mkString + * Expected: String: <1-2-3-4-5-6-7-8-9> + */ + Console.println("String: " + q6.mkString("<","-",">")) + + /* Testing length + * Expected: Length: 9 + */ + Console.println("Length: " + q6.length) + + /* Testing front + * Expected: Front: 1 + */ + Console.println("Front: " + q6.front); + } +} + +object Test { + def main(args: Array[String]): Unit = { + iq.main + } +} diff --git a/tests/run/iterator-concat.check b/tests/run/iterator-concat.check new file mode 100644 index 000000000..23835b07a --- /dev/null +++ b/tests/run/iterator-concat.check @@ -0,0 +1,4 @@ +100 +1000 +10000 +100000 diff --git a/tests/run/iterator-concat.scala b/tests/run/iterator-concat.scala new file mode 100644 index 000000000..f11363410 --- /dev/null +++ b/tests/run/iterator-concat.scala @@ -0,0 +1,15 @@ +object Test { + // Create `size` Function0s, each of which evaluates to an Iterator + // which produces 1. Then fold them over ++ to get a single iterator, + // which should sum to "size". + def mk(size: Int): Iterator[Int] = { + val closures = (1 to size).toList.map(x => (() => Iterator(1))) + closures.foldLeft(Iterator.empty: Iterator[Int])((res, f) => res ++ f()) + } + def main(args: Array[String]): Unit = { + println(mk(100).sum) + println(mk(1000).sum) + println(mk(10000).sum) + println(mk(100000).sum) + } +} diff --git a/tests/run/iterator-from.scala b/tests/run/iterator-from.scala new file mode 100644 index 000000000..4f403680c --- /dev/null +++ b/tests/run/iterator-from.scala @@ -0,0 +1,71 @@ +/* This file tests iteratorFrom, keysIteratorFrom, and valueIteratorFrom on various sorted sets and maps + * filter: inliner warnings; re-run with -Yinline-warnings for details + */ + +import scala.util.{Random => R} +import scala.collection._ +import scala.math.Ordered + +object Test extends dotty.runtime.LegacyApp { + val maxLength = 25 + val maxKey = 50 + val maxValue = 50 + + def testSet[A <% Ordered[A]](set: SortedSet[A], list: List[A]): Unit = { + val distinctSorted = list.distinct.sorted + assertEquals("Set size wasn't the same as list sze", set.size, distinctSorted.size) + + for(key <- distinctSorted) { + val clazz = set.getClass + val iteratorFrom = (set iteratorFrom key).toList + check(clazz, list, s"set iteratorFrom $key", s"(set from $key).iterator", iteratorFrom, (set from key).iterator.toList) + check(clazz, list, s"set.iteratorFrom $key", s"distinctSorted dropWhile (_ < $key)", iteratorFrom, distinctSorted dropWhile (_ < key)) + check(clazz, list, s"set iteratorFrom $key", s"set keysIterator from $key", iteratorFrom, (set keysIteratorFrom key).toList) + } + } + + def testMap[A <% Ordered[A], B](map: SortedMap[A, B], list: List[(A, B)]): Unit = { + val distinctSorted = distinctByKey(list).sortBy(_._1) + assertEquals("Map size wasn't the same as list sze", map.size, distinctSorted.size) + + for(keyValue <- distinctSorted) { + val key = keyValue._1 + val clazz = map.getClass + val iteratorFrom = (map iteratorFrom key).toList + check(clazz, list, s"map iteratorFrom $key", s"(map from $key).iterator", iteratorFrom, (map from key).iterator.toList) + check(clazz, list, s"map iteratorFrom $key", s"distinctSorted dropWhile (_._1 < $key)", iteratorFrom, distinctSorted dropWhile (_._1 < key)) + check(clazz, list, s"map iteratorFrom $key map (_._1)", s"map keysIteratorFrom $key", iteratorFrom map (_._1), (map keysIteratorFrom key).toList) + check(clazz, list, s"map iteratorFrom $key map (_._2)", s"map valuesIteratorFrom $key", iteratorFrom map (_._2), (map valuesIteratorFrom key).toList) + } + } + + def check[A](clazz: Class[_], list: List[_], m1: String, m2: String, l1: List[A], l2: List[A]): Unit = { + assertEquals(s"$clazz: `$m1` didn't match `$m2` on list $list", l1, l2) + } + + def assertEquals[A](msg: String, x: A, y: A): Unit = { + assert(x == y, s"$msg\n1: $x\n2: $y") + } + + def distinctByKey[A,B](list: List[(A, B)]) : List[(A,B)] = list.groupBy(_._1).map(_._2.last).toList + + object Weekday extends Enumeration { + type Weekday = Value + val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value + } + + 0 until maxLength foreach {length => + val keyValues = (0 until length map {_ => (R nextInt maxKey, R nextInt maxValue)}).toList + val keys = keyValues map (_._2) + testSet(immutable.BitSet(keys:_*), keys) + testSet(immutable.TreeSet(keys:_*), keys) + testSet(mutable.TreeSet(keys:_*), keys) + val days = keys map {n => Weekday(n % Weekday.values.size)} + testSet(Weekday.ValueSet(days:_*), days) + + val treeMap = immutable.TreeMap(keyValues:_*) + testMap(treeMap, keyValues) + testMap(treeMap.filterKeys(_ % 2 == 0), keyValues filter (_._1 % 2 == 0)) + testMap(treeMap mapValues (_ + 1), keyValues map {case (k,v) => (k, v + 1)}) + } +} diff --git a/tests/run/iterator-iterate-lazy.scala b/tests/run/iterator-iterate-lazy.scala new file mode 100644 index 000000000..92b170062 --- /dev/null +++ b/tests/run/iterator-iterate-lazy.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + Iterator.iterate((1 to 5).toList)(_.tail).takeWhile(_.nonEmpty).map(_.head).toList + } +} diff --git a/tests/run/iterator3444.scala b/tests/run/iterator3444.scala new file mode 100644 index 000000000..0a8f94291 --- /dev/null +++ b/tests/run/iterator3444.scala @@ -0,0 +1,23 @@ + + +// ticked #3444 +object Test { + + def main(args: Array[String]): Unit = { + val it = (1 to 12).toSeq.iterator + + assert(it.next == 1) + assert(it.take(2).toList == List(2, 3)) + + val jt = (4 to 12).toSeq.iterator + assert(jt.next == 4) + assert(jt.drop(5).toList == List(10, 11, 12)) + + val kt = (1 until 10).toSeq.iterator + assert(kt.drop(50).toList == Nil) + + val mt = (1 until 5).toSeq.iterator + assert(mt.take(50).toList == List(1, 2, 3, 4)) + } + +} diff --git a/tests/run/iterators.check b/tests/run/iterators.check new file mode 100644 index 000000000..bb139c161 --- /dev/null +++ b/tests/run/iterators.check @@ -0,0 +1,13 @@ +test check_from was successful +test check_range was successful +test check_range2 was successful +test check_range3 was successful +test check_take was successful +test check_drop was successful +test check_foreach was successful +test check_forall was successful +test check_fromArray was successful +test check_toSeq was successful +test check_indexOf was successful +test check_findIndexOf was successful + diff --git a/tests/run/iterators.scala b/tests/run/iterators.scala new file mode 100644 index 000000000..e2a97ec7a --- /dev/null +++ b/tests/run/iterators.scala @@ -0,0 +1,136 @@ +//############################################################################ +// Iterators +//############################################################################ + +//############################################################################ + +import scala.language.postfixOps + +object Test { + + def check_from: Int = { + val it1 = Iterator.from(-1) + val it2 = Iterator.from(0, -1) + it1.next + it2.next + } + + def check_range: Int = { + val xs1 = Iterator.range(0, 10, 2) toList; + val xs2 = Iterator.range(0, 10, -2) toList; + val xs3 = Iterator.range(10, 0, -2) toList; + val xs4 = Iterator.range(10, 0, 2) toList; + val xs5 = Iterator.range(0, 10, 11) toList; + xs1.length + xs2.length + xs3.length + xs4.length + xs5.length + } + + def check_range2: Int = { + val r1start = 0 + val r1end = 10 + val r1step = 1 + val r1 = Iterator.range(r1start, r1end, r1step) toList; + val r2 = Iterator.range(r1start, r1end, r1step + 1) toList; + val r3 = Iterator.range(r1end, r1start, -r1step) toList; + val r4 = Iterator.range(0, 10, 11) toList; + // 10 + 5 + 10 + 1 + r1.length + r2.length + r3.length + r4.length + } + + def check_range3: Int = { + def trues(xs: List[Boolean]) = xs.foldLeft(0)((a, b) => if (b) a+1 else a) + val r1 = Iterator.range(0, 10) + val xs1 = List(r1 contains 5, r1 contains 6) + val r2a = Iterator.range(0, 10, 2) + val r2b = Iterator.range(0, 10, 2) + val xs2 = List(r2a contains 5, r2b contains 6) + val r3 = Iterator.range(0, 10, 11) + val xs3 = List(r3 contains 5, r3 contains 6) + // 2 + 1 + 0 + trues(xs1) + trues(xs2) + trues(xs3) + } + + def check_take: Int = { + val it1 = Iterator.from(0) + val xs1 = it1 take 10 toList; + xs1.length + } + + def check_drop: Int = { + val it1 = Iterator.from(0) + val it2 = it1 map { 2 * _ } + val n1 = it1 drop 2 next + val n2 = it2 drop 2 next; + n1 + n2 + } + + def check_foreach: Int = { + val it1 = Iterator.from(0) take 20 + var n = 0 + it1 foreach { n += _ } + n + } + + def check_forall: Int = { + val it1 = Iterator.from(0) + val it2 = Iterator.from(1) + 0 + } + + def check_fromArray: Int = { // ticket #429 + val a = List(1, 2, 3, 4).toArray + var xs0 = a.iterator.toList; + var xs1 = a.slice(0, 1).iterator.toList; + var xs2 = a.slice(0, 2).iterator.toList; + var xs3 = a.slice(0, 3).iterator.toList; + var xs4 = a.slice(0, 4).iterator.toList; + xs0.length + xs1.length + xs2.length + xs3.length + xs4.length + } + + def check_toSeq: String = + List(1, 2, 3, 4, 5).iterator.toSeq.mkString("x") + + def check_indexOf: String = { + val i = List(1, 2, 3, 4, 5).indexOf(4) + val j = List(1, 2, 3, 4, 5).indexOf(16) + "" + i + "x" + j + } + + def check_findIndexOf: String = { + val i = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 4 } + val j = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 16 } + "" + i + "x" + j + } + + def check_success[A](name: String, closure: => A, expected: A): Unit = { + print("test " + name) + try { + val actual: A = closure + if (actual == expected) + print(" was successful") + else + print(" failed: expected "+ expected +", found "+ actual) + } + catch { + case exception: Throwable => + print(" raised exception " + exception) + } + println() + } + + def main(args: Array[String]): Unit = { + check_success("check_from", check_from, -1) + check_success("check_range", check_range, 11) + check_success("check_range2", check_range2, 26) + check_success("check_range3", check_range3, 3) + check_success("check_take", check_take, 10) + check_success("check_drop", check_drop, 12) + check_success("check_foreach", check_foreach, 190) + check_success("check_forall", check_forall, 0) + check_success("check_fromArray",check_fromArray, 14) + check_success("check_toSeq", check_toSeq, "1x2x3x4x5") + check_success("check_indexOf", check_indexOf, "3x-1") + check_success("check_findIndexOf", check_findIndexOf, "3x-1") + println() + } +} + +//############################################################################ diff --git a/tests/run/kmpSliceSearch.check b/tests/run/kmpSliceSearch.check new file mode 100644 index 000000000..9ce0eba5a --- /dev/null +++ b/tests/run/kmpSliceSearch.check @@ -0,0 +1,4 @@ +6 6 +5 10 +-1 -1 +4 4 diff --git a/tests/run/kmpSliceSearch.scala b/tests/run/kmpSliceSearch.scala new file mode 100644 index 000000000..4d582bb1c --- /dev/null +++ b/tests/run/kmpSliceSearch.scala @@ -0,0 +1,60 @@ +object Test { + import scala.collection.SeqLike + def slowSearch[A](xs: Seq[A], ys: Seq[A], start: Int = 0): Int = { + if (xs startsWith ys) start + else if (xs.isEmpty) -1 + else slowSearch(xs.tail, ys, start+1) + } + def bkwSlowSearch[A](xs: Seq[A], ys: Seq[A]) = { + val i = slowSearch(xs.reverse, ys.reverse) + if (i<0) i + else xs.length - ys.length - i + } + def main(args: Array[String]): Unit = { + val rng = new scala.util.Random(java.lang.Integer.parseInt("kmp",36)) + + // Make sure we agree with naive implementation + for (h <- Array(2,5,1000)) { + for (i <- 0 to 100) { + for (j <- 0 to 10) { + val xs = (0 to j).map(_ => (rng.nextInt & 0x7FFFFFFF) % h) + val xsa = xs.toArray + val xsv = Vector() ++ xs + val xsl = xs.toList + val xss = Vector[Seq[Int]](xs,xsa,xsv,xsl) + for (k <- 0 to 5) { + val ys = (0 to k).map(_ => (rng.nextInt & 0x7FFFFFFF) % h) + val ysa = ys.toArray + val ysv = Vector() ++ ys + val ysl = ys.toList + val yss = Vector[Seq[Int]](ys,ysa,ysv,ysl) + val fwd_slow = slowSearch(xs,ys) + val bkw_slow = bkwSlowSearch(xs,ys) + val fwd_fast = xss.flatMap(xs => yss.map(ys => SeqLike.indexOf(xs,0,xs.length,ys,0,ys.length,0))) + val bkw_fast = xss.flatMap(xs => yss.map(ys => SeqLike.lastIndexOf(xs,0,xs.length,ys,0,ys.length,xs.length))) + assert(fwd_fast.forall(_ == fwd_slow)) + assert(bkw_fast.forall(_ == bkw_slow)) + } + } + } + } + + // Check performance^Wcorrectness of common small test cases + val haystacks = List[Seq[Int]]( + Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), + Vector(99,2,99,99,2,99,99,99,2,99,99,99,99,2), + List(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + 1 to 15 + ) + val needles = List[Seq[Int]]( + Array(7,8,9,10), + Vector(99,99,99), + List(1,1,1,1,1,2), + 5 to 9 + ) + (haystacks zip needles) foreach { + case (hay, nee) => + println(hay.indexOfSlice(nee,2) + " " + hay.lastIndexOfSlice(nee,13)) + } + } +} diff --git a/tests/run/lazy-override-run.check b/tests/run/lazy-override-run.check new file mode 100644 index 000000000..a8f658d7b --- /dev/null +++ b/tests/run/lazy-override-run.check @@ -0,0 +1,3 @@ +a.x=/*A.x*/2 +b.x=/*B.x*/3 +b.z=/*B.z/3 diff --git a/tests/run/lazy-override-run.scala b/tests/run/lazy-override-run.scala new file mode 100644 index 000000000..3e00f31ef --- /dev/null +++ b/tests/run/lazy-override-run.scala @@ -0,0 +1,26 @@ +class A { + lazy val x: Int = { print("/*A.x*/"); 2 } + lazy val y: Int = { print("/*A.y*/"); 2 } + lazy val z: Int = { print("/*A.z*/"); 2 } +} + +class B extends A { + override lazy val x: Int = { print("/*B.x*/"); 3 } + override lazy val y: Int = { print("/*B.y*/"); 3 } + override lazy val z: Int = { print("/*B.z/"); 3 } +} + + + + +object Test extends dotty.runtime.LegacyApp { + val a = new A + print("a.x=") + println(a.x) + + val b = new B + print("b.x=") + println(b.x) + print("b.z=") + println(b.z) +} diff --git a/tests/run/list_map.scala b/tests/run/list_map.scala new file mode 100755 index 000000000..59acf09c6 --- /dev/null +++ b/tests/run/list_map.scala @@ -0,0 +1,26 @@ +import collection.immutable.ListMap + +object Test { + def testImmutableMinus(): Unit = { + val empty = ListMap.empty[Int, Int] + + val m0 = ListMap(1 -> 1, 2 -> 2) + val m1 = m0 - 3 + assert (m1 eq m0) + val m2 = m0 - 1 + assert (m2.size == 1) + val m3 = m2 - 2 + assert (m3 eq empty) + + val m4 = ListMap(1 -> 1, 2 -> 2, 3 -> 3) + val m5 = m4 - 1 + assert (m5 == ListMap(2 -> 2, 3 -> 3)) + assert (m5.toList == (2, 2)::(3, 3)::Nil) + + assert ((empty - 1) eq empty) + } + + def main(args: Array[String]): Unit = { + testImmutableMinus() + } +} diff --git a/tests/run/lists-run.scala b/tests/run/lists-run.scala new file mode 100644 index 000000000..713b19659 --- /dev/null +++ b/tests/run/lists-run.scala @@ -0,0 +1,187 @@ +/** Test the Scala implementation of class <code>scala.List</code>. + * + * @author Stephane Micheloud + */ +import scala.language.postfixOps + +object Test { + def main(args: Array[String]): Unit = { + Test_multiset.run() // multiset operations: union, intersect, diff + Test1.run() //count, exists, filter, .. + Test2.run() //#468 + Test3.run() //#1691 + Test4.run() //#1721 + Test5.run() + } +} + +object Test_multiset { + def run(): Unit = { + def isSubListOf[A](thiz: List[A], that: List[A]): Boolean = + thiz forall (that contains _) + val xs = List(1, 1, 2) + val ys = List(1, 2, 2, 3) + assert(List(1, 1, 2, 1, 2, 2, 3) == (xs union ys), "xs_union_ys") + assert(List(1, 2, 2, 3, 1, 1, 2) == (ys union xs), "ys_union_xs") + assert(List(1, 2) == (xs intersect ys), "xs_intersect_ys") + assert(List(1, 2) == (ys intersect xs), "ys_intersect_xs") + assert(List(1) == (xs diff ys), "xs_diff_ys") + assert(List(2, 3) == (ys diff xs), "ys_diff_xs") + assert(isSubListOf(xs filterNot (ys contains), xs diff ys), "xs_subset_ys") + + val zs = List(0, 1, 1, 2, 2, 2) + assert(List(0, 1, 1, 2, 2, 2, 1, 2, 2, 3) == (zs union ys), "zs_union_ys") + assert(List(1, 2, 2, 3, 0, 1, 1, 2, 2, 2) == (ys union zs), "ys_union_zs") + assert(List(1, 2, 2) == (zs intersect ys), "zs_intersect_ys") + assert(List(1, 2, 2) == (ys intersect zs), "ys_intersect_zs") + assert(List(0, 1, 2) == (zs diff ys), "zs_diff_ys") + assert(List(3) == (ys diff zs), "ys_diff_zs") + assert(isSubListOf(zs filterNot (ys contains), zs diff ys), "xs_subset_ys") + + val ws = List(2) + assert(List(2, 1, 2, 2, 3) == (ws union ys), "ws_union_ys") + assert(List(1, 2, 2, 3, 2) == (ys union ws), "ys_union_ws") + assert(List(2) == (ws intersect ys), "ws_intersect_ys") + assert(List(2) == (ys intersect ws), "ys_intersect_ws") + assert(List() == (ws diff ys), "ws_diff_ys") + assert(List(1, 2, 3) == (ys diff ws), "ys_diff_ws") + assert(isSubListOf(ws filterNot (ys contains), ws diff ys), "ws_subset_ys") + + val vs = List(3, 2, 2, 1) + assert(List(1, 1, 2, 3, 2, 2, 1) == (xs union vs), "xs_union_vs") + assert(List(3, 2, 2, 1, 1, 1, 2) == (vs union xs), "vs_union_xs") + assert(List(1, 2) == (xs intersect vs), "xs_intersect_vs") + assert(List(2, 1) == (vs intersect xs), "vs_intersect_xs") + assert(List(1) == (xs diff vs), "xs_diff_vs") + assert(List(3, 2) == (vs diff xs), "vs_diff_xs") + assert(isSubListOf(xs filterNot (vs contains), xs diff vs), "xs_subset_vs") + + // tests adapted from Thomas Jung + assert({ + def sort(zs: List[Int]) = zs sortWith ( _ > _ ) + sort(xs intersect ys) == sort(ys intersect xs) + }, "be symmetric after sorting") + assert({ + def cardinality[A](zs: List[A], e: A): Int = zs count (e == _) + val intersection = xs intersect ys + xs forall (e => cardinality(intersection, e) == (cardinality(xs, e) +min cardinality(ys, e))) + }, "obey min cardinality") + assert({ + val intersection = xs intersect ys + val unconsumed = xs.foldLeft(intersection){(rest, e) => + if (! rest.isEmpty && e == rest.head) rest.tail else rest + } + unconsumed.isEmpty + }, "maintain order") + assert(xs == (xs intersect xs), + "has the list as again intersection") + } +} + +object Test1 { + def run(): Unit = { + val xs1 = List(1, 2, 3) + val xs2 = List('a', 'b') + val xs3 = List(List(1, 2), List(4, 5)) + val xs4 = List(2, 4, 6, 8) + val xs5 = List(List(3, 4), List(3), List(4, 5)) + + { + val n1 = xs1 count { e => e % 2 != 0 } + val n2 = xs4 count { e => e < 5 } + assert(4 == (n1 + n2), "check_count") + } + { + val b1 = xs1 exists { e => e % 2 == 0 } + val b2 = xs4 exists { e => e == 5 } + assert(!(b1 & b2), "check_exists") + } + { + val ys1 = xs1 filter { e => e % 2 == 0 } + val ys2 = xs4 filter { e => e < 5 } + assert(3 == ys1.length + ys2.length, "check_filter") + } + { + val n1 = xs1.foldLeft(0)((e1, e2) => e1 + e2) + val ys1 = xs4.foldLeft(List[Int]())((e1, e2) => e2 :: e1) + assert(10 == n1 + ys1.length, "check_foldLeft") + } + { + val b1 = xs1 forall { e => e < 10} + val b2 = xs4 forall { e => e % 2 == 0 } + assert(b1 & b2, "check_forall") + } + { + val ys1 = xs1 filterNot { e => e % 2 != 0 } + val ys2 = xs4 filterNot { e => e < 5 } + assert(3 == ys1.length + ys2.length, "check_remove") + } + { + val ys1 = xs1 zip xs2 + val ys2 = xs1 zip xs3 + assert(4 == ys1.length + ys2.length, "check_zip") + } + { + val ys1 = xs1.zipAll(xs2, 0, '_') + val ys2 = xs2.zipAll(xs1, '_', 0) + val ys3 = xs1.zipAll(xs3, 0, List(-1)) + assert(9 == ys1.length + ys2.length + ys3.length, "check_zipAll") + } + } +} + +object Test2 { + def run(): Unit = { + val xs1 = List(1, 2, 3) + val xs2 = List(0) + + val ys1 = xs1 ::: List(4) + assert(List(1, 2, 3, 4) == ys1, "check_:::") + + val ys2 = ys1 filterNot (_ == 4) + assert(xs1 == ys2, "check_-") + + val n2 = (xs1 ++ ys1).length + val n3 = (xs1 ++ Nil).length + val n4 = (xs1 ++ ((new collection.mutable.ArrayBuffer[Int]) += 0)).length + assert(14 == n2 + n3 + n4, "check_++") + } +} + +object Test3 { + def run(): Unit = { + try { + List.range(1, 10, 0) + } catch { + case e: IllegalArgumentException => () + case _: Throwable => throw new Error("List.range(1, 10, 0)") + } + assert(List.range(10, 0, -2) == List(10, 8, 6, 4, 2)) + } +} + +object Test4 { + def run(): Unit = { + assert(List(1,2,3).endsWith(List(2,3))) + assert(!List(1,2,3).endsWith(List(1,3))) + assert(List(1,2,3).endsWith(List())) + assert(!List(1,2,3).endsWith(List(0,1,2,3))) + assert(List(1,2,3).endsWith(List(1,2,3))) + assert(!List().endsWith(List(1,2,3))) + assert(List().endsWith(List())) + } +} + +object Test5 { + def show(xs: List[String]) = xs match { + case "foo" :: args => args.toString + case List(x) => x.toString + case Nil => "Nil" + } + def run(): Unit = { + assert(show(List()) == "Nil") + assert(show(List("a")) == "a") + assert(show(List("foo", "b")) == "List(b)") + } +} diff --git a/tests/run/longmap.scala b/tests/run/longmap.scala new file mode 100644 index 000000000..b67fc75f1 --- /dev/null +++ b/tests/run/longmap.scala @@ -0,0 +1,8 @@ +object Test extends dotty.runtime.LegacyApp{ + import scala.collection.immutable.LongMap; + + val it = LongMap(8L -> 2, 11L -> 3, 1L -> 2, 7L -> 13); + + assert(it.firstKey == 1L); + assert(it.lastKey == 11L); +} diff --git a/tests/run/mapConserve.scala b/tests/run/mapConserve.scala new file mode 100644 index 000000000..4c842b0a5 --- /dev/null +++ b/tests/run/mapConserve.scala @@ -0,0 +1,56 @@ +/* + * filter: inliner warnings; re-run with -Yinline-warnings for details + */ +import scala.annotation.tailrec +import scala.collection.mutable.ListBuffer + +object Test { + val maxListLength = 7 // up to 16, but larger is slower + var testCount = 0 + + def checkStackOverflow() = { + var xs: List[String] = Nil + for (i <- 0 until 250000) + xs = "X" :: xs + + val lowers = xs.mapConserve(_.toLowerCase) + assert(xs.mapConserve(x => x) eq xs) + } + + def checkBehaviourUnchanged(input: List[_], oldOutput: List[_], newOutput: List[_]): Unit = { + if (oldOutput eq input) + assert(newOutput eq oldOutput) + else { + assert(newOutput.head == oldOutput.head) + checkBehaviourUnchanged(input.tail, oldOutput.tail, newOutput.tail) + } + testCount += 1 + } + + var callCount = 0 + val lastHexDigit: Function1[BigInt, AnyRef] = { x: BigInt => callCount+=1; if (x < 16) x else x % 16 } + + def main(args: Array[String]): Unit = { + for (length <- 0 to maxListLength; + bitmap <- 0 until (1 << length); + data = List.range(0, length) map { x: Int => + if ((bitmap & (1 << x)) != 0) BigInt(x+16) + else BigInt(x) + }) + { + // Behaves like map with respect to == + callCount = 0 + val numUnconserved = data.reverse.dropWhile(_ < 16).length + val result = data mapConserve lastHexDigit + val mapResult = data map lastHexDigit + assert(result == mapResult) + assert((result drop numUnconserved) eq (data drop numUnconserved)) + assert(callCount == 2 * length) // map, mapConserve call transform for each element in the list + + // Behaves like existing mapConserve with respect to eq + checkBehaviourUnchanged(data, data mapConserve lastHexDigit, data mapConserve lastHexDigit) + } + + checkStackOverflow(); + } +} diff --git a/tests/run/mapValues.scala b/tests/run/mapValues.scala new file mode 100644 index 000000000..d3266bd18 --- /dev/null +++ b/tests/run/mapValues.scala @@ -0,0 +1,8 @@ +object Test { + val m = Map(1 -> 1, 2 -> 2) + val mv = (m mapValues identity) - 1 + + def main(args: Array[String]): Unit = { + assert(mv.size == 1) + } +} diff --git a/tests/run/map_java_conversions.scala b/tests/run/map_java_conversions.scala new file mode 100644 index 000000000..b7b39128c --- /dev/null +++ b/tests/run/map_java_conversions.scala @@ -0,0 +1,60 @@ + + + + + +object Test { + + def main(args: Array[String]): Unit = { + import collection.JavaConversions._ + + test(new java.util.HashMap[String, String]) + test(new java.util.Properties) + testConcMap + } + + def testConcMap: Unit = { + import collection.JavaConversions._ + + val concMap = new java.util.concurrent.ConcurrentHashMap[String, String] + + test(concMap) + val cmap = mapAsScalaConcurrentMap(concMap) + cmap.putIfAbsent("absentKey", "absentValue") + cmap.put("somekey", "somevalue") + assert(cmap.remove("somekey", "somevalue") == true) + assert(cmap.replace("absentKey", "newAbsentValue") == Some("absentValue")) + assert(cmap.replace("absentKey", "newAbsentValue", ".......") == true) + } + + def test(m: collection.mutable.Map[String, String]): Unit = { + m.clear + assert(m.size == 0) + + m.put("key", "value") + assert(m.size == 1) + + assert(m.put("key", "anotherValue") == Some("value")) + assert(m.put("key2", "value2") == None) + assert(m.size == 2) + + m += (("key3", "value3")) + assert(m.size == 3) + + m -= "key2" + assert(m.size == 2) + assert(m.nonEmpty) + assert(m.remove("key") == Some("anotherValue")) + + m.clear + for (i <- 0 until 10) m += (("key" + i, "value" + i)) + for ((k, v) <- m) assert(k.startsWith("key")) + } + +} + + + + + + diff --git a/tests/run/map_test.check b/tests/run/map_test.check new file mode 100644 index 000000000..a788c0fbc --- /dev/null +++ b/tests/run/map_test.check @@ -0,0 +1,3 @@ +0->0 1->1 2->2 3->3 4->4 5->5 6->6 7->7 8->8 9->9 10->10 11->11 12->12 13->13 14->14 15->15 16->16 17->17 18->18 19->19 20->20 21->21 22->22 23->23 24->24 25->25 26->26 27->27 28->28 29->29 30->30 31->31 32->32 33->33 34->34 35->35 36->36 37->37 38->38 39->39 40->40 41->41 42->42 666->A bigger random number 4711->A big random number +0->0 1->1 2->2 3->3 4->4 5->5 6->6 7->7 8->8 9->9 10->10 11->11 12->12 13->13 14->14 15->15 16->16 17->17 18->18 19->19 20->20 21->21 22->22 23->23 24->24 25->25 26->26 27->27 28->28 29->29 30->30 31->31 32->32 33->33 34->34 35->35 36->36 37->37 38->38 39->39 40->40 41->41 42->42 666->A bigger random number 4711->A big random number +OK diff --git a/tests/run/map_test.scala b/tests/run/map_test.scala new file mode 100644 index 000000000..947c846bd --- /dev/null +++ b/tests/run/map_test.scala @@ -0,0 +1,38 @@ +import scala.collection.immutable.{ListMap, Map, TreeMap} + +object Test extends dotty.runtime.LegacyApp { + test1() + test2() + println("OK") + + def test1(): Unit = { + val myMap: TreeMap[Int, String] = new TreeMap + test_map(myMap) + } + + def test2(): Unit = { + val myMap: ListMap[Int, String] = new ListMap + test_map(myMap) + } + + def test_map(myMap: Map[Int, String]): Unit = { + val map1 = myMap.updated(42,"The answer") + val map2 = map1.updated(17,"A small random number") + val map3 = map2.updated(666,"A bigger random number") + val map4 = map3.updated(4711,"A big random number") + map1 == myMap + ((42, "The answer")) + var i = 0 + var map = map4 + while(i < 43) { + map = map.updated(i,i.toString()) + i += 1 + } + i = 0 + while(i < 4712) { + if (map.isDefinedAt(i)) + print(i + "->" + map(i) + " "); + i += 1 + } + println("") + } +} diff --git a/tests/run/matchbytes.check b/tests/run/matchbytes.check new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/run/matchbytes.check @@ -0,0 +1 @@ +1 diff --git a/tests/run/matchbytes.scala b/tests/run/matchbytes.scala new file mode 100644 index 000000000..b4455e8f4 --- /dev/null +++ b/tests/run/matchbytes.scala @@ -0,0 +1,7 @@ +object Test extends dotty.runtime.LegacyApp{ + val x = (1 : Byte) match { + case 2 => println(2); + case 1 => println(1); + case _ => println("????"); + } +} diff --git a/tests/run/matchemptyarray.check b/tests/run/matchemptyarray.check new file mode 100644 index 000000000..815225fc6 --- /dev/null +++ b/tests/run/matchemptyarray.check @@ -0,0 +1 @@ +Array() diff --git a/tests/run/matchemptyarray.scala b/tests/run/matchemptyarray.scala new file mode 100644 index 000000000..fa56c0ed3 --- /dev/null +++ b/tests/run/matchemptyarray.scala @@ -0,0 +1,5 @@ +object Test extends dotty.runtime.LegacyApp{ + Array[String]() match { + case x@Array() => println(x.deep.toString()); + } +} diff --git a/tests/run/matchnull.check b/tests/run/matchnull.check new file mode 100644 index 000000000..64861d87d --- /dev/null +++ b/tests/run/matchnull.check @@ -0,0 +1,3 @@ +-1 +-1 +-1 diff --git a/tests/run/matchnull.scala b/tests/run/matchnull.scala new file mode 100644 index 000000000..2cc8550d4 --- /dev/null +++ b/tests/run/matchnull.scala @@ -0,0 +1,12 @@ +object Test +{ + def f1 = null match { case x: AnyRef => 1 case _ => -1 } + def f2(x: Any) = x match { case 52 => 1 ; case null => -1 ; case _ => 0 } + def f3(x: AnyRef) = x match { case x: String => 1 ; case List(_) => 0 ; case null => -1 ; case _ => -2 } + + def main(args: Array[String]): Unit = { + println(f1) + println(f2(null)) + println(f3(null)) + } +} diff --git a/tests/run/matchonseq.check b/tests/run/matchonseq.check new file mode 100644 index 000000000..3fe554095 --- /dev/null +++ b/tests/run/matchonseq.check @@ -0,0 +1,2 @@ +It worked! head=1 +It worked! last=3 diff --git a/tests/run/matchonseq.scala b/tests/run/matchonseq.scala new file mode 100644 index 000000000..99138706b --- /dev/null +++ b/tests/run/matchonseq.scala @@ -0,0 +1,8 @@ +object Test extends dotty.runtime.LegacyApp { + Vector(1,2,3) match { + case head +: tail => println("It worked! head=" + head) + } + Vector(1,2,3) match { + case init :+ last => println("It worked! last=" + last) + } +} diff --git a/tests/run/missingparams.check b/tests/run/missingparams.check new file mode 100644 index 000000000..b0047fa49 --- /dev/null +++ b/tests/run/missingparams.check @@ -0,0 +1 @@ +None diff --git a/tests/run/missingparams.scala b/tests/run/missingparams.scala new file mode 100644 index 000000000..21c9ae170 --- /dev/null +++ b/tests/run/missingparams.scala @@ -0,0 +1,21 @@ +/** Tests the optimiser. */ + +final class Foo(val x: Int) { + def filter(p: Int => Boolean) = + if (p(x)) Some(x) else None + + // test that the closure elimination is not wrongly replacing + // 'that' by 'this' + def intersect(that: Foo) = + filter { dummy => +// x // dummy + that.x > 0 + } +} + +object Test extends dotty.runtime.LegacyApp { + val foo1 = new Foo(42) + val foo2 = new Foo(-42) + + println(foo1 intersect foo2) +} diff --git a/tests/run/mixins.check b/tests/run/mixins.check new file mode 100644 index 000000000..59a2c1d3f --- /dev/null +++ b/tests/run/mixins.check @@ -0,0 +1,7 @@ +M1::B::f +M1::f M2::f M3::f +one +two +A +B +C diff --git a/tests/run/mixins.scala b/tests/run/mixins.scala new file mode 100644 index 000000000..23aec6b52 --- /dev/null +++ b/tests/run/mixins.scala @@ -0,0 +1,83 @@ +// Test 1: "super" coming from mixins + +import Console._; + +object Test1 { + class A { + def f = "A::f"; + } + + class B extends A { + override def f = "B::f"; + } + + trait M1 extends A { + override def f = "M1::" + super.f; + } + + class C extends B with M1 { + override def f = super[M1].f; + } + + def test(): Unit = { + val c = new C; + Console.println(c.f); + } +} + +// Test 2: qualified "super" inside of the host class + +object Test2 { + class M1 { + def f = "M1::f"; + } + + trait M2 { + def f = "M2::f"; + } + + trait M3 { + def f = "M3::f"; + } + + class Host extends M1 with M2 with M3 { + override def f = super[M1].f + " " + super[M2].f + " " + super[M3].f + } + + def test(): Unit = { + val h = new Host; + Console.println(h.f) + } +} + +// Test 3: mixin evaluation order (bug 120) + +object Test3 { + + class A(x: Unit, y: Unit) { + Console.println("A"); + } + + trait B { + println("B"); + } + + class C extends A({ println("one"); }, { println("two"); }) + with B { + println("C"); + } + + def test() = { + val c = new C(); + } +} + +// Main testing function + +object Test { + def main(args: Array[String]): Unit = { + Test1.test(); + Test2.test(); + Test3.test(); + } +} diff --git a/tests/run/multi-array.check b/tests/run/multi-array.check new file mode 100644 index 000000000..f163dae13 --- /dev/null +++ b/tests/run/multi-array.check @@ -0,0 +1,4 @@ +Array(1, 2, 3) +null +Array(Array(0, 0, 0), Array(0, 0, 0), Array(0, 0, 0)) +Array(Array(0, 1, 2), Array(1, 2, 3), Array(2, 3, 4)) diff --git a/tests/run/multi-array.scala b/tests/run/multi-array.scala new file mode 100644 index 000000000..ff8b8ff2e --- /dev/null +++ b/tests/run/multi-array.scala @@ -0,0 +1,14 @@ +object Test extends dotty.runtime.LegacyApp { + val a = Array(1, 2, 3) + println(a.deep.toString) + + val aaiIncomplete = new Array[Array[Array[Int]]](3) + println(aaiIncomplete(0)) + + val aaiComplete: Array[Array[Int]] = Array.ofDim[Int](3, 3) // new Array[Array[Int]](3, 3) + println(aaiComplete.deep) + for (i <- 0 until 3; j <- 0 until 3) + aaiComplete(i)(j) = i + j + println(aaiComplete.deep.toString) + assert(aaiComplete.last.last == 4) +} diff --git a/tests/run/mutable-treeset.scala b/tests/run/mutable-treeset.scala new file mode 100644 index 000000000..97dda6531 --- /dev/null +++ b/tests/run/mutable-treeset.scala @@ -0,0 +1,145 @@ +import scala.collection.mutable.TreeSet + +object Test extends dotty.runtime.LegacyApp { + val list = List(6,5,4,3,2,1,1,2,3,4,5,6,6,5,4,3,2,1) + val distinct = list.distinct + val sorted = distinct.sorted + + // sublist stuff for a single level of slicing + val min = list.min + val max = list.max + val nonlist = ((min - 10) until (max + 20) filterNot list.contains).toList + val sublist = list filter {x => x >=(min + 1) && x < max} + val distinctSublist = sublist.distinct + val subnonlist = min :: max :: nonlist + val subsorted = distinctSublist.sorted + + // subsublist for a 2nd level of slicing + val almostmin = sublist.min + val almostmax = sublist.max + val subsublist = sublist filter {x => x >=(almostmin + 1) && x < almostmax} + val distinctSubsublist = subsublist.distinct + val subsubnonlist = almostmin :: almostmax :: subnonlist + val subsubsorted = distinctSubsublist.sorted + + def testSize: Unit = { + def check(set : TreeSet[Int], list: List[Int]): Unit = { + assert(set.size == list.size, s"$set had size ${set.size} while $list had size ${list.size}") + } + + check(TreeSet[Int](), List[Int]()) + val set = TreeSet(list:_*) + check(set, distinct) + check(set.clone, distinct) + + val subset = set from (min + 1) until max + check(subset, distinctSublist) + check(subset.clone, distinctSublist) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, distinctSubsublist) + check(subsubset.clone, distinctSubsublist) + } + + def testContains: Unit = { + def check(set : TreeSet[Int], list: List[Int], nonlist: List[Int]): Unit = { + assert(list forall set.apply, s"$set did not contain all elements of $list using apply") + assert(list forall set.contains, s"$set did not contain all elements of $list using contains") + assert(!(nonlist exists set.apply), s"$set had an element from $nonlist using apply") + assert(!(nonlist exists set.contains), s"$set had an element from $nonlist using contains") + } + + val set = TreeSet(list:_*) + check(set, list, nonlist) + check(set.clone, list, nonlist) + + val subset = set from (min + 1) until max + check(subset, sublist, subnonlist) + check(subset.clone, sublist, subnonlist) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, subsublist, subsubnonlist) + check(subsubset.clone, subsublist, subsubnonlist) + } + + def testAdd: Unit = { + def check(set : TreeSet[Int], list: List[Int], nonlist: List[Int]): Unit = { + var builtList = List[Int]() + for (x <- list) { + set += x + builtList = (builtList :+ x).distinct.sorted filterNot nonlist.contains + assert(builtList forall set.apply, s"$set did not contain all elements of $builtList using apply") + assert(builtList.size == set.size, s"$set had size ${set.size} while $builtList had size ${builtList.size}") + } + assert(!(nonlist exists set.apply), s"$set had an element from $nonlist using apply") + assert(!(nonlist exists set.contains), s"$set had an element from $nonlist using contains") + } + + val set = TreeSet[Int]() + val clone = set.clone + val subset = set.clone from (min + 1) until max + val subclone = subset.clone + val subsubset = subset.clone from (almostmin + 1) until almostmax + val subsubclone = subsubset.clone + + check(set, list, nonlist) + check(clone, list, nonlist) + + check(subset, list, subnonlist) + check(subclone, list, subnonlist) + + check(subsubset, list, subsubnonlist) + check(subsubclone, list, subsubnonlist) + } + + def testRemove: Unit = { + def check(set: TreeSet[Int], sorted: List[Int]): Unit = { + var builtList = sorted + for (x <- list) { + set remove x + builtList = builtList filterNot (_ == x) + assert(builtList forall set.apply, s"$set did not contain all elements of $builtList using apply") + assert(builtList.size == set.size, s"$set had size $set.size while $builtList had size $builtList.size") + } + } + val set = TreeSet(list:_*) + val clone = set.clone + val subset = set.clone from (min + 1) until max + val subclone = subset.clone + val subsubset = subset.clone from (almostmin + 1) until almostmax + val subsubclone = subsubset.clone + + check(set, sorted) + check(clone, sorted) + + check(subset, subsorted) + check(subclone, subsorted) + + check(subsubset, subsubsorted) + check(subsubclone, subsubsorted) + } + + def testIterator: Unit = { + def check(set: TreeSet[Int], list: List[Int]): Unit = { + val it = set.iterator.toList + assert(it == list, s"$it did not equal $list") + } + val set = TreeSet(list: _*) + check(set, sorted) + check(set.clone, sorted) + + val subset = set from (min + 1) until max + check(subset, subsorted) + check(subset.clone, subsorted) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, subsubsorted) + check(subsubset.clone, subsubsorted) + } + + testSize + testContains + testAdd + testRemove + testIterator +} diff --git a/tests/run/nothingTypeDce.flags b/tests/run/nothingTypeDce.flags new file mode 100644 index 000000000..d85321ca0 --- /dev/null +++ b/tests/run/nothingTypeDce.flags @@ -0,0 +1 @@ +-target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code diff --git a/tests/run/nothingTypeDce.scala b/tests/run/nothingTypeDce.scala new file mode 100644 index 000000000..b1acb7d51 --- /dev/null +++ b/tests/run/nothingTypeDce.scala @@ -0,0 +1,63 @@ +// See comment in BCodeBodyBuilder + +// -target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code +// target enables stack map frames generation + +class C { + // can't just emit a call to ???, that returns value of type Nothing$ (not Int). + def f1: Int = ??? + + def f2: Int = throw new Error("") + + def f3(x: Boolean) = { + var y = 0 + // cannot assign an object of type Nothing$ to Int + if (x) y = ??? + else y = 1 + y + } + + def f4(x: Boolean) = { + var y = 0 + // tests that whatever is emitted after the throw is valid (what? depends on opts, presence of stack map frames) + if (x) y = throw new Error("") + else y = 1 + y + } + + def f5(x: Boolean) = { + // stack heights need to be the same. ??? looks to the jvm like returning a value of + // type Nothing$, need to drop or throw it. + println( + if (x) { ???; 10 } + else 20 + ) + } + + def f6(x: Boolean) = { + println( + if (x) { throw new Error(""); 10 } + else 20 + ) + } + + def f7(x: Boolean) = { + println( + if (x) throw new Error("") + else 20 + ) + } + + def f8(x: Boolean) = { + println( + if (x) throw new Error("") + else 20 + ) + } +} + +object Test extends dotty.runtime.LegacyApp { + // creating an instance is enough to trigger bytecode verification for all methods, + // no need to invoke the methods. + new C() +} diff --git a/tests/run/nothingTypeNoOpt.flags b/tests/run/nothingTypeNoOpt.flags new file mode 100644 index 000000000..b3b518051 --- /dev/null +++ b/tests/run/nothingTypeNoOpt.flags @@ -0,0 +1 @@ +-target:jvm-1.6 -Ybackend:GenBCode -Yopt:l:none diff --git a/tests/run/nothingTypeNoOpt.scala b/tests/run/nothingTypeNoOpt.scala new file mode 100644 index 000000000..840859287 --- /dev/null +++ b/tests/run/nothingTypeNoOpt.scala @@ -0,0 +1,61 @@ +// See comment in BCodeBodyBuilder + +// -target:jvm-1.6 -Ybackend:GenBCode -Yopt:l:none +// target enables stack map frame generation + +class C { + // can't just emit a call to ???, that returns value of type Nothing$ (not Int). + def f1: Int = ??? + + def f2: Int = throw new Error("") + + def f3(x: Boolean) = { + var y = 0 + // cannot assign an object of type Nothing$ to Int + if (x) y = ??? + else y = 1 + y + } + + def f4(x: Boolean) = { + var y = 0 + // tests that whatever is emitted after the throw is valid (what? depends on opts, presence of stack map frames) + if (x) y = throw new Error("") + else y = 1 + y + } + + def f5(x: Boolean) = { + // stack heights need to be the smae. ??? looks to the jvm like returning a value of + // type Nothing$, need to drop or throw it. + println( + if (x) { ???; 10 } + else 20 + ) + } + + def f6(x: Boolean) = { + println( + if (x) { throw new Error(""); 10 } + else 20 + ) + } + + def f7(x: Boolean) = { + println( + if (x) throw new Error("") + else 20 + ) + } + + def f8(x: Boolean) = { + println( + if (x) throw new Error("") + else 20 + ) + } +} + +object Test extends dotty.runtime.LegacyApp { + new C() +} diff --git a/tests/run/null-hash.scala b/tests/run/null-hash.scala new file mode 100644 index 000000000..9b1f28b08 --- /dev/null +++ b/tests/run/null-hash.scala @@ -0,0 +1,15 @@ +object Test { + def f1 = List(5, 10, null: String).## + def f2(x: Any) = x.## + def f3 = ((55, "abc", null: List[Int])).## + + def main(args: Array[String]): Unit = { + f1 + f2(null) + f2(null: String) + f3 + null.## + (null: Any).## + (null: String).## + } +} diff --git a/tests/run/numbereq.scala b/tests/run/numbereq.scala new file mode 100644 index 000000000..7ce4b23cf --- /dev/null +++ b/tests/run/numbereq.scala @@ -0,0 +1,91 @@ +object Test { + def mkNumbers(x: Int): List[AnyRef] = { + val base = List( + BigDecimal(x), + BigInt(x), + new java.lang.Double(x.toDouble), + new java.lang.Float(x.toFloat), + new java.lang.Long(x.toLong), + new java.lang.Integer(x) + ) + val extras = List( + if (x >= Short.MinValue && x <= Short.MaxValue) List(new java.lang.Short(x.toShort)) else Nil, + if (x >= Byte.MinValue && x <= Byte.MaxValue) List(new java.lang.Byte(x.toByte)) else Nil, + if (x >= Char.MinValue && x <= Char.MaxValue) List(new java.lang.Character(x.toChar)) else Nil + ).flatten + + base ::: extras + } + + def mkNumbers(x: BigInt): List[AnyRef] = { + List( + List(BigDecimal(x, java.math.MathContext.UNLIMITED)), + List(x), + if (x.isValidDouble) List(new java.lang.Double(x.toDouble)) else Nil, + if (x.isValidFloat) List(new java.lang.Float(x.toFloat)) else Nil, + if (x.isValidLong) List(new java.lang.Long(x.toLong)) else Nil, + if (x.isValidInt) List(new java.lang.Integer(x.toInt)) else Nil, + if (x.isValidShort) List(new java.lang.Short(x.toShort)) else Nil, + if (x.isValidByte) List(new java.lang.Byte(x.toByte)) else Nil, + if (x.isValidChar) List(new java.lang.Character(x.toChar)) else Nil + ).flatten + } + + // Don't necessarily expect BigDecimal created from BigInt to agree with Double here. + def isIffy(x: Any, y: Any, canSwap: Boolean = true): Boolean = x match { + case bd: BigDecimal => y match { + case _: Float | _: Double => bd.toString.length > 15 + case _ => false + } + case _ => canSwap && isIffy(y, x, false) + } + + // Don't necessarily expect BigInt to agree with Float/Double beyond a Long + def isIffyB(x: Any, y: Any, canSwap: Boolean = true): Boolean = x match { + case bi: BigInt => y match { + case _: Float | _: Double => bi < Long.MinValue || bi > Long.MaxValue + case _ => false + } + case _ => canSwap && isIffyB(y, x, false) + } + + def main(args: Array[String]): Unit = { + val ints = (0 to 15).toList map (Short.MinValue >> _) + val ints2 = ints map (x => -x) + val ints3 = ints map (_ + 1) + val ints4 = ints2 map (_ - 1) + + val setneg1 = ints map mkNumbers + val setneg2 = ints3 map mkNumbers + val setpos1 = ints2 map mkNumbers + val setpos2 = ints4 map mkNumbers + val zero = mkNumbers(0) + + val sets = setneg1 ++ setneg2 ++ List(zero) ++ setpos1 ++ setpos2 + + for (set <- sets ; x <- set ; y <- set) { + assert(x == y, "%s/%s != %s/%s".format(x, x.getClass, y, y.getClass)) + assert(x.## == y.##, "%s != %s".format(x.getClass, y.getClass)) + } + + val bigInts = (0 to 1024).toList map (BigInt(-1) << _) + val bigInts2 = bigInts map (x => -x) + val bigInts3 = bigInts map (_ + 1) + val bigInts4 = bigInts2 map (_ - 1) + + val setneg1b = bigInts map mkNumbers + val setneg2b = bigInts3 map mkNumbers + val setpos1b = bigInts2 map mkNumbers + val setpos2b = bigInts4 map mkNumbers + + val sets2 = setneg1 ++ setneg1b ++ setneg2 ++ setneg2b ++ List(zero) ++ setpos1 ++ setpos1b ++ setpos2 ++ setpos2b + + for (set <- sets2 ; x <- set ; y <- set) { + if (!isIffy(x,y)) { + assert(x == y, "%s/%s != %s/%s".format(x, x.getClass, y, y.getClass)) + // The following is blocked by SI-8150 + // if (!isIffyB(x,y)) assert(x.## == y.##, "%x/%s != %x/%s from %s.## and %s.##".format(x.##, x.getClass, y.##, y.getClass, x, y)) + } + } + } +} diff --git a/tests/run/numeric-range.scala b/tests/run/numeric-range.scala new file mode 100644 index 000000000..9cf8e605e --- /dev/null +++ b/tests/run/numeric-range.scala @@ -0,0 +1,13 @@ + + + + +object Test { + def main(args: Array[String]): Unit = { + val r = 'a' to 'z' + for (i <- -2 to (r.length + 2)) { + assert(r.take(i) == r.toList.take(i), (i, r.take(i))) + assert(r.drop(i) == r.toList.drop(i), (i, r.drop(i))) + } + } +} diff --git a/tests/run/optimizer-array-load.check b/tests/run/optimizer-array-load.check new file mode 100644 index 000000000..e8371f006 --- /dev/null +++ b/tests/run/optimizer-array-load.check @@ -0,0 +1,6 @@ +0 +1 +2 +3 +4 +5 diff --git a/tests/run/optimizer-array-load.flags b/tests/run/optimizer-array-load.flags new file mode 100644 index 000000000..eb4d19bcb --- /dev/null +++ b/tests/run/optimizer-array-load.flags @@ -0,0 +1 @@ +-optimise
\ No newline at end of file diff --git a/tests/run/optimizer-array-load.scala b/tests/run/optimizer-array-load.scala new file mode 100644 index 000000000..a4d76f738 --- /dev/null +++ b/tests/run/optimizer-array-load.scala @@ -0,0 +1,16 @@ +object Test { + def f() = { + val ar = Array.ofDim[Int](5) + var x = 0 + + while (x<=5) { + println(x) + val a = ar(x) + x+=1 + } + } + def main(args: Array[String]): Unit = { + try { f() ; assert(false, "should have thrown exception") } + catch { case _: ArrayIndexOutOfBoundsException => () } + } +} diff --git a/tests/run/overloads.check b/tests/run/overloads.check new file mode 100644 index 000000000..7d294870f --- /dev/null +++ b/tests/run/overloads.check @@ -0,0 +1,15 @@ +ok: -('a') = -97 +ok: -(97) = -97 +ok: Ops.-('a') = a +ok: Ops.-(97) = 97 +ok: -- = 0 +ok: --('a') = a +ok: --(97) = 97 +ok: Ops.-- = 0 +ok: Ops.--('a') = a +ok: Ops.--(97) = 97 +ok: Funcs.foo = 0 +ok: Funcs.foo('a') = 2 +ok: Funcs.foo(97) = 3 +ok: M1.f(3) = 11 +ok: M2.f(3) = 22 diff --git a/tests/run/overloads.scala b/tests/run/overloads.scala new file mode 100644 index 000000000..e84fef021 --- /dev/null +++ b/tests/run/overloads.scala @@ -0,0 +1,95 @@ +//############################################################################ +// Overloads +//############################################################################ + +//############################################################################ + +object Ops { + def - = 0; + def -(c: Char) = c; + def -(i: Int) = i; + + def -- = 0; + def --(c: Char) = c; + def --(i: Int) = i; +} + +object Funcs { + def foo = 0; +// def foo() = 1; + def foo(c: Char) = 2; + def foo(i: Int) = 3; +} + +object M1 { + def f[A](x: A) = 11; + def f[A <: Ordered[A]](x: Ordered[A]) = 12; +} + +object M2 { + def f[A <: Ordered[A]](x: Ordered[A]) = 21; + def f[A](x: A) = 22; +} + +object overloads { + + def check(what: String, actual: Any, expected: Any): Unit = { + val success: Boolean = actual == expected; + Console.print(if (success) "ok" else "KO"); + var value: String = if (actual == null) "null" else actual.toString(); + if (value == "\u0000") value = "\\u0000"; + Console.print(": " + what + " = " + value); + if (!success) Console.print(" != " + expected); + Console.println; + Console.flush; + } + + def - = 0; + def -(c: Char) = c; + def -(i: Int) = i; + + def -- = 0; + def --(c: Char) = c; + def --(i: Int) = i; + + def test: Unit = { + check("-('a')", -('a'), -97); + check("-(97)", -(97), -97); + + check("Ops.-('a')", Ops.-('a'), 'a'); + check("Ops.-(97)", Ops.-(97), 97); + + check("--", --, 0); + check("--('a')", --('a'), 'a'); + check("--(97)", --(97), 97); + + check("Ops.--", Ops.--, 0); + check("Ops.--('a')", Ops.--('a'), 'a'); + check("Ops.--(97)", Ops.--(97), 97); + + check("Funcs.foo", Funcs.foo, 0); +// check("Funcs.foo()", Funcs.foo(), 1); + check("Funcs.foo('a')", Funcs.foo('a'), 2); + check("Funcs.foo(97)", Funcs.foo(97), 3); + + val x = 3; + check("M1.f(" + x +")", M1.f(x), 11); + check("M2.f(" + x +")", M2.f(x), 22); +// val y = new scala.collection.mutable.Stack[Int]; +// check("M1.f(" + y +")", M1.f(y), 12); +// check("M2.f(" + y +")", M2.f(y), 21); + } + +} + +//############################################################################ + +object Test { + + def main(args: Array[String]): Unit = { + overloads.test; + } + +} + +//############################################################################ diff --git a/tests/run/parmap-ops.scala b/tests/run/parmap-ops.scala new file mode 100644 index 000000000..3c0d8ee4b --- /dev/null +++ b/tests/run/parmap-ops.scala @@ -0,0 +1,48 @@ +import collection._ + +object Test { + + def main(args: Array[String]): Unit = { + val gm: GenMap[Int, Int] = GenMap(0 -> 0, 1 -> 1).par + + // ops + assert(gm.isDefinedAt(1)) + assert(gm.contains(1)) + assert(gm.getOrElse(1, 2) == 1) + assert(gm.getOrElse(2, 3) == 3) + assert(gm.keysIterator.toSet == Set(0, 1)) + assert(gm.valuesIterator.toSet == Set(0, 1)) + assert(gm.keySet == Set(0, 1)) + assert(gm.keys.toSet == Set(0, 1)) + assert(gm.values.toSet == Set(0, 1)) + try { + gm.default(-1) + assert(false) + } catch { + case e: NoSuchElementException => // ok + } + + assert(gm.filterKeys(_ % 2 == 0)(0) == 0) + assert(gm.filterKeys(_ % 2 == 0).get(1) == None) + assert(gm.mapValues(_ + 1)(0) == 1) + + // with defaults + val pm = parallel.mutable.ParMap(0 -> 0, 1 -> 1) + val dm = pm.withDefault(x => -x) + assert(dm(0) == 0) + assert(dm(1) == 1) + assert(dm(2) == -2) + assert(dm.updated(2, 2) == parallel.ParMap(0 -> 0, 1 -> 1, 2 -> 2)) + dm.put(3, 3) + assert(dm(3) == 3) + assert(pm(3) == 3) + assert(dm(4) == -4) + + val imdm = parallel.immutable.ParMap(0 -> 0, 1 -> 1).withDefault(x => -x) + assert(imdm(0) == 0) + assert(imdm(1) == 1) + assert(imdm(2) == -2) + assert(imdm.updated(2, 2) == parallel.ParMap(0 -> 0, 1 -> 1, 2 -> 2)) + } + +} diff --git a/tests/run/patch-boundary.scala b/tests/run/patch-boundary.scala new file mode 100644 index 000000000..ed1a0e9fc --- /dev/null +++ b/tests/run/patch-boundary.scala @@ -0,0 +1,8 @@ +object Test { + def f = collection.mutable.ArrayBuffer(1, 2, 3, 4, 5, 6, 7, 8) + def g = f.patch(4, List(1, 2), 10) + + def main(args: Array[String]): Unit = { + assert(g.size == 6) + } +} diff --git a/tests/run/patmat-bind-typed.check b/tests/run/patmat-bind-typed.check new file mode 100644 index 000000000..8baef1b4a --- /dev/null +++ b/tests/run/patmat-bind-typed.check @@ -0,0 +1 @@ +abc diff --git a/tests/run/patmat-bind-typed.scala b/tests/run/patmat-bind-typed.scala new file mode 100644 index 000000000..10de921c5 --- /dev/null +++ b/tests/run/patmat-bind-typed.scala @@ -0,0 +1,8 @@ +object Test { + def f(xs: List[Any]) = for (key @ (dummy: String) <- xs) yield key + + def main(args: Array[String]): Unit = { + f("abc" :: Nil) foreach println + f(5 :: Nil) foreach println + } +} diff --git a/tests/run/pc-conversions.scala b/tests/run/pc-conversions.scala new file mode 100644 index 000000000..effac118b --- /dev/null +++ b/tests/run/pc-conversions.scala @@ -0,0 +1,94 @@ +/* + * filter: inliner warning; re-run with -Yinline-warnings for details + */ + +import collection._ + + +// test conversions between collections +object Test { + + def main(args: Array[String]): Unit = { + testConversions + } + + def testConversions: Unit = { + // seq conversions + assertSeq(parallel.mutable.ParArray(1, 2, 3)) + assertSeq(parallel.mutable.ParHashMap(1 -> 2, 2 -> 3)) + assertSeq(parallel.mutable.ParHashSet(1, 2, 3)) + assertSeq(parallel.immutable.ParRange(1, 50, 1, false)) + assertSeq(parallel.immutable.ParHashMap(1 -> 2, 2 -> 4)) + assertSeq(parallel.immutable.ParHashSet(1, 2, 3)) + + // par conversions + assertPar(Array(1, 2, 3)) + assertPar(mutable.ArrayBuffer(1, 2, 3)) + assertPar(mutable.ArraySeq(1, 2, 3)) + assertPar(mutable.WrappedArray.make[Int](Array(1, 2, 3))) + assertPar(mutable.HashMap(1 -> 1, 2 -> 2)) + assertPar(mutable.HashSet(1, 2, 3)) + assertPar(immutable.Range(1, 50, 1)) + assertPar(immutable.HashMap(1 -> 1, 2 -> 2)) + assertPar(immutable.HashSet(1, 2, 3)) + + // par.to* and to*.par tests + assertToPar(List(1 -> 1, 2 -> 2, 3 -> 3)) + assertToPar(Stream(1 -> 1, 2 -> 2)) + assertToPar(Array(1 -> 1, 2 -> 2)) + assertToPar(mutable.PriorityQueue(1 -> 1, 2 -> 2, 3 -> 3)) + assertToPar(mutable.ArrayBuffer(1 -> 1, 2 -> 2)) + assertToPar(mutable.ArraySeq(1 -> 3)) + assertToPar(mutable.WrappedArray.make[(Int, Int)](Array(1 -> 3))) + assertToPar(mutable.HashMap(1 -> 3)) + assertToPar(mutable.HashSet(1 -> 3)) + assertToPar(immutable.HashMap(1 -> 3)) + assertToPar(immutable.HashSet(1 -> 3)) + assertToPar(parallel.mutable.ParArray(1 -> 1, 2 -> 2, 3 -> 3)) + assertToPar(parallel.mutable.ParHashMap(1 -> 2)) + assertToPar(parallel.mutable.ParHashSet(1 -> 2)) + assertToPar(parallel.immutable.ParHashMap(1 -> 2)) + assertToPar(parallel.immutable.ParHashSet(1 -> 3)) + + assertToParWoMap(immutable.Range(1, 10, 2)) + + // seq and par again conversions) + assertSeqPar(parallel.mutable.ParArray(1, 2, 3)) + } + + def assertSeqPar[T](pc: parallel.ParIterable[T]) = pc.seq.par == pc + + def assertSeq[T](pc: parallel.ParIterable[T]) = assert(pc.seq == pc) + + def assertPar[T, P <: Parallel](xs: GenIterable[T]) = assert(xs == xs.par) + + def assertToPar[K, V](xs: GenTraversable[(K, V)]): Unit = { + xs match { + case _: Seq[_] => + assert(xs.toIterable.par == xs) + assert(xs.par.toIterable == xs) + case _ => + } + + assert(xs.toSeq.par == xs.toSeq) + assert(xs.par.toSeq == xs.toSeq) + + assert(xs.toSet.par == xs.toSet) + assert(xs.par.toSet == xs.toSet) + + assert(xs.toMap.par == xs.toMap) + assert(xs.par.toMap == xs.toMap) + } + + def assertToParWoMap[T](xs: GenSeq[T]): Unit = { + assert(xs.toIterable.par == xs.toIterable) + assert(xs.par.toIterable == xs.toIterable) + + assert(xs.toSeq.par == xs.toSeq) + assert(xs.par.toSeq == xs.toSeq) + + assert(xs.toSet.par == xs.toSet) + assert(xs.par.toSet == xs.toSet) + } + +} diff --git a/tests/run/phantomValueClass.check b/tests/run/phantomValueClass.check new file mode 100644 index 000000000..323fae03f --- /dev/null +++ b/tests/run/phantomValueClass.check @@ -0,0 +1 @@ +foobar diff --git a/tests/run/phantomValueClass.scala b/tests/run/phantomValueClass.scala new file mode 100644 index 000000000..fb4b8e2d0 --- /dev/null +++ b/tests/run/phantomValueClass.scala @@ -0,0 +1,10 @@ +final class Phantom[A](val s: String) extends AnyVal { + def compose(p: Phantom[A]): Phantom[A] = new Phantom[A](s+p.s) +} + +object Test extends dotty.runtime.LegacyApp { + val x = new Phantom[Int]("foo") + val y = new Phantom[Int]("bar") + val z = x compose y + println(z.s) +} diff --git a/tests/run/predef-cycle.scala b/tests/run/predef-cycle.scala new file mode 100644 index 000000000..64b352bc4 --- /dev/null +++ b/tests/run/predef-cycle.scala @@ -0,0 +1,71 @@ +class Force { + val t1 = new Thread { + override def run(): Unit = { + scala.`package` + } + } + val t2 = new Thread { + override def run(): Unit = { + scala.Predef + } + } + t1.start() + t2.start() + t1.join() + t2.join() +} + +object Test { + def main(args: Array[String]): Unit = { + new Force() + } +} + +/* Was deadlocking: +"Thread-2" prio=5 tid=7f9637268000 nid=0x119601000 in Object.wait() [119600000] + java.lang.Thread.State: RUNNABLE + at scala.Predef$.<init>(Predef.scala:90) + at scala.Predef$.<clinit>(Predef.scala) + at Force$$anon$2.run(predef-cycle.scala:10) + +"Thread-1" prio=5 tid=7f9637267800 nid=0x1194fe000 in Object.wait() [1194fb000] + java.lang.Thread.State: RUNNABLE + at scala.collection.immutable.Set$Set4.$plus(Set.scala:127) + at scala.collection.immutable.Set$Set4.$plus(Set.scala:121) + at scala.collection.mutable.SetBuilder.$plus$eq(SetBuilder.scala:24) + at scala.collection.mutable.SetBuilder.$plus$eq(SetBuilder.scala:22) + at scala.collection.generic.Growable$$anonfun$$plus$plus$eq$1.apply(Growable.scala:48) + at scala.collection.generic.Growable$$anonfun$$plus$plus$eq$1.apply(Growable.scala:48) + at scala.collection.immutable.List.foreach(List.scala:318) + at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48) + at scala.collection.mutable.SetBuilder.$plus$plus$eq(SetBuilder.scala:22) + at scala.collection.TraversableLike$class.to(TraversableLike.scala:629) + at scala.collection.AbstractTraversable.to(Traversable.scala:105) + at scala.collection.TraversableOnce$class.toSet(TraversableOnce.scala:267) + at scala.collection.AbstractTraversable.toSet(Traversable.scala:105) + at scala.runtime.ScalaRunTime$.<init>(ScalaRunTime.scala:50) + at scala.runtime.ScalaRunTime$.<clinit>(ScalaRunTime.scala) + at scala.collection.mutable.HashTable$HashUtils$class.elemHashCode(HashTable.scala) + at scala.collection.mutable.HashMap.elemHashCode(HashMap.scala:39) + at scala.collection.mutable.HashTable$class.findOrAddEntry(HashTable.scala:161) + at scala.collection.mutable.HashMap.findOrAddEntry(HashMap.scala:39) + at scala.collection.mutable.HashMap.put(HashMap.scala:75) + at scala.collection.mutable.HashMap.update(HashMap.scala:80) + at scala.sys.SystemProperties$.addHelp(SystemProperties.scala:64) + at scala.sys.SystemProperties$.bool(SystemProperties.scala:68) + at scala.sys.SystemProperties$.noTraceSupression$lzycompute(SystemProperties.scala:80) + - locked <7b8b0e228> (a scala.sys.SystemProperties$) + at scala.sys.SystemProperties$.noTraceSupression(SystemProperties.scala:80) + at scala.util.control.NoStackTrace$.<init>(NoStackTrace.scala:31) + at scala.util.control.NoStackTrace$.<clinit>(NoStackTrace.scala) + at scala.util.control.NoStackTrace$class.fillInStackTrace(NoStackTrace.scala:22) + at scala.util.control.BreakControl.fillInStackTrace(Breaks.scala:93) + at java.lang.Throwable.<init>(Throwable.java:181) + at scala.util.control.BreakControl.<init>(Breaks.scala:93) + at scala.util.control.Breaks.<init>(Breaks.scala:28) + at scala.collection.Traversable$.<init>(Traversable.scala:96) + at scala.collection.Traversable$.<clinit>(Traversable.scala) + at scala.package$.<init>(package.scala:46) + at scala.package$.<clinit>(package.scala) + at Force$$anon$1.run(predef-cycle.scala:4) + */ diff --git a/tests/run/priorityQueue.scala b/tests/run/priorityQueue.scala new file mode 100644 index 000000000..56f7ac3c8 --- /dev/null +++ b/tests/run/priorityQueue.scala @@ -0,0 +1,373 @@ + + + +import scala.collection.mutable.PriorityQueue + + + + + + +// populate a priority queue a few different ways and make sure they all seem equal +object Test { + + def main(args: Array[String]): Unit = { + // testInsertionsAndEqualities + // testIntensiveEnqueueDequeue + // testTails + // testInits + // testFilters + // testDrops + // testEquality + // testMisc + // testReverse + // testToList + // testForeach + } + + // def testInsertionsAndEqualities { + // import scala.util.Random.nextInt + // val pq1 = new PriorityQueue[String] + // val pq2 = new PriorityQueue[String] + // val pq3 = new PriorityQueue[String] + // val pq4 = new PriorityQueue[String] + + // val strings = (1 to 20).toList map (i => List.fill((Math.abs(nextInt % 20)) + 1)("x").mkString) + + // pq1 ++= strings + // pq2 ++= strings.reverse + // for (s <- strings) pq3 += s + // for (s <- strings.reverse) pq4 += s + + // val pqs = List(pq1, pq2, pq3, pq4, pq1.clone, pq2.clone) + + // for (queue1 <- pqs ; queue2 <- pqs) { + // val l1: List[String] = queue1.dequeueAll[String, List[String]] + // val l2: List[String] = queue2.dequeueAll[String, List[String]] + // assert(l1 == l2) + // assert(queue1.max == queue2.max) + // } + + // assertPriorityDestructive(pq1) + // } + + // not a sequence anymore, Mildred + // def testIndexing { + // val pq = new PriorityQueue[Char] + // "The quick brown fox jumps over the lazy dog".foreach(pq += _) + + // // val iter = pq.iterator + // // while (iter.hasNext) println("`" + iter.next + "`") + // assert(pq(0) == 'z') + // assert(pq(1) == 'y') + // assert(pq(2) == 'x') + // assert(pq(3) == 'w') + // assert(pq(4) == 'v') + // assert(pq(5) == 'u') + // assert(pq(7) == 't') + // assert(pq(8) == 's') + // assert(pq(9) == 'r') + // assert(pq(10) == 'r') + + // pq.clear + // "abcdefghijklmnopqrstuvwxyz".foreach(pq += _) + // for (i <- 0 until 26) assert(pq(i) == ('z' - i)) + + // val intpq = new PriorityQueue[Int] + // val intlst = new collection.mutable.ArrayBuffer ++ (0 until 100) + // val random = new util.Random(101) + // while (intlst.nonEmpty) { + // val idx = random.nextInt(intlst.size) + // intpq += intlst(idx) + // intlst.remove(idx) + // } + // for (i <- 0 until 100) assert(intpq(i) == (99 - i)) + // } + + // def testTails { + // val pq = new PriorityQueue[Int] + // for (i <- 0 until 10) pq += i * 4321 % 200 + + // assert(pq.size == 10) + // assert(pq.nonEmpty) + + // val tailpq = pq.tail + // // pq.printstate + // // tailpq.printstate + // assert(tailpq.size == 9) + // assert(tailpq.nonEmpty) + // assertPriorityDestructive(tailpq) + // } + + // def assertPriorityDestructive[A](pq: PriorityQueue[A])(implicit ord: Ordering[A]) { + // import ord._ + // var prev: A = null.asInstanceOf[A] + // while (pq.nonEmpty) { + // val curr = pq.dequeue + // if (prev != null) assert(curr <= prev) + // prev = curr + // } + // } + + // def testInits { + // val pq = new PriorityQueue[Long] + // for (i <- 0 until 20) pq += (i + 313) * 111 % 300 + + // assert(pq.size == 20) + + // val initpq = pq.init + // assert(initpq.size == 19) + // assertPriorityDestructive(initpq) + // } + + // def testFilters { + // val pq = new PriorityQueue[String] + // for (i <- 0 until 100) pq += "Some " + (i * 312 % 200) + + // val filpq = pq.filter(_.indexOf('0') != -1) + // assertPriorityDestructive(filpq) + // } + + // def testIntensiveEnqueueDequeue { + // val pq = new PriorityQueue[Int] + + // testIntensive(1000, pq) + // pq.clear + // testIntensive(200, pq) + // } + + // def testIntensive(sz: Int, pq: PriorityQueue[Int]) { + // val lst = new collection.mutable.ArrayBuffer[Int] ++ (0 until sz) + // val rand = new util.Random(7) + // while (lst.nonEmpty) { + // val idx = rand.nextInt(lst.size) + // pq.enqueue(lst(idx)) + // lst.remove(idx) + // if (rand.nextDouble < 0.25 && pq.nonEmpty) pq.dequeue + // assertPriority(pq) + // } + // } + + // def testDrops { + // val pq = new PriorityQueue[Int] + // pq ++= (0 until 100) + // val droppq = pq.drop(50) + // assertPriority(droppq) + + // pq.clear + // pq ++= droppq + // assertPriorityDestructive(droppq) + // assertPriority(pq) + // assertPriorityDestructive(pq) + // } + + // // your sequence days have ended, foul priority queue + // // def testUpdates { + // // val pq = new PriorityQueue[Int] + // // pq ++= (0 until 36) + // // assertPriority(pq) + + // // pq(0) = 100 + // // assert(pq(0) == 100) + // // assert(pq.dequeue == 100) + // // assertPriority(pq) + + // // pq.clear + + // // pq ++= (1 to 100) + // // pq(5) = 200 + // // assert(pq(0) == 200) + // // assert(pq(1) == 100) + // // assert(pq(2) == 99) + // // assert(pq(3) == 98) + // // assert(pq(4) == 97) + // // assert(pq(5) == 96) + // // assert(pq(6) == 94) + // // assert(pq(7) == 93) + // // assert(pq(98) == 2) + // // assert(pq(99) == 1) + // // assertPriority(pq) + + // // pq(99) = 450 + // // assert(pq(0) == 450) + // // assert(pq(1) == 200) + // // assert(pq(99) == 2) + // // assertPriority(pq) + + // // pq(1) = 0 + // // assert(pq(1) == 100) + // // assert(pq(99) == 0) + // // assertPriority(pq) + // // assertPriorityDestructive(pq) + // // } + + // def testEquality { + // val pq1 = new PriorityQueue[Int] + // val pq2 = new PriorityQueue[Int] + + // pq1 ++= (0 until 50) + // var i = 49 + // while (i >= 0) { + // pq2 += i + // i -= 1 + // } + // assert(pq1 == pq2) + // assertPriority(pq2) + + // pq1 += 100 + // assert(pq1 != pq2) + // pq2 += 100 + // assert(pq1 == pq2) + // pq2 += 200 + // assert(pq1 != pq2) + // pq1 += 200 + // assert(pq1 == pq2) + // assertPriorityDestructive(pq1) + // assertPriorityDestructive(pq2) + // } + + // def testMisc { + // val pq = new PriorityQueue[Int] + // pq ++= (0 until 100) + // assert(pq.size == 100) + + // val (p1, p2) = pq.partition(_ < 50) + // assertPriorityDestructive(p1) + // assertPriorityDestructive(p2) + + // val spq = pq.slice(25, 75) + // assertPriorityDestructive(spq) + + // pq.clear + // pq ++= (0 until 10) + // pq += 5 + // assert(pq.size == 11) + + // val ind = pq.lastIndexWhere(_ == 5) + // assert(ind == 5) + // assertPriorityDestructive(pq) + + // pq.clear + // pq ++= (0 until 10) + // assert(pq.lastIndexWhere(_ == 9) == 0) + // assert(pq.lastIndexOf(8) == 1) + // assert(pq.lastIndexOf(7) == 2) + + // pq += 5 + // pq += 9 + // assert(pq.lastIndexOf(9) == 1) + // assert(pq.lastIndexWhere(_ % 2 == 1) == 10) + // assert(pq.lastIndexOf(5) == 6) + + // val lst = pq.reverseIterator.toList + // for (i <- 0 until 5) assert(lst(i) == i) + // assert(lst(5) == 5) + // assert(lst(6) == 5) + // assert(lst(7) == 6) + // assert(lst(8) == 7) + // assert(lst(9) == 8) + // assert(lst(10) == 9) + // assert(lst(11) == 9) + + // pq.clear + // assert(pq.reverseIterator.toList.isEmpty) + + // pq ++= (50 to 75) + // assert(pq.lastIndexOf(70) == 5) + + // pq += 55 + // pq += 70 + // assert(pq.lastIndexOf(70) == 6) + // assert(pq.lastIndexOf(55) == 22) + // assert(pq.lastIndexOf(55, 21) == 21) + // assert(pq.lastIndexWhere(_ > 54) == 22) + // assert(pq.lastIndexWhere(_ > 54, 21) == 21) + // assert(pq.lastIndexWhere(_ > 69, 5) == 5) + // } + + // def testReverse { + // val pq = new PriorityQueue[(Int, Int)] + // pq ++= (for (i <- 0 until 10) yield (i, i * i % 10)) + + // assert(pq.reverse.size == pq.reverseIterator.toList.size) + // assert((pq.reverse zip pq.reverseIterator.toList).forall(p => p._1 == p._2)) + // assert(pq.reverse.sameElements(pq.reverseIterator.toSeq)) + // assert(pq.reverse(0)._1 == pq(9)._1) + // assert(pq.reverse(1)._1 == pq(8)._1) + // assert(pq.reverse(4)._1 == pq(5)._1) + // assert(pq.reverse(9)._1 == pq(0)._1) + + // pq += ((7, 7)) + // pq += ((7, 9)) + // pq += ((7, 8)) + // assert(pq.reverse.reverse == pq) + // assert(pq.reverse.lastIndexWhere(_._2 == 6) == 6) + // assertPriorityDestructive(pq.reverse.reverse) + + // val iq = new PriorityQueue[Int] + // iq ++= (0 until 50) + // assert(iq.reverse == iq.reverseIterator.toSeq) + // assert(iq.reverse.reverse == iq) + + // iq += 25 + // iq += 40 + // iq += 10 + // assert(iq.reverse == iq.reverseIterator.toList) + // assert(iq.reverse.reverse == iq) + // assert(iq.reverse.lastIndexWhere(_ == 10) == 11) + // assertPriorityDestructive(iq.reverse.reverse) + // } + + // def testToList { + // val pq = new PriorityQueue[Int] + + // pq += 1 + // pq += 4 + // pq += 0 + // pq += 5 + // pq += 3 + // pq += 2 + // assert(pq.toList == pq) + // assert(pq == List(5, 4, 3, 2, 1, 0)) + // assert(pq.reverse == List(0, 1, 2, 3, 4, 5)) + + // pq.clear + // for (i <- -50 until 50) pq += i + // assert(pq.toList == pq) + // assert(pq.toList == (-50 until 50).reverse) + // } + + // def testForeach { + // val pq = new PriorityQueue[Char] + + // pq += 't' + // pq += 'o' + // pq += 'b' + // pq += 'y' + // val sbf = new StringBuilder + // val sbi = new StringBuilder + // pq.foreach(sbf += _) + // pq.iterator.foreach(sbi += _) + // assert(sbf.toString == sbi.toString) + // assert(sbf.toString == "ytob") + // } + +} + + + + + + + + + + + + + + + + + + diff --git a/tests/run/programmatic-main.check b/tests/run/programmatic-main.check new file mode 100644 index 000000000..1cd94ccb4 --- /dev/null +++ b/tests/run/programmatic-main.check @@ -0,0 +1,27 @@ + phase name id description + ---------- -- ----------- + parser 1 parse source into ASTs, perform simple desugaring + namer 2 resolve names, attach symbols to named trees +packageobjects 3 load package objects + typer 4 the meat and potatoes: type the trees + patmat 5 translate match expressions +superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + delambdafy 22 remove lambdas + icode 23 generate portable intermediate code + jvm 24 generate JVM bytecode + terminal 25 the last phase during a compilation run diff --git a/tests/run/programmatic-main.scala b/tests/run/programmatic-main.scala new file mode 100644 index 000000000..542ac2781 --- /dev/null +++ b/tests/run/programmatic-main.scala @@ -0,0 +1,16 @@ + +import scala.language.postfixOps +import scala.tools.nsc._ +import io.Path + +object Test { + val cwd = Option(System.getProperty("partest.cwd")) getOrElse "." + val basedir = Path(cwd).parent / "lib" path + val baseargs = Array("-usejavacp", "-bootclasspath", basedir + "/scala-library.jar", "-cp", basedir + "/scala-compiler.jar") + + def main(args: Array[String]): Unit = { + Console.withErr(Console.out) { + Main process (baseargs ++ "-Xpluginsdir /does/not/exist/foo/quux -Xshow-phases".split(' ')) + } + } +} diff --git a/tests/run/promotion.check b/tests/run/promotion.check new file mode 100644 index 000000000..e769775ce --- /dev/null +++ b/tests/run/promotion.check @@ -0,0 +1,4 @@ +2.0 +6.0 +20.0 +30.0 diff --git a/tests/run/promotion.scala b/tests/run/promotion.scala new file mode 100644 index 000000000..9f3be9661 --- /dev/null +++ b/tests/run/promotion.scala @@ -0,0 +1,14 @@ + +/** Test that unboxing and promotion (from int to double) work together. + * Was bug 819. + */ +object Test { + + def id[A](x: A): A = x; + def main(args: Array[String]): Unit = { + Console.println(id(1) * 2.0) + Console.println(3.0 * id(2)) + Console.println(id(4.0) * 5) + Console.println(6 * id(5.0)) + } +} diff --git a/tests/run/pure-args-byname-noinline.check b/tests/run/pure-args-byname-noinline.check new file mode 100644 index 000000000..a39c61eb6 --- /dev/null +++ b/tests/run/pure-args-byname-noinline.check @@ -0,0 +1,12 @@ +2 +2 +2 +2 +List(1) +List() + +1 +1 +1 +1 +1 diff --git a/tests/run/pure-args-byname-noinline.scala b/tests/run/pure-args-byname-noinline.scala new file mode 100644 index 000000000..3ed4c480b --- /dev/null +++ b/tests/run/pure-args-byname-noinline.scala @@ -0,0 +1,33 @@ +object Test { + //Were affected by SI-6306 + def f[A](a: =>A) = println(a.toString) + def f1[A <: AnyVal](a: =>A) = println(a.toString) + def f1a[A <: AnyVal](a: =>A) = println(a.##) + def f2[A <: AnyRef](a: =>A) = println(a.toString) + def f2a[A <: String](a: =>A) = println(a.toString) + //Works + def f3[A](a: =>Seq[A]) = println(a.toString) + + def foo() = println(2) + def client(f: () => Unit) = {f(); f()} + def attempt2(): Unit = { + val bar: () => Unit = foo _ + //The code causing SI-6306 was supposed to optimize code like this: + client(() => bar ()) + //to: + client(bar) + } + def main(args: Array[String]): Unit = { + attempt2() + f3(Seq(1)) + f3(Seq()) + f("") + f((1).toString) + f((1).##) + f1((1).##) + f2((1).toString) + f2a((1).toString) + } +} + +// vim: set ts=8 sw=2 et: diff --git a/tests/run/range-unit.check b/tests/run/range-unit.check new file mode 100644 index 000000000..3daf91cd6 --- /dev/null +++ b/tests/run/range-unit.check @@ -0,0 +1,4178 @@ +>>> Range.inclusive <<< + +start end step length/first/last +----------------------------------------- +0 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 0 -1 1/0/0 +0 0 1 1/0/0 +0 0 -2 1/0/0 +0 0 2 1/0/0 +0 0 -3 1/0/0 +0 0 3 1/0/0 +0 0 17 1/0/0 +0 0 127 1/0/0 +0 0 MIN+1 1/0/0 +0 0 MAX 1/0/0 +0 0 MIN 1/0/0 +0 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 -1 -1 2/0/-1 +0 -1 1 0 +0 -1 -2 1/0/0 +0 -1 2 0 +0 -1 -3 1/0/0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 1/0/0 +0 -1 MAX 0 +0 -1 MIN 1/0/0 +0 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 1 -1 0 +0 1 1 2/0/1 +0 1 -2 0 +0 1 2 1/0/0 +0 1 -3 0 +0 1 3 1/0/0 +0 1 17 1/0/0 +0 1 127 1/0/0 +0 1 MIN+1 0 +0 1 MAX 1/0/0 +0 1 MIN 0 +0 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 3 -1 0 +0 3 1 4/0/3 +0 3 -2 0 +0 3 2 2/0/2 +0 3 -3 0 +0 3 3 2/0/3 +0 3 17 1/0/0 +0 3 127 1/0/0 +0 3 MIN+1 0 +0 3 MAX 1/0/0 +0 3 MIN 0 +0 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN+1 -1 --- + java.lang.IllegalArgumentException: 0 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN+1 1 0 +0 MIN+1 -2 1073741824/0/MIN+2 +0 MIN+1 2 0 +0 MIN+1 -3 715827883/0/MIN+2 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 2/0/MIN+1 +0 MIN+1 MAX 0 +0 MIN+1 MIN 1/0/0 +0 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MAX -1 0 +0 MAX 1 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX -2 0 +0 MAX 2 1073741824/0/MAX-1 +0 MAX -3 0 +0 MAX 3 715827883/0/MAX-1 +0 MAX 17 126322568/0/MAX-8 +0 MAX 127 16909321/0/MAX-7 +0 MAX MIN+1 0 +0 MAX MAX 2/0/MAX +0 MAX MIN 0 +0 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN -1 --- + java.lang.IllegalArgumentException: 0 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN 1 0 +0 MIN -2 1073741825/0/MIN +0 MIN 2 0 +0 MIN -3 715827883/0/MIN+2 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 2/0/MIN+1 +0 MIN MAX 0 +0 MIN MIN 2/0/MIN + +start end step length/first/last +----------------------------------------- +-1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 0 -1 0 +-1 0 1 2/-1/0 +-1 0 -2 0 +-1 0 2 1/-1/-1 +-1 0 -3 0 +-1 0 3 1/-1/-1 +-1 0 17 1/-1/-1 +-1 0 127 1/-1/-1 +-1 0 MIN+1 0 +-1 0 MAX 1/-1/-1 +-1 0 MIN 0 +-1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 -1 -1 1/-1/-1 +-1 -1 1 1/-1/-1 +-1 -1 -2 1/-1/-1 +-1 -1 2 1/-1/-1 +-1 -1 -3 1/-1/-1 +-1 -1 3 1/-1/-1 +-1 -1 17 1/-1/-1 +-1 -1 127 1/-1/-1 +-1 -1 MIN+1 1/-1/-1 +-1 -1 MAX 1/-1/-1 +-1 -1 MIN 1/-1/-1 +-1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 1 -1 0 +-1 1 1 3/-1/1 +-1 1 -2 0 +-1 1 2 2/-1/1 +-1 1 -3 0 +-1 1 3 1/-1/-1 +-1 1 17 1/-1/-1 +-1 1 127 1/-1/-1 +-1 1 MIN+1 0 +-1 1 MAX 1/-1/-1 +-1 1 MIN 0 +-1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 3 -1 0 +-1 3 1 5/-1/3 +-1 3 -2 0 +-1 3 2 3/-1/3 +-1 3 -3 0 +-1 3 3 2/-1/2 +-1 3 17 1/-1/-1 +-1 3 127 1/-1/-1 +-1 3 MIN+1 0 +-1 3 MAX 1/-1/-1 +-1 3 MIN 0 +-1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN+1 -1 MAX/-1/MIN+1 +-1 MIN+1 1 0 +-1 MIN+1 -2 1073741824/-1/MIN+1 +-1 MIN+1 2 0 +-1 MIN+1 -3 715827883/-1/MIN+1 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 1/-1/-1 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 1/-1/-1 +-1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MAX -1 0 +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 0 +-1 MAX 2 1073741825/-1/MAX +-1 MAX -3 0 +-1 MAX 3 715827883/-1/MAX-2 +-1 MAX 17 126322568/-1/MAX-9 +-1 MAX 127 16909321/-1/MAX-8 +-1 MAX MIN+1 0 +-1 MAX MAX 2/-1/MAX-1 +-1 MAX MIN 0 +-1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN -1 --- + java.lang.IllegalArgumentException: -1 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +-1 MIN 1 0 +-1 MIN -2 1073741824/-1/MIN+1 +-1 MIN 2 0 +-1 MIN -3 715827883/-1/MIN+1 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 2/-1/MIN +-1 MIN MAX 0 +-1 MIN MIN 1/-1/-1 + +start end step length/first/last +----------------------------------------- +1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 0 -1 2/1/0 +1 0 1 0 +1 0 -2 1/1/1 +1 0 2 0 +1 0 -3 1/1/1 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 1/1/1 +1 0 MAX 0 +1 0 MIN 1/1/1 +1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 -1 -1 3/1/-1 +1 -1 1 0 +1 -1 -2 2/1/-1 +1 -1 2 0 +1 -1 -3 1/1/1 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 1/1/1 +1 -1 MAX 0 +1 -1 MIN 1/1/1 +1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 1 -1 1/1/1 +1 1 1 1/1/1 +1 1 -2 1/1/1 +1 1 2 1/1/1 +1 1 -3 1/1/1 +1 1 3 1/1/1 +1 1 17 1/1/1 +1 1 127 1/1/1 +1 1 MIN+1 1/1/1 +1 1 MAX 1/1/1 +1 1 MIN 1/1/1 +1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 3 -1 0 +1 3 1 3/1/3 +1 3 -2 0 +1 3 2 2/1/3 +1 3 -3 0 +1 3 3 1/1/1 +1 3 17 1/1/1 +1 3 127 1/1/1 +1 3 MIN+1 0 +1 3 MAX 1/1/1 +1 3 MIN 0 +1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN+1 -1 --- + java.lang.IllegalArgumentException: 1 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN+1 1 0 +1 MIN+1 -2 1073741825/1/MIN+1 +1 MIN+1 2 0 +1 MIN+1 -3 715827883/1/MIN+3 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 2/1/MIN+2 +1 MIN+1 MAX 0 +1 MIN+1 MIN 2/1/MIN+1 +1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MAX -1 0 +1 MAX 1 MAX/1/MAX +1 MAX -2 0 +1 MAX 2 1073741824/1/MAX +1 MAX -3 0 +1 MAX 3 715827883/1/MAX +1 MAX 17 126322568/1/MAX-7 +1 MAX 127 16909321/1/MAX-6 +1 MAX MIN+1 0 +1 MAX MAX 1/1/1 +1 MAX MIN 0 +1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN -1 --- + java.lang.IllegalArgumentException: 1 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN 1 0 +1 MIN -2 1073741825/1/MIN+1 +1 MIN 2 0 +1 MIN -3 715827884/1/MIN +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 2/1/MIN+2 +1 MIN MAX 0 +1 MIN MIN 2/1/MIN+1 + +start end step length/first/last +----------------------------------------- +3 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 0 -1 4/3/0 +3 0 1 0 +3 0 -2 2/3/1 +3 0 2 0 +3 0 -3 2/3/0 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 1/3/3 +3 0 MAX 0 +3 0 MIN 1/3/3 +3 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 -1 -1 5/3/-1 +3 -1 1 0 +3 -1 -2 3/3/-1 +3 -1 2 0 +3 -1 -3 2/3/0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 1/3/3 +3 -1 MAX 0 +3 -1 MIN 1/3/3 +3 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 1 -1 3/3/1 +3 1 1 0 +3 1 -2 2/3/1 +3 1 2 0 +3 1 -3 1/3/3 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 1/3/3 +3 1 MAX 0 +3 1 MIN 1/3/3 +3 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 3 -1 1/3/3 +3 3 1 1/3/3 +3 3 -2 1/3/3 +3 3 2 1/3/3 +3 3 -3 1/3/3 +3 3 3 1/3/3 +3 3 17 1/3/3 +3 3 127 1/3/3 +3 3 MIN+1 1/3/3 +3 3 MAX 1/3/3 +3 3 MIN 1/3/3 +3 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN+1 -1 --- + java.lang.IllegalArgumentException: 3 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN+1 1 0 +3 MIN+1 -2 1073741826/3/MIN+1 +3 MIN+1 2 0 +3 MIN+1 -3 715827884/3/MIN+2 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 2/3/MIN+4 +3 MIN+1 MAX 0 +3 MIN+1 MIN 2/3/MIN+3 +3 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MAX -1 0 +3 MAX 1 MAX-2/3/MAX +3 MAX -2 0 +3 MAX 2 1073741823/3/MAX +3 MAX -3 0 +3 MAX 3 715827882/3/MAX-1 +3 MAX 17 126322568/3/MAX-5 +3 MAX 127 16909321/3/MAX-4 +3 MAX MIN+1 0 +3 MAX MAX 1/3/3 +3 MAX MIN 0 +3 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN -1 --- + java.lang.IllegalArgumentException: 3 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN 1 0 +3 MIN -2 1073741826/3/MIN+1 +3 MIN 2 0 +3 MIN -3 715827884/3/MIN+2 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 2/3/MIN+4 +3 MIN MAX 0 +3 MIN MIN 2/3/MIN+3 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 0 -1 0 +MIN+1 0 1 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 -2 0 +MIN+1 0 2 1073741824/MIN+1/-1 +MIN+1 0 -3 0 +MIN+1 0 3 715827883/MIN+1/-1 +MIN+1 0 17 126322568/MIN+1/-8 +MIN+1 0 127 16909321/MIN+1/-7 +MIN+1 0 MIN+1 0 +MIN+1 0 MAX 2/MIN+1/0 +MIN+1 0 MIN 0 +MIN+1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 -1 -1 0 +MIN+1 -1 1 MAX/MIN+1/-1 +MIN+1 -1 -2 0 +MIN+1 -1 2 1073741824/MIN+1/-1 +MIN+1 -1 -3 0 +MIN+1 -1 3 715827883/MIN+1/-1 +MIN+1 -1 17 126322568/MIN+1/-8 +MIN+1 -1 127 16909321/MIN+1/-7 +MIN+1 -1 MIN+1 0 +MIN+1 -1 MAX 1/MIN+1/MIN+1 +MIN+1 -1 MIN 0 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 1 -1 0 +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 0 +MIN+1 1 2 1073741825/MIN+1/1 +MIN+1 1 -3 0 +MIN+1 1 3 715827883/MIN+1/-1 +MIN+1 1 17 126322568/MIN+1/-8 +MIN+1 1 127 16909321/MIN+1/-7 +MIN+1 1 MIN+1 0 +MIN+1 1 MAX 2/MIN+1/0 +MIN+1 1 MIN 0 +MIN+1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 3 -1 0 +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 0 +MIN+1 3 2 1073741826/MIN+1/3 +MIN+1 3 -3 0 +MIN+1 3 3 715827884/MIN+1/2 +MIN+1 3 17 126322568/MIN+1/-8 +MIN+1 3 127 16909321/MIN+1/-7 +MIN+1 3 MIN+1 0 +MIN+1 3 MAX 2/MIN+1/0 +MIN+1 3 MIN 0 +MIN+1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN+1 -1 1/MIN+1/MIN+1 +MIN+1 MIN+1 1 1/MIN+1/MIN+1 +MIN+1 MIN+1 -2 1/MIN+1/MIN+1 +MIN+1 MIN+1 2 1/MIN+1/MIN+1 +MIN+1 MIN+1 -3 1/MIN+1/MIN+1 +MIN+1 MIN+1 3 1/MIN+1/MIN+1 +MIN+1 MIN+1 17 1/MIN+1/MIN+1 +MIN+1 MIN+1 127 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN+1 MAX 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN 1/MIN+1/MIN+1 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MAX -1 0 +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 0 +MIN+1 MAX 2 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -3 0 +MIN+1 MAX 3 1431655765/MIN+1/MAX-2 +MIN+1 MAX 17 252645135/MIN+1/MAX-16 +MIN+1 MAX 127 33818641/MIN+1/MAX-14 +MIN+1 MAX MIN+1 0 +MIN+1 MAX MAX 3/MIN+1/MAX +MIN+1 MAX MIN 0 +MIN+1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN -1 2/MIN+1/MIN +MIN+1 MIN 1 0 +MIN+1 MIN -2 1/MIN+1/MIN+1 +MIN+1 MIN 2 0 +MIN+1 MIN -3 1/MIN+1/MIN+1 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 1/MIN+1/MIN+1 + +start end step length/first/last +----------------------------------------- +MAX 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 0 -1 --- + java.lang.IllegalArgumentException: 2147483647 to 0 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX 0 1 0 +MAX 0 -2 1073741824/MAX/1 +MAX 0 2 0 +MAX 0 -3 715827883/MAX/1 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 2/MAX/0 +MAX 0 MAX 0 +MAX 0 MIN 1/MAX/MAX +MAX -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX -1 -1 --- + java.lang.IllegalArgumentException: 2147483647 to -1 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX -1 1 0 +MAX -1 -2 1073741825/MAX/-1 +MAX -1 2 0 +MAX -1 -3 715827883/MAX/1 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 2/MAX/0 +MAX -1 MAX 0 +MAX -1 MIN 2/MAX/-1 +MAX 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 1 -1 MAX/MAX/1 +MAX 1 1 0 +MAX 1 -2 1073741824/MAX/1 +MAX 1 2 0 +MAX 1 -3 715827883/MAX/1 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 1/MAX/MAX +MAX 1 MAX 0 +MAX 1 MIN 1/MAX/MAX +MAX 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 3 -1 MAX-2/MAX/3 +MAX 3 1 0 +MAX 3 -2 1073741823/MAX/3 +MAX 3 2 0 +MAX 3 -3 715827882/MAX/4 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 1/MAX/MAX +MAX 3 MAX 0 +MAX 3 MIN 1/MAX/MAX +MAX MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN+1 -1 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 1 0 +MAX MIN+1 -2 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483647 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 2 0 +MAX MIN+1 -3 1431655765/MAX/MIN+3 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 3/MAX/MIN+1 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 2/MAX/-1 +MAX MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MAX -1 1/MAX/MAX +MAX MAX 1 1/MAX/MAX +MAX MAX -2 1/MAX/MAX +MAX MAX 2 1/MAX/MAX +MAX MAX -3 1/MAX/MAX +MAX MAX 3 1/MAX/MAX +MAX MAX 17 1/MAX/MAX +MAX MAX 127 1/MAX/MAX +MAX MAX MIN+1 1/MAX/MAX +MAX MAX MAX 1/MAX/MAX +MAX MAX MIN 1/MAX/MAX +MAX MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN -1 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 1 0 +MAX MIN -2 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483648 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 2 0 +MAX MIN -3 1431655766/MAX/MIN +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 3/MAX/MIN+1 +MAX MIN MAX 0 +MAX MIN MIN 2/MAX/-1 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 0 -1 0 +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 0 +MIN 0 2 1073741825/MIN/0 +MIN 0 -3 0 +MIN 0 3 715827883/MIN/-2 +MIN 0 17 126322568/MIN/-9 +MIN 0 127 16909321/MIN/-8 +MIN 0 MIN+1 0 +MIN 0 MAX 2/MIN/-1 +MIN 0 MIN 0 +MIN -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN -1 -1 0 +MIN -1 1 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 -2 0 +MIN -1 2 1073741824/MIN/-2 +MIN -1 -3 0 +MIN -1 3 715827883/MIN/-2 +MIN -1 17 126322568/MIN/-9 +MIN -1 127 16909321/MIN/-8 +MIN -1 MIN+1 0 +MIN -1 MAX 2/MIN/-1 +MIN -1 MIN 0 +MIN 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 1 -1 0 +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 0 +MIN 1 2 1073741825/MIN/0 +MIN 1 -3 0 +MIN 1 3 715827884/MIN/1 +MIN 1 17 126322568/MIN/-9 +MIN 1 127 16909321/MIN/-8 +MIN 1 MIN+1 0 +MIN 1 MAX 2/MIN/-1 +MIN 1 MIN 0 +MIN 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 3 -1 0 +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 0 +MIN 3 2 1073741826/MIN/2 +MIN 3 -3 0 +MIN 3 3 715827884/MIN/1 +MIN 3 17 126322568/MIN/-9 +MIN 3 127 16909321/MIN/-8 +MIN 3 MIN+1 0 +MIN 3 MAX 2/MIN/-1 +MIN 3 MIN 0 +MIN MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN+1 -1 0 +MIN MIN+1 1 2/MIN/MIN+1 +MIN MIN+1 -2 0 +MIN MIN+1 2 1/MIN/MIN +MIN MIN+1 -3 0 +MIN MIN+1 3 1/MIN/MIN +MIN MIN+1 17 1/MIN/MIN +MIN MIN+1 127 1/MIN/MIN +MIN MIN+1 MIN+1 0 +MIN MIN+1 MAX 1/MIN/MIN +MIN MIN+1 MIN 0 +MIN MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MAX -1 0 +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 0 +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 0 +MIN MAX 3 1431655766/MIN/MAX +MIN MAX 17 252645136/MIN/MAX +MIN MAX 127 33818641/MIN/MAX-15 +MIN MAX MIN+1 0 +MIN MAX MAX 3/MIN/MAX-1 +MIN MAX MIN 0 +MIN MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN -1 1/MIN/MIN +MIN MIN 1 1/MIN/MIN +MIN MIN -2 1/MIN/MIN +MIN MIN 2 1/MIN/MIN +MIN MIN -3 1/MIN/MIN +MIN MIN 3 1/MIN/MIN +MIN MIN 17 1/MIN/MIN +MIN MIN 127 1/MIN/MIN +MIN MIN MIN+1 1/MIN/MIN +MIN MIN MAX 1/MIN/MIN +MIN MIN MIN 1/MIN/MIN + +>>> Range.apply <<< + +start end step length/first/last +----------------------------------------- +0 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 0 -1 0 +0 0 1 0 +0 0 -2 0 +0 0 2 0 +0 0 -3 0 +0 0 3 0 +0 0 17 0 +0 0 127 0 +0 0 MIN+1 0 +0 0 MAX 0 +0 0 MIN 0 +0 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 -1 -1 1/0/0 +0 -1 1 0 +0 -1 -2 1/0/0 +0 -1 2 0 +0 -1 -3 1/0/0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 1/0/0 +0 -1 MAX 0 +0 -1 MIN 1/0/0 +0 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 1 -1 0 +0 1 1 1/0/0 +0 1 -2 0 +0 1 2 1/0/0 +0 1 -3 0 +0 1 3 1/0/0 +0 1 17 1/0/0 +0 1 127 1/0/0 +0 1 MIN+1 0 +0 1 MAX 1/0/0 +0 1 MIN 0 +0 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 3 -1 0 +0 3 1 3/0/2 +0 3 -2 0 +0 3 2 2/0/2 +0 3 -3 0 +0 3 3 1/0/0 +0 3 17 1/0/0 +0 3 127 1/0/0 +0 3 MIN+1 0 +0 3 MAX 1/0/0 +0 3 MIN 0 +0 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN+1 -1 MAX/0/MIN+2 +0 MIN+1 1 0 +0 MIN+1 -2 1073741824/0/MIN+2 +0 MIN+1 2 0 +0 MIN+1 -3 715827883/0/MIN+2 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 1/0/0 +0 MIN+1 MAX 0 +0 MIN+1 MIN 1/0/0 +0 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MAX -1 0 +0 MAX 1 MAX/0/MAX-1 +0 MAX -2 0 +0 MAX 2 1073741824/0/MAX-1 +0 MAX -3 0 +0 MAX 3 715827883/0/MAX-1 +0 MAX 17 126322568/0/MAX-8 +0 MAX 127 16909321/0/MAX-7 +0 MAX MIN+1 0 +0 MAX MAX 1/0/0 +0 MAX MIN 0 +0 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN -1 --- + java.lang.IllegalArgumentException: 0 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN 1 0 +0 MIN -2 1073741824/0/MIN+2 +0 MIN 2 0 +0 MIN -3 715827883/0/MIN+2 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 2/0/MIN+1 +0 MIN MAX 0 +0 MIN MIN 1/0/0 + +start end step length/first/last +----------------------------------------- +-1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 0 -1 0 +-1 0 1 1/-1/-1 +-1 0 -2 0 +-1 0 2 1/-1/-1 +-1 0 -3 0 +-1 0 3 1/-1/-1 +-1 0 17 1/-1/-1 +-1 0 127 1/-1/-1 +-1 0 MIN+1 0 +-1 0 MAX 1/-1/-1 +-1 0 MIN 0 +-1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 -1 -1 0 +-1 -1 1 0 +-1 -1 -2 0 +-1 -1 2 0 +-1 -1 -3 0 +-1 -1 3 0 +-1 -1 17 0 +-1 -1 127 0 +-1 -1 MIN+1 0 +-1 -1 MAX 0 +-1 -1 MIN 0 +-1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 1 -1 0 +-1 1 1 2/-1/0 +-1 1 -2 0 +-1 1 2 1/-1/-1 +-1 1 -3 0 +-1 1 3 1/-1/-1 +-1 1 17 1/-1/-1 +-1 1 127 1/-1/-1 +-1 1 MIN+1 0 +-1 1 MAX 1/-1/-1 +-1 1 MIN 0 +-1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 3 -1 0 +-1 3 1 4/-1/2 +-1 3 -2 0 +-1 3 2 2/-1/1 +-1 3 -3 0 +-1 3 3 2/-1/2 +-1 3 17 1/-1/-1 +-1 3 127 1/-1/-1 +-1 3 MIN+1 0 +-1 3 MAX 1/-1/-1 +-1 3 MIN 0 +-1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN+1 -1 MAX-1/-1/MIN+2 +-1 MIN+1 1 0 +-1 MIN+1 -2 1073741823/-1/MIN+3 +-1 MIN+1 2 0 +-1 MIN+1 -3 715827882/-1/MIN+4 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 1/-1/-1 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 1/-1/-1 +-1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MAX -1 0 +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 0 +-1 MAX 2 1073741824/-1/MAX-2 +-1 MAX -3 0 +-1 MAX 3 715827883/-1/MAX-2 +-1 MAX 17 126322568/-1/MAX-9 +-1 MAX 127 16909321/-1/MAX-8 +-1 MAX MIN+1 0 +-1 MAX MAX 2/-1/MAX-1 +-1 MAX MIN 0 +-1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN -1 MAX/-1/MIN+1 +-1 MIN 1 0 +-1 MIN -2 1073741824/-1/MIN+1 +-1 MIN 2 0 +-1 MIN -3 715827883/-1/MIN+1 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 1/-1/-1 +-1 MIN MAX 0 +-1 MIN MIN 1/-1/-1 + +start end step length/first/last +----------------------------------------- +1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 0 -1 1/1/1 +1 0 1 0 +1 0 -2 1/1/1 +1 0 2 0 +1 0 -3 1/1/1 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 1/1/1 +1 0 MAX 0 +1 0 MIN 1/1/1 +1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 -1 -1 2/1/0 +1 -1 1 0 +1 -1 -2 1/1/1 +1 -1 2 0 +1 -1 -3 1/1/1 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 1/1/1 +1 -1 MAX 0 +1 -1 MIN 1/1/1 +1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 1 -1 0 +1 1 1 0 +1 1 -2 0 +1 1 2 0 +1 1 -3 0 +1 1 3 0 +1 1 17 0 +1 1 127 0 +1 1 MIN+1 0 +1 1 MAX 0 +1 1 MIN 0 +1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 3 -1 0 +1 3 1 2/1/2 +1 3 -2 0 +1 3 2 1/1/1 +1 3 -3 0 +1 3 3 1/1/1 +1 3 17 1/1/1 +1 3 127 1/1/1 +1 3 MIN+1 0 +1 3 MAX 1/1/1 +1 3 MIN 0 +1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN+1 -1 --- + java.lang.IllegalArgumentException: 1 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN+1 1 0 +1 MIN+1 -2 1073741824/1/MIN+3 +1 MIN+1 2 0 +1 MIN+1 -3 715827883/1/MIN+3 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 2/1/MIN+2 +1 MIN+1 MAX 0 +1 MIN+1 MIN 1/1/1 +1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MAX -1 0 +1 MAX 1 MAX-1/1/MAX-1 +1 MAX -2 0 +1 MAX 2 1073741823/1/MAX-2 +1 MAX -3 0 +1 MAX 3 715827882/1/MAX-3 +1 MAX 17 126322568/1/MAX-7 +1 MAX 127 16909321/1/MAX-6 +1 MAX MIN+1 0 +1 MAX MAX 1/1/1 +1 MAX MIN 0 +1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN -1 --- + java.lang.IllegalArgumentException: 1 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN 1 0 +1 MIN -2 1073741825/1/MIN+1 +1 MIN 2 0 +1 MIN -3 715827883/1/MIN+3 +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 2/1/MIN+2 +1 MIN MAX 0 +1 MIN MIN 2/1/MIN+1 + +start end step length/first/last +----------------------------------------- +3 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 0 -1 3/3/1 +3 0 1 0 +3 0 -2 2/3/1 +3 0 2 0 +3 0 -3 1/3/3 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 1/3/3 +3 0 MAX 0 +3 0 MIN 1/3/3 +3 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 -1 -1 4/3/0 +3 -1 1 0 +3 -1 -2 2/3/1 +3 -1 2 0 +3 -1 -3 2/3/0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 1/3/3 +3 -1 MAX 0 +3 -1 MIN 1/3/3 +3 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 1 -1 2/3/2 +3 1 1 0 +3 1 -2 1/3/3 +3 1 2 0 +3 1 -3 1/3/3 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 1/3/3 +3 1 MAX 0 +3 1 MIN 1/3/3 +3 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 3 -1 0 +3 3 1 0 +3 3 -2 0 +3 3 2 0 +3 3 -3 0 +3 3 3 0 +3 3 17 0 +3 3 127 0 +3 3 MIN+1 0 +3 3 MAX 0 +3 3 MIN 0 +3 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN+1 -1 --- + java.lang.IllegalArgumentException: 3 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN+1 1 0 +3 MIN+1 -2 1073741825/3/MIN+3 +3 MIN+1 2 0 +3 MIN+1 -3 715827884/3/MIN+2 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 2/3/MIN+4 +3 MIN+1 MAX 0 +3 MIN+1 MIN 2/3/MIN+3 +3 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MAX -1 0 +3 MAX 1 MAX-3/3/MAX-1 +3 MAX -2 0 +3 MAX 2 1073741822/3/MAX-2 +3 MAX -3 0 +3 MAX 3 715827882/3/MAX-1 +3 MAX 17 126322568/3/MAX-5 +3 MAX 127 16909321/3/MAX-4 +3 MAX MIN+1 0 +3 MAX MAX 1/3/3 +3 MAX MIN 0 +3 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN -1 --- + java.lang.IllegalArgumentException: 3 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN 1 0 +3 MIN -2 1073741826/3/MIN+1 +3 MIN 2 0 +3 MIN -3 715827884/3/MIN+2 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 2/3/MIN+4 +3 MIN MAX 0 +3 MIN MIN 2/3/MIN+3 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 0 -1 0 +MIN+1 0 1 MAX/MIN+1/-1 +MIN+1 0 -2 0 +MIN+1 0 2 1073741824/MIN+1/-1 +MIN+1 0 -3 0 +MIN+1 0 3 715827883/MIN+1/-1 +MIN+1 0 17 126322568/MIN+1/-8 +MIN+1 0 127 16909321/MIN+1/-7 +MIN+1 0 MIN+1 0 +MIN+1 0 MAX 1/MIN+1/MIN+1 +MIN+1 0 MIN 0 +MIN+1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 -1 -1 0 +MIN+1 -1 1 MAX-1/MIN+1/-2 +MIN+1 -1 -2 0 +MIN+1 -1 2 1073741823/MIN+1/-3 +MIN+1 -1 -3 0 +MIN+1 -1 3 715827882/MIN+1/-4 +MIN+1 -1 17 126322568/MIN+1/-8 +MIN+1 -1 127 16909321/MIN+1/-7 +MIN+1 -1 MIN+1 0 +MIN+1 -1 MAX 1/MIN+1/MIN+1 +MIN+1 -1 MIN 0 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 1 -1 0 +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 0 +MIN+1 1 2 1073741824/MIN+1/-1 +MIN+1 1 -3 0 +MIN+1 1 3 715827883/MIN+1/-1 +MIN+1 1 17 126322568/MIN+1/-8 +MIN+1 1 127 16909321/MIN+1/-7 +MIN+1 1 MIN+1 0 +MIN+1 1 MAX 2/MIN+1/0 +MIN+1 1 MIN 0 +MIN+1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 3 -1 0 +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 0 +MIN+1 3 2 1073741825/MIN+1/1 +MIN+1 3 -3 0 +MIN+1 3 3 715827884/MIN+1/2 +MIN+1 3 17 126322568/MIN+1/-8 +MIN+1 3 127 16909321/MIN+1/-7 +MIN+1 3 MIN+1 0 +MIN+1 3 MAX 2/MIN+1/0 +MIN+1 3 MIN 0 +MIN+1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN+1 -1 0 +MIN+1 MIN+1 1 0 +MIN+1 MIN+1 -2 0 +MIN+1 MIN+1 2 0 +MIN+1 MIN+1 -3 0 +MIN+1 MIN+1 3 0 +MIN+1 MIN+1 17 0 +MIN+1 MIN+1 127 0 +MIN+1 MIN+1 MIN+1 0 +MIN+1 MIN+1 MAX 0 +MIN+1 MIN+1 MIN 0 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MAX -1 0 +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 0 +MIN+1 MAX 2 MAX/MIN+1/MAX-2 +MIN+1 MAX -3 0 +MIN+1 MAX 3 1431655765/MIN+1/MAX-2 +MIN+1 MAX 17 252645135/MIN+1/MAX-16 +MIN+1 MAX 127 33818641/MIN+1/MAX-14 +MIN+1 MAX MIN+1 0 +MIN+1 MAX MAX 2/MIN+1/0 +MIN+1 MAX MIN 0 +MIN+1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN -1 1/MIN+1/MIN+1 +MIN+1 MIN 1 0 +MIN+1 MIN -2 1/MIN+1/MIN+1 +MIN+1 MIN 2 0 +MIN+1 MIN -3 1/MIN+1/MIN+1 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 1/MIN+1/MIN+1 + +start end step length/first/last +----------------------------------------- +MAX 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 0 -1 MAX/MAX/1 +MAX 0 1 0 +MAX 0 -2 1073741824/MAX/1 +MAX 0 2 0 +MAX 0 -3 715827883/MAX/1 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 1/MAX/MAX +MAX 0 MAX 0 +MAX 0 MIN 1/MAX/MAX +MAX -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX -1 -1 --- + java.lang.IllegalArgumentException: 2147483647 until -1 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX -1 1 0 +MAX -1 -2 1073741824/MAX/1 +MAX -1 2 0 +MAX -1 -3 715827883/MAX/1 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 2/MAX/0 +MAX -1 MAX 0 +MAX -1 MIN 1/MAX/MAX +MAX 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 1 -1 MAX-1/MAX/2 +MAX 1 1 0 +MAX 1 -2 1073741823/MAX/3 +MAX 1 2 0 +MAX 1 -3 715827882/MAX/4 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 1/MAX/MAX +MAX 1 MAX 0 +MAX 1 MIN 1/MAX/MAX +MAX 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 3 -1 MAX-3/MAX/4 +MAX 3 1 0 +MAX 3 -2 1073741822/MAX/5 +MAX 3 2 0 +MAX 3 -3 715827882/MAX/4 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 1/MAX/MAX +MAX 3 MAX 0 +MAX 3 MIN 1/MAX/MAX +MAX MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN+1 -1 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 1 0 +MAX MIN+1 -2 MAX/MAX/MIN+3 +MAX MIN+1 2 0 +MAX MIN+1 -3 1431655765/MAX/MIN+3 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 2/MAX/0 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 2/MAX/-1 +MAX MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MAX -1 0 +MAX MAX 1 0 +MAX MAX -2 0 +MAX MAX 2 0 +MAX MAX -3 0 +MAX MAX 3 0 +MAX MAX 17 0 +MAX MAX 127 0 +MAX MAX MIN+1 0 +MAX MAX MAX 0 +MAX MAX MIN 0 +MAX MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN -1 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 1 0 +MAX MIN -2 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483648 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 2 0 +MAX MIN -3 1431655765/MAX/MIN+3 +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 3/MAX/MIN+1 +MAX MIN MAX 0 +MAX MIN MIN 2/MAX/-1 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 0 -1 0 +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 0 +MIN 0 2 1073741824/MIN/-2 +MIN 0 -3 0 +MIN 0 3 715827883/MIN/-2 +MIN 0 17 126322568/MIN/-9 +MIN 0 127 16909321/MIN/-8 +MIN 0 MIN+1 0 +MIN 0 MAX 2/MIN/-1 +MIN 0 MIN 0 +MIN -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN -1 -1 0 +MIN -1 1 MAX/MIN/-2 +MIN -1 -2 0 +MIN -1 2 1073741824/MIN/-2 +MIN -1 -3 0 +MIN -1 3 715827883/MIN/-2 +MIN -1 17 126322568/MIN/-9 +MIN -1 127 16909321/MIN/-8 +MIN -1 MIN+1 0 +MIN -1 MAX 1/MIN/MIN +MIN -1 MIN 0 +MIN 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 1 -1 0 +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 0 +MIN 1 2 1073741825/MIN/0 +MIN 1 -3 0 +MIN 1 3 715827883/MIN/-2 +MIN 1 17 126322568/MIN/-9 +MIN 1 127 16909321/MIN/-8 +MIN 1 MIN+1 0 +MIN 1 MAX 2/MIN/-1 +MIN 1 MIN 0 +MIN 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 3 -1 0 +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 0 +MIN 3 2 1073741826/MIN/2 +MIN 3 -3 0 +MIN 3 3 715827884/MIN/1 +MIN 3 17 126322568/MIN/-9 +MIN 3 127 16909321/MIN/-8 +MIN 3 MIN+1 0 +MIN 3 MAX 2/MIN/-1 +MIN 3 MIN 0 +MIN MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN+1 -1 0 +MIN MIN+1 1 1/MIN/MIN +MIN MIN+1 -2 0 +MIN MIN+1 2 1/MIN/MIN +MIN MIN+1 -3 0 +MIN MIN+1 3 1/MIN/MIN +MIN MIN+1 17 1/MIN/MIN +MIN MIN+1 127 1/MIN/MIN +MIN MIN+1 MIN+1 0 +MIN MIN+1 MAX 1/MIN/MIN +MIN MIN+1 MIN 0 +MIN MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MAX -1 0 +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 0 +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 0 +MIN MAX 3 1431655765/MIN/MAX-3 +MIN MAX 17 252645135/MIN/MAX-17 +MIN MAX 127 33818641/MIN/MAX-15 +MIN MAX MIN+1 0 +MIN MAX MAX 3/MIN/MAX-1 +MIN MAX MIN 0 +MIN MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN -1 0 +MIN MIN 1 0 +MIN MIN -2 0 +MIN MIN 2 0 +MIN MIN -3 0 +MIN MIN 3 0 +MIN MIN 17 0 +MIN MIN 127 0 +MIN MIN MIN+1 0 +MIN MIN MAX 0 +MIN MIN MIN 0 + +>>> start to end <<< + +start end step length/first/last +----------------------------------------- +0 0 0 1/0/0 +0 0 -1 1/0/0 +0 0 1 1/0/0 +0 0 -2 1/0/0 +0 0 2 1/0/0 +0 0 -3 1/0/0 +0 0 3 1/0/0 +0 0 17 1/0/0 +0 0 127 1/0/0 +0 0 MIN+1 1/0/0 +0 0 MAX 1/0/0 +0 0 MIN 1/0/0 +0 -1 0 0 +0 -1 -1 0 +0 -1 1 0 +0 -1 -2 0 +0 -1 2 0 +0 -1 -3 0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 0 +0 -1 MAX 0 +0 -1 MIN 0 +0 1 0 2/0/1 +0 1 -1 2/0/1 +0 1 1 2/0/1 +0 1 -2 2/0/1 +0 1 2 2/0/1 +0 1 -3 2/0/1 +0 1 3 2/0/1 +0 1 17 2/0/1 +0 1 127 2/0/1 +0 1 MIN+1 2/0/1 +0 1 MAX 2/0/1 +0 1 MIN 2/0/1 +0 3 0 4/0/3 +0 3 -1 4/0/3 +0 3 1 4/0/3 +0 3 -2 4/0/3 +0 3 2 4/0/3 +0 3 -3 4/0/3 +0 3 3 4/0/3 +0 3 17 4/0/3 +0 3 127 4/0/3 +0 3 MIN+1 4/0/3 +0 3 MAX 4/0/3 +0 3 MIN 4/0/3 +0 MIN+1 0 0 +0 MIN+1 -1 0 +0 MIN+1 1 0 +0 MIN+1 -2 0 +0 MIN+1 2 0 +0 MIN+1 -3 0 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 0 +0 MIN+1 MAX 0 +0 MIN+1 MIN 0 +0 MAX 0 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX -1 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX 1 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX -2 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX 2 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX -3 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX 3 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX 17 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX 127 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX MIN+1 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX MAX --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX MIN --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MIN 0 0 +0 MIN -1 0 +0 MIN 1 0 +0 MIN -2 0 +0 MIN 2 0 +0 MIN -3 0 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 0 +0 MIN MAX 0 +0 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +-1 0 0 2/-1/0 +-1 0 -1 2/-1/0 +-1 0 1 2/-1/0 +-1 0 -2 2/-1/0 +-1 0 2 2/-1/0 +-1 0 -3 2/-1/0 +-1 0 3 2/-1/0 +-1 0 17 2/-1/0 +-1 0 127 2/-1/0 +-1 0 MIN+1 2/-1/0 +-1 0 MAX 2/-1/0 +-1 0 MIN 2/-1/0 +-1 -1 0 1/-1/-1 +-1 -1 -1 1/-1/-1 +-1 -1 1 1/-1/-1 +-1 -1 -2 1/-1/-1 +-1 -1 2 1/-1/-1 +-1 -1 -3 1/-1/-1 +-1 -1 3 1/-1/-1 +-1 -1 17 1/-1/-1 +-1 -1 127 1/-1/-1 +-1 -1 MIN+1 1/-1/-1 +-1 -1 MAX 1/-1/-1 +-1 -1 MIN 1/-1/-1 +-1 1 0 3/-1/1 +-1 1 -1 3/-1/1 +-1 1 1 3/-1/1 +-1 1 -2 3/-1/1 +-1 1 2 3/-1/1 +-1 1 -3 3/-1/1 +-1 1 3 3/-1/1 +-1 1 17 3/-1/1 +-1 1 127 3/-1/1 +-1 1 MIN+1 3/-1/1 +-1 1 MAX 3/-1/1 +-1 1 MIN 3/-1/1 +-1 3 0 5/-1/3 +-1 3 -1 5/-1/3 +-1 3 1 5/-1/3 +-1 3 -2 5/-1/3 +-1 3 2 5/-1/3 +-1 3 -3 5/-1/3 +-1 3 3 5/-1/3 +-1 3 17 5/-1/3 +-1 3 127 5/-1/3 +-1 3 MIN+1 5/-1/3 +-1 3 MAX 5/-1/3 +-1 3 MIN 5/-1/3 +-1 MIN+1 0 0 +-1 MIN+1 -1 0 +-1 MIN+1 1 0 +-1 MIN+1 -2 0 +-1 MIN+1 2 0 +-1 MIN+1 -3 0 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 0 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 0 +-1 MAX 0 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -1 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 2 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -3 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 3 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 17 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 127 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MIN+1 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MAX --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MIN --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MIN 0 0 +-1 MIN -1 0 +-1 MIN 1 0 +-1 MIN -2 0 +-1 MIN 2 0 +-1 MIN -3 0 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 0 +-1 MIN MAX 0 +-1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +1 0 0 0 +1 0 -1 0 +1 0 1 0 +1 0 -2 0 +1 0 2 0 +1 0 -3 0 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 0 +1 0 MAX 0 +1 0 MIN 0 +1 -1 0 0 +1 -1 -1 0 +1 -1 1 0 +1 -1 -2 0 +1 -1 2 0 +1 -1 -3 0 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 0 +1 -1 MAX 0 +1 -1 MIN 0 +1 1 0 1/1/1 +1 1 -1 1/1/1 +1 1 1 1/1/1 +1 1 -2 1/1/1 +1 1 2 1/1/1 +1 1 -3 1/1/1 +1 1 3 1/1/1 +1 1 17 1/1/1 +1 1 127 1/1/1 +1 1 MIN+1 1/1/1 +1 1 MAX 1/1/1 +1 1 MIN 1/1/1 +1 3 0 3/1/3 +1 3 -1 3/1/3 +1 3 1 3/1/3 +1 3 -2 3/1/3 +1 3 2 3/1/3 +1 3 -3 3/1/3 +1 3 3 3/1/3 +1 3 17 3/1/3 +1 3 127 3/1/3 +1 3 MIN+1 3/1/3 +1 3 MAX 3/1/3 +1 3 MIN 3/1/3 +1 MIN+1 0 0 +1 MIN+1 -1 0 +1 MIN+1 1 0 +1 MIN+1 -2 0 +1 MIN+1 2 0 +1 MIN+1 -3 0 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 0 +1 MIN+1 MAX 0 +1 MIN+1 MIN 0 +1 MAX 0 MAX/1/MAX +1 MAX -1 MAX/1/MAX +1 MAX 1 MAX/1/MAX +1 MAX -2 MAX/1/MAX +1 MAX 2 MAX/1/MAX +1 MAX -3 MAX/1/MAX +1 MAX 3 MAX/1/MAX +1 MAX 17 MAX/1/MAX +1 MAX 127 MAX/1/MAX +1 MAX MIN+1 MAX/1/MAX +1 MAX MAX MAX/1/MAX +1 MAX MIN MAX/1/MAX +1 MIN 0 0 +1 MIN -1 0 +1 MIN 1 0 +1 MIN -2 0 +1 MIN 2 0 +1 MIN -3 0 +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 0 +1 MIN MAX 0 +1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +3 0 0 0 +3 0 -1 0 +3 0 1 0 +3 0 -2 0 +3 0 2 0 +3 0 -3 0 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 0 +3 0 MAX 0 +3 0 MIN 0 +3 -1 0 0 +3 -1 -1 0 +3 -1 1 0 +3 -1 -2 0 +3 -1 2 0 +3 -1 -3 0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 0 +3 -1 MAX 0 +3 -1 MIN 0 +3 1 0 0 +3 1 -1 0 +3 1 1 0 +3 1 -2 0 +3 1 2 0 +3 1 -3 0 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 0 +3 1 MAX 0 +3 1 MIN 0 +3 3 0 1/3/3 +3 3 -1 1/3/3 +3 3 1 1/3/3 +3 3 -2 1/3/3 +3 3 2 1/3/3 +3 3 -3 1/3/3 +3 3 3 1/3/3 +3 3 17 1/3/3 +3 3 127 1/3/3 +3 3 MIN+1 1/3/3 +3 3 MAX 1/3/3 +3 3 MIN 1/3/3 +3 MIN+1 0 0 +3 MIN+1 -1 0 +3 MIN+1 1 0 +3 MIN+1 -2 0 +3 MIN+1 2 0 +3 MIN+1 -3 0 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 0 +3 MIN+1 MAX 0 +3 MIN+1 MIN 0 +3 MAX 0 MAX-2/3/MAX +3 MAX -1 MAX-2/3/MAX +3 MAX 1 MAX-2/3/MAX +3 MAX -2 MAX-2/3/MAX +3 MAX 2 MAX-2/3/MAX +3 MAX -3 MAX-2/3/MAX +3 MAX 3 MAX-2/3/MAX +3 MAX 17 MAX-2/3/MAX +3 MAX 127 MAX-2/3/MAX +3 MAX MIN+1 MAX-2/3/MAX +3 MAX MAX MAX-2/3/MAX +3 MAX MIN MAX-2/3/MAX +3 MIN 0 0 +3 MIN -1 0 +3 MIN 1 0 +3 MIN -2 0 +3 MIN 2 0 +3 MIN -3 0 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 0 +3 MIN MAX 0 +3 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 -1 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 1 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 -2 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 2 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 -3 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 3 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 17 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 127 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 MAX --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 MIN --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 -1 0 MAX/MIN+1/-1 +MIN+1 -1 -1 MAX/MIN+1/-1 +MIN+1 -1 1 MAX/MIN+1/-1 +MIN+1 -1 -2 MAX/MIN+1/-1 +MIN+1 -1 2 MAX/MIN+1/-1 +MIN+1 -1 -3 MAX/MIN+1/-1 +MIN+1 -1 3 MAX/MIN+1/-1 +MIN+1 -1 17 MAX/MIN+1/-1 +MIN+1 -1 127 MAX/MIN+1/-1 +MIN+1 -1 MIN+1 MAX/MIN+1/-1 +MIN+1 -1 MAX MAX/MIN+1/-1 +MIN+1 -1 MIN MAX/MIN+1/-1 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -1 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 2 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -3 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 3 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 17 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 127 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MAX --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MIN --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 0 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -1 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 2 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -3 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 3 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 17 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 127 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MAX --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MIN --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MIN+1 0 1/MIN+1/MIN+1 +MIN+1 MIN+1 -1 1/MIN+1/MIN+1 +MIN+1 MIN+1 1 1/MIN+1/MIN+1 +MIN+1 MIN+1 -2 1/MIN+1/MIN+1 +MIN+1 MIN+1 2 1/MIN+1/MIN+1 +MIN+1 MIN+1 -3 1/MIN+1/MIN+1 +MIN+1 MIN+1 3 1/MIN+1/MIN+1 +MIN+1 MIN+1 17 1/MIN+1/MIN+1 +MIN+1 MIN+1 127 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN+1 MAX 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN 1/MIN+1/MIN+1 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -1 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 2 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -3 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 3 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 17 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 127 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MAX --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MIN --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MIN 0 0 +MIN+1 MIN -1 0 +MIN+1 MIN 1 0 +MIN+1 MIN -2 0 +MIN+1 MIN 2 0 +MIN+1 MIN -3 0 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 0 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MAX 0 0 0 +MAX 0 -1 0 +MAX 0 1 0 +MAX 0 -2 0 +MAX 0 2 0 +MAX 0 -3 0 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 0 +MAX 0 MAX 0 +MAX 0 MIN 0 +MAX -1 0 0 +MAX -1 -1 0 +MAX -1 1 0 +MAX -1 -2 0 +MAX -1 2 0 +MAX -1 -3 0 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 0 +MAX -1 MAX 0 +MAX -1 MIN 0 +MAX 1 0 0 +MAX 1 -1 0 +MAX 1 1 0 +MAX 1 -2 0 +MAX 1 2 0 +MAX 1 -3 0 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 0 +MAX 1 MAX 0 +MAX 1 MIN 0 +MAX 3 0 0 +MAX 3 -1 0 +MAX 3 1 0 +MAX 3 -2 0 +MAX 3 2 0 +MAX 3 -3 0 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 0 +MAX 3 MAX 0 +MAX 3 MIN 0 +MAX MIN+1 0 0 +MAX MIN+1 -1 0 +MAX MIN+1 1 0 +MAX MIN+1 -2 0 +MAX MIN+1 2 0 +MAX MIN+1 -3 0 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 0 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 0 +MAX MAX 0 1/MAX/MAX +MAX MAX -1 1/MAX/MAX +MAX MAX 1 1/MAX/MAX +MAX MAX -2 1/MAX/MAX +MAX MAX 2 1/MAX/MAX +MAX MAX -3 1/MAX/MAX +MAX MAX 3 1/MAX/MAX +MAX MAX 17 1/MAX/MAX +MAX MAX 127 1/MAX/MAX +MAX MAX MIN+1 1/MAX/MAX +MAX MAX MAX 1/MAX/MAX +MAX MAX MIN 1/MAX/MAX +MAX MIN 0 0 +MAX MIN -1 0 +MAX MIN 1 0 +MAX MIN -2 0 +MAX MIN 2 0 +MAX MIN -3 0 +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 0 +MAX MIN MAX 0 +MAX MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -1 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 2 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -3 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 3 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 17 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 127 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MAX --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MIN --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 0 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 -1 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 1 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 -2 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 2 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 -3 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 3 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 17 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 127 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 MAX --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 MIN --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 0 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -1 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 2 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -3 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 3 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 17 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 127 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MAX --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MIN --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 0 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -1 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 2 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -3 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 3 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 17 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 127 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MAX --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MIN --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MIN+1 0 2/MIN/MIN+1 +MIN MIN+1 -1 2/MIN/MIN+1 +MIN MIN+1 1 2/MIN/MIN+1 +MIN MIN+1 -2 2/MIN/MIN+1 +MIN MIN+1 2 2/MIN/MIN+1 +MIN MIN+1 -3 2/MIN/MIN+1 +MIN MIN+1 3 2/MIN/MIN+1 +MIN MIN+1 17 2/MIN/MIN+1 +MIN MIN+1 127 2/MIN/MIN+1 +MIN MIN+1 MIN+1 2/MIN/MIN+1 +MIN MIN+1 MAX 2/MIN/MIN+1 +MIN MIN+1 MIN 2/MIN/MIN+1 +MIN MAX 0 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -1 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 3 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 17 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 127 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MAX --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MIN --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MIN 0 1/MIN/MIN +MIN MIN -1 1/MIN/MIN +MIN MIN 1 1/MIN/MIN +MIN MIN -2 1/MIN/MIN +MIN MIN 2 1/MIN/MIN +MIN MIN -3 1/MIN/MIN +MIN MIN 3 1/MIN/MIN +MIN MIN 17 1/MIN/MIN +MIN MIN 127 1/MIN/MIN +MIN MIN MIN+1 1/MIN/MIN +MIN MIN MAX 1/MIN/MIN +MIN MIN MIN 1/MIN/MIN + +>>> start to end by step <<< + +start end step length/first/last +----------------------------------------- +0 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 0 -1 1/0/0 +0 0 1 1/0/0 +0 0 -2 1/0/0 +0 0 2 1/0/0 +0 0 -3 1/0/0 +0 0 3 1/0/0 +0 0 17 1/0/0 +0 0 127 1/0/0 +0 0 MIN+1 1/0/0 +0 0 MAX 1/0/0 +0 0 MIN 1/0/0 +0 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 -1 -1 2/0/-1 +0 -1 1 0 +0 -1 -2 1/0/0 +0 -1 2 0 +0 -1 -3 1/0/0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 1/0/0 +0 -1 MAX 0 +0 -1 MIN 1/0/0 +0 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 1 -1 0 +0 1 1 2/0/1 +0 1 -2 0 +0 1 2 1/0/0 +0 1 -3 0 +0 1 3 1/0/0 +0 1 17 1/0/0 +0 1 127 1/0/0 +0 1 MIN+1 0 +0 1 MAX 1/0/0 +0 1 MIN 0 +0 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 3 -1 0 +0 3 1 4/0/3 +0 3 -2 0 +0 3 2 2/0/2 +0 3 -3 0 +0 3 3 2/0/3 +0 3 17 1/0/0 +0 3 127 1/0/0 +0 3 MIN+1 0 +0 3 MAX 1/0/0 +0 3 MIN 0 +0 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN+1 -1 --- + java.lang.IllegalArgumentException: 0 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN+1 1 0 +0 MIN+1 -2 1073741824/0/MIN+2 +0 MIN+1 2 0 +0 MIN+1 -3 715827883/0/MIN+2 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 2/0/MIN+1 +0 MIN+1 MAX 0 +0 MIN+1 MIN 1/0/0 +0 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MAX -1 0 +0 MAX 1 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX -2 0 +0 MAX 2 1073741824/0/MAX-1 +0 MAX -3 0 +0 MAX 3 715827883/0/MAX-1 +0 MAX 17 126322568/0/MAX-8 +0 MAX 127 16909321/0/MAX-7 +0 MAX MIN+1 0 +0 MAX MAX 2/0/MAX +0 MAX MIN 0 +0 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN -1 --- + java.lang.IllegalArgumentException: 0 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN 1 0 +0 MIN -2 1073741825/0/MIN +0 MIN 2 0 +0 MIN -3 715827883/0/MIN+2 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 2/0/MIN+1 +0 MIN MAX 0 +0 MIN MIN 2/0/MIN + +start end step length/first/last +----------------------------------------- +-1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 0 -1 0 +-1 0 1 2/-1/0 +-1 0 -2 0 +-1 0 2 1/-1/-1 +-1 0 -3 0 +-1 0 3 1/-1/-1 +-1 0 17 1/-1/-1 +-1 0 127 1/-1/-1 +-1 0 MIN+1 0 +-1 0 MAX 1/-1/-1 +-1 0 MIN 0 +-1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 -1 -1 1/-1/-1 +-1 -1 1 1/-1/-1 +-1 -1 -2 1/-1/-1 +-1 -1 2 1/-1/-1 +-1 -1 -3 1/-1/-1 +-1 -1 3 1/-1/-1 +-1 -1 17 1/-1/-1 +-1 -1 127 1/-1/-1 +-1 -1 MIN+1 1/-1/-1 +-1 -1 MAX 1/-1/-1 +-1 -1 MIN 1/-1/-1 +-1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 1 -1 0 +-1 1 1 3/-1/1 +-1 1 -2 0 +-1 1 2 2/-1/1 +-1 1 -3 0 +-1 1 3 1/-1/-1 +-1 1 17 1/-1/-1 +-1 1 127 1/-1/-1 +-1 1 MIN+1 0 +-1 1 MAX 1/-1/-1 +-1 1 MIN 0 +-1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 3 -1 0 +-1 3 1 5/-1/3 +-1 3 -2 0 +-1 3 2 3/-1/3 +-1 3 -3 0 +-1 3 3 2/-1/2 +-1 3 17 1/-1/-1 +-1 3 127 1/-1/-1 +-1 3 MIN+1 0 +-1 3 MAX 1/-1/-1 +-1 3 MIN 0 +-1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN+1 -1 MAX/-1/MIN+1 +-1 MIN+1 1 0 +-1 MIN+1 -2 1073741824/-1/MIN+1 +-1 MIN+1 2 0 +-1 MIN+1 -3 715827883/-1/MIN+1 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 1/-1/-1 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 1/-1/-1 +-1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MAX -1 0 +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 0 +-1 MAX 2 1073741825/-1/MAX +-1 MAX -3 0 +-1 MAX 3 715827883/-1/MAX-2 +-1 MAX 17 126322568/-1/MAX-9 +-1 MAX 127 16909321/-1/MAX-8 +-1 MAX MIN+1 0 +-1 MAX MAX 2/-1/MAX-1 +-1 MAX MIN 0 +-1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN -1 --- + java.lang.IllegalArgumentException: -1 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +-1 MIN 1 0 +-1 MIN -2 1073741824/-1/MIN+1 +-1 MIN 2 0 +-1 MIN -3 715827883/-1/MIN+1 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 2/-1/MIN +-1 MIN MAX 0 +-1 MIN MIN 1/-1/-1 + +start end step length/first/last +----------------------------------------- +1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 0 -1 2/1/0 +1 0 1 0 +1 0 -2 1/1/1 +1 0 2 0 +1 0 -3 1/1/1 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 1/1/1 +1 0 MAX 0 +1 0 MIN 1/1/1 +1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 -1 -1 3/1/-1 +1 -1 1 0 +1 -1 -2 2/1/-1 +1 -1 2 0 +1 -1 -3 1/1/1 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 1/1/1 +1 -1 MAX 0 +1 -1 MIN 1/1/1 +1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 1 -1 1/1/1 +1 1 1 1/1/1 +1 1 -2 1/1/1 +1 1 2 1/1/1 +1 1 -3 1/1/1 +1 1 3 1/1/1 +1 1 17 1/1/1 +1 1 127 1/1/1 +1 1 MIN+1 1/1/1 +1 1 MAX 1/1/1 +1 1 MIN 1/1/1 +1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 3 -1 0 +1 3 1 3/1/3 +1 3 -2 0 +1 3 2 2/1/3 +1 3 -3 0 +1 3 3 1/1/1 +1 3 17 1/1/1 +1 3 127 1/1/1 +1 3 MIN+1 0 +1 3 MAX 1/1/1 +1 3 MIN 0 +1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN+1 -1 --- + java.lang.IllegalArgumentException: 1 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN+1 1 0 +1 MIN+1 -2 1073741825/1/MIN+1 +1 MIN+1 2 0 +1 MIN+1 -3 715827883/1/MIN+3 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 2/1/MIN+2 +1 MIN+1 MAX 0 +1 MIN+1 MIN 2/1/MIN+1 +1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MAX -1 0 +1 MAX 1 MAX/1/MAX +1 MAX -2 0 +1 MAX 2 1073741824/1/MAX +1 MAX -3 0 +1 MAX 3 715827883/1/MAX +1 MAX 17 126322568/1/MAX-7 +1 MAX 127 16909321/1/MAX-6 +1 MAX MIN+1 0 +1 MAX MAX 1/1/1 +1 MAX MIN 0 +1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN -1 --- + java.lang.IllegalArgumentException: 1 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN 1 0 +1 MIN -2 1073741825/1/MIN+1 +1 MIN 2 0 +1 MIN -3 715827884/1/MIN +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 2/1/MIN+2 +1 MIN MAX 0 +1 MIN MIN 2/1/MIN+1 + +start end step length/first/last +----------------------------------------- +3 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 0 -1 4/3/0 +3 0 1 0 +3 0 -2 2/3/1 +3 0 2 0 +3 0 -3 2/3/0 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 1/3/3 +3 0 MAX 0 +3 0 MIN 1/3/3 +3 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 -1 -1 5/3/-1 +3 -1 1 0 +3 -1 -2 3/3/-1 +3 -1 2 0 +3 -1 -3 2/3/0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 1/3/3 +3 -1 MAX 0 +3 -1 MIN 1/3/3 +3 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 1 -1 3/3/1 +3 1 1 0 +3 1 -2 2/3/1 +3 1 2 0 +3 1 -3 1/3/3 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 1/3/3 +3 1 MAX 0 +3 1 MIN 1/3/3 +3 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 3 -1 1/3/3 +3 3 1 1/3/3 +3 3 -2 1/3/3 +3 3 2 1/3/3 +3 3 -3 1/3/3 +3 3 3 1/3/3 +3 3 17 1/3/3 +3 3 127 1/3/3 +3 3 MIN+1 1/3/3 +3 3 MAX 1/3/3 +3 3 MIN 1/3/3 +3 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN+1 -1 --- + java.lang.IllegalArgumentException: 3 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN+1 1 0 +3 MIN+1 -2 1073741826/3/MIN+1 +3 MIN+1 2 0 +3 MIN+1 -3 715827884/3/MIN+2 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 2/3/MIN+4 +3 MIN+1 MAX 0 +3 MIN+1 MIN 2/3/MIN+3 +3 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MAX -1 0 +3 MAX 1 MAX-2/3/MAX +3 MAX -2 0 +3 MAX 2 1073741823/3/MAX +3 MAX -3 0 +3 MAX 3 715827882/3/MAX-1 +3 MAX 17 126322568/3/MAX-5 +3 MAX 127 16909321/3/MAX-4 +3 MAX MIN+1 0 +3 MAX MAX 1/3/3 +3 MAX MIN 0 +3 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN -1 --- + java.lang.IllegalArgumentException: 3 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN 1 0 +3 MIN -2 1073741826/3/MIN+1 +3 MIN 2 0 +3 MIN -3 715827884/3/MIN+2 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 2/3/MIN+4 +3 MIN MAX 0 +3 MIN MIN 2/3/MIN+3 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 0 -1 0 +MIN+1 0 1 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 -2 0 +MIN+1 0 2 1073741824/MIN+1/-1 +MIN+1 0 -3 0 +MIN+1 0 3 715827883/MIN+1/-1 +MIN+1 0 17 126322568/MIN+1/-8 +MIN+1 0 127 16909321/MIN+1/-7 +MIN+1 0 MIN+1 0 +MIN+1 0 MAX 2/MIN+1/0 +MIN+1 0 MIN 0 +MIN+1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 -1 -1 0 +MIN+1 -1 1 MAX/MIN+1/-1 +MIN+1 -1 -2 0 +MIN+1 -1 2 1073741824/MIN+1/-1 +MIN+1 -1 -3 0 +MIN+1 -1 3 715827883/MIN+1/-1 +MIN+1 -1 17 126322568/MIN+1/-8 +MIN+1 -1 127 16909321/MIN+1/-7 +MIN+1 -1 MIN+1 0 +MIN+1 -1 MAX 1/MIN+1/MIN+1 +MIN+1 -1 MIN 0 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 1 -1 0 +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 0 +MIN+1 1 2 1073741825/MIN+1/1 +MIN+1 1 -3 0 +MIN+1 1 3 715827883/MIN+1/-1 +MIN+1 1 17 126322568/MIN+1/-8 +MIN+1 1 127 16909321/MIN+1/-7 +MIN+1 1 MIN+1 0 +MIN+1 1 MAX 2/MIN+1/0 +MIN+1 1 MIN 0 +MIN+1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 3 -1 0 +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 0 +MIN+1 3 2 1073741826/MIN+1/3 +MIN+1 3 -3 0 +MIN+1 3 3 715827884/MIN+1/2 +MIN+1 3 17 126322568/MIN+1/-8 +MIN+1 3 127 16909321/MIN+1/-7 +MIN+1 3 MIN+1 0 +MIN+1 3 MAX 2/MIN+1/0 +MIN+1 3 MIN 0 +MIN+1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN+1 -1 1/MIN+1/MIN+1 +MIN+1 MIN+1 1 1/MIN+1/MIN+1 +MIN+1 MIN+1 -2 1/MIN+1/MIN+1 +MIN+1 MIN+1 2 1/MIN+1/MIN+1 +MIN+1 MIN+1 -3 1/MIN+1/MIN+1 +MIN+1 MIN+1 3 1/MIN+1/MIN+1 +MIN+1 MIN+1 17 1/MIN+1/MIN+1 +MIN+1 MIN+1 127 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN+1 MAX 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN 1/MIN+1/MIN+1 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MAX -1 0 +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 0 +MIN+1 MAX 2 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -3 0 +MIN+1 MAX 3 1431655765/MIN+1/MAX-2 +MIN+1 MAX 17 252645135/MIN+1/MAX-16 +MIN+1 MAX 127 33818641/MIN+1/MAX-14 +MIN+1 MAX MIN+1 0 +MIN+1 MAX MAX 3/MIN+1/MAX +MIN+1 MAX MIN 0 +MIN+1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN -1 2/MIN+1/MIN +MIN+1 MIN 1 0 +MIN+1 MIN -2 1/MIN+1/MIN+1 +MIN+1 MIN 2 0 +MIN+1 MIN -3 1/MIN+1/MIN+1 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 1/MIN+1/MIN+1 + +start end step length/first/last +----------------------------------------- +MAX 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 0 -1 --- + java.lang.IllegalArgumentException: 2147483647 to 0 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX 0 1 0 +MAX 0 -2 1073741824/MAX/1 +MAX 0 2 0 +MAX 0 -3 715827883/MAX/1 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 2/MAX/0 +MAX 0 MAX 0 +MAX 0 MIN 1/MAX/MAX +MAX -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX -1 -1 --- + java.lang.IllegalArgumentException: 2147483647 to -1 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX -1 1 0 +MAX -1 -2 1073741825/MAX/-1 +MAX -1 2 0 +MAX -1 -3 715827883/MAX/1 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 2/MAX/0 +MAX -1 MAX 0 +MAX -1 MIN 2/MAX/-1 +MAX 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 1 -1 MAX/MAX/1 +MAX 1 1 0 +MAX 1 -2 1073741824/MAX/1 +MAX 1 2 0 +MAX 1 -3 715827883/MAX/1 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 1/MAX/MAX +MAX 1 MAX 0 +MAX 1 MIN 1/MAX/MAX +MAX 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 3 -1 MAX-2/MAX/3 +MAX 3 1 0 +MAX 3 -2 1073741823/MAX/3 +MAX 3 2 0 +MAX 3 -3 715827882/MAX/4 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 1/MAX/MAX +MAX 3 MAX 0 +MAX 3 MIN 1/MAX/MAX +MAX MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN+1 -1 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 1 0 +MAX MIN+1 -2 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483647 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 2 0 +MAX MIN+1 -3 1431655765/MAX/MIN+3 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 3/MAX/MIN+1 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 2/MAX/-1 +MAX MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MAX -1 1/MAX/MAX +MAX MAX 1 1/MAX/MAX +MAX MAX -2 1/MAX/MAX +MAX MAX 2 1/MAX/MAX +MAX MAX -3 1/MAX/MAX +MAX MAX 3 1/MAX/MAX +MAX MAX 17 1/MAX/MAX +MAX MAX 127 1/MAX/MAX +MAX MAX MIN+1 1/MAX/MAX +MAX MAX MAX 1/MAX/MAX +MAX MAX MIN 1/MAX/MAX +MAX MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN -1 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 1 0 +MAX MIN -2 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483648 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 2 0 +MAX MIN -3 1431655766/MAX/MIN +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 3/MAX/MIN+1 +MAX MIN MAX 0 +MAX MIN MIN 2/MAX/-1 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 0 -1 0 +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 0 +MIN 0 2 1073741825/MIN/0 +MIN 0 -3 0 +MIN 0 3 715827883/MIN/-2 +MIN 0 17 126322568/MIN/-9 +MIN 0 127 16909321/MIN/-8 +MIN 0 MIN+1 0 +MIN 0 MAX 2/MIN/-1 +MIN 0 MIN 0 +MIN -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN -1 -1 0 +MIN -1 1 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 -2 0 +MIN -1 2 1073741824/MIN/-2 +MIN -1 -3 0 +MIN -1 3 715827883/MIN/-2 +MIN -1 17 126322568/MIN/-9 +MIN -1 127 16909321/MIN/-8 +MIN -1 MIN+1 0 +MIN -1 MAX 2/MIN/-1 +MIN -1 MIN 0 +MIN 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 1 -1 0 +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 0 +MIN 1 2 1073741825/MIN/0 +MIN 1 -3 0 +MIN 1 3 715827884/MIN/1 +MIN 1 17 126322568/MIN/-9 +MIN 1 127 16909321/MIN/-8 +MIN 1 MIN+1 0 +MIN 1 MAX 2/MIN/-1 +MIN 1 MIN 0 +MIN 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 3 -1 0 +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 0 +MIN 3 2 1073741826/MIN/2 +MIN 3 -3 0 +MIN 3 3 715827884/MIN/1 +MIN 3 17 126322568/MIN/-9 +MIN 3 127 16909321/MIN/-8 +MIN 3 MIN+1 0 +MIN 3 MAX 2/MIN/-1 +MIN 3 MIN 0 +MIN MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN+1 -1 0 +MIN MIN+1 1 2/MIN/MIN+1 +MIN MIN+1 -2 0 +MIN MIN+1 2 1/MIN/MIN +MIN MIN+1 -3 0 +MIN MIN+1 3 1/MIN/MIN +MIN MIN+1 17 1/MIN/MIN +MIN MIN+1 127 1/MIN/MIN +MIN MIN+1 MIN+1 0 +MIN MIN+1 MAX 1/MIN/MIN +MIN MIN+1 MIN 0 +MIN MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MAX -1 0 +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 0 +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 0 +MIN MAX 3 1431655766/MIN/MAX +MIN MAX 17 252645136/MIN/MAX +MIN MAX 127 33818641/MIN/MAX-15 +MIN MAX MIN+1 0 +MIN MAX MAX 3/MIN/MAX-1 +MIN MAX MIN 0 +MIN MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN -1 1/MIN/MIN +MIN MIN 1 1/MIN/MIN +MIN MIN -2 1/MIN/MIN +MIN MIN 2 1/MIN/MIN +MIN MIN -3 1/MIN/MIN +MIN MIN 3 1/MIN/MIN +MIN MIN 17 1/MIN/MIN +MIN MIN 127 1/MIN/MIN +MIN MIN MIN+1 1/MIN/MIN +MIN MIN MAX 1/MIN/MIN +MIN MIN MIN 1/MIN/MIN + +>>> start until end <<< + +start end step length/first/last +----------------------------------------- +0 0 0 0 +0 0 -1 0 +0 0 1 0 +0 0 -2 0 +0 0 2 0 +0 0 -3 0 +0 0 3 0 +0 0 17 0 +0 0 127 0 +0 0 MIN+1 0 +0 0 MAX 0 +0 0 MIN 0 +0 -1 0 0 +0 -1 -1 0 +0 -1 1 0 +0 -1 -2 0 +0 -1 2 0 +0 -1 -3 0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 0 +0 -1 MAX 0 +0 -1 MIN 0 +0 1 0 1/0/0 +0 1 -1 1/0/0 +0 1 1 1/0/0 +0 1 -2 1/0/0 +0 1 2 1/0/0 +0 1 -3 1/0/0 +0 1 3 1/0/0 +0 1 17 1/0/0 +0 1 127 1/0/0 +0 1 MIN+1 1/0/0 +0 1 MAX 1/0/0 +0 1 MIN 1/0/0 +0 3 0 3/0/2 +0 3 -1 3/0/2 +0 3 1 3/0/2 +0 3 -2 3/0/2 +0 3 2 3/0/2 +0 3 -3 3/0/2 +0 3 3 3/0/2 +0 3 17 3/0/2 +0 3 127 3/0/2 +0 3 MIN+1 3/0/2 +0 3 MAX 3/0/2 +0 3 MIN 3/0/2 +0 MIN+1 0 0 +0 MIN+1 -1 0 +0 MIN+1 1 0 +0 MIN+1 -2 0 +0 MIN+1 2 0 +0 MIN+1 -3 0 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 0 +0 MIN+1 MAX 0 +0 MIN+1 MIN 0 +0 MAX 0 MAX/0/MAX-1 +0 MAX -1 MAX/0/MAX-1 +0 MAX 1 MAX/0/MAX-1 +0 MAX -2 MAX/0/MAX-1 +0 MAX 2 MAX/0/MAX-1 +0 MAX -3 MAX/0/MAX-1 +0 MAX 3 MAX/0/MAX-1 +0 MAX 17 MAX/0/MAX-1 +0 MAX 127 MAX/0/MAX-1 +0 MAX MIN+1 MAX/0/MAX-1 +0 MAX MAX MAX/0/MAX-1 +0 MAX MIN MAX/0/MAX-1 +0 MIN 0 0 +0 MIN -1 0 +0 MIN 1 0 +0 MIN -2 0 +0 MIN 2 0 +0 MIN -3 0 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 0 +0 MIN MAX 0 +0 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +-1 0 0 1/-1/-1 +-1 0 -1 1/-1/-1 +-1 0 1 1/-1/-1 +-1 0 -2 1/-1/-1 +-1 0 2 1/-1/-1 +-1 0 -3 1/-1/-1 +-1 0 3 1/-1/-1 +-1 0 17 1/-1/-1 +-1 0 127 1/-1/-1 +-1 0 MIN+1 1/-1/-1 +-1 0 MAX 1/-1/-1 +-1 0 MIN 1/-1/-1 +-1 -1 0 0 +-1 -1 -1 0 +-1 -1 1 0 +-1 -1 -2 0 +-1 -1 2 0 +-1 -1 -3 0 +-1 -1 3 0 +-1 -1 17 0 +-1 -1 127 0 +-1 -1 MIN+1 0 +-1 -1 MAX 0 +-1 -1 MIN 0 +-1 1 0 2/-1/0 +-1 1 -1 2/-1/0 +-1 1 1 2/-1/0 +-1 1 -2 2/-1/0 +-1 1 2 2/-1/0 +-1 1 -3 2/-1/0 +-1 1 3 2/-1/0 +-1 1 17 2/-1/0 +-1 1 127 2/-1/0 +-1 1 MIN+1 2/-1/0 +-1 1 MAX 2/-1/0 +-1 1 MIN 2/-1/0 +-1 3 0 4/-1/2 +-1 3 -1 4/-1/2 +-1 3 1 4/-1/2 +-1 3 -2 4/-1/2 +-1 3 2 4/-1/2 +-1 3 -3 4/-1/2 +-1 3 3 4/-1/2 +-1 3 17 4/-1/2 +-1 3 127 4/-1/2 +-1 3 MIN+1 4/-1/2 +-1 3 MAX 4/-1/2 +-1 3 MIN 4/-1/2 +-1 MIN+1 0 0 +-1 MIN+1 -1 0 +-1 MIN+1 1 0 +-1 MIN+1 -2 0 +-1 MIN+1 2 0 +-1 MIN+1 -3 0 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 0 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 0 +-1 MAX 0 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -1 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 2 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -3 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 3 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 17 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 127 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MIN+1 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MAX --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MIN --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MIN 0 0 +-1 MIN -1 0 +-1 MIN 1 0 +-1 MIN -2 0 +-1 MIN 2 0 +-1 MIN -3 0 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 0 +-1 MIN MAX 0 +-1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +1 0 0 0 +1 0 -1 0 +1 0 1 0 +1 0 -2 0 +1 0 2 0 +1 0 -3 0 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 0 +1 0 MAX 0 +1 0 MIN 0 +1 -1 0 0 +1 -1 -1 0 +1 -1 1 0 +1 -1 -2 0 +1 -1 2 0 +1 -1 -3 0 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 0 +1 -1 MAX 0 +1 -1 MIN 0 +1 1 0 0 +1 1 -1 0 +1 1 1 0 +1 1 -2 0 +1 1 2 0 +1 1 -3 0 +1 1 3 0 +1 1 17 0 +1 1 127 0 +1 1 MIN+1 0 +1 1 MAX 0 +1 1 MIN 0 +1 3 0 2/1/2 +1 3 -1 2/1/2 +1 3 1 2/1/2 +1 3 -2 2/1/2 +1 3 2 2/1/2 +1 3 -3 2/1/2 +1 3 3 2/1/2 +1 3 17 2/1/2 +1 3 127 2/1/2 +1 3 MIN+1 2/1/2 +1 3 MAX 2/1/2 +1 3 MIN 2/1/2 +1 MIN+1 0 0 +1 MIN+1 -1 0 +1 MIN+1 1 0 +1 MIN+1 -2 0 +1 MIN+1 2 0 +1 MIN+1 -3 0 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 0 +1 MIN+1 MAX 0 +1 MIN+1 MIN 0 +1 MAX 0 MAX-1/1/MAX-1 +1 MAX -1 MAX-1/1/MAX-1 +1 MAX 1 MAX-1/1/MAX-1 +1 MAX -2 MAX-1/1/MAX-1 +1 MAX 2 MAX-1/1/MAX-1 +1 MAX -3 MAX-1/1/MAX-1 +1 MAX 3 MAX-1/1/MAX-1 +1 MAX 17 MAX-1/1/MAX-1 +1 MAX 127 MAX-1/1/MAX-1 +1 MAX MIN+1 MAX-1/1/MAX-1 +1 MAX MAX MAX-1/1/MAX-1 +1 MAX MIN MAX-1/1/MAX-1 +1 MIN 0 0 +1 MIN -1 0 +1 MIN 1 0 +1 MIN -2 0 +1 MIN 2 0 +1 MIN -3 0 +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 0 +1 MIN MAX 0 +1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +3 0 0 0 +3 0 -1 0 +3 0 1 0 +3 0 -2 0 +3 0 2 0 +3 0 -3 0 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 0 +3 0 MAX 0 +3 0 MIN 0 +3 -1 0 0 +3 -1 -1 0 +3 -1 1 0 +3 -1 -2 0 +3 -1 2 0 +3 -1 -3 0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 0 +3 -1 MAX 0 +3 -1 MIN 0 +3 1 0 0 +3 1 -1 0 +3 1 1 0 +3 1 -2 0 +3 1 2 0 +3 1 -3 0 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 0 +3 1 MAX 0 +3 1 MIN 0 +3 3 0 0 +3 3 -1 0 +3 3 1 0 +3 3 -2 0 +3 3 2 0 +3 3 -3 0 +3 3 3 0 +3 3 17 0 +3 3 127 0 +3 3 MIN+1 0 +3 3 MAX 0 +3 3 MIN 0 +3 MIN+1 0 0 +3 MIN+1 -1 0 +3 MIN+1 1 0 +3 MIN+1 -2 0 +3 MIN+1 2 0 +3 MIN+1 -3 0 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 0 +3 MIN+1 MAX 0 +3 MIN+1 MIN 0 +3 MAX 0 MAX-3/3/MAX-1 +3 MAX -1 MAX-3/3/MAX-1 +3 MAX 1 MAX-3/3/MAX-1 +3 MAX -2 MAX-3/3/MAX-1 +3 MAX 2 MAX-3/3/MAX-1 +3 MAX -3 MAX-3/3/MAX-1 +3 MAX 3 MAX-3/3/MAX-1 +3 MAX 17 MAX-3/3/MAX-1 +3 MAX 127 MAX-3/3/MAX-1 +3 MAX MIN+1 MAX-3/3/MAX-1 +3 MAX MAX MAX-3/3/MAX-1 +3 MAX MIN MAX-3/3/MAX-1 +3 MIN 0 0 +3 MIN -1 0 +3 MIN 1 0 +3 MIN -2 0 +3 MIN 2 0 +3 MIN -3 0 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 0 +3 MIN MAX 0 +3 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 MAX/MIN+1/-1 +MIN+1 0 -1 MAX/MIN+1/-1 +MIN+1 0 1 MAX/MIN+1/-1 +MIN+1 0 -2 MAX/MIN+1/-1 +MIN+1 0 2 MAX/MIN+1/-1 +MIN+1 0 -3 MAX/MIN+1/-1 +MIN+1 0 3 MAX/MIN+1/-1 +MIN+1 0 17 MAX/MIN+1/-1 +MIN+1 0 127 MAX/MIN+1/-1 +MIN+1 0 MIN+1 MAX/MIN+1/-1 +MIN+1 0 MAX MAX/MIN+1/-1 +MIN+1 0 MIN MAX/MIN+1/-1 +MIN+1 -1 0 MAX-1/MIN+1/-2 +MIN+1 -1 -1 MAX-1/MIN+1/-2 +MIN+1 -1 1 MAX-1/MIN+1/-2 +MIN+1 -1 -2 MAX-1/MIN+1/-2 +MIN+1 -1 2 MAX-1/MIN+1/-2 +MIN+1 -1 -3 MAX-1/MIN+1/-2 +MIN+1 -1 3 MAX-1/MIN+1/-2 +MIN+1 -1 17 MAX-1/MIN+1/-2 +MIN+1 -1 127 MAX-1/MIN+1/-2 +MIN+1 -1 MIN+1 MAX-1/MIN+1/-2 +MIN+1 -1 MAX MAX-1/MIN+1/-2 +MIN+1 -1 MIN MAX-1/MIN+1/-2 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -1 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 2 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -3 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 3 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 17 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 127 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MAX --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MIN --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 0 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -1 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 2 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -3 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 3 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 17 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 127 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MAX --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MIN --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MIN+1 0 0 +MIN+1 MIN+1 -1 0 +MIN+1 MIN+1 1 0 +MIN+1 MIN+1 -2 0 +MIN+1 MIN+1 2 0 +MIN+1 MIN+1 -3 0 +MIN+1 MIN+1 3 0 +MIN+1 MIN+1 17 0 +MIN+1 MIN+1 127 0 +MIN+1 MIN+1 MIN+1 0 +MIN+1 MIN+1 MAX 0 +MIN+1 MIN+1 MIN 0 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -1 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 2 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -3 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 3 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 17 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 127 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MAX --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MIN --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MIN 0 0 +MIN+1 MIN -1 0 +MIN+1 MIN 1 0 +MIN+1 MIN -2 0 +MIN+1 MIN 2 0 +MIN+1 MIN -3 0 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 0 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MAX 0 0 0 +MAX 0 -1 0 +MAX 0 1 0 +MAX 0 -2 0 +MAX 0 2 0 +MAX 0 -3 0 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 0 +MAX 0 MAX 0 +MAX 0 MIN 0 +MAX -1 0 0 +MAX -1 -1 0 +MAX -1 1 0 +MAX -1 -2 0 +MAX -1 2 0 +MAX -1 -3 0 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 0 +MAX -1 MAX 0 +MAX -1 MIN 0 +MAX 1 0 0 +MAX 1 -1 0 +MAX 1 1 0 +MAX 1 -2 0 +MAX 1 2 0 +MAX 1 -3 0 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 0 +MAX 1 MAX 0 +MAX 1 MIN 0 +MAX 3 0 0 +MAX 3 -1 0 +MAX 3 1 0 +MAX 3 -2 0 +MAX 3 2 0 +MAX 3 -3 0 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 0 +MAX 3 MAX 0 +MAX 3 MIN 0 +MAX MIN+1 0 0 +MAX MIN+1 -1 0 +MAX MIN+1 1 0 +MAX MIN+1 -2 0 +MAX MIN+1 2 0 +MAX MIN+1 -3 0 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 0 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 0 +MAX MAX 0 0 +MAX MAX -1 0 +MAX MAX 1 0 +MAX MAX -2 0 +MAX MAX 2 0 +MAX MAX -3 0 +MAX MAX 3 0 +MAX MAX 17 0 +MAX MAX 127 0 +MAX MAX MIN+1 0 +MAX MAX MAX 0 +MAX MAX MIN 0 +MAX MIN 0 0 +MAX MIN -1 0 +MAX MIN 1 0 +MAX MIN -2 0 +MAX MIN 2 0 +MAX MIN -3 0 +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 0 +MAX MIN MAX 0 +MAX MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -1 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 2 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -3 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 3 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 17 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 127 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MAX --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MIN --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 0 MAX/MIN/-2 +MIN -1 -1 MAX/MIN/-2 +MIN -1 1 MAX/MIN/-2 +MIN -1 -2 MAX/MIN/-2 +MIN -1 2 MAX/MIN/-2 +MIN -1 -3 MAX/MIN/-2 +MIN -1 3 MAX/MIN/-2 +MIN -1 17 MAX/MIN/-2 +MIN -1 127 MAX/MIN/-2 +MIN -1 MIN+1 MAX/MIN/-2 +MIN -1 MAX MAX/MIN/-2 +MIN -1 MIN MAX/MIN/-2 +MIN 1 0 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -1 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 2 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -3 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 3 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 17 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 127 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MAX --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MIN --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 0 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -1 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 2 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -3 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 3 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 17 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 127 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MAX --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MIN --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MIN+1 0 1/MIN/MIN +MIN MIN+1 -1 1/MIN/MIN +MIN MIN+1 1 1/MIN/MIN +MIN MIN+1 -2 1/MIN/MIN +MIN MIN+1 2 1/MIN/MIN +MIN MIN+1 -3 1/MIN/MIN +MIN MIN+1 3 1/MIN/MIN +MIN MIN+1 17 1/MIN/MIN +MIN MIN+1 127 1/MIN/MIN +MIN MIN+1 MIN+1 1/MIN/MIN +MIN MIN+1 MAX 1/MIN/MIN +MIN MIN+1 MIN 1/MIN/MIN +MIN MAX 0 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -1 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 3 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 17 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 127 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MAX --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MIN --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MIN 0 0 +MIN MIN -1 0 +MIN MIN 1 0 +MIN MIN -2 0 +MIN MIN 2 0 +MIN MIN -3 0 +MIN MIN 3 0 +MIN MIN 17 0 +MIN MIN 127 0 +MIN MIN MIN+1 0 +MIN MIN MAX 0 +MIN MIN MIN 0 + +>>> start until end by step <<< + +start end step length/first/last +----------------------------------------- +0 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 0 -1 0 +0 0 1 0 +0 0 -2 0 +0 0 2 0 +0 0 -3 0 +0 0 3 0 +0 0 17 0 +0 0 127 0 +0 0 MIN+1 0 +0 0 MAX 0 +0 0 MIN 0 +0 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 -1 -1 1/0/0 +0 -1 1 0 +0 -1 -2 1/0/0 +0 -1 2 0 +0 -1 -3 1/0/0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 1/0/0 +0 -1 MAX 0 +0 -1 MIN 1/0/0 +0 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 1 -1 0 +0 1 1 1/0/0 +0 1 -2 0 +0 1 2 1/0/0 +0 1 -3 0 +0 1 3 1/0/0 +0 1 17 1/0/0 +0 1 127 1/0/0 +0 1 MIN+1 0 +0 1 MAX 1/0/0 +0 1 MIN 0 +0 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 3 -1 0 +0 3 1 3/0/2 +0 3 -2 0 +0 3 2 2/0/2 +0 3 -3 0 +0 3 3 1/0/0 +0 3 17 1/0/0 +0 3 127 1/0/0 +0 3 MIN+1 0 +0 3 MAX 1/0/0 +0 3 MIN 0 +0 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN+1 -1 MAX/0/MIN+2 +0 MIN+1 1 0 +0 MIN+1 -2 1073741824/0/MIN+2 +0 MIN+1 2 0 +0 MIN+1 -3 715827883/0/MIN+2 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 1/0/0 +0 MIN+1 MAX 0 +0 MIN+1 MIN 1/0/0 +0 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MAX -1 0 +0 MAX 1 MAX/0/MAX-1 +0 MAX -2 0 +0 MAX 2 1073741824/0/MAX-1 +0 MAX -3 0 +0 MAX 3 715827883/0/MAX-1 +0 MAX 17 126322568/0/MAX-8 +0 MAX 127 16909321/0/MAX-7 +0 MAX MIN+1 0 +0 MAX MAX 1/0/0 +0 MAX MIN 0 +0 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN -1 --- + java.lang.IllegalArgumentException: 0 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN 1 0 +0 MIN -2 1073741824/0/MIN+2 +0 MIN 2 0 +0 MIN -3 715827883/0/MIN+2 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 2/0/MIN+1 +0 MIN MAX 0 +0 MIN MIN 1/0/0 + +start end step length/first/last +----------------------------------------- +-1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 0 -1 0 +-1 0 1 1/-1/-1 +-1 0 -2 0 +-1 0 2 1/-1/-1 +-1 0 -3 0 +-1 0 3 1/-1/-1 +-1 0 17 1/-1/-1 +-1 0 127 1/-1/-1 +-1 0 MIN+1 0 +-1 0 MAX 1/-1/-1 +-1 0 MIN 0 +-1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 -1 -1 0 +-1 -1 1 0 +-1 -1 -2 0 +-1 -1 2 0 +-1 -1 -3 0 +-1 -1 3 0 +-1 -1 17 0 +-1 -1 127 0 +-1 -1 MIN+1 0 +-1 -1 MAX 0 +-1 -1 MIN 0 +-1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 1 -1 0 +-1 1 1 2/-1/0 +-1 1 -2 0 +-1 1 2 1/-1/-1 +-1 1 -3 0 +-1 1 3 1/-1/-1 +-1 1 17 1/-1/-1 +-1 1 127 1/-1/-1 +-1 1 MIN+1 0 +-1 1 MAX 1/-1/-1 +-1 1 MIN 0 +-1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 3 -1 0 +-1 3 1 4/-1/2 +-1 3 -2 0 +-1 3 2 2/-1/1 +-1 3 -3 0 +-1 3 3 2/-1/2 +-1 3 17 1/-1/-1 +-1 3 127 1/-1/-1 +-1 3 MIN+1 0 +-1 3 MAX 1/-1/-1 +-1 3 MIN 0 +-1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN+1 -1 MAX-1/-1/MIN+2 +-1 MIN+1 1 0 +-1 MIN+1 -2 1073741823/-1/MIN+3 +-1 MIN+1 2 0 +-1 MIN+1 -3 715827882/-1/MIN+4 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 1/-1/-1 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 1/-1/-1 +-1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MAX -1 0 +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 0 +-1 MAX 2 1073741824/-1/MAX-2 +-1 MAX -3 0 +-1 MAX 3 715827883/-1/MAX-2 +-1 MAX 17 126322568/-1/MAX-9 +-1 MAX 127 16909321/-1/MAX-8 +-1 MAX MIN+1 0 +-1 MAX MAX 2/-1/MAX-1 +-1 MAX MIN 0 +-1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN -1 MAX/-1/MIN+1 +-1 MIN 1 0 +-1 MIN -2 1073741824/-1/MIN+1 +-1 MIN 2 0 +-1 MIN -3 715827883/-1/MIN+1 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 1/-1/-1 +-1 MIN MAX 0 +-1 MIN MIN 1/-1/-1 + +start end step length/first/last +----------------------------------------- +1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 0 -1 1/1/1 +1 0 1 0 +1 0 -2 1/1/1 +1 0 2 0 +1 0 -3 1/1/1 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 1/1/1 +1 0 MAX 0 +1 0 MIN 1/1/1 +1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 -1 -1 2/1/0 +1 -1 1 0 +1 -1 -2 1/1/1 +1 -1 2 0 +1 -1 -3 1/1/1 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 1/1/1 +1 -1 MAX 0 +1 -1 MIN 1/1/1 +1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 1 -1 0 +1 1 1 0 +1 1 -2 0 +1 1 2 0 +1 1 -3 0 +1 1 3 0 +1 1 17 0 +1 1 127 0 +1 1 MIN+1 0 +1 1 MAX 0 +1 1 MIN 0 +1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 3 -1 0 +1 3 1 2/1/2 +1 3 -2 0 +1 3 2 1/1/1 +1 3 -3 0 +1 3 3 1/1/1 +1 3 17 1/1/1 +1 3 127 1/1/1 +1 3 MIN+1 0 +1 3 MAX 1/1/1 +1 3 MIN 0 +1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN+1 -1 --- + java.lang.IllegalArgumentException: 1 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN+1 1 0 +1 MIN+1 -2 1073741824/1/MIN+3 +1 MIN+1 2 0 +1 MIN+1 -3 715827883/1/MIN+3 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 2/1/MIN+2 +1 MIN+1 MAX 0 +1 MIN+1 MIN 1/1/1 +1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MAX -1 0 +1 MAX 1 MAX-1/1/MAX-1 +1 MAX -2 0 +1 MAX 2 1073741823/1/MAX-2 +1 MAX -3 0 +1 MAX 3 715827882/1/MAX-3 +1 MAX 17 126322568/1/MAX-7 +1 MAX 127 16909321/1/MAX-6 +1 MAX MIN+1 0 +1 MAX MAX 1/1/1 +1 MAX MIN 0 +1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN -1 --- + java.lang.IllegalArgumentException: 1 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN 1 0 +1 MIN -2 1073741825/1/MIN+1 +1 MIN 2 0 +1 MIN -3 715827883/1/MIN+3 +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 2/1/MIN+2 +1 MIN MAX 0 +1 MIN MIN 2/1/MIN+1 + +start end step length/first/last +----------------------------------------- +3 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 0 -1 3/3/1 +3 0 1 0 +3 0 -2 2/3/1 +3 0 2 0 +3 0 -3 1/3/3 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 1/3/3 +3 0 MAX 0 +3 0 MIN 1/3/3 +3 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 -1 -1 4/3/0 +3 -1 1 0 +3 -1 -2 2/3/1 +3 -1 2 0 +3 -1 -3 2/3/0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 1/3/3 +3 -1 MAX 0 +3 -1 MIN 1/3/3 +3 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 1 -1 2/3/2 +3 1 1 0 +3 1 -2 1/3/3 +3 1 2 0 +3 1 -3 1/3/3 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 1/3/3 +3 1 MAX 0 +3 1 MIN 1/3/3 +3 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 3 -1 0 +3 3 1 0 +3 3 -2 0 +3 3 2 0 +3 3 -3 0 +3 3 3 0 +3 3 17 0 +3 3 127 0 +3 3 MIN+1 0 +3 3 MAX 0 +3 3 MIN 0 +3 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN+1 -1 --- + java.lang.IllegalArgumentException: 3 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN+1 1 0 +3 MIN+1 -2 1073741825/3/MIN+3 +3 MIN+1 2 0 +3 MIN+1 -3 715827884/3/MIN+2 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 2/3/MIN+4 +3 MIN+1 MAX 0 +3 MIN+1 MIN 2/3/MIN+3 +3 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MAX -1 0 +3 MAX 1 MAX-3/3/MAX-1 +3 MAX -2 0 +3 MAX 2 1073741822/3/MAX-2 +3 MAX -3 0 +3 MAX 3 715827882/3/MAX-1 +3 MAX 17 126322568/3/MAX-5 +3 MAX 127 16909321/3/MAX-4 +3 MAX MIN+1 0 +3 MAX MAX 1/3/3 +3 MAX MIN 0 +3 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN -1 --- + java.lang.IllegalArgumentException: 3 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN 1 0 +3 MIN -2 1073741826/3/MIN+1 +3 MIN 2 0 +3 MIN -3 715827884/3/MIN+2 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 2/3/MIN+4 +3 MIN MAX 0 +3 MIN MIN 2/3/MIN+3 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 0 -1 0 +MIN+1 0 1 MAX/MIN+1/-1 +MIN+1 0 -2 0 +MIN+1 0 2 1073741824/MIN+1/-1 +MIN+1 0 -3 0 +MIN+1 0 3 715827883/MIN+1/-1 +MIN+1 0 17 126322568/MIN+1/-8 +MIN+1 0 127 16909321/MIN+1/-7 +MIN+1 0 MIN+1 0 +MIN+1 0 MAX 1/MIN+1/MIN+1 +MIN+1 0 MIN 0 +MIN+1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 -1 -1 0 +MIN+1 -1 1 MAX-1/MIN+1/-2 +MIN+1 -1 -2 0 +MIN+1 -1 2 1073741823/MIN+1/-3 +MIN+1 -1 -3 0 +MIN+1 -1 3 715827882/MIN+1/-4 +MIN+1 -1 17 126322568/MIN+1/-8 +MIN+1 -1 127 16909321/MIN+1/-7 +MIN+1 -1 MIN+1 0 +MIN+1 -1 MAX 1/MIN+1/MIN+1 +MIN+1 -1 MIN 0 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 1 -1 0 +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 0 +MIN+1 1 2 1073741824/MIN+1/-1 +MIN+1 1 -3 0 +MIN+1 1 3 715827883/MIN+1/-1 +MIN+1 1 17 126322568/MIN+1/-8 +MIN+1 1 127 16909321/MIN+1/-7 +MIN+1 1 MIN+1 0 +MIN+1 1 MAX 2/MIN+1/0 +MIN+1 1 MIN 0 +MIN+1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 3 -1 0 +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 0 +MIN+1 3 2 1073741825/MIN+1/1 +MIN+1 3 -3 0 +MIN+1 3 3 715827884/MIN+1/2 +MIN+1 3 17 126322568/MIN+1/-8 +MIN+1 3 127 16909321/MIN+1/-7 +MIN+1 3 MIN+1 0 +MIN+1 3 MAX 2/MIN+1/0 +MIN+1 3 MIN 0 +MIN+1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN+1 -1 0 +MIN+1 MIN+1 1 0 +MIN+1 MIN+1 -2 0 +MIN+1 MIN+1 2 0 +MIN+1 MIN+1 -3 0 +MIN+1 MIN+1 3 0 +MIN+1 MIN+1 17 0 +MIN+1 MIN+1 127 0 +MIN+1 MIN+1 MIN+1 0 +MIN+1 MIN+1 MAX 0 +MIN+1 MIN+1 MIN 0 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MAX -1 0 +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 0 +MIN+1 MAX 2 MAX/MIN+1/MAX-2 +MIN+1 MAX -3 0 +MIN+1 MAX 3 1431655765/MIN+1/MAX-2 +MIN+1 MAX 17 252645135/MIN+1/MAX-16 +MIN+1 MAX 127 33818641/MIN+1/MAX-14 +MIN+1 MAX MIN+1 0 +MIN+1 MAX MAX 2/MIN+1/0 +MIN+1 MAX MIN 0 +MIN+1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN -1 1/MIN+1/MIN+1 +MIN+1 MIN 1 0 +MIN+1 MIN -2 1/MIN+1/MIN+1 +MIN+1 MIN 2 0 +MIN+1 MIN -3 1/MIN+1/MIN+1 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 1/MIN+1/MIN+1 + +start end step length/first/last +----------------------------------------- +MAX 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 0 -1 MAX/MAX/1 +MAX 0 1 0 +MAX 0 -2 1073741824/MAX/1 +MAX 0 2 0 +MAX 0 -3 715827883/MAX/1 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 1/MAX/MAX +MAX 0 MAX 0 +MAX 0 MIN 1/MAX/MAX +MAX -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX -1 -1 --- + java.lang.IllegalArgumentException: 2147483647 until -1 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX -1 1 0 +MAX -1 -2 1073741824/MAX/1 +MAX -1 2 0 +MAX -1 -3 715827883/MAX/1 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 2/MAX/0 +MAX -1 MAX 0 +MAX -1 MIN 1/MAX/MAX +MAX 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 1 -1 MAX-1/MAX/2 +MAX 1 1 0 +MAX 1 -2 1073741823/MAX/3 +MAX 1 2 0 +MAX 1 -3 715827882/MAX/4 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 1/MAX/MAX +MAX 1 MAX 0 +MAX 1 MIN 1/MAX/MAX +MAX 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 3 -1 MAX-3/MAX/4 +MAX 3 1 0 +MAX 3 -2 1073741822/MAX/5 +MAX 3 2 0 +MAX 3 -3 715827882/MAX/4 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 1/MAX/MAX +MAX 3 MAX 0 +MAX 3 MIN 1/MAX/MAX +MAX MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN+1 -1 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 1 0 +MAX MIN+1 -2 MAX/MAX/MIN+3 +MAX MIN+1 2 0 +MAX MIN+1 -3 1431655765/MAX/MIN+3 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 2/MAX/0 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 2/MAX/-1 +MAX MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MAX -1 0 +MAX MAX 1 0 +MAX MAX -2 0 +MAX MAX 2 0 +MAX MAX -3 0 +MAX MAX 3 0 +MAX MAX 17 0 +MAX MAX 127 0 +MAX MAX MIN+1 0 +MAX MAX MAX 0 +MAX MAX MIN 0 +MAX MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN -1 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 1 0 +MAX MIN -2 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483648 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 2 0 +MAX MIN -3 1431655765/MAX/MIN+3 +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 3/MAX/MIN+1 +MAX MIN MAX 0 +MAX MIN MIN 2/MAX/-1 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 0 -1 0 +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 0 +MIN 0 2 1073741824/MIN/-2 +MIN 0 -3 0 +MIN 0 3 715827883/MIN/-2 +MIN 0 17 126322568/MIN/-9 +MIN 0 127 16909321/MIN/-8 +MIN 0 MIN+1 0 +MIN 0 MAX 2/MIN/-1 +MIN 0 MIN 0 +MIN -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN -1 -1 0 +MIN -1 1 MAX/MIN/-2 +MIN -1 -2 0 +MIN -1 2 1073741824/MIN/-2 +MIN -1 -3 0 +MIN -1 3 715827883/MIN/-2 +MIN -1 17 126322568/MIN/-9 +MIN -1 127 16909321/MIN/-8 +MIN -1 MIN+1 0 +MIN -1 MAX 1/MIN/MIN +MIN -1 MIN 0 +MIN 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 1 -1 0 +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 0 +MIN 1 2 1073741825/MIN/0 +MIN 1 -3 0 +MIN 1 3 715827883/MIN/-2 +MIN 1 17 126322568/MIN/-9 +MIN 1 127 16909321/MIN/-8 +MIN 1 MIN+1 0 +MIN 1 MAX 2/MIN/-1 +MIN 1 MIN 0 +MIN 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 3 -1 0 +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 0 +MIN 3 2 1073741826/MIN/2 +MIN 3 -3 0 +MIN 3 3 715827884/MIN/1 +MIN 3 17 126322568/MIN/-9 +MIN 3 127 16909321/MIN/-8 +MIN 3 MIN+1 0 +MIN 3 MAX 2/MIN/-1 +MIN 3 MIN 0 +MIN MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN+1 -1 0 +MIN MIN+1 1 1/MIN/MIN +MIN MIN+1 -2 0 +MIN MIN+1 2 1/MIN/MIN +MIN MIN+1 -3 0 +MIN MIN+1 3 1/MIN/MIN +MIN MIN+1 17 1/MIN/MIN +MIN MIN+1 127 1/MIN/MIN +MIN MIN+1 MIN+1 0 +MIN MIN+1 MAX 1/MIN/MIN +MIN MIN+1 MIN 0 +MIN MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MAX -1 0 +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 0 +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 0 +MIN MAX 3 1431655765/MIN/MAX-3 +MIN MAX 17 252645135/MIN/MAX-17 +MIN MAX 127 33818641/MIN/MAX-15 +MIN MAX MIN+1 0 +MIN MAX MAX 3/MIN/MAX-1 +MIN MAX MIN 0 +MIN MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN -1 0 +MIN MIN 1 0 +MIN MIN -2 0 +MIN MIN 2 0 +MIN MIN -3 0 +MIN MIN 3 0 +MIN MIN 17 0 +MIN MIN 127 0 +MIN MIN MIN+1 0 +MIN MIN MAX 0 +MIN MIN MIN 0 + diff --git a/tests/run/range-unit.scala b/tests/run/range-unit.scala new file mode 100644 index 000000000..730a1d7c1 --- /dev/null +++ b/tests/run/range-unit.scala @@ -0,0 +1,55 @@ +import scala.collection.immutable.Range + +object Test { + // ha ha, I always forget math.abs(Int.MinValue) == Int.MinValue + val numbers = ( + ( (-3 to 3) ++ List(17, 127, Int.MaxValue, Int.MinValue + 1) + ).distinct.sortBy(n => (math.abs(n), n)) + ) :+ Int.MinValue + + // reducing output a little + val endpoints = numbers filterNot Set(-3, -2, 2, 17, 127) + + def num(n: Int) = { + val frommax = Int.MaxValue - n + val frommin = Int.MinValue - n + + if (n > 0) { + if (frommax == 0) "MAX" + else if (frommax < 1000) "MAX-" + frommax + else "" + n + } + else { + if (frommin == 0) "MIN" + else if (frommin > -1000) "MIN+" + (-frommin) + else "" + n + } + } + + def run[T](body: => Range): List[Any] = { + try { val r = body ; if (r.isEmpty) List(r.length) else List(num(r.length), num(r.head), num(r.last)) } + catch { case e: IllegalArgumentException => List("---\n " + e) } + } + + def runGroup(label: String, f: (Int, Int, Int) => Range): Unit = { + println(">>> " + label + " <<<\n") + for (start <- endpoints) { + val s = "%-7s %-7s %-7s %s".format("start", "end", "step", "length/first/last") + println(s + "\n" + ("-" * s.length)) + for (end <- endpoints ; step <- numbers) { + print("%-7s %-7s %-7s ".format(num(start), num(end), num(step))) + println(run(f(start, end, step)).mkString("/")) + } + println("") + } + } + + def main(args: Array[String]): Unit = { + runGroup("Range.inclusive", Range.inclusive(_, _, _)) + runGroup("Range.apply", Range.apply(_, _, _)) + runGroup("start to end", (x, y, _) => x to y) + runGroup("start to end by step", _ to _ by _) + runGroup("start until end", (x, y, _) => x until y) + runGroup("start until end by step", _ until _ by _) + } +} diff --git a/tests/run/rawstrings.check b/tests/run/rawstrings.check new file mode 100644 index 000000000..2b6c40725 --- /dev/null +++ b/tests/run/rawstrings.check @@ -0,0 +1 @@ +[\n\t'"$\n] diff --git a/tests/run/rawstrings.scala b/tests/run/rawstrings.scala new file mode 100644 index 000000000..bf4c684f3 --- /dev/null +++ b/tests/run/rawstrings.scala @@ -0,0 +1,3 @@ +object Test extends dotty.runtime.LegacyApp { + println(raw"[\n\t'${'"'}$$\n]") +} diff --git a/tests/run/retsynch.check b/tests/run/retsynch.check new file mode 100644 index 000000000..8c40598f9 --- /dev/null +++ b/tests/run/retsynch.check @@ -0,0 +1 @@ +abs(-5) = 5 diff --git a/tests/run/retsynch.scala b/tests/run/retsynch.scala new file mode 100644 index 000000000..7735df7d9 --- /dev/null +++ b/tests/run/retsynch.scala @@ -0,0 +1,11 @@ +object Test { + def abs(x: Int): Int = synchronized { + if (x > 0) + return x + return -x + } + + def main(args: Array[String]) = { + Console.println("abs(-5) = " + abs(-5)) + } +} diff --git a/tests/run/richWrapperEquals.scala b/tests/run/richWrapperEquals.scala new file mode 100644 index 000000000..4a43617cd --- /dev/null +++ b/tests/run/richWrapperEquals.scala @@ -0,0 +1,6 @@ +object Test { + def main(args: Array[String]): Unit = { + assert(5 == (5: java.lang.Integer)) + assert((5: java.lang.Integer) == 5) + } +} diff --git a/tests/run/run-bug4840.check b/tests/run/run-bug4840.check new file mode 100644 index 000000000..cdfc1f911 --- /dev/null +++ b/tests/run/run-bug4840.check @@ -0,0 +1,2 @@ +Some(5) +Some(Some(Some(5))) diff --git a/tests/run/run-bug4840.flags b/tests/run/run-bug4840.flags new file mode 100644 index 000000000..eb4d19bcb --- /dev/null +++ b/tests/run/run-bug4840.flags @@ -0,0 +1 @@ +-optimise
\ No newline at end of file diff --git a/tests/run/run-bug4840.scala b/tests/run/run-bug4840.scala new file mode 100644 index 000000000..dda280fd1 --- /dev/null +++ b/tests/run/run-bug4840.scala @@ -0,0 +1,30 @@ +object Test { + def g(x: Boolean): Option[String] = if (x) Some("booya") else None + + def f1() = { + for (x <- g(true)) yield { + g(false) match { + case Some(_) => sys.error("") + case None => 5 + } + } + } + + def f2() = { + for (x <- g(true) ; y <- g(true) ; z <- g(true)) yield { + for (x <- g(true) ; y <- g(true) ; z <- g(true)) yield { + g(true) map { _ => + (null: Any) match { + case Some(x: Int) => x + case _ => 5 + } + } + } + } + } + + def main(args: Array[String]): Unit = { + println(f1()) + println(f2()) + } +} diff --git a/tests/run/runtime-richChar.check b/tests/run/runtime-richChar.check new file mode 100644 index 000000000..8d7a00858 --- /dev/null +++ b/tests/run/runtime-richChar.check @@ -0,0 +1,10 @@ +'a' to 'c' ok +'a' until 'c' ok +'a' to 'b' ok +'a' until 'b' ok +'a' to 'a' ok +'a' until 'a' ok +'b' to 'a' ok +'b' until 'a' ok +'c' to 'a' ok +'c' until 'a' ok diff --git a/tests/run/runtime-richChar.scala b/tests/run/runtime-richChar.scala new file mode 100644 index 000000000..0368368bf --- /dev/null +++ b/tests/run/runtime-richChar.scala @@ -0,0 +1,25 @@ +object Test extends dotty.runtime.LegacyApp { + def testSeq(name: String, expected: Seq[Char], got: Seq[Char]): Unit = { + if (expected.toList == got.toList) + println(name + " ok") + else + println(name + " failed: " + expected + " differs from " + got) + } + + testSeq("'a' to 'c'", List('a', 'b', 'c'), 'a' to 'c') + testSeq("'a' until 'c'", List('a', 'b'), 'a' until 'c') + + testSeq("'a' to 'b'", List('a', 'b'), 'a' to 'b') + testSeq("'a' until 'b'", List('a'), 'a' until 'b') + + testSeq("'a' to 'a'", List('a'), 'a' to 'a') + testSeq("'a' until 'a'", List(), 'a' until 'a') + + testSeq("'b' to 'a'", List(), 'b' to 'a') + testSeq("'b' until 'a'", List(), 'b' until 'a') + + testSeq("'c' to 'a'", List(), 'c' to 'a') + testSeq("'c' until 'a'", List(), 'c' until 'a') +} + +// vim: set ts=2 sw=2 et: diff --git a/tests/run/sammy_repeated.check b/tests/run/sammy_repeated.check new file mode 100644 index 000000000..1cff0f067 --- /dev/null +++ b/tests/run/sammy_repeated.check @@ -0,0 +1 @@ +WrappedArray(1) diff --git a/tests/run/sammy_repeated.flags b/tests/run/sammy_repeated.flags new file mode 100644 index 000000000..e1b37447c --- /dev/null +++ b/tests/run/sammy_repeated.flags @@ -0,0 +1 @@ +-Xexperimental
\ No newline at end of file diff --git a/tests/run/sammy_repeated.scala b/tests/run/sammy_repeated.scala new file mode 100644 index 000000000..c24dc4190 --- /dev/null +++ b/tests/run/sammy_repeated.scala @@ -0,0 +1,8 @@ +trait RepeatedSink { def accept(a: Any*): Unit } + +object Test { + def main(args: Array[String]): Unit = { + val f: RepeatedSink = (a) => println(a) + f.accept(1) + } +}
\ No newline at end of file diff --git a/tests/run/scan.scala b/tests/run/scan.scala new file mode 100644 index 000000000..a43da3387 --- /dev/null +++ b/tests/run/scan.scala @@ -0,0 +1,23 @@ + + + + +object Test { + + def main(args: Array[String]): Unit = { + val lst = List(1, 2, 3, 4, 5) + + assert(lst.scanLeft(0)(_ + _) == List(0, 1, 3, 6, 10, 15)) + assert(lst.scanRight(0)(_ + _) == List(15, 14, 12, 9, 5, 0)) + + val emp = List[Int]() + assert(emp.scanLeft(0)(_ + _) == List(0)) + assert(emp.scanRight(0)(_ + _) == List(0)) + + val stream = Stream(1, 2, 3, 4, 5) + assert(stream.scanLeft(0)(_ + _) == Stream(0, 1, 3, 6, 10, 15)) + + assert(Stream.from(1).scanLeft(0)(_ + _).take(5) == Stream(0, 1, 3, 6, 10)) + } + +} diff --git a/tests/run/seqlike-kmp.check b/tests/run/seqlike-kmp.check new file mode 100644 index 000000000..6040710c7 --- /dev/null +++ b/tests/run/seqlike-kmp.check @@ -0,0 +1,90 @@ +indexOfSlice + (97) with idx >= -1 = 97 + (97) with idx >= 0 = 97 + (97) with idx >= 1 = 97 + (97) with idx >= 2 = 97 + (97) with idx >= 97 = 97 + (97) with idx >= 98 = -1 + (97) with idx >= 99 = -1 + (97) with idx >= 100 = -1 +lastIndexOfSlice + (97) with idx <= -1 = -1 + (97) with idx <= 0 = -1 + (97) with idx <= 1 = -1 + (97) with idx <= 2 = -1 + (97) with idx <= 97 = 97 + (97) with idx <= 98 = 97 + (97) with idx <= 99 = 97 + (97) with idx <= 100 = 97 +indexOfSlice + (97, 98) with idx >= -1 = 97 + (97, 98) with idx >= 0 = 97 + (97, 98) with idx >= 1 = 97 + (97, 98) with idx >= 2 = 97 + (97, 98) with idx >= 97 = 97 + (97, 98) with idx >= 98 = -1 + (97, 98) with idx >= 99 = -1 + (97, 98) with idx >= 100 = -1 +lastIndexOfSlice + (97, 98) with idx <= -1 = -1 + (97, 98) with idx <= 0 = -1 + (97, 98) with idx <= 1 = -1 + (97, 98) with idx <= 2 = -1 + (97, 98) with idx <= 97 = 97 + (97, 98) with idx <= 98 = 97 + (97, 98) with idx <= 99 = 97 + (97, 98) with idx <= 100 = 97 +indexOfSlice + (97, 98, 99) with idx >= -1 = 97 + (97, 98, 99) with idx >= 0 = 97 + (97, 98, 99) with idx >= 1 = 97 + (97, 98, 99) with idx >= 2 = 97 + (97, 98, 99) with idx >= 97 = 97 + (97, 98, 99) with idx >= 98 = -1 + (97, 98, 99) with idx >= 99 = -1 + (97, 98, 99) with idx >= 100 = -1 +lastIndexOfSlice + (97, 98, 99) with idx <= -1 = -1 + (97, 98, 99) with idx <= 0 = -1 + (97, 98, 99) with idx <= 1 = -1 + (97, 98, 99) with idx <= 2 = -1 + (97, 98, 99) with idx <= 97 = 97 + (97, 98, 99) with idx <= 98 = 97 + (97, 98, 99) with idx <= 99 = 97 + (97, 98, 99) with idx <= 100 = 97 +indexOfSlice + (98, 99) with idx >= -1 = 98 + (98, 99) with idx >= 0 = 98 + (98, 99) with idx >= 1 = 98 + (98, 99) with idx >= 2 = 98 + (98, 99) with idx >= 97 = 98 + (98, 99) with idx >= 98 = 98 + (98, 99) with idx >= 99 = -1 + (98, 99) with idx >= 100 = -1 +lastIndexOfSlice + (98, 99) with idx <= -1 = -1 + (98, 99) with idx <= 0 = -1 + (98, 99) with idx <= 1 = -1 + (98, 99) with idx <= 2 = -1 + (98, 99) with idx <= 97 = -1 + (98, 99) with idx <= 98 = 98 + (98, 99) with idx <= 99 = 98 + (98, 99) with idx <= 100 = 98 +indexOfSlice + (99) with idx >= -1 = 99 + (99) with idx >= 0 = 99 + (99) with idx >= 1 = 99 + (99) with idx >= 2 = 99 + (99) with idx >= 97 = 99 + (99) with idx >= 98 = 99 + (99) with idx >= 99 = 99 + (99) with idx >= 100 = -1 +lastIndexOfSlice + (99) with idx <= -1 = -1 + (99) with idx <= 0 = -1 + (99) with idx <= 1 = -1 + (99) with idx <= 2 = -1 + (99) with idx <= 97 = -1 + (99) with idx <= 98 = -1 + (99) with idx <= 99 = 99 + (99) with idx <= 100 = 99 diff --git a/tests/run/seqlike-kmp.scala b/tests/run/seqlike-kmp.scala new file mode 100644 index 000000000..af39fda9a --- /dev/null +++ b/tests/run/seqlike-kmp.scala @@ -0,0 +1,32 @@ +object Test { + val source = 0 to 99 + val idxes = (-1 to 2) ++ (97 to 100) + def str(xs: Seq[Int]) = xs.mkString("(", ", ", ")") + + def f(tgt: Seq[Int]) = { + println("indexOfSlice") + // the first index `>= from` such that... + for (x <- idxes) { + val res = source.indexOfSlice(tgt, x) + println(" %s with idx >= %d = %d".format(str(tgt), x, res)) + } + // the last index `<= end` such that... + println("lastIndexOfSlice") + for (x <- idxes) { + val res = source.lastIndexOfSlice(tgt, x) + println(" %s with idx <= %d = %d".format(str(tgt), x, res)) + } + } + + def g(idx: Int, len: Int) = { + f(source.slice(idx, idx + len)) + } + + def main(args: Array[String]): Unit = { + g(97, 1) + g(97, 2) + g(97, 3) + g(98, 2) + g(99, 1) + } +} diff --git a/tests/run/serialize-stream.check b/tests/run/serialize-stream.check new file mode 100644 index 000000000..e2a9f57aa --- /dev/null +++ b/tests/run/serialize-stream.check @@ -0,0 +1,6 @@ +Stream(1, ?) +List(1, 2, 3) +Stream(1, ?) +List(1) +Stream() +List() diff --git a/tests/run/serialize-stream.scala b/tests/run/serialize-stream.scala new file mode 100644 index 000000000..fc84d610a --- /dev/null +++ b/tests/run/serialize-stream.scala @@ -0,0 +1,20 @@ + + +object Test { + def ser[T](s: Stream[T]): Unit = { + val bos = new java.io.ByteArrayOutputStream() + val oos = new java.io.ObjectOutputStream(bos) + oos.writeObject(s) + + val ois = new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(bos.toByteArray)) + val obj = ois.readObject() + println(obj) + println(obj.asInstanceOf[Seq[T]].toList) + } + + def main(args: Array[String]): Unit = { + ser(Stream(1, 2, 3)) + ser(Stream(1)) + ser(Stream()) + } +} diff --git a/tests/run/showraw_nosymbol.check b/tests/run/showraw_nosymbol.check new file mode 100644 index 000000000..c54fe7471 --- /dev/null +++ b/tests/run/showraw_nosymbol.check @@ -0,0 +1 @@ +NoSymbol diff --git a/tests/run/showraw_nosymbol.scala b/tests/run/showraw_nosymbol.scala new file mode 100644 index 000000000..191647583 --- /dev/null +++ b/tests/run/showraw_nosymbol.scala @@ -0,0 +1,5 @@ +import scala.reflect.runtime.universe._ + +object Test extends dotty.runtime.LegacyApp { + println(showRaw(NoSymbol)) +} diff --git a/tests/run/shutdownhooks.check b/tests/run/shutdownhooks.check new file mode 100644 index 000000000..29956956e --- /dev/null +++ b/tests/run/shutdownhooks.check @@ -0,0 +1,3 @@ +Fooblitzky! +main#shutdown. +Test#shutdown. diff --git a/tests/run/shutdownhooks.scala b/tests/run/shutdownhooks.scala new file mode 100644 index 000000000..5f512a391 --- /dev/null +++ b/tests/run/shutdownhooks.scala @@ -0,0 +1,37 @@ +object Test { + scala.sys.addShutdownHook { + Thread.sleep(1000) + println("Test#shutdown.") + } + + def daemon() = { + val t = new Thread { + override def run(): Unit = { + Thread.sleep(10000) + println("Hallelujah!") // should not see this + } + } + t.setDaemon(true) + t.start() + t + } + + def nonDaemon() = { + val t = new Thread { + override def run(): Unit = { + Thread.sleep(100) + println("Fooblitzky!") + } + } + t.start() + t + } + + def main(args: Array[String]): Unit = { + daemon() + nonDaemon() + scala.sys.addShutdownHook { + println("main#shutdown.") + } + } +} diff --git a/tests/run/slice-strings.scala b/tests/run/slice-strings.scala new file mode 100644 index 000000000..129314387 --- /dev/null +++ b/tests/run/slice-strings.scala @@ -0,0 +1,19 @@ +object Test { + def cmp(x1: String) = { + val x2 = x1.toList + + -10 to 10 foreach { i => + assert(x1.take(i) == x2.take(i).mkString) + assert(x1.drop(i) == x2.drop(i).mkString) + assert(x1.takeRight(i) == x2.takeRight(i).mkString) + assert(x1.dropRight(i) == x2.dropRight(i).mkString) + } + for (idx1 <- -3 to 3 ; idx2 <- -3 to 3) { + assert(x1.slice(idx1, idx2) == x2.slice(idx1, idx2).mkString) + } + } + + def main(args: Array[String]): Unit = { + cmp("abcde") + } +} diff --git a/tests/run/slices.check b/tests/run/slices.check new file mode 100644 index 000000000..c7af9db46 --- /dev/null +++ b/tests/run/slices.check @@ -0,0 +1,34 @@ +List(2) +List() +List(1) +List() +List(1, 2) + +List(1, 2, 3) +List(1, 2, 3) +List(1, 2) +List() +List() + +List(4) +List() +List() +List() +List() + +Array(2) +Array() +Array(1) +Array() +Array(1, 2) + +Array(1, 2, 3) +Array(1, 2, 3) +Array(1, 2) +Array() + +Array(4) +Array() +Array() +Array() + diff --git a/tests/run/slices.scala b/tests/run/slices.scala new file mode 100644 index 000000000..1ffedaea0 --- /dev/null +++ b/tests/run/slices.scala @@ -0,0 +1,49 @@ + +import scala.language.postfixOps + +object Test extends dotty.runtime.LegacyApp { + + // lists + println(List(1, 2, 3, 4).slice(1, 2)) + println(List(1, 2, 3, 4).slice(2, 1)) + println(List(1, 2, 3, 4).slice(-1, 1)) + println(List(1, 2, 3, 4).slice(1, -1)) + println(List(1, 2, 3, 4).slice(-2, 2)) + println + + println(List(1, 2, 3, 4) take 3) + println(List(1, 2, 3) take 3) + println(List(1, 2) take 3) + println((List(): List[Int]) take 3) + println(List[Nothing]() take 3) + println + + println(List(1, 2, 3, 4) drop 3) + println(List(1, 2, 3) drop 3) + println(List(1, 2) drop 3) + println((List(): List[Int]) drop 3) + println(List[Nothing]() drop 3) + println + + // arrays + println(Array(1, 2, 3, 4).slice(1, 2).deep) + println(Array(1, 2, 3, 4).slice(2, 1).deep) + println(Array(1, 2, 3, 4).slice(-1, 1).deep) + println(Array(1, 2, 3, 4).slice(1, -1).deep) + println(Array(1, 2, 3, 4).slice(-2, 2).deep) + println + + println(Array(1, 2, 3, 4) take 3 deep) + println(Array(1, 2, 3) take 3 deep) + println(Array(1, 2) take 3 deep) + println((Array(): Array[Int]) take 3 deep) +// println(Array[Nothing]() take 3) // contrib #757 + println + + println(Array(1, 2, 3, 4) drop 3 deep) + println(Array(1, 2, 3) drop 3 deep) + println(Array(1, 2) drop 3 deep) + println((Array(): Array[Int]) drop 3 deep) +// println(Array[Nothing]() drop 3) + println +} diff --git a/tests/run/sm-interpolator.scala b/tests/run/sm-interpolator.scala new file mode 100644 index 000000000..e4bec7afb --- /dev/null +++ b/tests/run/sm-interpolator.scala @@ -0,0 +1,41 @@ +object Test extends dotty.runtime.LegacyApp { + import scala.reflect.internal.util.StringContextStripMarginOps + def check(actual: Any, expected: Any) = if (actual != expected) sys.error(s"\nexpected:\n$expected\n\nactual:\n$actual") + + val bar = "|\n ||" + + check( + sm"""|ab + |de + |${bar} | ${1}""", + "ab\nde\n|\n || | 1") + + check( + sm"|", + "") + + check( + sm"${0}", + "0") + + check( + sm"${0}", + "0") + + check( + sm"""${0}|${1} + |""", + "0|1\n") + + check( + sm""" ||""", + "|") + + check( + sm""" ${" "} ||""", + " ||") + + check( + sm"\n", + raw"\n".stripMargin) +} diff --git a/tests/run/sort.check b/tests/run/sort.check new file mode 100644 index 000000000..e06a4f666 --- /dev/null +++ b/tests/run/sort.check @@ -0,0 +1,6 @@ +100000 +List(1, 2, 3, 5, 10) +List(10, 5, 3, 2, 1) +List(10) +List(9, 10) +List() diff --git a/tests/run/sort.scala b/tests/run/sort.scala new file mode 100644 index 000000000..c38b8fbde --- /dev/null +++ b/tests/run/sort.scala @@ -0,0 +1,9 @@ +object Test extends dotty.runtime.LegacyApp { + println((1 to 100000).toList.sortWith(_<_).length) + println(List(1, 5, 10, 3, 2).toList.sortWith(_<_)) + println(List(1, 5, 10, 3, 2).toList.sortWith(_>_)) + println(List(10).toList.sortWith(_<_)) + println(List(10,9).toList.sortWith(_<_)) + println(List[Int]().toList.sortWith(_<_)) +} + diff --git a/tests/run/static-module-method.check b/tests/run/static-module-method.check new file mode 100644 index 000000000..ce0136250 --- /dev/null +++ b/tests/run/static-module-method.check @@ -0,0 +1 @@ +hello diff --git a/tests/run/static-module-method.scala b/tests/run/static-module-method.scala new file mode 100644 index 000000000..3e3b3cc07 --- /dev/null +++ b/tests/run/static-module-method.scala @@ -0,0 +1,14 @@ +// During development of delayed delambdafy there was a problem where +// GenASM would eliminate a loadmodule for all methods defined within that module +// even if those methods were static. This test would thus fail +// with a verify error under -Ydelambdafy:method + +object Test { + def moduleMethod(x: String) = x + + def map(x: String, f: String => String) = f(x) + + def main(args: Array[String]): Unit = { + println(map("hello", Test.moduleMethod)) + } +} diff --git a/tests/run/stream-stack-overflow-filter-map.scala b/tests/run/stream-stack-overflow-filter-map.scala new file mode 100644 index 000000000..22db619a3 --- /dev/null +++ b/tests/run/stream-stack-overflow-filter-map.scala @@ -0,0 +1,44 @@ +import collection.generic.{FilterMonadic, CanBuildFrom} + +object Test extends dotty.runtime.LegacyApp { + def mapSucc[Repr, That](s: FilterMonadic[Int, Repr])(implicit cbf: CanBuildFrom[Repr, Int, That]) = s map (_ + 1) + def flatMapId[T, Repr, That](s: FilterMonadic[T, Repr])(implicit cbf: CanBuildFrom[Repr, T, That]) = s flatMap (Seq(_)) + + def testStreamPred(s: Stream[Int])(p: Int => Boolean): Unit = { + val res1 = s withFilter p + val res2 = s filter p + + val expected = s.toSeq filter p + + val fMapped1 = flatMapId(res1) + val fMapped2 = flatMapId(res2) + assert(fMapped1 == fMapped2) + assert(fMapped1.toSeq == expected) + + val mapped1 = mapSucc(res1) + val mapped2 = mapSucc(res2) + assert(mapped1 == mapped2) + assert(mapped1.toSeq == (expected map (_ + 1))) + + assert((res1 map identity).toSeq == res2.toSeq) + } + + def testStream(s: Stream[Int]): Unit = { + testStreamPred(s)(_ => false) + testStreamPred(s)(_ => true) + testStreamPred(s)(_ % 2 == 0) + testStreamPred(s)(_ % 3 == 0) + } + + //Reduced version of the test case - either invocation used to cause a stack + //overflow before commit 80b3f433e5536d086806fa108ccdfacf10719cc2. + val resFMap = (1 to 10000).toStream withFilter (_ => false) flatMap (Seq(_)) + val resMap = (1 to 10000).toStream withFilter (_ => false) map (_ + 1) + + //Complete test case for withFilter + map/flatMap, as requested by @axel22. + for (j <- (0 to 3) :+ 10000) { + val stream = (1 to j).toStream + assert(stream.toSeq == (1 to j).toSeq) + testStream(stream) + } +} diff --git a/tests/run/streamWithFilter.check b/tests/run/streamWithFilter.check new file mode 100644 index 000000000..6b0e91a14 --- /dev/null +++ b/tests/run/streamWithFilter.check @@ -0,0 +1,5 @@ +15 +30 +45 +60 +75 diff --git a/tests/run/streamWithFilter.scala b/tests/run/streamWithFilter.scala new file mode 100644 index 000000000..cb919d4f5 --- /dev/null +++ b/tests/run/streamWithFilter.scala @@ -0,0 +1,11 @@ +object Test { + val nums = Stream.from(1) + def isFizz(x: Int) = x % 3 == 0 + def isBuzz(x: Int) = x % 5 == 0 + // next line will run forever if withFilter isn't doing its thing. + val fizzbuzzes = for (n <- nums ; if isFizz(n) ; if isBuzz(n)) yield n + + def main(args: Array[String]): Unit = { + fizzbuzzes take 5 foreach println + } +} diff --git a/tests/run/stream_flatmap_odds.check b/tests/run/stream_flatmap_odds.check new file mode 100644 index 000000000..2b945e7c6 --- /dev/null +++ b/tests/run/stream_flatmap_odds.check @@ -0,0 +1 @@ +Stream(1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83) diff --git a/tests/run/stream_flatmap_odds.scala b/tests/run/stream_flatmap_odds.scala new file mode 100644 index 000000000..9e12e6dfa --- /dev/null +++ b/tests/run/stream_flatmap_odds.scala @@ -0,0 +1,4 @@ +object Test extends dotty.runtime.LegacyApp { + lazy val odds: Stream[Int] = Stream(1) append ( odds flatMap {x => Stream(x + 2)} ) + Console println (odds take 42).force +} diff --git a/tests/run/stringbuilder-drop.scala b/tests/run/stringbuilder-drop.scala new file mode 100644 index 000000000..422fb2bc7 --- /dev/null +++ b/tests/run/stringbuilder-drop.scala @@ -0,0 +1,7 @@ +object Test { + def main(args: Array[String]): Unit = { + val s = (new StringBuilder ++= "hello world") dropRight 1 + assert("" + s == "hello worl") + } +} + diff --git a/tests/run/sysprops.scala b/tests/run/sysprops.scala new file mode 100644 index 000000000..bdad67722 --- /dev/null +++ b/tests/run/sysprops.scala @@ -0,0 +1,50 @@ +import sys._ + +/** Basic sys.Prop test. */ +object Test { + val key = "ding.dong.doobie" + + def bool() = { + val prop = BooleanProp.valueIsTrue(key) + assert(prop.key == key) + + prop.clear() + assert(!prop.value) + assert(!prop.isSet) + assert(prop.get != null) + + prop set "dingus" + assert(prop.get == "dingus") + assert(!prop.value) + prop set "true" + assert(prop.value) + prop.toggle() + assert(!prop.value) + prop.enable() + assert(prop.value) + prop.disable() + assert(!prop.value) + } + def int() = { + val prop = Prop[Int](key) + prop.clear() + assert(prop.value == 0) + prop.set("523") + assert(prop.value == 523) + prop.set("DingusInt") + + try { println(prop.value) ; assert(false, "should not get here") } + catch { case _: Exception => () } + } + def double() = { + val prop = Prop[Double](key) + prop.set("55.0") + assert(prop.value == 55.0) + } + + def main(args: Array[String]): Unit = { + bool() + int() + double() + } +} diff --git a/tests/run/t0005.check b/tests/run/t0005.check new file mode 100644 index 000000000..1e8b31496 --- /dev/null +++ b/tests/run/t0005.check @@ -0,0 +1 @@ +6 diff --git a/tests/run/t0005.scala b/tests/run/t0005.scala new file mode 100644 index 000000000..38c24745f --- /dev/null +++ b/tests/run/t0005.scala @@ -0,0 +1,47 @@ +object A1 { + object A2 { + class X { def unapply(v : Int) = Some(v + 1) } + } +} + +object B1 { + object B2 { + val q = new A1.A2.X + } +} + +object Test { + def main(args: Array[String]): Unit = { + import B1.B2.q + val res = 5 match { case q(x) => x } + println(res) + } +} + + + +/* +compiler crash: + +object A1 { + object A2 { + class X { def unapply(v : Int) = Some(v + 1) } + } +} + +object B1 { + object B2 { + val q = new A1.A2.X + } +} + +object C { + def main(args: Array[String]) { + //import B1.B2.q + val q = new A1.A2.X + val res = 5 match { case q(x) => x } + println(res) + } +} + +*/ diff --git a/tests/run/t0048.check b/tests/run/t0048.check new file mode 100644 index 000000000..1e8b31496 --- /dev/null +++ b/tests/run/t0048.check @@ -0,0 +1 @@ +6 diff --git a/tests/run/t0048.scala b/tests/run/t0048.scala new file mode 100644 index 000000000..c1fcc6ddc --- /dev/null +++ b/tests/run/t0048.scala @@ -0,0 +1,13 @@ +object A1 { + object A2 { + class X { def unapply(v : Int) = Some(v + 1) } + } +} + +object Test { + def main(args: Array[String]): Unit = { + val q = new A1.A2.X + val res = 5 match { case q(x) => x } + println(res) + } +} diff --git a/tests/run/t0668.scala b/tests/run/t0668.scala new file mode 100644 index 000000000..f97c360e5 --- /dev/null +++ b/tests/run/t0668.scala @@ -0,0 +1,5 @@ +object Test extends dotty.runtime.LegacyApp { + val ints: Array[Int] = Array(1, 2, 3) + ints.toArray +} + diff --git a/tests/run/t0677-old.scala b/tests/run/t0677-old.scala new file mode 100644 index 000000000..fde0aac9f --- /dev/null +++ b/tests/run/t0677-old.scala @@ -0,0 +1,11 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test extends dotty.runtime.LegacyApp { + class X[T: ClassManifest] { + val a = Array.ofDim[T](3, 4) + } + val x = new X[String] + x.a(1)(2) = "hello" + assert(x.a(1)(2) == "hello") +} diff --git a/tests/run/t0883.check b/tests/run/t0883.check new file mode 100644 index 000000000..2c94e4837 --- /dev/null +++ b/tests/run/t0883.check @@ -0,0 +1,2 @@ +OK +OK diff --git a/tests/run/t0883.scala b/tests/run/t0883.scala new file mode 100644 index 000000000..fb46f423e --- /dev/null +++ b/tests/run/t0883.scala @@ -0,0 +1,14 @@ +object Foo { def apply(x: String) = new Foo(x) } +class Foo(name: String) +case object Bar extends Foo("Bar") +case class Baz() extends Foo("Baz") +object Test extends dotty.runtime.LegacyApp { + Foo("Bar") match { + case Bar => println("What?") + case _ => println("OK") + } + Foo("Baz") match { + case Baz() => println("What?") + case _ => println("OK") + } +} diff --git a/tests/run/t1005.check b/tests/run/t1005.check new file mode 100644 index 000000000..6ec092909 --- /dev/null +++ b/tests/run/t1005.check @@ -0,0 +1,2 @@ +Halp! +Halp! diff --git a/tests/run/t1005.scala b/tests/run/t1005.scala new file mode 100644 index 000000000..562e2e4c6 --- /dev/null +++ b/tests/run/t1005.scala @@ -0,0 +1,20 @@ +import scala.language.postfixOps +object Test +{ + class Foo[T](x : Array[AnyRef]) { def bar = x.asInstanceOf[Array[T]] } + class Bar[T](x : Array[T]) { def bar = x.asInstanceOf[Array[AnyRef]] } + + object FromMono{ + def mainer(args : Array[String]) = (new Foo[AnyRef](Array[AnyRef]("Halp!"))).bar + } + + object FromPoly{ + def mainer(args : Array[String]) = (new Bar[AnyRef](Array[AnyRef]("Halp!"))).bar + } + + def main(args: Array[String]): Unit = { + println(FromMono mainer null mkString) + println(FromPoly mainer null mkString) + } +} + diff --git a/tests/run/t1044.scala b/tests/run/t1044.scala new file mode 100644 index 000000000..227f6de27 --- /dev/null +++ b/tests/run/t1044.scala @@ -0,0 +1,4 @@ +object Test extends dotty.runtime.LegacyApp { + val ducks = Array[AnyRef]("Huey", "Dewey", "Louie"); + ducks.iterator.asInstanceOf[Iterator[String]] +} diff --git a/tests/run/t107.check b/tests/run/t107.check new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/run/t107.check @@ -0,0 +1 @@ +1 diff --git a/tests/run/t107.scala b/tests/run/t107.scala new file mode 100644 index 000000000..2cd4c9820 --- /dev/null +++ b/tests/run/t107.scala @@ -0,0 +1,8 @@ +object Test { + def main(args : Array[String]) : Unit = { + var hash : Long = 0 + val bytes = Array(1.toByte, 2.toByte, 3.toByte) + hash += bytes(0) + Console.println(hash) + } +} diff --git a/tests/run/t1074.check b/tests/run/t1074.check new file mode 100644 index 000000000..ccf1cb155 --- /dev/null +++ b/tests/run/t1074.check @@ -0,0 +1,3 @@ +q0 = Set(kl, jk, cd, fg, ef, gh, a, de, hj, b, lm, mn) +q1 = Set() 0 +q2 = Set() 0 diff --git a/tests/run/t1074.scala b/tests/run/t1074.scala new file mode 100644 index 000000000..a95f9eedb --- /dev/null +++ b/tests/run/t1074.scala @@ -0,0 +1,14 @@ +import scala.collection.immutable._ +object Test { + def main(args : Array[String]) : Unit = { + var words = "a" :: "b" :: "cd" :: "de" :: "fg" :: "ef" :: + "gh" :: "jk" :: "hj" :: "kl" :: "lm" :: "mn" :: Nil + val q0:Set[String] = + new HashSet[String]() ++ words + val q1 = q0.filter(w => false) + val q2 = q1.filter(w => false) + Console.println("q0 = " + q0) + Console.println("q1 = " + q1+" "+q1.size) + Console.println("q2 = " + q2+" "+q2.size) + } +} diff --git a/tests/run/t1192.check b/tests/run/t1192.check new file mode 100644 index 000000000..57234e1d8 --- /dev/null +++ b/tests/run/t1192.check @@ -0,0 +1,2 @@ +Array(1, 2) +Array(3, 4) diff --git a/tests/run/t1192.scala b/tests/run/t1192.scala new file mode 100644 index 000000000..073d34685 --- /dev/null +++ b/tests/run/t1192.scala @@ -0,0 +1,7 @@ +object Test extends dotty.runtime.LegacyApp { + val v1: Array[Array[Int]] = Array(Array(1, 2), Array(3, 4)) + def f[T](w: Array[Array[T]]): Unit = { + for (r <- w) println(r.deep.toString) + } + f(v1) +} diff --git a/tests/run/t1300.check b/tests/run/t1300.check new file mode 100644 index 000000000..0f29a1fef --- /dev/null +++ b/tests/run/t1300.check @@ -0,0 +1 @@ +abcdabcdabcd diff --git a/tests/run/t1300.scala b/tests/run/t1300.scala new file mode 100644 index 000000000..8ba13fae1 --- /dev/null +++ b/tests/run/t1300.scala @@ -0,0 +1,13 @@ +object Test extends dotty.runtime.LegacyApp +{ + val a1 = Array(0,1,2,3).toArray[Any] +// val a1 = x1.toArray[Any] + val a2 = Array('a','b','c','d').toArray[Any] + val a3 = Array("e","f","g","h").toArray[Any] + + Array.copy(a3, 0, a1, 0, 4) + Array.copy(a2, 0, a3, 0, 4) + Array.copy(a2, 0, a1, 0, 4) + + println(a1.mkString + a2.mkString + a3.mkString) +} diff --git a/tests/run/t1309.scala b/tests/run/t1309.scala new file mode 100644 index 000000000..84963549a --- /dev/null +++ b/tests/run/t1309.scala @@ -0,0 +1,7 @@ +object Test { + def f(ras: => IndexedSeq[Byte]): IndexedSeq[Byte] = ras + + def main(args: Array[String]): Unit = { + f(new Array[Byte](0)) + } +} diff --git a/tests/run/t1323.check b/tests/run/t1323.check new file mode 100644 index 000000000..0d540f71b --- /dev/null +++ b/tests/run/t1323.check @@ -0,0 +1,18 @@ + 1:-1 + 2:0 + 3:1 + 4:2 + 5:-1 + 6:-1 + 7:-1 + 8:-1 + 9:-1 +10:0 +11:-1 +12:-1 +13:-1 +14:0 +15:0 +16:-1 +17:-1 +18:3 diff --git a/tests/run/t1323.scala b/tests/run/t1323.scala new file mode 100644 index 000000000..68692d92a --- /dev/null +++ b/tests/run/t1323.scala @@ -0,0 +1,25 @@ +object Test extends dotty.runtime.LegacyApp { + println(" 1:" + List(1,2,3,4).indexOfSlice(List(0,1))) // -1 + println(" 2:" + List(1,2,3,4).indexOfSlice(List(1,2))) // 0 + println(" 3:" + List(1,2,3,4).indexOfSlice(List(2,3))) // 1 + println(" 4:" + List(1,2,3,4).indexOfSlice(List(3,4))) // 2 + println(" 5:" + List(1,2,3,4).indexOfSlice(List(4,5))) // -1 + println(" 6:" + List(1,2,3,4).indexOfSlice(List(2,4))) // -1 + println(" 7:" + List(1,2,3,4).indexOfSlice(List(4,3))) // -1 + println(" 8:" + List(1,2,3,4).indexOfSlice(List(1,3))) // -1 + println(" 9:" + List(1,2,3,4).indexOfSlice(List(1,3))) // -1 + println("10:" + List(1,2,3,4).indexOfSlice(List(1,2,3,4))) // 0 + println("11:" + List(1,2,3,4).indexOfSlice(List(4,3,2,1))) // -1 + println("12:" + List(1,2,3,4).indexOfSlice(List(1,2,3,4,5))) // -1 + println("13:" + List(1,2,3,4).indexOfSlice(List(5,4,3,2,1))) // -1 + println("14:" + List(1,2,3,4).indexOfSlice(List())) // 0 + println("15:" + List().indexOfSlice(List())) // 0 + println("16:" + List().indexOfSlice(List(1,2,3,4))) // -1 + + // Do some testing with infinite sequences + def from(n: Int): Stream[Int] = Stream.cons(n, from(n + 1)) + + println("17:" + List(1,2,3,4).indexOfSlice(from(1))) // -1 + println("18:" + from(1).indexOfSlice(List(4,5,6))) // 3 +} + diff --git a/tests/run/t1360.check b/tests/run/t1360.check new file mode 100644 index 000000000..8417e208a --- /dev/null +++ b/tests/run/t1360.check @@ -0,0 +1,2 @@ +[one, two] +[1, 2, 3] diff --git a/tests/run/t1360.scala b/tests/run/t1360.scala new file mode 100644 index 000000000..959c1cd2f --- /dev/null +++ b/tests/run/t1360.scala @@ -0,0 +1,7 @@ +object Test { + def main(args: Array[String]): Unit = { + val seq: Seq[String] = List("one", "two") + println(java.util.Arrays.asList(seq: _*)) + println(java.util.Arrays.asList(Seq(1,2,3): _*)) + } +} diff --git a/tests/run/t1423.check b/tests/run/t1423.check new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/run/t1423.check @@ -0,0 +1 @@ +1 diff --git a/tests/run/t1423.scala b/tests/run/t1423.scala new file mode 100644 index 000000000..d8b089827 --- /dev/null +++ b/tests/run/t1423.scala @@ -0,0 +1,8 @@ +object Test extends dotty.runtime.LegacyApp{ + val x = 1 match { + case 0xFFFFFFFF00000001L => println("Oops, overflow!"); + case 2L => println(2); + case 1L => println(1); + case _ => println("????"); + } +} diff --git a/tests/run/t1434.scala b/tests/run/t1434.scala new file mode 100644 index 000000000..63bd88ec9 --- /dev/null +++ b/tests/run/t1434.scala @@ -0,0 +1,15 @@ +object Test { + class A[T] { val op = null } + class B extends A[Any] + class C extends B + + def f(o: AnyRef) = o match { + case a: A[_] if(a.op != null) => "with op" + case c: C => "C" + case b: B => "B" + } + + def main(args: Array[String]) = { + assert("C" == f(new C)) + } +} diff --git a/tests/run/t1466.scala b/tests/run/t1466.scala new file mode 100644 index 000000000..cacadd53e --- /dev/null +++ b/tests/run/t1466.scala @@ -0,0 +1,11 @@ +object IOvervalueMyPrivacy { + private[this] var i = 0 + def go = { + List(1,2,3).foreach(i += _) + i + } +} + +object Test extends dotty.runtime.LegacyApp { + assert(IOvervalueMyPrivacy.go == 6) +} diff --git a/tests/run/t1524.check b/tests/run/t1524.check new file mode 100644 index 000000000..e79c5e8f9 --- /dev/null +++ b/tests/run/t1524.check @@ -0,0 +1 @@ +initial diff --git a/tests/run/t1524.scala b/tests/run/t1524.scala new file mode 100644 index 000000000..d28d56efb --- /dev/null +++ b/tests/run/t1524.scala @@ -0,0 +1,7 @@ +object Test extends dotty.runtime.LegacyApp { + + val buf = new scala.collection.mutable.ArrayBuffer[String](0) + buf += "initial" + buf += "second" + println(buf.head) +} diff --git a/tests/run/t153.check b/tests/run/t153.check new file mode 100644 index 000000000..648a6de7c --- /dev/null +++ b/tests/run/t153.check @@ -0,0 +1 @@ +Stream(262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1) diff --git a/tests/run/t153.scala b/tests/run/t153.scala new file mode 100644 index 000000000..610a9d6df --- /dev/null +++ b/tests/run/t153.scala @@ -0,0 +1,5 @@ +object Test extends dotty.runtime.LegacyApp { + def powers(x: Int) = if ((x&(x-1))==0) Some(x) else None + val res = (Stream.range(1, 500000) flatMap powers).reverse + println((res take 42).force) +} diff --git a/tests/run/t1535.check b/tests/run/t1535.check new file mode 100644 index 000000000..458a9ef08 --- /dev/null +++ b/tests/run/t1535.check @@ -0,0 +1,2 @@ +42 +true diff --git a/tests/run/t1535.scala b/tests/run/t1535.scala new file mode 100644 index 000000000..853a31cac --- /dev/null +++ b/tests/run/t1535.scala @@ -0,0 +1,15 @@ +class ASTNode { + lazy val x = 42 +} + +class BlockStmt extends ASTNode + +class ClassDecl extends BlockStmt { + lazy val y = true +} + +object Test extends dotty.runtime.LegacyApp { + val n = new ClassDecl () + println (n.x) + println (n.y) +} diff --git a/tests/run/t1591.check b/tests/run/t1591.check new file mode 100644 index 000000000..48082f72f --- /dev/null +++ b/tests/run/t1591.check @@ -0,0 +1 @@ +12 diff --git a/tests/run/t1591.scala b/tests/run/t1591.scala new file mode 100644 index 000000000..78efb695a --- /dev/null +++ b/tests/run/t1591.scala @@ -0,0 +1,14 @@ +abstract class A { + + lazy val lazyBar = bar + + object bar { + val foo = 12 + } + +} + +object Test extends dotty.runtime.LegacyApp { + val a = new A{} + println(a.lazyBar.foo) +} diff --git a/tests/run/t1618.scala b/tests/run/t1618.scala new file mode 100644 index 000000000..248af9b4f --- /dev/null +++ b/tests/run/t1618.scala @@ -0,0 +1,11 @@ + +object Test extends dotty.runtime.LegacyApp { + import scala.tools.nsc.io._ + + val dir: VirtualDirectory = new VirtualDirectory("foo", None) + dir.subdirectoryNamed("foo") + assert(dir.lookupName("foo", true) != null) + +} + + diff --git a/tests/run/t1672.scala b/tests/run/t1672.scala new file mode 100644 index 000000000..510530ab4 --- /dev/null +++ b/tests/run/t1672.scala @@ -0,0 +1,28 @@ +object Test { + @annotation.tailrec + def bar(i : Int) : Int = { + if (i == 0) 0 + else try { + throw new RuntimeException + } catch { + case _: Throwable => bar(i - 1) + } + } + + @annotation.tailrec + def nestedTry1(i : Int) : Int = { + if (i == 0) 0 + else try { + throw new RuntimeException + } catch { + case _: Throwable => + try { ??? } catch { case _: Throwable => nestedTry1(i - 1) } + } + } + + def main(args: Array[String]): Unit = { + assert(bar(2) == 0) + + assert(nestedTry1(2) == 0) + } +} diff --git a/tests/run/t1718.check b/tests/run/t1718.check new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/tests/run/t1718.check @@ -0,0 +1 @@ +true diff --git a/tests/run/t1718.scala b/tests/run/t1718.scala new file mode 100644 index 000000000..e6f520254 --- /dev/null +++ b/tests/run/t1718.scala @@ -0,0 +1,10 @@ +object Test extends dotty.runtime.LegacyApp{ + def matchesNull[T](mightBeNull: Array[T]): Boolean = mightBeNull match { + case null => true + case x => false + } + + val nullArray: Array[String] = null + println(matchesNull(nullArray)) +} + diff --git a/tests/run/t1747.scala b/tests/run/t1747.scala new file mode 100644 index 000000000..f2b51a253 --- /dev/null +++ b/tests/run/t1747.scala @@ -0,0 +1,6 @@ +object Foo extends Foo { + def f: Unit = {} +} +class Foo + +object Test extends dotty.runtime.LegacyApp { Foo } diff --git a/tests/run/t1829.scala b/tests/run/t1829.scala new file mode 100644 index 000000000..b51055a5a --- /dev/null +++ b/tests/run/t1829.scala @@ -0,0 +1,12 @@ +object Test{ + def main(args : Array[String]): Unit = { + import scala.collection.immutable._ + assert(IntMap.empty == HashMap.empty); + assert(HashMap.empty == IntMap.empty); + assert(LongMap.empty == HashMap.empty); + assert(HashMap.empty == LongMap.empty); + assert(IntMap.empty == LongMap.empty); + assert(IntMap(1 -> 2) == HashMap(1 -> 2)); + assert(LongMap(1L -> 2) == HashMap(1L -> 2)); + } +} diff --git a/tests/run/t1909c.scala b/tests/run/t1909c.scala new file mode 100644 index 000000000..50e06b39e --- /dev/null +++ b/tests/run/t1909c.scala @@ -0,0 +1,9 @@ +class Base(a: Any) + +// java.lang.VerifyError: (class: Sub, method: <init> signature: ()V) Expecting to find object/array on stack +// at Test$.<init>(t1909c.scala) +class Sub() extends Base({ def bippy = 5; bippy }) + +object Test extends dotty.runtime.LegacyApp { + new Sub() +} diff --git a/tests/run/t1939.scala b/tests/run/t1939.scala new file mode 100644 index 000000000..620c5b76f --- /dev/null +++ b/tests/run/t1939.scala @@ -0,0 +1,34 @@ +class Module {} + +abstract class T { + type moduleType <: Module + def module: moduleType +} + +final class T1(val module: Module) extends T { + type moduleType = Module +} + +final class T2(_module: Module) extends T { + type moduleType = Module + + def module = _module +} + +object Test extends dotty.runtime.LegacyApp { + + type mType = Module + + type tType = T { type moduleType <: mType } + // type tType = T { type moduleType <: Module } // runs successfully + // type tType = T // runs successfully + + def f(ts: List[tType]): Unit = { + + for (t <- ts; m = t.module) {} + ts.map(t => t.module).foreach { _ => () } + // ts.map(t => (t : T).module).foreach { _ => () } // runs successfully + } + + f(new T1(new Module) :: new T2(new Module) :: Nil) +} diff --git a/tests/run/t1987.check b/tests/run/t1987.check new file mode 100644 index 000000000..d2102a4a1 --- /dev/null +++ b/tests/run/t1987.check @@ -0,0 +1,16 @@ +long +long +double +double +long +long +double +double +long +long +double +double +long +long +double +double diff --git a/tests/run/t1987.flags b/tests/run/t1987.flags new file mode 100644 index 000000000..e8fb65d50 --- /dev/null +++ b/tests/run/t1987.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/tests/run/t1987.scala b/tests/run/t1987.scala new file mode 100644 index 000000000..f5abc262c --- /dev/null +++ b/tests/run/t1987.scala @@ -0,0 +1,62 @@ +// a.scala +// Fri Jan 13 11:31:47 PST 2012 + +package foo { + package object bar { + def duh(n: Long) = println("long") + def duh(n: Double) = println("double") + + def duh2(n: Double) = println("double") + def duh2(n: Long) = println("long") + } + package bar { + object Main { + def main(args:Array[String]): Unit = { + duh(33L) + bip.bar.duh(33L) + duh(33d) + bip.bar.duh(33d) + + duh2(33L) + bip.bar.duh2(33L) + duh2(33d) + bip.bar.duh2(33d) + } + } + } +} + +package bip { + trait Duh { + def duh(n: Long) = println("long") + def duh(n: Double) = println("double") + } + trait Duh2 { + def duh2(n: Double) = println("double") + def duh2(n: Long) = println("long") + } + + package object bar extends Duh with Duh2 { } + package bar { + object Main { + def main(args:Array[String]): Unit = { + duh(33L) + bip.bar.duh(33L) + duh(33d) + bip.bar.duh(33d) + + duh2(33L) + bip.bar.duh2(33L) + duh2(33d) + bip.bar.duh2(33d) + } + } + } +} + +object Test { + def main(args: Array[String]): Unit = { + foo.bar.Main.main(null) + bip.bar.Main.main(null) + } +} diff --git a/tests/run/t1987b.check b/tests/run/t1987b.check new file mode 100644 index 000000000..68d4b10e1 --- /dev/null +++ b/tests/run/t1987b.check @@ -0,0 +1 @@ +ok! diff --git a/tests/run/t1987b/PullIteratees.scala b/tests/run/t1987b/PullIteratees.scala new file mode 100644 index 000000000..a5a3e65d8 --- /dev/null +++ b/tests/run/t1987b/PullIteratees.scala @@ -0,0 +1,17 @@ +package scales.xml + +trait PullType +class QName +trait RetUrn[T] + +/** + * Iteratees related to pull parsing + */ +trait PullIteratees { + /** + * Without the overload it doesn't trigger the CCE, even though its + * not used + */ + def iterate(path: List[QName], xml: String): RetUrn[String] = null + def iterate(path: List[QName], xml: Iterator[PullType]): RetUrn[String] = null +} diff --git a/tests/run/t1987b/a.scala b/tests/run/t1987b/a.scala new file mode 100644 index 000000000..c1be5fe3e --- /dev/null +++ b/tests/run/t1987b/a.scala @@ -0,0 +1,6 @@ +object Test { + def main(args: Array[String]): Unit = { + scales.xml.CCE_Test.main(args) + println("ok!") + } +} diff --git a/tests/run/t1987b/cce_test.scala b/tests/run/t1987b/cce_test.scala new file mode 100644 index 000000000..4f9acf026 --- /dev/null +++ b/tests/run/t1987b/cce_test.scala @@ -0,0 +1,15 @@ +package scales.xml +//import scales.xml._ // using another pacakge and importing doesn't CCE + +object CCE_Test { + def main(args: Array[String]): Unit = { + // without the import it doesn't trigger the CCE + import scaley.funny._ + + val pull = null.asInstanceOf[Iterator[PullType]] + val LogEntries = null.asInstanceOf[List[QName]] + // fully qualify with scales.xml. and it won't trigger it + iterate(LogEntries, + pull) + } +} diff --git a/tests/run/t1987b/pkg1.scala b/tests/run/t1987b/pkg1.scala new file mode 100644 index 000000000..6e749fc6b --- /dev/null +++ b/tests/run/t1987b/pkg1.scala @@ -0,0 +1,4 @@ +package scaley + +package object funny { +} diff --git a/tests/run/t1987b/pkg2.scala b/tests/run/t1987b/pkg2.scala new file mode 100644 index 000000000..38056a199 --- /dev/null +++ b/tests/run/t1987b/pkg2.scala @@ -0,0 +1,3 @@ +package scales + +package object xml extends PullIteratees diff --git a/tests/run/t1994.scala b/tests/run/t1994.scala new file mode 100644 index 000000000..0b463e344 --- /dev/null +++ b/tests/run/t1994.scala @@ -0,0 +1,20 @@ +class A { + protected def x = 0 + protected[A] def y = 0 +} + +class B extends A { + override def x = 1 + def superY = super[A].y + override def y = 1 +} + + +object Test { + def main(args: Array[String]): Unit = { + val b = new B + assert(b.x == 1) + assert(b.y == 1) + assert(b.superY == 0) + } +} diff --git a/tests/run/t2005.scala b/tests/run/t2005.scala new file mode 100644 index 000000000..342a4dad0 --- /dev/null +++ b/tests/run/t2005.scala @@ -0,0 +1,10 @@ +object Test { + def main(args: Array[String]): Unit = { + val a = Array.ofDim[Int](2,2) + test(a) + } + def test[A](t: Array[Array[A]]): Unit = { + val tmp = t(0) + t(1) = tmp + } +} diff --git a/tests/run/t2027.check b/tests/run/t2027.check new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/run/t2027.check @@ -0,0 +1 @@ +1 diff --git a/tests/run/t2027.scala b/tests/run/t2027.scala new file mode 100644 index 000000000..96012d90f --- /dev/null +++ b/tests/run/t2027.scala @@ -0,0 +1,6 @@ +object Test { + def main(args: Array[String]): Unit = { + def fibs: Stream[Int] = Stream.cons(0, Stream.cons(1, fibs.zip(fibs.tail).map(p => p._1 + p._2))) + println(fibs(2)) // stack overflow + } +} diff --git a/tests/run/t2029.check b/tests/run/t2029.check new file mode 100644 index 000000000..57b610ccc --- /dev/null +++ b/tests/run/t2029.check @@ -0,0 +1,3 @@ +1,2,3,4,5 +4,3,2 +true diff --git a/tests/run/t2029.scala b/tests/run/t2029.scala new file mode 100644 index 000000000..d4ab0f02b --- /dev/null +++ b/tests/run/t2029.scala @@ -0,0 +1,16 @@ +object Test{ + def main(args : Array[String]): Unit = { + import scala.collection.immutable.TreeSet; + + val mainSet = TreeSet(1 to 5 :_*) + + var compareCalled = false; + val smallerSet = TreeSet(2 to 4 :_*)(Ordering[Int].reverse) + + println(mainSet.mkString(",")) + println(smallerSet.mkString(",")) + println(smallerSet.subsetOf(mainSet)); + } + + +} diff --git a/tests/run/t2030.check b/tests/run/t2030.check new file mode 100644 index 000000000..5923569f4 --- /dev/null +++ b/tests/run/t2030.check @@ -0,0 +1,2 @@ +true +class scala.collection.immutable.TreeSet
\ No newline at end of file diff --git a/tests/run/t2030.scala b/tests/run/t2030.scala new file mode 100644 index 000000000..cbd62baba --- /dev/null +++ b/tests/run/t2030.scala @@ -0,0 +1,8 @@ +import scala.collection.immutable._ + +object Test extends dotty.runtime.LegacyApp { + val res0 = TreeSet(1, 2, 3, 4, 5, 6) + val res1 = res0.map(x => x) + println(res0.toList == res1.toList) + println(res1.getClass) +} diff --git a/tests/run/t2075.scala b/tests/run/t2075.scala new file mode 100644 index 000000000..e81fb201c --- /dev/null +++ b/tests/run/t2075.scala @@ -0,0 +1,7 @@ +object Test extends dotty.runtime.LegacyApp { + var tm = new scala.collection.immutable.TreeMap[Int,Int] + for (i <- 0 to 100) + tm = tm.insert(i, i) + + tm.keySet.filter(_ < 40) +} diff --git a/tests/run/t2127.scala b/tests/run/t2127.scala new file mode 100755 index 000000000..d913ca1d1 --- /dev/null +++ b/tests/run/t2127.scala @@ -0,0 +1,32 @@ +// Seems to be fixed in trunk + +// As discussed here: http://www.nabble.com/Companion-object-constructor-visibility-td24342096.html + +//Simplified example: + + class Test private (val value : Int) + + abstract class Bar(val ctor : (Int) => Test) + + object Test extends Bar(new Test(_)) { //<--- ILLEGAL ACCESS + def main(args: Array[String]): Unit = {} + } + +//however the following is legal: +/* + class Foo private (val value : Int) + + abstract class Bar{ + + var ctor : (Int) => Foo + + } + + object Foo extends Bar{ + + ctor = new Foo(_) //<--- Legal access + + } + +The constructor invocation of Bar is done within the scope of object Foo's constructor, and therefor the private constructor of Foo should be visible and accessible. +*/ diff --git a/tests/run/t2147.check b/tests/run/t2147.check new file mode 100644 index 000000000..47e320610 --- /dev/null +++ b/tests/run/t2147.check @@ -0,0 +1,2 @@ +11 +11 diff --git a/tests/run/t2147.scala b/tests/run/t2147.scala new file mode 100644 index 000000000..ff5b71fee --- /dev/null +++ b/tests/run/t2147.scala @@ -0,0 +1,8 @@ +object Test extends dotty.runtime.LegacyApp { + val s: Seq[Int] = Stream.from(1) + val res0 = s.map(a => 2).head + val res1 = Stream.from(1).flatMap(a => List(1)).head + + println((for{a <- Stream.from(1); b <- 1 to 5; if a > 10} yield a).head) + println((for{a <- Stream.from(1); b <- 1 to a; if a > 10} yield a).head) +} diff --git a/tests/run/t216.check b/tests/run/t216.check new file mode 100644 index 000000000..d86bac9de --- /dev/null +++ b/tests/run/t216.check @@ -0,0 +1 @@ +OK diff --git a/tests/run/t216.scala b/tests/run/t216.scala new file mode 100644 index 000000000..56efb4502 --- /dev/null +++ b/tests/run/t216.scala @@ -0,0 +1,7 @@ +object Test extends dotty.runtime.LegacyApp { + object m { + val f = { x: Unit => () } + Console.println("OK") + } + m; +} diff --git a/tests/run/t2176.check b/tests/run/t2176.check new file mode 100644 index 000000000..2298e8b6e --- /dev/null +++ b/tests/run/t2176.check @@ -0,0 +1 @@ +Stream(1) diff --git a/tests/run/t2176.scala b/tests/run/t2176.scala new file mode 100644 index 000000000..8e2c583f1 --- /dev/null +++ b/tests/run/t2176.scala @@ -0,0 +1,4 @@ +object Test extends dotty.runtime.LegacyApp { + val res0 = Stream.cons(1, Stream.cons( { println("ouch"); 2 }, Stream.empty)) + println(res0.take(1).force) +} diff --git a/tests/run/t2177.check b/tests/run/t2177.check new file mode 100644 index 000000000..e56e15bb7 --- /dev/null +++ b/tests/run/t2177.check @@ -0,0 +1 @@ +12345 diff --git a/tests/run/t2177.scala b/tests/run/t2177.scala new file mode 100644 index 000000000..4485cfb86 --- /dev/null +++ b/tests/run/t2177.scala @@ -0,0 +1,3 @@ +object Test extends dotty.runtime.LegacyApp { + println(Stream.from(1).take(5).mkString) +} diff --git a/tests/run/t2255.check b/tests/run/t2255.check new file mode 100644 index 000000000..dda391b36 --- /dev/null +++ b/tests/run/t2255.check @@ -0,0 +1 @@ +List(1, 2, 3, 1, 2, 3) diff --git a/tests/run/t2255.scala b/tests/run/t2255.scala new file mode 100644 index 000000000..64dec8cae --- /dev/null +++ b/tests/run/t2255.scala @@ -0,0 +1,3 @@ +object Test extends dotty.runtime.LegacyApp { + println(Stream.continually(Stream(1, 2, 3)).flatten.take(6).toList) +} diff --git a/tests/run/t2378.scala b/tests/run/t2378.scala new file mode 100644 index 000000000..f696a78b4 --- /dev/null +++ b/tests/run/t2378.scala @@ -0,0 +1,9 @@ +object Test +{ + val f1 = -0.0 + val f2 = -(0.0) + def main(args: Array[String]): Unit = { + assert(f1.toString startsWith "-") + assert(f2.toString startsWith "-") + } +} diff --git a/tests/run/t2418.check b/tests/run/t2418.check new file mode 100644 index 000000000..f599e28b8 --- /dev/null +++ b/tests/run/t2418.check @@ -0,0 +1 @@ +10 diff --git a/tests/run/t2418.scala b/tests/run/t2418.scala new file mode 100644 index 000000000..f330bef60 --- /dev/null +++ b/tests/run/t2418.scala @@ -0,0 +1,10 @@ +class Foo { + @volatile final var x=10 + override def toString = "" + x +} + +object Test { + def main(args: Array[String]): Unit = { + println((new Foo)) + } +} diff --git a/tests/run/t2446.check b/tests/run/t2446.check new file mode 100644 index 000000000..00750edc0 --- /dev/null +++ b/tests/run/t2446.check @@ -0,0 +1 @@ +3 diff --git a/tests/run/t2446.scala b/tests/run/t2446.scala new file mode 100644 index 000000000..29494ab3e --- /dev/null +++ b/tests/run/t2446.scala @@ -0,0 +1,9 @@ +object Test { + def main(args : Array[String]) : Unit = { + val arr = new Array[Int](10000) + arr(5000) = 1 + arr (9000) = 2 + val sum = arr.reduceRight(_ + _) + println(sum) + } +} diff --git a/tests/run/t2488.check b/tests/run/t2488.check new file mode 100644 index 000000000..1af4bf896 --- /dev/null +++ b/tests/run/t2488.check @@ -0,0 +1,4 @@ +1 +1 +1 +2 diff --git a/tests/run/t2488.scala b/tests/run/t2488.scala new file mode 100644 index 000000000..c4cd0f60c --- /dev/null +++ b/tests/run/t2488.scala @@ -0,0 +1,11 @@ +class C { + def f(a:Int, b:Int) = 1 + def f() = 2 +} +object Test extends dotty.runtime.LegacyApp { + val c = new C() + println(c.f(a = 1,2)) + println(c.f(a = 1, b = 2)) + println(c.f(b = 2, a = 1)) + println(c.f()) +} diff --git a/tests/run/t2503.scala b/tests/run/t2503.scala new file mode 100755 index 000000000..d0983f2ca --- /dev/null +++ b/tests/run/t2503.scala @@ -0,0 +1,19 @@ +import scala.collection.mutable._ + +trait SB[A] extends Buffer[A] { + + import collection.Traversable + + abstract override def insertAll(n: Int, iter: Traversable[A]): Unit = synchronized { + super.insertAll(n, iter) + } + + abstract override def update(n: Int, newelem: A): Unit = synchronized { + super.update(n, newelem) + } +} + +object Test extends dotty.runtime.LegacyApp { + new ArrayBuffer[Int] with SB[Int] +} + diff --git a/tests/run/t2512.scala b/tests/run/t2512.scala new file mode 100644 index 000000000..8166839a9 --- /dev/null +++ b/tests/run/t2512.scala @@ -0,0 +1,13 @@ +import scala.tools.nsc.util.HashSet + +object Test { + val runs = 10000 + class Bop + + def main(args: Array[String]): Unit = { + val set: HashSet[Bop] = HashSet("Bop", 16) + (1 to runs).toList foreach (_ => set addEntry new Bop) + + assert(runs == set.size && set.size == set.iterator.length) + } +} diff --git a/tests/run/t2524.scala b/tests/run/t2524.scala new file mode 100644 index 000000000..e806b8c35 --- /dev/null +++ b/tests/run/t2524.scala @@ -0,0 +1,10 @@ +object Test { + def main(args: Array[String]): Unit = { + val m = new collection.mutable.HashMap[String, String] { + override def initialSize = 0 + } + m.toString + m("key") = "value" + assert(m("key") == "value") + } +} diff --git a/tests/run/t2552.check b/tests/run/t2552.check new file mode 100644 index 000000000..1deeae772 --- /dev/null +++ b/tests/run/t2552.check @@ -0,0 +1,48 @@ +p(0) +0 +p(1) +1 +p(2) +2 +p(3) +3 +p(4) +4 +p(5) +5 +p(6) +6 +p(7) +7 +p(8) +8 +p(9) +9 +p(10) +p(0) +true +true +0 +p(1) +true +1 +p(2) +false +false +p(0) +true +true +0 +p(1) +p(2) +2 +p(3) +p(4) +4 +p(5) +p(6) +6 +p(7) +p(8) +8 +p(9) diff --git a/tests/run/t2552.scala b/tests/run/t2552.scala new file mode 100644 index 000000000..27a6606ca --- /dev/null +++ b/tests/run/t2552.scala @@ -0,0 +1,34 @@ +object Test extends dotty.runtime.LegacyApp { + def testTakeWhile = { + val numbers = Iterator.range(0, 50) + val zeroTo9 = numbers.takeWhile(x => { println("p(" + x + ")"); x < 10 } ) + + zeroTo9.foreach(println _) + + val zeroTo1 = Iterator.range(0, 20).takeWhile(x => { println("p(" + x + ")"); x < 2 } ) + + println(zeroTo1.hasNext) + println(zeroTo1.hasNext) + println(zeroTo1.next) + println(zeroTo1.hasNext) + println(zeroTo1.next) + println(zeroTo1.hasNext) + println(zeroTo1.hasNext) + } + + def testFilter = { + val predicate = (x: Int) => { println("p(" + x + ")"); x % 2 == 0 } + + val evens = Iterator.range(0, 10).filter(predicate) + + println(evens.hasNext) + println(evens.hasNext) + println(evens.next) + + evens.foreach(println _) + } + + testTakeWhile + testFilter +} + diff --git a/tests/run/t2594_tcpoly.scala b/tests/run/t2594_tcpoly.scala new file mode 100644 index 000000000..789833bc0 --- /dev/null +++ b/tests/run/t2594_tcpoly.scala @@ -0,0 +1,21 @@ + +import scala.language.{ higherKinds } + +trait Monad[M[_]] { + def foo[A](a: M[A]): M[A] +} + +class Bar[A, B] +class Bar1[A] { type And[B] = Bar[A, B] } + +object Test { + // the combination of partial applications and anonymous class is essential to reproduce the bug + // problem: missing bridge method + // --> abstractmethoderror `Main$$anon$1.foo(Ljava/lang/Object;)Ljava/lang/Object;` + // the anonymous class only gets `public Bar foo(Bar a)` + def BarMonad[X] = new Monad[Bar1[X]#And] { + def foo[A](a: Bar[X, A]) = a + } + + def main(as: Array[String]): Unit = { BarMonad[Int] foo (new Bar[Int, Int]) } +} diff --git a/tests/run/t261.check b/tests/run/t261.check new file mode 100644 index 000000000..35d242ba7 --- /dev/null +++ b/tests/run/t261.check @@ -0,0 +1,2 @@ +A +B diff --git a/tests/run/t261.scala b/tests/run/t261.scala new file mode 100644 index 000000000..4e1aa9ff9 --- /dev/null +++ b/tests/run/t261.scala @@ -0,0 +1,11 @@ +trait A { val foo: String = "A" } +trait B { + private val foo: String = "B" + def f = println(foo) +} +object Test extends A with B { + def main(args: Array[String]) = { + println(foo) + f + } +} diff --git a/tests/run/t266.scala b/tests/run/t266.scala new file mode 100644 index 000000000..ea5f63c29 --- /dev/null +++ b/tests/run/t266.scala @@ -0,0 +1,23 @@ +// #266, yee ha + +trait O { + self: Test.type => + + Nil foreach identity + + def f = (1 to 10).toList map identity +} + +object Test extends O { + def main(args: Array[String]): Unit = { + assert(f.sum == 55) + } +} + +// Don't lose this part, it's what (formerly) crashes. +// For some reason the one actually mixed in does not. +object Pip + +trait P { self: Pip.type => + Nil foreach identity +} diff --git a/tests/run/t2754.scala b/tests/run/t2754.scala new file mode 100644 index 000000000..8817b62c7 --- /dev/null +++ b/tests/run/t2754.scala @@ -0,0 +1,39 @@ +object Test { + def main(args: Array[String]): Unit = { + val v: FooBarPlus[Int] = new FooBarPlusImpl() + v.foo += 10 + } +} + +trait Foo[P] { + def foo: P +} + +trait FooBar[P] extends Foo[P] { + def bar: P +} + +trait FooBarPlus[P] extends FooBar[P] { + override def foo: P + override def bar: P + + def foo_=(x: P): Unit + def bar_=(x: P): Unit +} + +class FooImpl extends Foo[Int] { + def foo = 1 +} + +class FooBarImpl extends FooImpl with FooBar[Int] { + protected var f = 0 + protected var b = 0 + + override def foo = f + def bar = b +} + +class FooBarPlusImpl extends FooBarImpl with FooBarPlus[Int] { + def foo_=(x: Int): Unit = { f = x } + def bar_=(x: Int): Unit = { b = x } +} diff --git a/tests/run/t2818.check b/tests/run/t2818.check new file mode 100644 index 000000000..31286c990 --- /dev/null +++ b/tests/run/t2818.check @@ -0,0 +1,4 @@ +105 +499999500000 +0 +1 diff --git a/tests/run/t2818.scala b/tests/run/t2818.scala new file mode 100644 index 000000000..7829b0251 --- /dev/null +++ b/tests/run/t2818.scala @@ -0,0 +1,6 @@ +object Test extends dotty.runtime.LegacyApp { + println((List.range(1L, 15L) :\ 0L) (_ + _)) + println((List.range(1L, 1000000L) :\ 0L) (_ + _)) + println((List.fill(5)(1) :\ 1) (_ - _)) + println((List.fill(1000000)(1) :\ 1) (_ - _)) +} diff --git a/tests/run/t2849.scala b/tests/run/t2849.scala new file mode 100644 index 000000000..bfc2135da --- /dev/null +++ b/tests/run/t2849.scala @@ -0,0 +1,48 @@ +import scala.collection.immutable.SortedSet +import scala.collection.immutable.TreeSet + +object Test { + + def main(args: Array[String]): Unit = { + ticketExample + similarExample + } + + //def freeMBytes = Runtime.getRuntime.freeMemory / 1048576 + def totalMBytes = Runtime.getRuntime.totalMemory / 1048576 + + val N = if (totalMBytes > 1000) 10000 else 4000 + val M = N / 10 + + def ticketExample: Unit = { + var big = 100000 + + var aSortedSet: SortedSet[Int] = TreeSet(big) + + for (i <- 1 until N) { + aSortedSet = (aSortedSet - big) ++ (TreeSet(i, big - 1)) + big -= 1 + if (i % M == 0) { + //println("big: "+big+", free memory: "+freeMBytes) + aSortedSet.until(i) + } + } + } + + def similarExample: Unit = { + var big = 100 + + var aSortedSet: SortedSet[Int] = TreeSet(big) + + for (i <- 1 until N) { + aSortedSet = (aSortedSet - big) ++ (TreeSet(i, big - 1)) + big + big -= 1 + if (i % M == 0) { + aSortedSet.until(i) + } + } + } + +} + + diff --git a/tests/run/t2876.scala b/tests/run/t2876.scala new file mode 100644 index 000000000..f71879ebf --- /dev/null +++ b/tests/run/t2876.scala @@ -0,0 +1,7 @@ +object Test +{ + def main(args: Array[String]): Unit = { + "x".view.filter(_ => true).take(1) + } +} + diff --git a/tests/run/t2958.scala b/tests/run/t2958.scala new file mode 100644 index 000000000..cf4867ab5 --- /dev/null +++ b/tests/run/t2958.scala @@ -0,0 +1,16 @@ +object Test { + def f(args: Array[String]) = args match { + case Array("-p", prefix, from, to) => + prefix + from + to + + case Array(from, to) => + from + to + + case _ => + "default" + } + + def main(args: Array[String]): Unit = { + assert(f(Array("1", "2")) == "12") + } +} diff --git a/tests/run/t3004.scala b/tests/run/t3004.scala new file mode 100644 index 000000000..a1e9c6c72 --- /dev/null +++ b/tests/run/t3004.scala @@ -0,0 +1,14 @@ +object MyClass { + val duplicate: Int = 10 +} + +class MyClass { + private val duplicate = MyClass.duplicate +} + +object Test { + def main(args: Array[String]): Unit = { + val x = new MyClass + () + } +} diff --git a/tests/run/t3088.scala b/tests/run/t3088.scala new file mode 100644 index 000000000..ea820b1c9 --- /dev/null +++ b/tests/run/t3088.scala @@ -0,0 +1,9 @@ +import collection.mutable._ + +object Test { + def main(args: Array[String]): Unit = { + val b = new ListBuffer[Int] + b += 1 + b ++= b + } +} diff --git a/tests/run/t3097.check b/tests/run/t3097.check new file mode 100644 index 000000000..63695f771 --- /dev/null +++ b/tests/run/t3097.check @@ -0,0 +1 @@ +atomic diff --git a/tests/run/t3097.scala b/tests/run/t3097.scala new file mode 100644 index 000000000..c5bac528b --- /dev/null +++ b/tests/run/t3097.scala @@ -0,0 +1,18 @@ +sealed trait ISimpleValue + +sealed trait IListValue extends ISimpleValue +sealed trait IAtomicValue[O] extends ISimpleValue + +sealed trait IAbstractDoubleValue[O] extends IAtomicValue[O] +sealed trait IDoubleValue extends IAbstractDoubleValue[Double] + +case class ListValue(val items: List[IAtomicValue[_]]) extends IListValue +class DoubleValue(val data: Double) extends IDoubleValue + +object Test extends dotty.runtime.LegacyApp { + // match is exhaustive + (new DoubleValue(1): ISimpleValue) match { + case m: IListValue => println("list") + case a: IAtomicValue[_] => println("atomic") + } +} diff --git a/tests/run/t3112.check b/tests/run/t3112.check new file mode 100644 index 000000000..a95644c82 --- /dev/null +++ b/tests/run/t3112.check @@ -0,0 +1,4 @@ +Vector() +Vector() +Vector() +Vector()
\ No newline at end of file diff --git a/tests/run/t3112.scala b/tests/run/t3112.scala new file mode 100644 index 000000000..44aa9471d --- /dev/null +++ b/tests/run/t3112.scala @@ -0,0 +1,11 @@ +// #3112 +object Test { + + def main(args: Array[String]): Unit = { + println((Vector() ++ (0 until 32)) take 0) // works + println((Vector() ++ (0 until 33)) take 0) // error + println((Vector() ++ (0 until 32)) takeRight 0) // works + println((Vector() ++ (0 until 33)) takeRight 0) // error + } + +} diff --git a/tests/run/t3186.check b/tests/run/t3186.check new file mode 100644 index 000000000..c508d5366 --- /dev/null +++ b/tests/run/t3186.check @@ -0,0 +1 @@ +false diff --git a/tests/run/t3186.scala b/tests/run/t3186.scala new file mode 100644 index 000000000..e170a4d50 --- /dev/null +++ b/tests/run/t3186.scala @@ -0,0 +1,7 @@ +object Dist1 extends Enumeration { val Mile, Foot, Inch = Value } + +object Dist2 extends Enumeration { val Kilometer, Millimeter, Parsec = Value } + +object Test extends dotty.runtime.LegacyApp { + println(Dist1.Mile == Dist2.Kilometer) +} diff --git a/tests/run/t3199b.check b/tests/run/t3199b.check new file mode 100644 index 000000000..b5d8bb58d --- /dev/null +++ b/tests/run/t3199b.check @@ -0,0 +1 @@ +[1, 2, 3] diff --git a/tests/run/t3199b.scala b/tests/run/t3199b.scala new file mode 100644 index 000000000..8052ef996 --- /dev/null +++ b/tests/run/t3199b.scala @@ -0,0 +1,11 @@ +object Test { + + def test() = { + java.util.Arrays.asList(Array(1,2,3):_*) + } + + def main(args: Array[String]): Unit = { + println(test()) + } + +} diff --git a/tests/run/t3232.scala b/tests/run/t3232.scala new file mode 100644 index 000000000..900a1f5db --- /dev/null +++ b/tests/run/t3232.scala @@ -0,0 +1,21 @@ +object Test { + // some maximally sized ranges + val r1 = 0 until Int.MaxValue + val r2 = 1 to Int.MaxValue + val r3 = Int.MinValue to -2 + val r4 = Int.MinValue until -1 + + // some exceptional conditions + val e1 = () => (0 to Int.MaxValue).length + val e2 = () => (5 until 5).last + + def main(args: Array[String]): Unit = { + List(r1, r2, r3, r4) foreach (x => assert(x.length == Int.MaxValue)) + + // exception required + List(e1, e2) foreach { f => + try { f() ; assert(false) } + catch { case _: Throwable => () } + } + } +} diff --git a/tests/run/t3241.check b/tests/run/t3241.check new file mode 100644 index 000000000..348ebd949 --- /dev/null +++ b/tests/run/t3241.check @@ -0,0 +1 @@ +done
\ No newline at end of file diff --git a/tests/run/t3241.scala b/tests/run/t3241.scala new file mode 100644 index 000000000..40097a046 --- /dev/null +++ b/tests/run/t3241.scala @@ -0,0 +1,23 @@ +object Test { + + def main(args : Array[String]) : Unit = { + recurse(Map(1->1, 2->2, 3->3, 4->4, 5->5, 6->6, 7->7)) + recurse(Set(1,2,3,4,5,6,7)) + println("done") + } + + def recurse(map: collection.immutable.Map[Int, Int]): Unit = { + if (!map.isEmpty) { + val x = map.keys.head + recurse(map - x) + } + } + + def recurse(set: collection.immutable.Set[Int]): Unit = { + if (!set.isEmpty) { + val x = set.toStream.head + recurse(set - x) + } + } + +} diff --git a/tests/run/t3242.check b/tests/run/t3242.check new file mode 100644 index 000000000..a145f6df8 --- /dev/null +++ b/tests/run/t3242.check @@ -0,0 +1,18 @@ + append [num: 200] vec + remove [num: 200] vec + append [num: 400] vec + remove [num: 400] vec + append [num: 600] vec + remove [num: 600] vec + append [num: 800] vec + remove [num: 800] vec +>> comparison done, num: 200 + append [num: 2000] vec + remove [num: 2000] vec + append [num: 4000] vec + remove [num: 4000] vec + append [num: 6000] vec + remove [num: 6000] vec + append [num: 8000] vec + remove [num: 8000] vec +>> comparison done, num: 2000 diff --git a/tests/run/t3242.scala b/tests/run/t3242.scala new file mode 100644 index 000000000..6a8ecd7a2 --- /dev/null +++ b/tests/run/t3242.scala @@ -0,0 +1,52 @@ + +import scala.language.{ higherKinds } + +object Test { + + def benchmarkA(num: Int): Unit = { + + type A = Int + + def updateM[M[_]](ms: M[A], update: (M[A], A)=>M[A]): M[A] = { + var is = ms + for (i <- 0 until num) is = update(is, i) + is + } + + // + def vectorAppend: Vector[A] = updateM[Vector](Vector(), (as, a)=>{ + val v = (as :+ a) + //println("==>append: i: "+i1+", v: "+v) + v + }) + // this will crash, Vector bug! + def vectorRemove(vec: Vector[A]): Vector[A] = updateM[Vector](vec, (as, a)=>{ + val v = (as filterNot{ _ == a}) + //val v = (is filter{ _ != i}) + //println("==>remove: i: "+a) + v + }) + + val ct = vectorAppend + println(" append [num: "+num+"] vec") + vectorRemove(ct) + println(" remove [num: "+num+"] vec") + } // BenchmarkA + + def comparison(num: Int): Unit = { + for (i <- 1 until 5) benchmarkA(num*i) + println(">> comparison done, num: "+num); + } + + def main(args: Array[String]): Unit = { + try { + //createBenchmarkA(23).testRun + + comparison(200) // OK + comparison(2000) // this will crach + + } catch { + case e: Exception => e.printStackTrace() + } + } +} diff --git a/tests/run/t3242b.scala b/tests/run/t3242b.scala new file mode 100644 index 000000000..7a296aac1 --- /dev/null +++ b/tests/run/t3242b.scala @@ -0,0 +1,17 @@ +import scala.collection.immutable._ + +object Test { + + def test(n: Int) = { + var vb = new VectorBuilder[Int] + for (i <- 0 until n) + vb += i + val v = vb.result + assert(v == (0 until n), "not same as (0 until " + n + "): " + v) + } + + def main(args: Array[String]): Unit = { + for (i <- 0 until 2000) + test(i) + } +} diff --git a/tests/run/t3269.check b/tests/run/t3269.check new file mode 100644 index 000000000..c25611c15 --- /dev/null +++ b/tests/run/t3269.check @@ -0,0 +1,2 @@ +1 +Hello diff --git a/tests/run/t3269.scala b/tests/run/t3269.scala new file mode 100644 index 000000000..17e42cdb0 --- /dev/null +++ b/tests/run/t3269.scala @@ -0,0 +1,9 @@ +object Test { + def main(args: Array[String]): Unit = { + val it = List(1).iterator ++ { println("Hello"); Iterator.empty } + println(it.next) + it.hasNext + it.hasNext + it.hasNext + } +} diff --git a/tests/run/t3273.scala b/tests/run/t3273.scala new file mode 100644 index 000000000..379a8a29c --- /dev/null +++ b/tests/run/t3273.scala @@ -0,0 +1,10 @@ +object Test { + val num1: Stream[Int] = 1 #:: num1.map(_ + 1) + val num2: Stream[Int] = 1 #:: num2.iterator.map(_ + 1).toStream + + def main(args: Array[String]): Unit = { + val x1 = (num1 take 10).toList + val x2 = (num2 take 10).toList + assert(x1 == x2) + } +} diff --git a/tests/run/t3326.check b/tests/run/t3326.check new file mode 100644 index 000000000..d0e11cebf --- /dev/null +++ b/tests/run/t3326.check @@ -0,0 +1,8 @@ +Map(2 -> Hello, 1 -> World) +Map(5 -> Foo, 4 -> Bar) +Map(5 -> Foo, 4 -> Bar, 2 -> Hello, 1 -> World) +Map(3 -> ?, 2 -> Hello, 1 -> World) +Map(2 -> Hello, 1 -> World) +Map(5 -> Foo, 4 -> Bar) +Map(5 -> Foo, 4 -> Bar, 2 -> Hello, 1 -> World) +Map(3 -> ?, 2 -> Hello, 1 -> World)
\ No newline at end of file diff --git a/tests/run/t3326.scala b/tests/run/t3326.scala new file mode 100644 index 000000000..5e403794d --- /dev/null +++ b/tests/run/t3326.scala @@ -0,0 +1,74 @@ + + + +import scala.math.Ordering + + + +/** The heart of the problem - we want to retain the ordering when + * using `++` on sorted maps. + * + * There are 2 `++` overloads - a generic one in traversables and + * a map-specific one in `MapLike` - which knows about the ordering. + * + * The problem here is that the expected return type for the expression + * in which `++` appears drives the decision of the overload that needs + * to be taken. + * The `collection.SortedMap` does not have `++` overridden to return + * `SortedMap`, but `immutable.Map` instead. + * This is why `collection.SortedMap` used to resort to the generic + * `TraversableLike.++` which knows nothing about the ordering. + * + * To avoid `collection.SortedMap`s resort to the more generic `TraverableLike.++`, + * we override the `MapLike.++` overload in `collection.SortedMap` to return + * the proper type `SortedMap`. + */ +object Test { + + def main(args: Array[String]): Unit = { + testCollectionSorted() + testImmutableSorted() + } + + def testCollectionSorted(): Unit = { + import collection._ + val order = implicitly[Ordering[Int]].reverse + var m1: SortedMap[Int, String] = SortedMap.empty[Int, String](order) + var m2: SortedMap[Int, String] = SortedMap.empty[Int, String](order) + + m1 += (1 -> "World") + m1 += (2 -> "Hello") + + m2 += (4 -> "Bar") + m2 += (5 -> "Foo") + + val m3: SortedMap[Int, String] = m1 ++ m2 + + println(m1) + println(m2) + println(m3) + + println(m1 + (3 -> "?")) + } + + def testImmutableSorted(): Unit = { + import collection.immutable._ + val order = implicitly[Ordering[Int]].reverse + var m1: SortedMap[Int, String] = SortedMap.empty[Int, String](order) + var m2: SortedMap[Int, String] = SortedMap.empty[Int, String](order) + + m1 += (1 -> "World") + m1 += (2 -> "Hello") + + m2 += (4 -> "Bar") + m2 += (5 -> "Foo") + + val m3: SortedMap[Int, String] = m1 ++ m2 + + println(m1) + println(m2) + println(m3) + + println(m1 + (3 -> "?")) + } +} diff --git a/tests/run/t3327.check b/tests/run/t3327.check new file mode 100644 index 000000000..980a0d5f1 --- /dev/null +++ b/tests/run/t3327.check @@ -0,0 +1 @@ +Hello World! diff --git a/tests/run/t3327.scala b/tests/run/t3327.scala new file mode 100644 index 000000000..9274841d0 --- /dev/null +++ b/tests/run/t3327.scala @@ -0,0 +1,8 @@ +object Test { + def main (args : Array[String]): Unit = { + val b = new StringBuilder + b.append ("Hello World!") + b.lastIndexOf ('e') + println (b.toString) + } +} diff --git a/tests/run/t3346a.check b/tests/run/t3346a.check new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/run/t3346a.check @@ -0,0 +1 @@ +1 diff --git a/tests/run/t3346a.scala b/tests/run/t3346a.scala new file mode 100644 index 000000000..dce126716 --- /dev/null +++ b/tests/run/t3346a.scala @@ -0,0 +1,11 @@ +import scala.language.implicitConversions + +object Test extends dotty.runtime.LegacyApp { + class Rep[T](x : T) + + class SomeOps[T](x : Rep[T]) { def foo = 1 } + implicit def mkOps[X, T](x : X)(implicit conv: X => Rep[T]) : SomeOps[T] = new SomeOps(conv(x)) + + val a: Rep[Int] = new Rep(42) + println(a.foo) +} diff --git a/tests/run/t3346d.scala b/tests/run/t3346d.scala new file mode 100644 index 000000000..6a4434a9d --- /dev/null +++ b/tests/run/t3346d.scala @@ -0,0 +1,21 @@ +import scala.language.implicitConversions + +object Test extends dotty.runtime.LegacyApp { + trait TARInt + + trait Basket[A,B] { + def iAmABasket = {} + } + + trait BasketFactory[A,B] { + def create(v: A): Basket[A,B] + } + + implicit val bf: Test.BasketFactory[Int,Test.TARInt] = new BasketFactory[Int,TARInt] { + def create(v: Int): Basket[Int,TARInt] = new Basket[Int, TARInt]{} + } + + implicit def i2[A,B](a: A)(implicit bf: BasketFactory[A,B]): Basket[A,B] = bf.create(a) + + 1.iAmABasket // <-- i2 conversion not applicable +} diff --git a/tests/run/t3346h.check b/tests/run/t3346h.check new file mode 100644 index 000000000..587be6b4c --- /dev/null +++ b/tests/run/t3346h.check @@ -0,0 +1 @@ +x diff --git a/tests/run/t3346h.scala b/tests/run/t3346h.scala new file mode 100644 index 000000000..0dc4b9f2e --- /dev/null +++ b/tests/run/t3346h.scala @@ -0,0 +1,9 @@ +import scala.language.implicitConversions + +object Test extends dotty.runtime.LegacyApp { + trait Fundep[T, U] { def u(t: T): U } + class C { def y = "x" } + implicit val FundepStringC: Test.Fundep[String,Test.C] = new Fundep[String, C]{ def u(t: String) = new C } + implicit def foo[T, U](x: T)(implicit y: Fundep[T, U]): U = y.u(x) + println("x".y) +} diff --git a/tests/run/t3395.check b/tests/run/t3395.check new file mode 100644 index 000000000..5f5521fae --- /dev/null +++ b/tests/run/t3395.check @@ -0,0 +1,2 @@ +abc +def diff --git a/tests/run/t3395.scala b/tests/run/t3395.scala new file mode 100644 index 000000000..5f663d68f --- /dev/null +++ b/tests/run/t3395.scala @@ -0,0 +1,13 @@ +object Test { + def main(args: Array[String]): Unit = { + Seq("") match { + case Seq("") => println("abc") + case Seq(_, _, x) => println(x) + } + + Seq(1, 2, "def") match { + case Seq("") => println("abc") + case Seq(_, _, x) => println(x) + } + } +} diff --git a/tests/run/t3397.scala b/tests/run/t3397.scala new file mode 100644 index 000000000..2c8cbed3a --- /dev/null +++ b/tests/run/t3397.scala @@ -0,0 +1,7 @@ +object Test { + def main(args: Array[String]): Unit = { + val x = Seq(Set(1,2,3),Set(4,5,6),Set(7,8,9)).transpose + + () + } +} diff --git a/tests/run/t3487.scala b/tests/run/t3487.scala new file mode 100644 index 000000000..f2ca73591 --- /dev/null +++ b/tests/run/t3487.scala @@ -0,0 +1,15 @@ +trait Bippy { + def bippy = 5 +} + +class Test extends Bippy { + def f1 = 55 +} + +object Test extends Test { + def dingus = bippy + def main(args: Array[String]): Unit = { + assert(bippy + f1 == 110) + } + override def bippy = 55 +} diff --git a/tests/run/t3493.scala b/tests/run/t3493.scala new file mode 100644 index 000000000..c13da2551 --- /dev/null +++ b/tests/run/t3493.scala @@ -0,0 +1,15 @@ + + + + +object Test { + + def main(args: Array[String]): Unit = { + import scala.collection.immutable._ + val x = TreeSet("a", "b", "c", "d") + val x2 = x + "e" + assert(x2.toString == "TreeSet(a, b, c, d, e)") + assert(x2.toString == runtime.ScalaRunTime.stringOf(x2).trim) + } + +} diff --git a/tests/run/t3496.scala b/tests/run/t3496.scala new file mode 100644 index 000000000..35bc5db24 --- /dev/null +++ b/tests/run/t3496.scala @@ -0,0 +1,15 @@ + + + + +// ticket #3496 +object Test { + + def main(args: Array[String]): Unit = { + val s = Stream.from(1) + s.take(5) + s.drop(5) + s.splitAt(5) + } + +} diff --git a/tests/run/t3508.scala b/tests/run/t3508.scala new file mode 100644 index 000000000..80ef89a61 --- /dev/null +++ b/tests/run/t3508.scala @@ -0,0 +1,11 @@ + + +import collection.immutable._ + + +// ticket #3508 +object Test { + def main(args: Array[String]): Unit = { + assert(Stream.tabulate(123)(_ + 1).toList == List.tabulate(123)(_ + 1)) + } +} diff --git a/tests/run/t3509.flags b/tests/run/t3509.flags new file mode 100644 index 000000000..6933d924d --- /dev/null +++ b/tests/run/t3509.flags @@ -0,0 +1 @@ +-Yinline
\ No newline at end of file diff --git a/tests/run/t3509.scala b/tests/run/t3509.scala new file mode 100644 index 000000000..8e1986f34 --- /dev/null +++ b/tests/run/t3509.scala @@ -0,0 +1,9 @@ +object Test { + + class Foo(final var i:Int) + + def main(args : Array[String]) : Unit = { + val foo = new Foo(0) + foo.i += 1 + } +} diff --git a/tests/run/t3511.scala b/tests/run/t3511.scala new file mode 100644 index 000000000..0df0321ad --- /dev/null +++ b/tests/run/t3511.scala @@ -0,0 +1,36 @@ + + + +import scala.collection.immutable._ + + +// ticket #3511 +object Test { + + def main(args: Array[String]): Unit = { + assert(Stream.from(0).view.force.take(5) == List(0, 1, 2, 3, 4)) + + val s = Stream.from(0) + val smap = s.view.map(_ * 2).force.take(5) + assert(smap == List(0, 2, 4, 6, 8)) + + val sfilter = s.view.filter(_ % 2 == 0).force.take(5) + assert(sfilter == List(0, 2, 4, 6, 8)) + + val sflatmap = s.view.flatMap(n => List(n, n * 2)).force.take(6) + assert(sflatmap == List(0, 0, 1, 2, 2, 4)) + + val stakewhile = s.view.takeWhile(_ < 10).force + assert(stakewhile == List.range(0, 10)) + + val szip = s.view.zip(s.map(_ / 2)).force.take(5) + assert(szip == List((0, 0), (1, 0), (2, 1), (3, 1), (4, 2))) + + val szipall = s.view.zipAll(List(0, 1, 2), 0, 0).force.take(5) + assert(szipall == List((0, 0), (1, 1), (2, 2), (3, 0), (4, 0))) + + val spatch = s.view.patch(1, List(5, 5, 5), 5).force.take(5) + assert(spatch == List(0, 5, 5, 5, 6)) + } + +} diff --git a/tests/run/t3516.check b/tests/run/t3516.check new file mode 100644 index 000000000..d0d10d82f --- /dev/null +++ b/tests/run/t3516.check @@ -0,0 +1,3 @@ +1 +1 +21 diff --git a/tests/run/t3516.scala b/tests/run/t3516.scala new file mode 100644 index 000000000..aa302ce85 --- /dev/null +++ b/tests/run/t3516.scala @@ -0,0 +1,13 @@ +object Test { + def mkIterator = (1 to 5).iterator map (x => { println(x) ; x }) + def mkInfinite = Iterator continually { println(1) ; 1 } + + def main(args: Array[String]): Unit = { + // Stream is strict in its head so we should see 1 from each of them. + val s1 = mkIterator.toStream + val s2 = mkInfinite.toStream + // back and forth without slipping into nontermination. + println((Stream from 1).toIterator.drop(10).toStream.drop(10).toIterator.next) + () + } +} diff --git a/tests/run/t3518.scala b/tests/run/t3518.scala new file mode 100644 index 000000000..033cc1954 --- /dev/null +++ b/tests/run/t3518.scala @@ -0,0 +1,16 @@ +object Test { + val r1 = 1.0 to 10.0 by 0.5 + val r2 = 1.0 to 1.0 by 1.0 + val r3 = 10.0 to 1.0 by -0.5 + val r4 = 1.0 until 1.0 by 1.0 + val r5 = 1 to 100 by 2 + + def main(args: Array[String]): Unit = { + assert(r3 forall (r1 contains _)) + assert(r1 forall (r3 contains _)) + assert(r2.size == 1) + assert(r4.isEmpty) + assert(List(1,3,5,97,99) forall (r5 contains _)) + assert(List(2,4,6,98,100) forall (x => !r5.contains(x))) + } +} diff --git a/tests/run/t3529.scala b/tests/run/t3529.scala new file mode 100644 index 000000000..a5977d0a6 --- /dev/null +++ b/tests/run/t3529.scala @@ -0,0 +1,15 @@ +import scala.language.postfixOps +object Test { + def main(args: Array[String]): Unit = { + assert(1 to 10 drop 10 isEmpty) + assert(1 until 10 drop 9 isEmpty) + assert(1 to 10 by 2 drop 5 isEmpty) + assert(10 to 1 by -1 drop 10 isEmpty) + assert((10 to 1 by -1 drop 9) == Seq(1)) + + assert((1 to 10 drop 9) == Seq(10)) + assert((1 until 10 drop 9) == Nil) + + assert(Stream(1 to 10).flatten.toList == Stream(1 until 11).flatten.toList) + } +} diff --git a/tests/run/t3540.scala b/tests/run/t3540.scala new file mode 100644 index 000000000..5ffacb5df --- /dev/null +++ b/tests/run/t3540.scala @@ -0,0 +1,7 @@ +object Test { + def main(args: Array[String]): Unit = { + assert(List.iterate(List(1,2,3), 4)(_.tail).last.isEmpty) + assert(Stream.iterate(Stream(1,2,3), 4)(_.tail).last.isEmpty) + assert(Array.iterate(Array(1,2,3), 4)(_.tail).last.isEmpty) + } +} diff --git a/tests/run/t3563.scala b/tests/run/t3563.scala new file mode 100644 index 000000000..5cc5a611a --- /dev/null +++ b/tests/run/t3563.scala @@ -0,0 +1,21 @@ + + + + + +// ticket #3563 +object Test { + + def main(args: Array[String]): Unit = { + var sum = 0 + val setseq = Set(1, 2, 3, 4).toSeq + setseq.map( n => { sum += n; n * n }).head + assert(sum == 10) + + sum = 0 + val mapseq = Map(1 -> 1, 2 -> 2, 3 -> 3, 4 -> 4).toSeq + mapseq.map( n => { sum += n._1; (n._1 + n._1, n._2 * n._2) }).head + assert(sum == 10) + } + +} diff --git a/tests/run/t3603.scala b/tests/run/t3603.scala new file mode 100644 index 000000000..25ca49b54 --- /dev/null +++ b/tests/run/t3603.scala @@ -0,0 +1,18 @@ + + + +object Test { + + def main(args: Array[String]): Unit = { + import collection.immutable._ + + val intmap = IntMap(1 -> 1, 2 -> 2) + val intres = intmap.map { case (a, b) => (a, b.toString) } + assert(intres.isInstanceOf[IntMap[_]]) + + val longmap = LongMap(1L -> 1, 2L -> 2) + val longres = longmap.map { case (a, b) => (a, b.toString) } + assert(longres.isInstanceOf[LongMap[_]]) + } + +} diff --git a/tests/run/t3619.scala b/tests/run/t3619.scala new file mode 100644 index 000000000..75b0d3cf7 --- /dev/null +++ b/tests/run/t3619.scala @@ -0,0 +1,34 @@ +class Dep(x: Int)(implicit val nameClash: String) + +object Test extends dotty.runtime.LegacyApp { + implicit val nameClash: String = "meh" + + def meth(implicit w: String) = 1 + + // when typing Meh's default constructor Meh.this.nameClash (inherited from Dep) + // shadows Test.nameClash, thus, when inferring the argument `w` in the call to meth, + // Test.nameClash is not eligible statically, Meh.this.nameClash is picked (which then causes the VerifyError) + // BUG: Meth.this.nameClash should not be in (the implicit) scope during the super constructor call in the first place + class Meh extends Dep(meth) + /* + class Meh extends Dep { + def this() { + this(Test.this.meth(Meh.this.nameClash))(Test.this.nameClash) + } + } + */ + + new Meh +} + + +/* + { + def this(a: String, b: Int) { + this() + } + def this(x: String) { + this(Meh.this.nameClash, 1) + } + } +*/ diff --git a/tests/run/t363.check b/tests/run/t363.check new file mode 100644 index 000000000..040b97c07 --- /dev/null +++ b/tests/run/t363.check @@ -0,0 +1 @@ +I love the smell of (Array[String])Unit in the morning. diff --git a/tests/run/t363.scala b/tests/run/t363.scala new file mode 100644 index 000000000..68744ef48 --- /dev/null +++ b/tests/run/t363.scala @@ -0,0 +1,9 @@ +object Test { + def main(args: Array[String]): Unit = { + println("I love the smell of (Array[String])Unit in the morning.") + } +} + +class Test { + def kurtz() = "We must kill them. We must incinerate them." +} diff --git a/tests/run/t3645.scala b/tests/run/t3645.scala new file mode 100644 index 000000000..cada14cd1 --- /dev/null +++ b/tests/run/t3645.scala @@ -0,0 +1,6 @@ +object Test { + def main(args: Array[String]): Unit = { + val s = Stream.tabulate(5)(x => x+2) + assert( s.toList == List(2,3,4,5,6) ) + } +} diff --git a/tests/run/t3647.scala b/tests/run/t3647.scala new file mode 100644 index 000000000..8202c30e7 --- /dev/null +++ b/tests/run/t3647.scala @@ -0,0 +1,23 @@ + + + +import collection.immutable._ + + +object Test { + def main(args: Array[String]): Unit = { + val ps = PagedSeq.fromLines(List( + "line1", + "line2", + "line3", + "line4" + ).iterator) + assert(ps.filter(_ == '\n').size == 3) + + val ps1 = PagedSeq.fromLines(List("Ok").iterator) + assert(ps1.filter(_ == '\n').size == 0) + + val eps = PagedSeq.fromLines(List().iterator) + assert(eps.filter(_ == '\n').size == 0) + } +} diff --git a/tests/run/t3699.scala b/tests/run/t3699.scala new file mode 100644 index 000000000..f838bcb52 --- /dev/null +++ b/tests/run/t3699.scala @@ -0,0 +1,11 @@ +object Test { + def act: Int => Int = { + case _ => + lazy val (a, b) = (3,9) + a + b + } + def main(args: Array[String]) = { + assert(act(1) == 9) + } +} diff --git a/tests/run/t3702.check b/tests/run/t3702.check new file mode 100644 index 000000000..31c2ac4ed --- /dev/null +++ b/tests/run/t3702.check @@ -0,0 +1,2 @@ +() +6 diff --git a/tests/run/t3702.scala b/tests/run/t3702.scala new file mode 100644 index 000000000..0cdafd90b --- /dev/null +++ b/tests/run/t3702.scala @@ -0,0 +1,11 @@ +object Test { + def foo(h: Any, t: List[Any]) = h match { + case 5 :: _ => () + case List(from) => from + } + + def main(args: Array[String]): Unit = { + println(foo(5 :: Nil, List(1,2,3))) + println(foo(6 :: Nil, List(1,2,3))) + } +} diff --git a/tests/run/t3726.check b/tests/run/t3726.check new file mode 100644 index 000000000..7a5775bf3 --- /dev/null +++ b/tests/run/t3726.check @@ -0,0 +1,2 @@ +hi there +5
\ No newline at end of file diff --git a/tests/run/t3726.scala b/tests/run/t3726.scala new file mode 100644 index 000000000..fefc29f11 --- /dev/null +++ b/tests/run/t3726.scala @@ -0,0 +1,8 @@ +object Test extends dotty.runtime.LegacyApp { + def test(f: () => Int) = { + val x = f() + 5 + } + + println(test(() => { println("hi there"); 0 })) +} diff --git a/tests/run/t3760.scala b/tests/run/t3760.scala new file mode 100644 index 000000000..b78406824 --- /dev/null +++ b/tests/run/t3760.scala @@ -0,0 +1,17 @@ +object Test { + def main(args: Array[String]): Unit = { + { + val it = Iterable(1,2).iterator + val xs = it.toList + + assert(it.isEmpty) + } + + { + val it = Iterator(1, 2) + val xs = it.toStream.toList + + assert(it.isEmpty) + } + } +} diff --git a/tests/run/t3761-overload-byname.check b/tests/run/t3761-overload-byname.check new file mode 100644 index 000000000..ab7eff0d8 --- /dev/null +++ b/tests/run/t3761-overload-byname.check @@ -0,0 +1,12 @@ +hello! +hello working world +goodnight! +goodnight moon, nobody, noises everywhere +0 +1 +0 +1 +0 +1 +0 +1 diff --git a/tests/run/t3761-overload-byname.scala b/tests/run/t3761-overload-byname.scala new file mode 100644 index 000000000..3b27271f0 --- /dev/null +++ b/tests/run/t3761-overload-byname.scala @@ -0,0 +1,39 @@ + +class OverTheTop { + def info0(m: String) = m + "!" + def info0(m: String, args: Any*) = m +" "+ args.mkString(" ") + + // as reported + def info1(m: =>String) = m + "!" + def info1(m: =>String, args: Any*) = m +" "+ args.mkString(", ") + + // @lrytz + def m[A](x: => Int) = 0; def m[A](x: => Int, xs: Int*) = 1 + + def m1(x: => Int, s: String) = 0 + def m1(x: => Int, s: Object) = 1 + + def m2(x: => Int, s: String) = 0 + def m2(x: => AnyVal, s: Object) = 1 + + def m3(x: => Int, s: String) = 0 + def m3(x: => Any, s: Object) = 1 +} + +object Test { + def main(args: Array[String]): Unit = { + val top = new OverTheTop + println(top.info0("hello")) + println(top.info0("hello","working","world")) + println(top.info1("goodnight")) + println(top.info1("goodnight", "moon", "nobody", "noises everywhere")) + println(top.m(17)) + println(top.m(17,19)) + println(top.m1(1, "two")) + println(top.m1(1, new Object())) + println(top.m2(1, "")) + println(top.m2(1d, "")) + println(top.m3(1, "")) + println(top.m3("", "")) + } +} diff --git a/tests/run/t3763.scala b/tests/run/t3763.scala new file mode 100644 index 000000000..2fa2992a8 --- /dev/null +++ b/tests/run/t3763.scala @@ -0,0 +1,3 @@ +object Test extends dotty.runtime.LegacyApp { + val x = Array(Array(1), List(1)) +} diff --git a/tests/run/t3822.scala b/tests/run/t3822.scala new file mode 100644 index 000000000..c35804035 --- /dev/null +++ b/tests/run/t3822.scala @@ -0,0 +1,19 @@ +import scala.collection.{ mutable, immutable, generic } +import immutable.ListSet + +object Test { + def main(args: Array[String]): Unit = { + val xs = ListSet(-100000 to 100001: _*) + + assert(xs.size == 200002) + assert(xs.sum == 100001) + + val ys = ListSet[Int]() + val ys1 = (1 to 12).grouped(3).foldLeft(ys)(_ ++ _) + val ys2 = (1 to 12).foldLeft(ys)(_ + _) + + assert(ys1 == ys2) + } +} + + diff --git a/tests/run/t3829.scala b/tests/run/t3829.scala new file mode 100644 index 000000000..ec9772964 --- /dev/null +++ b/tests/run/t3829.scala @@ -0,0 +1,40 @@ +// ticket #3829 +object Test { + import collection.{ mutable, immutable } + + def main(args: Array[String]): Unit = { + val map = immutable.Map(1 -> 2, 3 -> 4) + assert(map.get(0) == None) + + // Since r24255 defaultMap.get(x) returns None rather than + // using the default, so these mostly use apply. + val defmap = map.withDefaultValue(-1) + assert(defmap(0) == -1) + assert(defmap.size == 2) + assert(defmap.iterator.size == 2) + assert(defmap.empty(0) == -1) + assert((defmap + (2 -> 3))(0) == -1) + assert((defmap + (2 -> 3))(1) == 2) + assert((defmap + (2 -> 3))(2) == 3) + assert((defmap - 1)(0) == -1) + assert((defmap - 1)(1) == -1) + assert((defmap - 1)(3) == 4) + + val mutmap = mutable.Map(1 -> 2, 2 -> 3) + assert(mutmap.get(0) == None) + + val defmutmap = mutmap.withDefaultValue(-1) + assert(defmutmap(0) == -1) + assert(defmutmap(3) == -1) + mutmap += 3 -> 4 + assert(defmutmap(3) == 4) + assert(defmutmap(1) == 2) + mutmap -= 1 + assert(defmutmap(1) == -1) + assert(mutmap.get(1) == None) + defmutmap += 1 -> 2 + assert(defmutmap(1) == 2) + assert(mutmap(1) == 2) + } + +} diff --git a/tests/run/t3835.check b/tests/run/t3835.check new file mode 100644 index 000000000..995415951 --- /dev/null +++ b/tests/run/t3835.check @@ -0,0 +1,2 @@ +6 +1 diff --git a/tests/run/t3835.scala b/tests/run/t3835.scala new file mode 100644 index 000000000..7863916f4 --- /dev/null +++ b/tests/run/t3835.scala @@ -0,0 +1,9 @@ +object Test extends dotty.runtime.LegacyApp { + // work around optimizer bug SI-5672 -- generates wrong bytecode for switches in arguments + // virtpatmat happily emits a switch for a one-case switch + // this is not the focus of this test, hence the temporary workaround + def a = (1, 2, 3) match { case (r, \u03b8, \u03c6) => r + \u03b8 + \u03c6 } + println(a) + def b = (1 match { case \u00e9 => \u00e9 }) + println(b) +} diff --git a/tests/run/t3855.scala b/tests/run/t3855.scala new file mode 100644 index 000000000..d10aab538 --- /dev/null +++ b/tests/run/t3855.scala @@ -0,0 +1,18 @@ +object Test { + def byval[A](a: => A) = a + def closure[A](f: () => A) = f() + + def f1(s: String) = { + var n = try { s.toInt } catch { case _: Throwable => 1 } + byval(n) + } + def f2(s: String) = { + var n = try { s.toInt } catch { case _: Throwable => 1 } + closure(() => n) + } + + def main(args: Array[String]) = { + val sum = f1("12") + f2("the witch is dead") + assert(sum == 13) + } +} diff --git a/tests/run/t3877.check b/tests/run/t3877.check new file mode 100644 index 000000000..72aa5577f --- /dev/null +++ b/tests/run/t3877.check @@ -0,0 +1,104 @@ +test1: 3 +test1: 4 +test1: 5 +test1: 6 +test1: 7 +test1: 8 +test1: 9 +test1: 10 +test2: 3 +test2: 4 +test2: 5 +test2: 6 +test2: 7 +test2: 8 +test2: 9 +test2: 10 +test3: 3 +test3: 4 +test3: 5 +test3: 6 +test3: 7 +test3: 8 +test3: 9 +test3: 10 +test4: 3 +test4: 4 +test4: 5 +test4: 6 +test4: 7 +test4: 8 +test4: 9 +test4: 10 +test5.1: 3 +test5.2: 3 +test5.2: 4 +test5.2: 5 +test5.2: 6 +test5.2: 7 +test5.2: 8 +test5.2: 9 +test5.2: 10 +test5.1: 4 +test5.2: 3 +test5.2: 4 +test5.2: 5 +test5.2: 6 +test5.2: 7 +test5.2: 8 +test5.2: 9 +test5.2: 10 +test5.1: 5 +test5.2: 3 +test5.2: 4 +test5.2: 5 +test5.2: 6 +test5.2: 7 +test5.2: 8 +test5.2: 9 +test5.2: 10 +test5.1: 6 +test5.2: 3 +test5.2: 4 +test5.2: 5 +test5.2: 6 +test5.2: 7 +test5.2: 8 +test5.2: 9 +test5.2: 10 +test5.1: 7 +test5.2: 3 +test5.2: 4 +test5.2: 5 +test5.2: 6 +test5.2: 7 +test5.2: 8 +test5.2: 9 +test5.2: 10 +test5.1: 8 +test5.2: 3 +test5.2: 4 +test5.2: 5 +test5.2: 6 +test5.2: 7 +test5.2: 8 +test5.2: 9 +test5.2: 10 +test5.1: 9 +test5.2: 3 +test5.2: 4 +test5.2: 5 +test5.2: 6 +test5.2: 7 +test5.2: 8 +test5.2: 9 +test5.2: 10 +test5.1: 10 +test5.2: 3 +test5.2: 4 +test5.2: 5 +test5.2: 6 +test5.2: 7 +test5.2: 8 +test5.2: 9 +test5.2: 10 diff --git a/tests/run/t3877.scala b/tests/run/t3877.scala new file mode 100644 index 000000000..5d8006f4f --- /dev/null +++ b/tests/run/t3877.scala @@ -0,0 +1,81 @@ +object Test { + val LIMIT = 10 + + def test1: Unit = { + var d = 2 + var i = 0 // avoid infinite loops + while (d < LIMIT && i < LIMIT) { + lazy val b = d + 1 + d = b + i += 1 + println("test1: " + d) + } + } + + def test2: Unit = { + var d = 2 + var i = 0 + while (true) { + lazy val b = d + 1 + d = b + i += 1 + println("test2: " + d) + + if (d >= LIMIT || i >= LIMIT) + return + } + } + + def test3: Unit = { + var d = 2 + var i = 0 + do { + lazy val b = d + 1 + d = b + i += 1 + println("test3: " + d) + } while (d < LIMIT && i < LIMIT) + } + + def test4: Unit = { + var d = 2 + var i = 0 + do { + lazy val b = d + 1 + d = b + i += 1 + println("test4: " + d) + if (d >= LIMIT || i >= LIMIT) + return + } while (true) + } + + def test5: Unit = { + var d = 2 + var i = 0 + while (d < LIMIT && i < LIMIT) { + lazy val b = d + 1 + d = b + i += 1 + println("test5.1: " + d) + + var e = 2 + var j = 0 + while (e < LIMIT && j < LIMIT) { + lazy val f = e + 1 + e = f + j += 1 + println("test5.2: " + e) + } + } + } + + + def main(args: Array[String]): Unit = { + test1 + test2 + test3 + test4 + test5 + } +} diff --git a/tests/run/t3887.scala b/tests/run/t3887.scala new file mode 100644 index 000000000..88a19419e --- /dev/null +++ b/tests/run/t3887.scala @@ -0,0 +1,16 @@ +object Test { + def main(args: Array[String]): Unit = { + assert( matchPair(1) ) + assert( !matchPair(2) ) + } + + def matchPair(i: Int) = { + (i, "abc") match { + case this.option1 => true + case _ => false + } + } + + val option1: (Int, String) = (1, "abc") + +} diff --git a/tests/run/t3923.scala b/tests/run/t3923.scala new file mode 100644 index 000000000..484095a60 --- /dev/null +++ b/tests/run/t3923.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]): Unit = { + assert(collection.mutable.ArraySeq() == Nil) + assert(collection.mutable.ArraySeq() == Seq()) + assert(Seq() == collection.mutable.ArraySeq()) + assert(Nil == collection.mutable.ArraySeq()) + } +} diff --git a/tests/run/t3935.scala b/tests/run/t3935.scala new file mode 100644 index 000000000..84e39571c --- /dev/null +++ b/tests/run/t3935.scala @@ -0,0 +1,15 @@ + + + + +object Test { + def main(args: Array[String]): Unit = { + val q = scala.collection.mutable.Queue[String]() + assert(q.length == 0) + try { + assert(q.front != null) + } catch { + case _: Throwable => + } + } +} diff --git a/tests/run/t3950.check b/tests/run/t3950.check new file mode 100644 index 000000000..10f81c51a --- /dev/null +++ b/tests/run/t3950.check @@ -0,0 +1,3 @@ +minus +zero +plus
\ No newline at end of file diff --git a/tests/run/t3950.scala b/tests/run/t3950.scala new file mode 100644 index 000000000..4634b3bf0 --- /dev/null +++ b/tests/run/t3950.scala @@ -0,0 +1,17 @@ + +object NegativeId extends Enumeration { + val Negative = Value(-1, "minus") + val Zero = Value(0, "zero") + val Positive = Value(1, "plus") + + def fromInt(id: Int) = values find (_.id == id) match { + case Some(v) => v + case None => null + } +} + +object Test extends dotty.runtime.LegacyApp { + println(NegativeId.fromInt(-1)) + println(NegativeId.fromInt(0)) + println(NegativeId.fromInt(1)) +} diff --git a/tests/run/t3989.scala b/tests/run/t3989.scala new file mode 100644 index 000000000..896283f19 --- /dev/null +++ b/tests/run/t3989.scala @@ -0,0 +1,17 @@ + + + + + +class Foo{ override def equals(o: Any) = false; override def hashCode = 1} + +// should not result in a stack overflow +object Test { + def main(args: Array[String]): Unit = { + import collection.immutable.HashMap + var m = Map[Foo, Int]() + for (i <- 1 to 30000) m += (new Foo) -> i + assert(m.size == 30000) + m.toString + } +} diff --git a/tests/run/t4013.scala b/tests/run/t4013.scala new file mode 100644 index 000000000..98cc5e881 --- /dev/null +++ b/tests/run/t4013.scala @@ -0,0 +1,24 @@ + + +trait Base[B] { + def data: AnyRef; +} + + +class Suba[@specialized B](override val data: Array[B]) extends Base[B] { + assert(data != null) +} + + +class Subopt[@specialized B](override val data: Option[B]) extends Base[B] { + assert(data != null) +} + + +object Test { + def main(args: Array[String]): Unit = { + val ss = new Suba[String](Array("")) + val si = new Suba[Int](Array(0)) + new Subopt[Int](Some(0)) + } +} diff --git a/tests/run/t4013b.scala b/tests/run/t4013b.scala new file mode 100644 index 000000000..78f554b33 --- /dev/null +++ b/tests/run/t4013b.scala @@ -0,0 +1,20 @@ + + +trait Base[B] { + def data: AnyRef; +} + + +class M[@specialized(Int) A] + + +class Sub3[@specialized(Int) B](override val data: M[B]) extends Base[B] { + assert(data != null) +} + + +object Test { + def main(args: Array[String]): Unit = { + new Sub3[Int](new M[Int]) + } +} diff --git a/tests/run/t4013c.scala b/tests/run/t4013c.scala new file mode 100644 index 000000000..3b0d87574 --- /dev/null +++ b/tests/run/t4013c.scala @@ -0,0 +1,10 @@ +class Suba[@specialized(Int) B](val data: Array[B]) { + assert(data != null) +} + + +object Test { + def main(args: Array[String]): Unit = { + new Suba[Int](Array(0)) + } +} diff --git a/tests/run/t4027.check b/tests/run/t4027.check new file mode 100644 index 000000000..bdacfc1c0 --- /dev/null +++ b/tests/run/t4027.check @@ -0,0 +1,12 @@ +Map(2 -> true, 4 -> true) +Map(1 -> false!, 2 -> true!, 3 -> false!, 4 -> true!) +Map(2 -> 4, 4 -> 4) +Map(1 -> 6, 2 -> 5, 3 -> 6, 4 -> 5) +Map() +Map(1 -> false!) +Map(2 -> true, 4 -> true) +Map(1 -> false!, 2 -> true!, 3 -> false!, 4 -> true!) +Map(2 -> 4, 4 -> 4) +Map(1 -> 6, 2 -> 5, 3 -> 6, 4 -> 5) +Map() +Map(1 -> false!)
\ No newline at end of file diff --git a/tests/run/t4027.scala b/tests/run/t4027.scala new file mode 100644 index 000000000..6a858afd9 --- /dev/null +++ b/tests/run/t4027.scala @@ -0,0 +1,27 @@ + + +import collection._ + + +/** Sorted maps should have `filterKeys` and `mapValues` which return sorted maps. + * Mapping, filtering, etc. on these views should return sorted maps again. + */ +object Test extends dotty.runtime.LegacyApp { + + val sortedmap = SortedMap(1 -> false, 2 -> true, 3 -> false, 4 -> true) + println(sortedmap.filterKeys(_ % 2 == 0): SortedMap[Int, Boolean]) + println(sortedmap.mapValues(_ + "!"): SortedMap[Int, String]) + println(sortedmap.filterKeys(_ % 2 == 0).map(t => (t._1, t._2.toString.length)): SortedMap[Int, Int]) + println(sortedmap.mapValues(_ + "!").map(t => (t._1, t._2.toString.length)): SortedMap[Int, Int]) + println(sortedmap.filterKeys(_ % 2 == 0).filter(t => t._1 < 2): SortedMap[Int, Boolean]) + println(sortedmap.mapValues(_ + "!").filter(t => t._1 < 2): SortedMap[Int, String]) + + val immsortedmap = immutable.SortedMap(1 -> false, 2 -> true, 3 -> false, 4 -> true) + println(immsortedmap.filterKeys(_ % 2 == 0): immutable.SortedMap[Int, Boolean]) + println(immsortedmap.mapValues(_ + "!"): immutable.SortedMap[Int, String]) + println(immsortedmap.filterKeys(_ % 2 == 0).map(t => (t._1, t._2.toString.length)): immutable.SortedMap[Int, Int]) + println(immsortedmap.mapValues(_ + "!").map(t => (t._1, t._2.toString.length)): immutable.SortedMap[Int, Int]) + println(immsortedmap.filterKeys(_ % 2 == 0).filter(t => t._1 < 2): immutable.SortedMap[Int, Boolean]) + println(immsortedmap.mapValues(_ + "!").filter(t => t._1 < 2): immutable.SortedMap[Int, String]) + +} diff --git a/tests/run/t405.scala b/tests/run/t405.scala new file mode 100644 index 000000000..a78203e3d --- /dev/null +++ b/tests/run/t405.scala @@ -0,0 +1,5 @@ +object Test extends dotty.runtime.LegacyApp { + val x = M; + object M; + assert(x eq M) +} diff --git a/tests/run/t4054.scala b/tests/run/t4054.scala new file mode 100644 index 000000000..b57c08361 --- /dev/null +++ b/tests/run/t4054.scala @@ -0,0 +1,25 @@ + + + + + + + + +object Test { + def main(args: Array[String]): Unit = { + val it = Iterator.from(1).map(n => n * n).scanLeft(0)(_+_) + + assert(it.next == 0) + assert(it.next == 1) + assert(it.next == 5) + assert(it.next == 14) + assert(it.next == 30) + assert(it.next == 55) + assert(it.next == 91) + assert(it.next == 140) + assert(it.next == 204) + assert(it.next == 285) + assert(it.next == 385) + } +} diff --git a/tests/run/t4062.check b/tests/run/t4062.check new file mode 100644 index 000000000..1d474d525 --- /dev/null +++ b/tests/run/t4062.check @@ -0,0 +1,2 @@ +false +true diff --git a/tests/run/t4062.scala b/tests/run/t4062.scala new file mode 100644 index 000000000..f5478e759 --- /dev/null +++ b/tests/run/t4062.scala @@ -0,0 +1,16 @@ +class A(val f : String) + +class B(f: String) extends A(f) { + def foo(x: String) = x match { + case `f` => true + case _ => false + } +} + +object Test { + def main(args: Array[String]): Unit = { + val b = new B("abc") + println(b foo "bippy") + println(b foo "abc") + } +} diff --git a/tests/run/t408.scala b/tests/run/t408.scala new file mode 100644 index 000000000..9e51e881e --- /dev/null +++ b/tests/run/t408.scala @@ -0,0 +1,12 @@ +object Test +{ + val a = scala.collection.immutable.Set.empty ++ (0 to 100000) + val b = scala.collection.immutable.Set.empty ++ (0 to 100000) + + def main(args: Array[String]): Unit = { + a -- b + a -- b + a -- b + a -- b + } +} diff --git a/tests/run/t4122.scala b/tests/run/t4122.scala new file mode 100644 index 000000000..5ff570c00 --- /dev/null +++ b/tests/run/t4122.scala @@ -0,0 +1,14 @@ +object Test { + val sw: Seq[Char] = "ab" + val sw2: Seq[Char] = Array('a', 'b') + val sw3 = Seq('a', 'b') + val sw4 = "ab".toList + val all = List(sw, sw2, sw3, sw4) + + def main(args: Array[String]): Unit = { + for (s1 <- all ; s2 <- all) { + assert(s1 == s2, s1 + " != " + s2) + assert(s1.## == s2.##, s1 + ".## != " + s2 + ".##") + } + } +} diff --git a/tests/run/t4147.scala b/tests/run/t4147.scala new file mode 100644 index 000000000..c638ab50a --- /dev/null +++ b/tests/run/t4147.scala @@ -0,0 +1,36 @@ + + + +import scala.collection._ + + + +object Test { + + def main(args: Array[String]): Unit = { + checkElementsAreSorted() + checkRangedImpl() + } + + def checkElementsAreSorted(): Unit = { + val tree = mutable.SortedSet[Int]() + tree ++= List(4, 3, 1, 6, 7, 5, 2) + assert(tree == immutable.SortedSet(1, 2, 3, 4, 5, 6, 7)) + assert(tree.size == 7) + } + + def checkRangedImpl(): Unit = { + val tree = mutable.SortedSet[Int](3, 1, 6, 7, 5, 2) + val projection = tree.rangeImpl(Some(3), Some(6)) + assert(projection == immutable.SortedSet(3, 5)) + assert(projection.size == 2) + + // Let's check that modification are taken into account + tree add 4 + assert(tree == immutable.SortedSet(1, 2, 3, 4, 5, 6, 7)) + assert(projection == immutable.SortedSet(3, 4, 5)) + assert(tree.size == 7) + assert(projection.size == 3) + } + +} diff --git a/tests/run/t4190.check b/tests/run/t4190.check new file mode 100644 index 000000000..b8aae0c7a --- /dev/null +++ b/tests/run/t4190.check @@ -0,0 +1,3 @@ +a0 +b0 +c0 diff --git a/tests/run/t4190.scala b/tests/run/t4190.scala new file mode 100644 index 000000000..0c91d62de --- /dev/null +++ b/tests/run/t4190.scala @@ -0,0 +1,6 @@ +import collection.mutable._ + +object Test extends dotty.runtime.LegacyApp { + val x: ArrayBuffer[String] = ArrayBuffer("a", "b", "c") + x.view map (_ + "0") foreach println +} diff --git a/tests/run/t4201.scala b/tests/run/t4201.scala new file mode 100644 index 000000000..f6c0acaf9 --- /dev/null +++ b/tests/run/t4201.scala @@ -0,0 +1,7 @@ +object Test { + def main(args: Array[String]): Unit = { + val f = 0.0 to 1.0 by 1.0 / 3.0 + assert(f.size == 4) + } +} + diff --git a/tests/run/t4288.scala b/tests/run/t4288.scala new file mode 100644 index 000000000..23319d1c2 --- /dev/null +++ b/tests/run/t4288.scala @@ -0,0 +1,13 @@ +object Test { + def f1 = scala.collection.mutable.ListBuffer(1 to 9: _*).slice(-5, -1) + def f2 = List(1 to 9: _*).slice(-5, -1) + def f3 = Vector(1 to 9: _*).slice(-5, -1) + def f4 = Traversable(1 to 9: _*).slice(-5, -1) + def f5 = (1 to 9).toArray.slice(-5, -1) + def f6 = (1 to 9).toStream.slice(-5, -1) + def f7 = (1 to 9).slice(-5, -1) + + def main(args: Array[String]): Unit = { + List[Traversable[Int]](f1, f2, f3, f4, f5, f6, f7) foreach (x => assert(x.isEmpty, x)) + } +} diff --git a/tests/run/t429.check b/tests/run/t429.check new file mode 100644 index 000000000..22b91b785 --- /dev/null +++ b/tests/run/t429.check @@ -0,0 +1 @@ +AyB5 diff --git a/tests/run/t429.scala b/tests/run/t429.scala new file mode 100644 index 000000000..e62a6b307 --- /dev/null +++ b/tests/run/t429.scala @@ -0,0 +1,15 @@ +object Test { + abstract class A { + Console.print("A"); + val x: Int; + val y: Int = {Console.print("y"); x + 1} + } + class B extends A { + Console.print("B"); + lazy val z = 0; + lazy val x = 4 + z + } + def main (args: Array[String]): Unit = { + Console.print((new B).y); + } +} diff --git a/tests/run/t4297.scala b/tests/run/t4297.scala new file mode 100644 index 000000000..7497dfe4c --- /dev/null +++ b/tests/run/t4297.scala @@ -0,0 +1,7 @@ +object Test { + def main(args: Array[String]): Unit = { + def f = List(1,2,3).view + assert(f.toString == "SeqView(...)") + assert(f.mkString == "123") + } +} diff --git a/tests/run/t4351.check b/tests/run/t4351.check new file mode 100644 index 000000000..cb5d407e1 --- /dev/null +++ b/tests/run/t4351.check @@ -0,0 +1 @@ +runtime exception diff --git a/tests/run/t4351.scala b/tests/run/t4351.scala new file mode 100644 index 000000000..d954d748b --- /dev/null +++ b/tests/run/t4351.scala @@ -0,0 +1,21 @@ +object Test { + def main(args: Array[String]): Unit = { + try new BooleanPropImpl().value + catch { + // was: StackOverflowError + case e: RuntimeException => println("runtime exception") + } + } +} + +trait Prop[@specialized(Boolean) +T] { + def value: T +} + +class PropImpl[+T] extends Prop[T] { + def value: T = scala.sys.error("") +} + +trait BooleanProp extends Prop[Boolean] + +class BooleanPropImpl() extends PropImpl[Boolean] with BooleanProp diff --git a/tests/run/t4398.scala b/tests/run/t4398.scala new file mode 100644 index 000000000..5e152f727 --- /dev/null +++ b/tests/run/t4398.scala @@ -0,0 +1,13 @@ + + +import scala.language.{ postfixOps } + +object Test { + def main(args: Array[String]): Unit = { + val x = 1 to 10 toSet + val y = x + 5 + val z = y - 154321 + assert(x eq y) + assert(x eq z) + } +} diff --git a/tests/run/t4459.scala b/tests/run/t4459.scala new file mode 100644 index 000000000..ea3b7420b --- /dev/null +++ b/tests/run/t4459.scala @@ -0,0 +1,12 @@ +import collection._ + +object Test { + def main(args: Array[String]): Unit = { + for (i <- 0 until 2000) { + foo((0 until 10000).toSeq.par) + } + } + + def foo(arg: GenSeq[_]): String = arg.map(x => x).mkString(",") +} + diff --git a/tests/run/t4535.check b/tests/run/t4535.check new file mode 100644 index 000000000..9d4ce0d53 --- /dev/null +++ b/tests/run/t4535.check @@ -0,0 +1,3 @@ +ArrayStack(1, 2, 3) +ArrayStack(1, 2, 3, 4, 5, 6) +ArrayStack(6, 5, 4, 3, 2, 1)
\ No newline at end of file diff --git a/tests/run/t4535.scala b/tests/run/t4535.scala new file mode 100644 index 000000000..37aacb0ad --- /dev/null +++ b/tests/run/t4535.scala @@ -0,0 +1,30 @@ + + +import collection._ + + +// #4535 +object Test { + + def main(args: Array[String]): Unit = { + val as = new mutable.ArrayStack[Int] + as push 1 + as push 2 + as push 3 + println(as.reverse) + + as push 4 + as push 5 + as push 6 + println(as.reverse) + + println(as map { x => x }) + + for (i <- 0 until 100) { + as push i + assert(as == as.map(x => x)) + assert(as == as.reverse.reverse) + } + } + +} diff --git a/tests/run/t4537.check b/tests/run/t4537.check new file mode 100644 index 000000000..63739ca64 --- /dev/null +++ b/tests/run/t4537.check @@ -0,0 +1 @@ +b.Settings diff --git a/tests/run/t4537/a.scala b/tests/run/t4537/a.scala new file mode 100644 index 000000000..125e223e1 --- /dev/null +++ b/tests/run/t4537/a.scala @@ -0,0 +1,5 @@ +package a + +private[a] object Settings { + val X = "a.Settings" +} diff --git a/tests/run/t4537/b.scala b/tests/run/t4537/b.scala new file mode 100644 index 000000000..c709d49b0 --- /dev/null +++ b/tests/run/t4537/b.scala @@ -0,0 +1,5 @@ +package b + +object Settings { + val Y = "b.Settings" +} diff --git a/tests/run/t4537/c.scala b/tests/run/t4537/c.scala new file mode 100644 index 000000000..ee05d4bbf --- /dev/null +++ b/tests/run/t4537/c.scala @@ -0,0 +1,8 @@ +package b +package c + +import a._ + +object Unambiguous { + println(Settings.Y) +} diff --git a/tests/run/t4537/d.scala b/tests/run/t4537/d.scala new file mode 100644 index 000000000..be0266710 --- /dev/null +++ b/tests/run/t4537/d.scala @@ -0,0 +1,6 @@ +import a._ +import b._ + +object Test extends dotty.runtime.LegacyApp { + println(Settings.Y) +} diff --git a/tests/run/t4558.scala b/tests/run/t4558.scala new file mode 100644 index 000000000..e7661421d --- /dev/null +++ b/tests/run/t4558.scala @@ -0,0 +1,6 @@ +object Test { + def main(args: Array[String]): Unit = { + val xs = Seq(1,2,3).view.groupBy(identity) + assert(xs.size == 3) + } +} diff --git a/tests/run/t4565_1.check b/tests/run/t4565_1.check new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/tests/run/t4565_1.check @@ -0,0 +1 @@ +true diff --git a/tests/run/t4565_1.scala b/tests/run/t4565_1.scala new file mode 100644 index 000000000..19b26b24e --- /dev/null +++ b/tests/run/t4565_1.scala @@ -0,0 +1,14 @@ +trait T { + def foo = { + object A + def a(x: Any) = x == A + a(A) + } +} + +object Test { + def main(args: Array[String]): Unit = { + val t = new T{} + println(t.foo) + } +} diff --git a/tests/run/t4577.scala b/tests/run/t4577.scala new file mode 100644 index 000000000..2859e5098 --- /dev/null +++ b/tests/run/t4577.scala @@ -0,0 +1,38 @@ +object Test { + val bippy = new Symbol("bippy") + val imposter = new Symbol("bippy") + val notBippy = new Symbol("not-bippy") + val syms = List(bippy, imposter, notBippy) + + // the equals method should only be used for case `bippy`, + // for the singleton type pattern, case _: bippy.type, the spec mandates `bippy eq _` as the test + class Symbol(val name: String) { + override def equals(other: Any) = other match { + case x: Symbol => name == x.name + case _ => false + } + override def toString = name + } + + // TODO: test bytecode equality for f and fDirect (and g and gDirect), + // for now the optimizer doesn't quite get from `f` to `fDirect` + def f(s: Symbol) = s match { + case _: bippy.type => true + case _ => false + } + def fDirect(s: Symbol) = bippy eq s + + def g(s: Symbol) = s match { + case _: bippy.type => 1 + case `bippy` => 2 + case _ => 3 + } + def gDirect(s: Symbol) = if (bippy eq s) 1 else if (bippy == s) 2 else 3 + + def main(args: Array[String]): Unit = { + // `syms map f` should be: true false false + assert(syms forall (s => f(s) == fDirect(s))) + // `syms map g` should be: 1 2 3 + assert(syms forall (s => g(s) == gDirect(s))) + } +} diff --git a/tests/run/t4582.scala b/tests/run/t4582.scala new file mode 100644 index 000000000..f74779154 --- /dev/null +++ b/tests/run/t4582.scala @@ -0,0 +1,11 @@ +object Test { + def main(args: Array[String]): Unit = { + var flag = true + def it = { + flag = false + Iterator(2) + } + val flat = (Iterator(Iterator(1)) ++ Iterator(it)).flatten + assert(flag) + } +} diff --git a/tests/run/t4592.check b/tests/run/t4592.check new file mode 100644 index 000000000..e13338648 --- /dev/null +++ b/tests/run/t4592.check @@ -0,0 +1,3 @@ +3.14 +3.14 +3.14 diff --git a/tests/run/t4592.scala b/tests/run/t4592.scala new file mode 100644 index 000000000..d1666d84d --- /dev/null +++ b/tests/run/t4592.scala @@ -0,0 +1,10 @@ +object Test { + def repeat[T](count: Int = 1, x: Boolean = true)(thunk: => T) : T = (0 until count).map(_ => thunk).last + def repeat[T](thunk: => T) : T = repeat()(thunk) + + def main(args: Array[String]): Unit = { + println(repeat(3.14)) + println(repeat(count=5)(3.14)) + println(repeat(count=5,x=false)(3.14)) + } +} diff --git a/tests/run/t4601.check b/tests/run/t4601.check new file mode 100644 index 000000000..83b0b0b0f --- /dev/null +++ b/tests/run/t4601.check @@ -0,0 +1 @@ +'blubber diff --git a/tests/run/t4601.scala b/tests/run/t4601.scala new file mode 100644 index 000000000..300da58b2 --- /dev/null +++ b/tests/run/t4601.scala @@ -0,0 +1,15 @@ +class A + +trait B { + self: A => + + def test: Unit = { + println('blubber) + } +} + +object Test extends A with B { + def main(args: Array[String]): Unit = { + test + } +} diff --git a/tests/run/t4608.scala b/tests/run/t4608.scala new file mode 100644 index 000000000..34586e2d0 --- /dev/null +++ b/tests/run/t4608.scala @@ -0,0 +1,8 @@ +// #4608 +object Test { + + def main(args: Array[String]): Unit = { + ((1 to 100) sliding 10).toList.par.map{_.map{i => i * i}}.flatten + } + +} diff --git a/tests/run/t4656.check b/tests/run/t4656.check new file mode 100644 index 000000000..15a62794a --- /dev/null +++ b/tests/run/t4656.check @@ -0,0 +1 @@ +List(1, 2, 3) diff --git a/tests/run/t4656.scala b/tests/run/t4656.scala new file mode 100644 index 000000000..4f3d189c8 --- /dev/null +++ b/tests/run/t4656.scala @@ -0,0 +1,13 @@ +object Test { + def f = { + val buf = new collection.mutable.ListBuffer[Int] + buf ++= List(1, 2, 3) + val l = buf.toList + buf prependToList List(4, 5, 6) + l + } + + def main(args: Array[String]): Unit = { + println(f) + } +} diff --git a/tests/run/t4660.scala b/tests/run/t4660.scala new file mode 100644 index 000000000..9aac10ddf --- /dev/null +++ b/tests/run/t4660.scala @@ -0,0 +1,11 @@ +object Test { + def main(args: Array[String]): Unit = { + val traversable = 1 to 20 map (_.toString) + def normalize(m: Map[Char, Traversable[String]]) = m.map { case (k,v) => (k, v.toList) } + + val groupedFromView = traversable.view.groupBy(_(0)) + val groupedFromStrict = traversable.groupBy(_(0)) + + assert(normalize(groupedFromView) == normalize(groupedFromStrict)) + } +} diff --git a/tests/run/t4697.check b/tests/run/t4697.check new file mode 100644 index 000000000..b9d569380 --- /dev/null +++ b/tests/run/t4697.check @@ -0,0 +1 @@ +50005000 diff --git a/tests/run/t4697.scala b/tests/run/t4697.scala new file mode 100644 index 000000000..95592172e --- /dev/null +++ b/tests/run/t4697.scala @@ -0,0 +1,8 @@ +object Test { + var st = Stream(0) + for (i <- 1 to 10000) st = i +: st + + def main(args: Array[String]): Unit = { + println(st.take(10000).sum) + } +} diff --git a/tests/run/t4709.scala b/tests/run/t4709.scala new file mode 100644 index 000000000..29d0dac61 --- /dev/null +++ b/tests/run/t4709.scala @@ -0,0 +1,10 @@ + + +import collection.GenSeq + + +object Test { + def main(args: Array[String]): Unit = { + val Seq(1, 2) = Stream(1, 2) + } +} diff --git a/tests/run/t4723.scala b/tests/run/t4723.scala new file mode 100644 index 000000000..462d0be43 --- /dev/null +++ b/tests/run/t4723.scala @@ -0,0 +1,9 @@ + + + +object Test { + def main(args: Array[String]): Unit = { + assert(Nil == collection.parallel.ParSeq()) + assert(collection.parallel.ParSeq() == Nil) + } +} diff --git a/tests/run/t4750.check b/tests/run/t4750.check new file mode 100644 index 000000000..bf55f70df --- /dev/null +++ b/tests/run/t4750.check @@ -0,0 +1 @@ +US$ 5.80 diff --git a/tests/run/t4750.scala b/tests/run/t4750.scala new file mode 100644 index 000000000..7b0432362 --- /dev/null +++ b/tests/run/t4750.scala @@ -0,0 +1,7 @@ +import scala.util.matching.Regex + +object Test extends dotty.runtime.LegacyApp { + val input = "CURRENCY 5.80" + println("CURRENCY".r.replaceAllIn(input, Regex quoteReplacement "US$")) +} + diff --git a/tests/run/t4761.check b/tests/run/t4761.check new file mode 100644 index 000000000..1698a57bf --- /dev/null +++ b/tests/run/t4761.check @@ -0,0 +1,4 @@ +Vector(1, 1, 1, 1, 1) +Vector(Vector(1, 1, 1, 1, 1)) +List(1, 2) +List(List(1, 2)) diff --git a/tests/run/t4761.scala b/tests/run/t4761.scala new file mode 100644 index 000000000..c9d8576ab --- /dev/null +++ b/tests/run/t4761.scala @@ -0,0 +1,11 @@ +object Test { + def main(args: Array[String]): Unit = { + val gs = for (x <- (1 to 5)) yield { if (x % 2 == 0) List(1).seq else List(1).par } + println(gs.flatten) + println(gs.transpose) + + val s = Stream(Vector(1).par, Vector(2).par) + println(s.flatten.toList) + println(s.transpose.map(_.toList).toList) + } +} diff --git a/tests/run/t4770.check b/tests/run/t4770.check new file mode 100644 index 000000000..38e5a831f --- /dev/null +++ b/tests/run/t4770.check @@ -0,0 +1,2 @@ +(a,2) +(2,a) diff --git a/tests/run/t4770.scala b/tests/run/t4770.scala new file mode 100644 index 000000000..25bf3050c --- /dev/null +++ b/tests/run/t4770.scala @@ -0,0 +1,15 @@ +package crasher { + class Z[@specialized A, @specialized(AnyRef) B](var a: A, var b: B) { + override def toString = "" + ((a, b)) + } + object O { + def apply[@specialized A, @specialized(AnyRef) B](a0: A, b0: B) = new Z(a0, b0) + } +} + +object Test { + def main(args: Array[String]): Unit = { + println(crasher.O("a", 2)) + println(crasher.O(2, "a")) + } +} diff --git a/tests/run/t4777.check b/tests/run/t4777.check new file mode 100644 index 000000000..11f1f59d4 --- /dev/null +++ b/tests/run/t4777.check @@ -0,0 +1,2 @@ +28 +28 diff --git a/tests/run/t4777.scala b/tests/run/t4777.scala new file mode 100644 index 000000000..ef163c476 --- /dev/null +++ b/tests/run/t4777.scala @@ -0,0 +1,8 @@ +class A(val a: Int = 13) +class DefaultsTest(x: Int = 25) extends A(28) +object DefaultsTest extends DefaultsTest(12) + +object Test extends dotty.runtime.LegacyApp { + println(new DefaultsTest().a) + println(DefaultsTest.a) +} diff --git a/tests/run/t4809.scala b/tests/run/t4809.scala new file mode 100644 index 000000000..9c6645805 --- /dev/null +++ b/tests/run/t4809.scala @@ -0,0 +1,34 @@ + + +import scala.util.control.Breaks._ + + + +object Test { + + def main(args: Array[String]): Unit = { + val x = tryBreakable { + break + 2 + } catchBreak { + 3 + } + assert(x == 3, x) + + val y = tryBreakable { + 2 + } catchBreak { + 3 + } + assert(y == 2, y) + + val z = tryBreakable { + break + 1.0 + } catchBreak { + 2 + } + assert(z == 2.0, z) + } + +} diff --git a/tests/run/t4827.scala b/tests/run/t4827.scala new file mode 100644 index 000000000..7270cf169 --- /dev/null +++ b/tests/run/t4827.scala @@ -0,0 +1,15 @@ +object Test { + def main(args: Array[String]): Unit = Foo.foo() +} + +trait CommonTrait { + def foo(): String = null +} + +class Foo + +object Foo { + def goo() = new Foo() with CommonTrait + + def foo(): String = null +} diff --git a/tests/run/t4827b.scala b/tests/run/t4827b.scala new file mode 100644 index 000000000..84d6d907d --- /dev/null +++ b/tests/run/t4827b.scala @@ -0,0 +1,18 @@ +package foo { + class Foo { } + object Foo { + def bippy(x: Int) = x + } +} + +package bar { + class Bippy extends foo.Foo { + def bippy(x: Int) = x + } +} + +object Test { + def main(args: Array[String]): Unit = { + new bar.Bippy bippy 5 + } +} diff --git a/tests/run/t4835.check b/tests/run/t4835.check new file mode 100644 index 000000000..0987722d5 --- /dev/null +++ b/tests/run/t4835.check @@ -0,0 +1,7 @@ +-1 0 1 2 3 4 5 6 7 8 9 +-1 1 3 5 7 9 11 13 15 17 19 +1 1 +2 1 2 +2 1 A 2 +3 1 2 3 +3 1 A 2 B 3 diff --git a/tests/run/t4835.scala b/tests/run/t4835.scala new file mode 100644 index 000000000..26275c0ab --- /dev/null +++ b/tests/run/t4835.scala @@ -0,0 +1,38 @@ +/* + * Test case for SI-4835. This tests confirm that the fix + * doesn't break laziness. To test memory consumption, + * I need to confirm that OutOfMemoryError doesn't occur. + * I could create such tests. However, such tests consume + * too much time and memory. + */ +object Test { + private final val INFINITE = -1 + def testStreamIterator(num: Int, stream: Stream[Int]): Unit = { + val iter = stream.iterator + print(num) + // if num == -1, then steram is infinite sequence + if (num == INFINITE) { + for(i <- 0 until 10) { + print(" " + iter.next()) + } + } else { + while(iter.hasNext) { + print(" " + iter.next()) + } + } + println() + } + + def main(args: Array[String]): Unit = { + import Stream.{from, cons, empty} + testStreamIterator(INFINITE, from(0)) + testStreamIterator(INFINITE, from(0).filter(_ % 2 == 1)) + testStreamIterator(1, Stream(1)) + testStreamIterator(2, Stream(1, 2)) + //Stream with side effect + testStreamIterator(2, cons(1, cons({ print(" A"); 2}, empty))) + testStreamIterator(3, Stream(1, 2, 3)) + //Stream with side effect + testStreamIterator(3, cons(1, cons({ print(" A"); 2}, cons({ print(" B"); 3}, Stream.empty)))) + } +} diff --git a/tests/run/t4894.scala b/tests/run/t4894.scala new file mode 100644 index 000000000..b2d915fda --- /dev/null +++ b/tests/run/t4894.scala @@ -0,0 +1,27 @@ + + + + + +object Test { + + def main(args: Array[String]): Unit = { + import collection._ + val hs = mutable.HashSet[Int]() + hs ++= 1 to 10 + hs --= 1 to 10 + + val phs = parallel.mutable.ParHashSet[Int]() + phs ++= 1 to 10 + for (i <- 1 to 10) assert(phs(i)) + phs --= 1 to 10 + assert(phs.isEmpty) + + val phm = parallel.mutable.ParHashMap[Int, Int]() + phm ++= ((1 to 10) zip (1 to 10)) + for (i <- 1 to 10) assert(phm(i) == i) + phm --= 1 to 10 + assert(phm.isEmpty) + } + +} diff --git a/tests/run/t4895.scala b/tests/run/t4895.scala new file mode 100644 index 000000000..fdd091511 --- /dev/null +++ b/tests/run/t4895.scala @@ -0,0 +1,16 @@ +object Test { + + def checkPar(sz: Int): Unit = { + import collection._ + val hs = mutable.HashSet[Int]() ++ (1 to sz) + assert(hs.par.map(_ + 1).seq.toSeq.sorted == (2 to (sz + 1))) + } + + def main(args: Array[String]): Unit = { + for (i <- 0 until 100) checkPar(i) + for (i <- 100 until 1000 by 50) checkPar(i) + for (i <- 1000 until 10000 by 500) checkPar(i) + for (i <- 10000 until 100000 by 5000) checkPar(i) + } + +} diff --git a/tests/run/t493.scala b/tests/run/t493.scala new file mode 100644 index 000000000..7aaad1fec --- /dev/null +++ b/tests/run/t493.scala @@ -0,0 +1,22 @@ +object Test { + + val y = new collection.mutable.HashMap[String,Any] + val z = new collection.mutable.HashMap[String,Any] + + y("msg") = Array[String]("1","2") + + val array: Array[String] = Array[String]("1","2") + z("msg") = array + + def main(args:Array[String]) = { + + assert(y("msg").isInstanceOf[Array[_]]) + assert(z("msg").isInstanceOf[Array[_]]) + + // these work, without producing a match error + + (z.get("msg"): @unchecked) match { + case Some(_:Array[String]) => + } + } +} diff --git a/tests/run/t4930.check b/tests/run/t4930.check new file mode 100644 index 000000000..a58efd468 --- /dev/null +++ b/tests/run/t4930.check @@ -0,0 +1,2 @@ +List(1) +List(1) diff --git a/tests/run/t4930.scala b/tests/run/t4930.scala new file mode 100644 index 000000000..775f62794 --- /dev/null +++ b/tests/run/t4930.scala @@ -0,0 +1,11 @@ +import collection.immutable.SortedMap + +object Test { + implicit val ord: Ordering[Array[Byte]] = Ordering.by((_: Array[Byte]).toIterable) + + def main(args: Array[String]): Unit = { + val m = SortedMap(Array[Byte](1) -> 0) + println(m.to(Array[Byte](1)) flatMap (_._1.mkString)) + println(m.from(Array[Byte](1)) flatMap (_._1.mkString)) + } +} diff --git a/tests/run/t4935.check b/tests/run/t4935.check new file mode 100644 index 000000000..ce0136250 --- /dev/null +++ b/tests/run/t4935.check @@ -0,0 +1 @@ +hello diff --git a/tests/run/t4935.flags b/tests/run/t4935.flags new file mode 100644 index 000000000..49d036a88 --- /dev/null +++ b/tests/run/t4935.flags @@ -0,0 +1 @@ +-optimize diff --git a/tests/run/t4935.scala b/tests/run/t4935.scala new file mode 100644 index 000000000..88940be6b --- /dev/null +++ b/tests/run/t4935.scala @@ -0,0 +1,9 @@ +object Test extends dotty.runtime.LegacyApp { + for (i <- 0 to 1) { + val a = Foo + } +} + +object Foo { + println("hello") +} diff --git a/tests/run/t4954.scala b/tests/run/t4954.scala new file mode 100644 index 000000000..655a90f74 --- /dev/null +++ b/tests/run/t4954.scala @@ -0,0 +1,45 @@ + + +import collection._ + + +object Test { + + def main(args: Array[String]): Unit = { + val m = scala.collection.mutable.LinkedHashMap("one" -> 1, "two" -> 2, "three" -> 3, "four" -> 4, "five" -> 5) + val expected = List("one", "two", "three", "four", "five") + assert(m.keys.iterator.toList == expected) + assert(m.keys.drop(0).iterator.toList == expected) + assert(m.keys.drop(1).iterator.toList == expected.drop(1)) + assert(m.keys.drop(2).iterator.toList == expected.drop(2)) + assert(m.keys.drop(3).iterator.toList == expected.drop(3)) + assert(m.keys.drop(4).iterator.toList == expected.drop(4)) + assert(m.keys.drop(5).iterator.toList == expected.drop(5)) + + val expvals = List(1, 2, 3, 4, 5) + assert(m.values.iterator.toList == expvals) + assert(m.values.drop(0).iterator.toList == expvals) + assert(m.values.drop(1).iterator.toList == expvals.drop(1)) + assert(m.values.drop(2).iterator.toList == expvals.drop(2)) + assert(m.values.drop(3).iterator.toList == expvals.drop(3)) + assert(m.values.drop(4).iterator.toList == expvals.drop(4)) + assert(m.values.drop(5).iterator.toList == expvals.drop(5)) + + val pred = (x: String) => x.length < 6 + val filtered = m.filterKeys(pred) + assert(filtered.drop(0).keys.toList == expected.filter(pred)) + assert(filtered.drop(1).keys.toList == expected.filter(pred).drop(1)) + assert(filtered.drop(2).keys.toList == expected.filter(pred).drop(2)) + assert(filtered.drop(3).keys.toList == expected.filter(pred).drop(3)) + assert(filtered.drop(4).keys.toList == expected.filter(pred).drop(4)) + + val mapped = m.mapValues(-_) + assert(mapped.drop(0).keys.toList == expected) + assert(mapped.drop(1).keys.toList == expected.drop(1)) + assert(mapped.drop(2).keys.toList == expected.drop(2)) + assert(mapped.drop(3).keys.toList == expected.drop(3)) + assert(mapped.drop(4).keys.toList == expected.drop(4)) + assert(mapped.drop(5).keys.toList == expected.drop(5)) + } + +} diff --git a/tests/run/t498.check b/tests/run/t498.check new file mode 100644 index 000000000..b1ce75e80 --- /dev/null +++ b/tests/run/t498.check @@ -0,0 +1 @@ +Stream(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) diff --git a/tests/run/t498.scala b/tests/run/t498.scala new file mode 100644 index 000000000..d50d8fd3f --- /dev/null +++ b/tests/run/t498.scala @@ -0,0 +1,8 @@ + +import scala.language.postfixOps + +object Test extends dotty.runtime.LegacyApp { +// the function passed to flatMap produces lots of empty streams, but this should not overflow the stack + val res = Stream.from(1).flatMap(i => if (i < 3000) Stream.empty else List(1)) + println(res take 42 force) +} diff --git a/tests/run/t4996.check b/tests/run/t4996.check new file mode 100644 index 000000000..8d45b413c --- /dev/null +++ b/tests/run/t4996.check @@ -0,0 +1,4 @@ +B.foo +M.foo +B.foo +M.foo
\ No newline at end of file diff --git a/tests/run/t4996.scala b/tests/run/t4996.scala new file mode 100644 index 000000000..e8ef5949c --- /dev/null +++ b/tests/run/t4996.scala @@ -0,0 +1,47 @@ + + + + + + +trait A[@specialized(Int) T] { + def foo(t: T): Unit +} + + +trait B extends A[Int] { + def foo(t: Int): Unit = { + println("B.foo") + } +} + + +trait M extends B { + abstract override def foo(t: Int): Unit = { + super.foo(t) + println("M.foo") + } +} + + +object C extends B with M + + +object D extends B { + override def foo(t: Int): Unit = { + super.foo(t) + println("M.foo") + } +} + + +object Test { + + def main(args: Array[String]): Unit = { + D.foo(42) // OK, prints B.foo M.foo + C.foo(42) // was StackOverflowError + } + +} + + diff --git a/tests/run/t5053.check b/tests/run/t5053.check new file mode 100644 index 000000000..5ec39bbde --- /dev/null +++ b/tests/run/t5053.check @@ -0,0 +1,6 @@ +true +true +true +true +true +true diff --git a/tests/run/t5053.scala b/tests/run/t5053.scala new file mode 100644 index 000000000..797faaeaf --- /dev/null +++ b/tests/run/t5053.scala @@ -0,0 +1,23 @@ + +import scala.language.{ existentials } + +object Test extends dotty.runtime.LegacyApp { + { + val (left, right) = Seq((1, "a"), (1, "a"), (1, "a"), (3, "c")).view.unzip + println(left.isInstanceOf[scala.collection.SeqViewLike[_,_,_]]) + val (l, m, r) = Seq((1, 1.0, "a"), (1, 1.0, "a"), (1, 1.0, "a"), (3, 3.0, "c")).view.unzip3 + println(l.isInstanceOf[scala.collection.SeqViewLike[_,_,_]]) + } + { + val (left, right) = Iterable((1, "a"), (1, "a"), (1, "a"), (3, "c")).view.unzip + println(left.isInstanceOf[scala.collection.IterableViewLike[_,_,_]]) + val (l, m, r) = Iterable((1, 1.0, "a"), (1, 1.0, "a"), (1, 1.0, "a"), (3, 3.0, "c")).view.unzip3 + println(l.isInstanceOf[scala.collection.IterableViewLike[_,_,_]]) + } + { + val (left, right) = Traversable((1, "a"), (1, "a"), (1, "a"), (3, "c")).view.unzip + println(left.isInstanceOf[scala.collection.TraversableViewLike[_,_,_]]) + val (l, m, r) = Traversable((1, 1.0, "a"), (1, 1.0, "a"), (1, 1.0, "a"), (3, 3.0, "c")).view.unzip3 + println(l.isInstanceOf[scala.collection.TraversableViewLike[_,_,_]]) + } +} diff --git a/tests/run/t5105.check b/tests/run/t5105.check new file mode 100644 index 000000000..1d4f6efff --- /dev/null +++ b/tests/run/t5105.check @@ -0,0 +1 @@ +You buttered your bread. Now sleep in it! diff --git a/tests/run/t5105.scala b/tests/run/t5105.scala new file mode 100644 index 000000000..9de714c87 --- /dev/null +++ b/tests/run/t5105.scala @@ -0,0 +1,14 @@ +object Test { + def main(args: Array[String]): Unit = { + new foo.Bar + println("You buttered your bread. Now sleep in it!") + } +} + +package foo { + trait Foo { def foo(): Unit = {} } + class Bar extends Baz with Foo + + abstract class Baz + object Baz extends Foo +} diff --git a/tests/run/t5162.scala b/tests/run/t5162.scala new file mode 100644 index 000000000..e4ad9ff8d --- /dev/null +++ b/tests/run/t5162.scala @@ -0,0 +1,19 @@ +// In run, rather than pos, to check for problems like SI-4283 +object O1 { + private[O1] class Base { + def foo: Int = 0 + } + class Mediator extends Base +} + +object O2 { + class Derived extends O1.Mediator { + override def foo: Int = super.foo + } +} + +object Test { + def main(args: Array[String]): Unit = { + new O2.Derived().foo + } +} diff --git a/tests/run/t5375.check b/tests/run/t5375.check new file mode 100644 index 000000000..b1a57eeee --- /dev/null +++ b/tests/run/t5375.check @@ -0,0 +1 @@ +Runtime exception diff --git a/tests/run/t5375.scala b/tests/run/t5375.scala new file mode 100644 index 000000000..8c2c06fde --- /dev/null +++ b/tests/run/t5375.scala @@ -0,0 +1,8 @@ +object Test extends dotty.runtime.LegacyApp { + val foos = (1 to 1000).toSeq + try + foos.par.map(i => if (i % 37 == 0) sys.error("i div 37") else i) + catch { + case ex: RuntimeException => println("Runtime exception") + } +} diff --git a/tests/run/t5377.check b/tests/run/t5377.check new file mode 100644 index 000000000..7bd0e297b --- /dev/null +++ b/tests/run/t5377.check @@ -0,0 +1,18 @@ +1 List(1) +1 List(1) +2 List(1, 2) List(2, 1) +2 List(1, 2) List(2, 1) +2 List(2, 1) List(1, 2) +2 List(2, 1) List(1, 2) +3 List(1, 2, 3) List(1, 3, 2) List(2, 1, 3) List(2, 3, 1) List(3, 1, 2) List(3, 2, 1) +3 List(1, 2, 3) List(1, 3, 2) List(2, 1, 3) List(2, 3, 1) List(3, 1, 2) List(3, 2, 1) +3 List(1, 3, 2) List(1, 2, 3) List(3, 1, 2) List(3, 2, 1) List(2, 1, 3) List(2, 3, 1) +3 List(1, 3, 2) List(1, 2, 3) List(3, 1, 2) List(3, 2, 1) List(2, 1, 3) List(2, 3, 1) +3 List(2, 1, 3) List(2, 3, 1) List(1, 2, 3) List(1, 3, 2) List(3, 2, 1) List(3, 1, 2) +3 List(2, 1, 3) List(2, 3, 1) List(1, 2, 3) List(1, 3, 2) List(3, 2, 1) List(3, 1, 2) +3 List(2, 3, 1) List(2, 1, 3) List(3, 2, 1) List(3, 1, 2) List(1, 2, 3) List(1, 3, 2) +3 List(2, 3, 1) List(2, 1, 3) List(3, 2, 1) List(3, 1, 2) List(1, 2, 3) List(1, 3, 2) +3 List(3, 1, 2) List(3, 2, 1) List(1, 3, 2) List(1, 2, 3) List(2, 3, 1) List(2, 1, 3) +3 List(3, 1, 2) List(3, 2, 1) List(1, 3, 2) List(1, 2, 3) List(2, 3, 1) List(2, 1, 3) +3 List(3, 2, 1) List(3, 1, 2) List(2, 3, 1) List(2, 1, 3) List(1, 3, 2) List(1, 2, 3) +3 List(3, 2, 1) List(3, 1, 2) List(2, 3, 1) List(2, 1, 3) List(1, 3, 2) List(1, 2, 3) diff --git a/tests/run/t5377.scala b/tests/run/t5377.scala new file mode 100644 index 000000000..2e8fb1a6a --- /dev/null +++ b/tests/run/t5377.scala @@ -0,0 +1,47 @@ +object Test { + def testPermutations1(num: Int, stream: Stream[Int]): Unit = { + val perm = stream.permutations + print(num) + while(perm.hasNext) { + print(" " + perm.next().toList) + } + println() + } + def testPermutations2(num: Int, stream: List[Int]): Unit = { + val perm = stream.permutations + print(num) + while(perm.hasNext) { + print(" " + perm.next().toList) + } + println() + } + + def main(args: Array[String]): Unit = { + testPermutations1(1, Stream(1)) + testPermutations2(1, List(1)) + + testPermutations1(2, Stream(1, 2)) + testPermutations2(2, List(1, 2)) + + testPermutations1(2, Stream(2, 1)) + testPermutations2(2, List(2, 1)) + + testPermutations1(3, Stream(1, 2, 3)) + testPermutations2(3, List(1, 2, 3)) + + testPermutations1(3, Stream(1, 3, 2)) + testPermutations2(3, List(1, 3, 2)) + + testPermutations1(3, Stream(2, 1, 3)) + testPermutations2(3, List(2, 1, 3)) + + testPermutations1(3, Stream(2, 3, 1)) + testPermutations2(3, List(2, 3, 1)) + + testPermutations1(3, Stream(3, 1, 2)) + testPermutations2(3, List(3, 1, 2)) + + testPermutations1(3, Stream(3, 2, 1)) + testPermutations2(3, List(3, 2, 1)) + } +} diff --git a/tests/run/t5387.scala b/tests/run/t5387.scala new file mode 100644 index 000000000..dabf9e201 --- /dev/null +++ b/tests/run/t5387.scala @@ -0,0 +1,15 @@ +/* + * This tests that the predicate of dropWhile is only evaluated as often as needed, see https://issues.scala-lang.org/browse/SI-5387 + */ +import scala.collection.immutable.ListMap +object Test extends dotty.runtime.LegacyApp{ + val subject = ListMap(1->1,2->2,3->3,4->4,5->5) + val result = ListMap(3->3,4->4,5->5) + assert( result == subject.dropWhile{ + case (key, value) => { + assert( key <= 3, "predicate evaluated more often than needed, key "+key ) + key < 3 + } + } + ) +} diff --git a/tests/run/t5394.scala b/tests/run/t5394.scala new file mode 100644 index 000000000..5f649ee0a --- /dev/null +++ b/tests/run/t5394.scala @@ -0,0 +1,4 @@ +object Test extends dotty.runtime.LegacyApp { + def f[T](l: List[T]): Int = l match { case x :: xs => f(xs) case Nil => 0 } + f(List.fill(10000)(0)) +} diff --git a/tests/run/t5530.check b/tests/run/t5530.check new file mode 100644 index 000000000..1013e3356 --- /dev/null +++ b/tests/run/t5530.check @@ -0,0 +1,2 @@ +something like this + 7 now works!. diff --git a/tests/run/t5530.scala b/tests/run/t5530.scala new file mode 100644 index 000000000..7975abca1 --- /dev/null +++ b/tests/run/t5530.scala @@ -0,0 +1,4 @@ +object Test extends dotty.runtime.LegacyApp { + println(s"""something like this + ${3+4} now works!.""") +} diff --git a/tests/run/t5532.scala b/tests/run/t5532.scala new file mode 100644 index 000000000..6304ec644 --- /dev/null +++ b/tests/run/t5532.scala @@ -0,0 +1,4 @@ +object Test extends dotty.runtime.LegacyApp { + val x = s"1" + val y = s"2" +} diff --git a/tests/run/t5544.check b/tests/run/t5544.check new file mode 100644 index 000000000..257cc5642 --- /dev/null +++ b/tests/run/t5544.check @@ -0,0 +1 @@ +foo diff --git a/tests/run/t5544/Api_1.scala b/tests/run/t5544/Api_1.scala new file mode 100644 index 000000000..b4c92864d --- /dev/null +++ b/tests/run/t5544/Api_1.scala @@ -0,0 +1,8 @@ +import scala.annotation.StaticAnnotation + +class ann(val bar: Any) extends StaticAnnotation + +object Api { + @ann({def foo = "foo!!"}) + def foo = println("foo") +} diff --git a/tests/run/t5544/Test_2.scala b/tests/run/t5544/Test_2.scala new file mode 100644 index 000000000..ea9232221 --- /dev/null +++ b/tests/run/t5544/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends dotty.runtime.LegacyApp { + Api.foo +} diff --git a/tests/run/t5552.check b/tests/run/t5552.check new file mode 100644 index 000000000..a19a60840 --- /dev/null +++ b/tests/run/t5552.check @@ -0,0 +1,2 @@ +(3,3) +(3.0,3.0) diff --git a/tests/run/t5552.scala b/tests/run/t5552.scala new file mode 100644 index 000000000..dd32ce22c --- /dev/null +++ b/tests/run/t5552.scala @@ -0,0 +1,10 @@ +class C[@specialized(Int) A](a:A) { + lazy val b = (a, a) + def c = b +} +object Test { + def main(args:Array[String]): Unit = { + println(new C(3).c) + println(new C(3.0).c) + } +} diff --git a/tests/run/t5577.check b/tests/run/t5577.check new file mode 100644 index 000000000..3eca38795 --- /dev/null +++ b/tests/run/t5577.check @@ -0,0 +1,11 @@ +Received a size hint: 10 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9
\ No newline at end of file diff --git a/tests/run/t5577.scala b/tests/run/t5577.scala new file mode 100644 index 000000000..d54a37e45 --- /dev/null +++ b/tests/run/t5577.scala @@ -0,0 +1,27 @@ + + + +import collection._ + + + +object Test { + + class AlarmingBuffer[T] extends mutable.ArrayBuffer[T] { + override def sizeHint(x: Int): Unit = { + println("Received a size hint: " + x) + super.sizeHint(x) + } + } + + def main(args: Array[String]): Unit = { + val iteratorBuilder = (new AlarmingBuffer[Int]) mapResult { + res => res.iterator + } + + iteratorBuilder.sizeHint(10) + iteratorBuilder ++= (0 until 10) + iteratorBuilder.result.foreach(println) + } + +} diff --git a/tests/run/t5588.check b/tests/run/t5588.check new file mode 100644 index 000000000..bb101b641 --- /dev/null +++ b/tests/run/t5588.check @@ -0,0 +1,2 @@ +true +true diff --git a/tests/run/t5588.scala b/tests/run/t5588.scala new file mode 100644 index 000000000..62bca8fd4 --- /dev/null +++ b/tests/run/t5588.scala @@ -0,0 +1,14 @@ +object Test { + object MyEnum extends Enumeration { + val Foo = Value(2000000000) + val Bar = Value(-2000000000) + val X = Value(Integer.MAX_VALUE) + val Y = Value(Integer.MIN_VALUE) + } + + import MyEnum._ + def main(args: Array[String]): Unit = { + println(Foo > Bar) + println(X > Y) + } +} diff --git a/tests/run/t5590.check b/tests/run/t5590.check new file mode 100644 index 000000000..ad4a2eee6 --- /dev/null +++ b/tests/run/t5590.check @@ -0,0 +1,4 @@ +Map(a -> a, b -> b, c -> c) +Map(a -> a, b -> b, c -> c) +Set(a, b, c, d, e) +Set(a, b, c, d, e)
\ No newline at end of file diff --git a/tests/run/t5590.scala b/tests/run/t5590.scala new file mode 100644 index 000000000..aded59863 --- /dev/null +++ b/tests/run/t5590.scala @@ -0,0 +1,31 @@ + + + +import java.io._ +import collection._ + + + +object Test { + + def check(obj: AnyRef): Unit = { + println(obj) + + val bos = new ByteArrayOutputStream() + val out = new ObjectOutputStream(bos) + out.writeObject(obj) + val arr = bos.toByteArray() + val in = new ObjectInputStream(new ByteArrayInputStream(arr)) + val deser = in.readObject() + + println(deser) + } + + def main(args: Array[String]): Unit = { + val lhm = mutable.LinkedHashMap("a" -> "a", "b" -> "b", "c" -> "c") + val lhs = mutable.LinkedHashSet("a", "b", "c", "d", "e") + check(lhm) + check(lhs) + } + +} diff --git a/tests/run/t5604.check b/tests/run/t5604.check new file mode 100644 index 000000000..53a2fc889 --- /dev/null +++ b/tests/run/t5604.check @@ -0,0 +1,8 @@ +long +double +long +double +long +double +long +double diff --git a/tests/run/t5604.scala b/tests/run/t5604.scala new file mode 100644 index 000000000..eccad1639 --- /dev/null +++ b/tests/run/t5604.scala @@ -0,0 +1,50 @@ +// a.scala +// Fri Jan 13 11:31:47 PST 2012 + +package foo { + object regular extends Duh { + def buh(n: Long) = println("long") + def buh(n: Double) = println("double") + } + class regular { + import regular._ + + duh(33L) + duh(3.0d) + foo.regular.duh(33L) + foo.regular.duh(3.0d) + buh(66L) + buh(6.0d) + foo.regular.buh(66L) + foo.regular.buh(6.0d) + } + + trait Duh { + def duh(n: Long) = println("long") + def duh(n: Double) = println("double") + } + package object bar extends Duh { + def buh(n: Long) = println("long") + def buh(n: Double) = println("double") + } + package bar { + object Main { + def main(args:Array[String]): Unit = { + duh(33L) + duh(3.0d) + foo.bar.duh(33L) + foo.bar.duh(3.0d) + buh(66L) + buh(6.0d) + foo.bar.buh(66L) + foo.bar.buh(6.0d) + } + } + } +} + +object Test { + def main(args: Array[String]): Unit = { + foo.bar.Main.main(null) + } +} diff --git a/tests/run/t5614.check b/tests/run/t5614.check new file mode 100644 index 000000000..f659f2da3 --- /dev/null +++ b/tests/run/t5614.check @@ -0,0 +1,3 @@ +3 +a +b diff --git a/tests/run/t5614.scala b/tests/run/t5614.scala new file mode 100644 index 000000000..c3410f28b --- /dev/null +++ b/tests/run/t5614.scala @@ -0,0 +1,5 @@ +object Test extends dotty.runtime.LegacyApp { + val str = s"a\nb" + println(str.length) + println(str) +} diff --git a/tests/run/t5656.check b/tests/run/t5656.check new file mode 100644 index 000000000..9543ee799 --- /dev/null +++ b/tests/run/t5656.check @@ -0,0 +1 @@ +List(1, 2, 3)_List(a, b, c)
\ No newline at end of file diff --git a/tests/run/t5656.scala b/tests/run/t5656.scala new file mode 100644 index 000000000..2c97d374d --- /dev/null +++ b/tests/run/t5656.scala @@ -0,0 +1,11 @@ + + + + +object Test { + + def main(args: Array[String]): Unit = { + println(Seq(List('1', '2', '3'), List('a', 'b', 'c')).view.addString(new StringBuilder, "_")) + } + +} diff --git a/tests/run/t5665.scala b/tests/run/t5665.scala new file mode 100644 index 000000000..3ac498b5c --- /dev/null +++ b/tests/run/t5665.scala @@ -0,0 +1,13 @@ +object O { + trait T { + private[this] val c: Int = 42 + def f = + { x: Int => c } + } +} + +object Test { + def main(args: Array[String]): Unit = { + assert(new O.T{}.f(0) == 42) + } +} diff --git a/tests/run/t5680.check b/tests/run/t5680.check new file mode 100644 index 000000000..0d825ab7d --- /dev/null +++ b/tests/run/t5680.check @@ -0,0 +1,3 @@ +[Lscala.runtime.BoxedUnit +() +() diff --git a/tests/run/t5680.scala b/tests/run/t5680.scala new file mode 100644 index 000000000..7f4252839 --- /dev/null +++ b/tests/run/t5680.scala @@ -0,0 +1,7 @@ +object Test extends dotty.runtime.LegacyApp { + val x = Array[Unit]((), ()) + println(x.toString.substring(0, x.toString.indexOf(";"))) + println(x(0)) + x(1) = () + println(x(1)) +} diff --git a/tests/run/t5804.check b/tests/run/t5804.check new file mode 100644 index 000000000..3ccc1c24d --- /dev/null +++ b/tests/run/t5804.check @@ -0,0 +1,4 @@ +128 +16 +128 +32
\ No newline at end of file diff --git a/tests/run/t5804.scala b/tests/run/t5804.scala new file mode 100644 index 000000000..93cfa69ff --- /dev/null +++ b/tests/run/t5804.scala @@ -0,0 +1,32 @@ + + +import collection.mutable._ + + +object Test { + + def main(args: Array[String]): Unit = { + class CustomHashMap extends HashMap[Int, Int] { + override def initialSize = 65 + + println(table.length) + } + + new CustomHashMap + new HashMap { + println(table.length) + } + + class CustomHashSet extends HashSet[Int] { + override def initialSize = 96 + + println(table.length) + } + + new CustomHashSet + new HashSet { + println(table.length) + } + } + +} diff --git a/tests/run/t5830.check b/tests/run/t5830.check new file mode 100644 index 000000000..926085467 --- /dev/null +++ b/tests/run/t5830.check @@ -0,0 +1,7 @@ +a with oef +a with oef +a with oef +a +def with oef +def +default diff --git a/tests/run/t5830.flags b/tests/run/t5830.flags new file mode 100644 index 000000000..e8fb65d50 --- /dev/null +++ b/tests/run/t5830.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/tests/run/t5830.scala b/tests/run/t5830.scala new file mode 100644 index 000000000..2ae1544e5 --- /dev/null +++ b/tests/run/t5830.scala @@ -0,0 +1,55 @@ +import scala.annotation.switch + +object Test extends dotty.runtime.LegacyApp { + def noSwitch(ch: Char, eof: Boolean) = ch match { + case 'a' if eof => println("a with oef") // then branch + } + + def onlyThen(ch: Char, eof: Boolean) = ch match { + case 'a' if eof => println("a with oef") // then branch + case 'c' => + } + + def ifThenElse(ch: Char, eof: Boolean) = (ch: @switch) match { + case 'a' if eof => println("a with oef") // then branch + case 'a' if eof => println("a with oef2") // unreachable, but the analysis is not that sophisticated + case 'a' => println("a") // else-branch + case 'c' => + } + + def defaultUnguarded(ch: Char, eof: Boolean) = ch match { + case ' ' if eof => println("spacey oef") + case _ => println("default") + } + + def defaults(ch: Char, eof: Boolean) = (ch: @switch) match { + case _ if eof => println("def with oef") // then branch + case _ if eof => println("def with oef2") // unreachable, but the analysis is not that sophisticated + case _ => println("def") // else-branch + } + + // test binders in collapsed cases (no need to run, it's "enough" to know it doesn't crash the compiler) + def guard(x: Any): Boolean = true + def testBinders = + try { println("") } // work around SI-6015 + catch { + case _ if guard(null) => + case x if guard(x) => throw x + } + + // def unreachable(ch: Char) = (ch: @switch) match { + // case 'a' => println("b") // ok + // case 'a' => println("b") // unreachable + // case 'c' => + // } + + noSwitch('a', true) + onlyThen('a', true) // 'a with oef' + ifThenElse('a', true) // 'a with oef' + ifThenElse('a', false) // 'a' + defaults('a', true) // 'def with oef' + defaults('a', false) // 'def' + + // test that it jumps to default case, no match error + defaultUnguarded(' ', false) // default +} diff --git a/tests/run/t5856.scala b/tests/run/t5856.scala new file mode 100644 index 000000000..e4e0e3f58 --- /dev/null +++ b/tests/run/t5856.scala @@ -0,0 +1,10 @@ +object Test extends dotty.runtime.LegacyApp { + override def toString = "Test" + + assert(s"$this" == "Test") + assert(s"$this$this" == "TestTest") + assert(s"$this$$" == "Test$") + assert(s"$this.##" == "Test.##") + assert(s"$this.toString" == "Test.toString") + assert(s"$this=THIS" == "Test=THIS") +} diff --git a/tests/run/t5857.scala b/tests/run/t5857.scala new file mode 100644 index 000000000..eabf5dc86 --- /dev/null +++ b/tests/run/t5857.scala @@ -0,0 +1,45 @@ + + + +object Test { + + def time[U](b: =>U): Long = { + val start = System.currentTimeMillis + b + val end = System.currentTimeMillis + + end - start + } + + def main(args: Array[String]): Unit = { + val sz = 1000000000 + + val range = 1 to sz + check { assert(range.min == 1, range.min) } + check { assert(range.max == sz, range.max) } + + val descending = sz to 1 by -1 + check { assert(descending.min == 1) } + check { assert(descending.max == sz) } + + val numeric = 1.0 to sz.toDouble by 1 + check { assert(numeric.min == 1.0) } + check { assert(numeric.max == sz.toDouble) } + + val numdesc = sz.toDouble to 1.0 by -1 + check { assert(numdesc.min == 1.0) } + check { assert(numdesc.max == sz.toDouble) } + } + + def check[U](b: =>U): Unit = { + val exectime = time { + b + } + + // whatever it is, it should be less than, say, 250ms + // if `max` involves traversal, it takes over 5 seconds on a 3.2GHz i7 CPU + //println(exectime) + assert(exectime < 250, exectime) + } + +} diff --git a/tests/run/t5867.check b/tests/run/t5867.check new file mode 100644 index 000000000..e1811eeef --- /dev/null +++ b/tests/run/t5867.check @@ -0,0 +1 @@ +UnrolledBuffer(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50)
\ No newline at end of file diff --git a/tests/run/t5867.scala b/tests/run/t5867.scala new file mode 100644 index 000000000..c7f5d0a41 --- /dev/null +++ b/tests/run/t5867.scala @@ -0,0 +1,14 @@ +import collection.mutable.UnrolledBuffer + + + +object Test { + + def main(args: Array[String]): Unit = { + val buf = UnrolledBuffer(1 to 50: _*) + val dub = buf ++ buf + + println(dub) + } + +} diff --git a/tests/run/t5879.check b/tests/run/t5879.check new file mode 100644 index 000000000..4bdf3f5fc --- /dev/null +++ b/tests/run/t5879.check @@ -0,0 +1,8 @@ +Map(1 -> 1) +1 +(1,1) +Map(1 -> 1) +1 +(1,2) +Map(1 -> 2) +2 diff --git a/tests/run/t5879.scala b/tests/run/t5879.scala new file mode 100644 index 000000000..f96a17410 --- /dev/null +++ b/tests/run/t5879.scala @@ -0,0 +1,59 @@ +import collection.immutable.HashMap + + +object Test { + + def main(args: Array[String]): Unit = { + resolveDefault() + resolveFirst() + resolveSecond() + resolveMany() + } + + def resolveDefault(): Unit = { + val a = HashMap(1 -> "1") + val b = HashMap(1 -> "2") + + val r = a.merged(b)(null) + println(r) + println(r(1)) + } + + def resolveFirst(): Unit = { + val a = HashMap(1 -> "1") + val b = HashMap(1 -> "2") + def collision(a: (Int, String), b: (Int, String)) = { + println(a) + a + } + + val r = a.merged(b) { collision } + println(r) + println(r(1)) + } + + def resolveSecond(): Unit = { + val a = HashMap(1 -> "1") + val b = HashMap(1 -> "2") + def collision(a: (Int, String), b: (Int, String)) = { + println(b) + b + } + + val r = a.merged(b) { collision } + println(r) + println(r(1)) + } + + def resolveMany(): Unit = { + val a = HashMap((0 until 100) zip (0 until 100): _*) + val b = HashMap((0 until 100) zip (100 until 200): _*) + def collision(a: (Int, Int), b: (Int, Int)) = { + (a._1, a._2 + b._2) + } + + val r = a.merged(b) { collision } + for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v)) + } + +} diff --git a/tests/run/t5880.scala b/tests/run/t5880.scala new file mode 100644 index 000000000..5608f4fed --- /dev/null +++ b/tests/run/t5880.scala @@ -0,0 +1,41 @@ + + +import scala.collection.JavaConversions._ + + + +object Test { + + def main(args:Array[String]) = { + val tests = 5000 + val jm: java.util.Map[Int, Int] = scala.collection.mutable.Map((0 until tests) zip (0 until tests).reverse: _*) + val es = jm.entrySet() + val it = es.iterator + + // chi square test + val groups = 10 + val hits = new Array[Int](groups) + def hit(hc: Int): Unit = { + val bucket = math.abs(hc) / (Int.MaxValue / groups) + hits(bucket) += 1 + } + def expected = tests / groups + def Dstat = { + val diffs = for (i <- 0 until groups) yield math.abs(hits(i) - expected) + diffs.sum.toDouble / expected + } + def ChiSquare = { + val diffs = for (i <- 0 until groups) yield (hits(i) - expected) * (hits(i) - expected) + diffs.sum.toDouble / expected + } + + while (it.hasNext) { + val x = it.next() + hit(x.##) + } + // println(hits.toBuffer) + // println(ChiSquare) + assert(ChiSquare < 4.0, ChiSquare + " -> " + hits.mkString(", ")) + } + +} diff --git a/tests/run/t5923c.scala b/tests/run/t5923c.scala new file mode 100644 index 000000000..5f3384638 --- /dev/null +++ b/tests/run/t5923c.scala @@ -0,0 +1,4 @@ +// see neg/macro-blackbox-fundep-materialization and run/macro-whitebox-fundep-materialization +object Test extends dotty.runtime.LegacyApp { + // do nothing +} diff --git a/tests/run/t5937.scala b/tests/run/t5937.scala new file mode 100644 index 000000000..8176d5438 --- /dev/null +++ b/tests/run/t5937.scala @@ -0,0 +1,12 @@ + + + +import collection._ + + + +object Test extends dotty.runtime.LegacyApp { + + val list: List[Int] = (immutable.Vector(1, 2, 3) :+ 4)(breakOut) + +} diff --git a/tests/run/t594.check b/tests/run/t594.check new file mode 100644 index 000000000..814f4a422 --- /dev/null +++ b/tests/run/t594.check @@ -0,0 +1,2 @@ +one +two diff --git a/tests/run/t594.scala b/tests/run/t594.scala new file mode 100644 index 000000000..f923a3cd2 --- /dev/null +++ b/tests/run/t594.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]): Unit = { + val array = Array("one", "two", "three") + val firstTwo: Array[String] = array.slice(0,2) + for (x <- firstTwo) + Console.println(x) + } +} diff --git a/tests/run/t5971.check b/tests/run/t5971.check new file mode 100644 index 000000000..0c36a1ff0 --- /dev/null +++ b/tests/run/t5971.check @@ -0,0 +1,4 @@ +r,b +r +a,b +r,a,b
\ No newline at end of file diff --git a/tests/run/t5971.scala b/tests/run/t5971.scala new file mode 100644 index 000000000..bd41350aa --- /dev/null +++ b/tests/run/t5971.scala @@ -0,0 +1,23 @@ + + + + + +/** When using `AbstractTransformed` abstract inner class in views in order + * to force generating bridges, one must take care to push the corresponding + * collection trait (such as `Iterable` or `Seq`) as far as possible to the + * left in the linearization order -- otherwise, overridden methods from these + * traits can override the already overridden methods in view. This was the + * case with `takeWhile`. + * Mind blowing, I know. + */ +object Test { + + def main(args: Array[String]): Unit = { + println("bar".view.reverse.filter(_ > 'a').mkString(",")) + println("bar".view.reverse.take(1).mkString(",")) + println("bar".view.reverse.dropWhile(_ > 'a').mkString(",")) + println("bar".view.reverse.takeWhile(_ => true).mkString(",")) + } + +} diff --git a/tests/run/t5974.check b/tests/run/t5974.check new file mode 100644 index 000000000..9766475a4 --- /dev/null +++ b/tests/run/t5974.check @@ -0,0 +1 @@ +ok diff --git a/tests/run/t5974.scala b/tests/run/t5974.scala new file mode 100644 index 000000000..e4e64c51e --- /dev/null +++ b/tests/run/t5974.scala @@ -0,0 +1,10 @@ +object Test extends dotty.runtime.LegacyApp { + import scala.collection.JavaConverters._ + + def ser(a: AnyRef) = + (new java.io.ObjectOutputStream(new java.io.ByteArrayOutputStream())).writeObject(a) + + val l = java.util.Arrays.asList("pigdog").asScala + ser(l) + println("ok") +} diff --git a/tests/run/t5986.check b/tests/run/t5986.check new file mode 100644 index 000000000..4101770c6 --- /dev/null +++ b/tests/run/t5986.check @@ -0,0 +1,15 @@ +Foo(bar, 1) +Foo(bar, 1) +Foo(bar, 1),Foo(baz, 3),Foo(bazz, 4) +Foo(bar, 1) +Foo(bar, 1) +Foo(bar, 1),Foo(baz, 3),Foo(bazz, 4) +Foo(bar, 1) +Foo(bar, 1) +Foo(bar, 1),Foo(baz, 3),Foo(bazz, 4) +Foo(bar, 1) +Foo(bar, 1) +Foo(bar, 1),Foo(baz, 3),Foo(bazz, 4) +Foo(bar, 1) +Foo(bar, 1) +Foo(bar, 1),Foo(baz, 3),Foo(bazz, 4)
\ No newline at end of file diff --git a/tests/run/t5986.scala b/tests/run/t5986.scala new file mode 100644 index 000000000..b05d488f2 --- /dev/null +++ b/tests/run/t5986.scala @@ -0,0 +1,36 @@ + + + +import scala.collection._ + + + +/** A sorted set should not replace elements when adding + * and the element already exists in the set. + */ +object Test { + + class Foo(val name: String, val n: Int) { + override def equals(obj: Any): Boolean = obj match { case other: Foo => name == other.name; case _ => false } + override def hashCode = name.## + override def toString = "Foo(" + name + ", " + n + ")" + } + + implicit val ordering: Ordering[Foo] = Ordering.fromLessThan[Foo] { (a, b) => a.name.compareTo(b.name) < 0 } + + def check[S <: Set[Foo]](set: S): Unit = { + def output(s: Set[Foo]) = println(s.toList.sorted.mkString(",")) + output(set + new Foo("bar", 2)) + output(set ++ List(new Foo("bar", 2), new Foo("bar", 3), new Foo("bar", 4))) + output(set union Set(new Foo("bar", 2), new Foo("baz", 3), new Foo("bazz", 4))) + } + + def main(args: Array[String]): Unit = { + check(Set(new Foo("bar", 1))) + check(immutable.Set(new Foo("bar", 1))) + check(mutable.Set(new Foo("bar", 1))) + check(immutable.SortedSet(new Foo("bar", 1))) + check(mutable.SortedSet(new Foo("bar", 1))) + } + +} diff --git a/tests/run/t6011b.check b/tests/run/t6011b.check new file mode 100644 index 000000000..00750edc0 --- /dev/null +++ b/tests/run/t6011b.check @@ -0,0 +1 @@ +3 diff --git a/tests/run/t6011b.scala b/tests/run/t6011b.scala new file mode 100644 index 000000000..d99bf46fc --- /dev/null +++ b/tests/run/t6011b.scala @@ -0,0 +1,11 @@ +object Test extends dotty.runtime.LegacyApp { + var cond = true + + // should not generate a switch + def f(ch: Char): Int = ch match { + case 'a' if cond => 1 + case 'z' | 'a' => 2 + } + + println(f('a') + f('z')) // 3 +} diff --git a/tests/run/t6052.scala b/tests/run/t6052.scala new file mode 100644 index 000000000..e740f00e1 --- /dev/null +++ b/tests/run/t6052.scala @@ -0,0 +1,21 @@ + + + + + + + +object Test extends dotty.runtime.LegacyApp { + def seqarr(i: Int) = Array[Int]() ++ (0 until i) + def pararr(i: Int) = seqarr(i).par + + def check[T](i: Int, f: Int => T): Unit = { + val gseq = seqarr(i).toSeq.groupBy(f) + val gpar = pararr(i).groupBy(f) + assert(gseq == gpar, (gseq, gpar)) + } + + for (i <- 0 until 20) check(i, _ > 0) + for (i <- 0 until 20) check(i, _ % 2) + for (i <- 0 until 20) check(i, _ % 4) +} diff --git a/tests/run/t6064.scala b/tests/run/t6064.scala new file mode 100644 index 000000000..319ad1ae2 --- /dev/null +++ b/tests/run/t6064.scala @@ -0,0 +1,9 @@ +object Test extends dotty.runtime.LegacyApp { + assert(Option(42) contains 42) + assert(Some(42) contains 42) + assert(Option(BigInt(42)) contains 42) + assert(Option(42) contains BigInt(42)) + assert(!(None contains 42)) + assert(Some(null) contains null) + assert(!(Option(null) contains null)) +} diff --git a/tests/run/t6077_patmat_cse_irrefutable.check b/tests/run/t6077_patmat_cse_irrefutable.check new file mode 100644 index 000000000..9766475a4 --- /dev/null +++ b/tests/run/t6077_patmat_cse_irrefutable.check @@ -0,0 +1 @@ +ok diff --git a/tests/run/t6077_patmat_cse_irrefutable.scala b/tests/run/t6077_patmat_cse_irrefutable.scala new file mode 100644 index 000000000..ef8c3dc59 --- /dev/null +++ b/tests/run/t6077_patmat_cse_irrefutable.scala @@ -0,0 +1,13 @@ +class LiteralNode(val value: Any) + +object LiteralNode { + // irrefutable + def unapply(n: LiteralNode) = Some(n.value) +} + +object Test extends dotty.runtime.LegacyApp { + ((new LiteralNode(false)): Any) match { + case LiteralNode(true) => println("uh-oh") + case LiteralNode(false) => println("ok") + } +} diff --git a/tests/run/t6090.scala b/tests/run/t6090.scala new file mode 100644 index 000000000..e7dbb36a0 --- /dev/null +++ b/tests/run/t6090.scala @@ -0,0 +1,6 @@ +class X { def ==(other: X) = true } +class V(val x: X) extends AnyVal +object Test extends { + def main(args: Array[String]) = + assert((new V(new X) == new V(new X))) +} diff --git a/tests/run/t6114.scala b/tests/run/t6114.scala new file mode 100644 index 000000000..8c19e4c2b --- /dev/null +++ b/tests/run/t6114.scala @@ -0,0 +1,61 @@ +object Test extends dotty.runtime.LegacyApp { + def testList = { + val list = new java.util.ArrayList[Int] + list.add(1) + list.add(2) + list.add(3) + import scala.collection.JavaConverters._ + val next = list.asScala ++ List(4,5,6) + assert(next != list.asScala) + + val raw = list.asScala + val cloned = raw.clone + list.add(1) + assert(raw != cloned) + } + def testSet = { + val set = new java.util.HashSet[Int] + set.add(1) + set.add(2) + set.add(3) + import scala.collection.JavaConverters._ + val next = set.asScala ++ Set(4,5,6) + assert(next != set.asScala) + + val raw = set.asScala + val cloned = raw.clone + set.add(4) + assert(raw != cloned) + } + def testMap = { + val map = new java.util.HashMap[Int,Int] + map.put(1,1) + map.put(2,2) + map.put(3,3) + import scala.collection.JavaConverters._ + val next = map.asScala ++ Map(4->4,5->5,6->6) + assert(next != map.asScala) + + val raw = map.asScala + val cloned = raw.clone + map.put(4,4) + assert(raw != cloned) + } + + def testCollection = { + val list: java.util.Collection[Int] = new java.util.ArrayDeque[Int] + list.add(1) + list.add(2) + list.add(3) + import scala.collection.JavaConverters._ + val next = list.asScala ++ List(4,5,6) + assert(next != list.asScala) + + // Note: Clone is hidden at this level, so no overriden cloning. + } + + testList + testSet + testMap + testCollection +} diff --git a/tests/run/t6126.scala b/tests/run/t6126.scala new file mode 100644 index 000000000..c328bf08f --- /dev/null +++ b/tests/run/t6126.scala @@ -0,0 +1,8 @@ +trait LogLevelType +object Test { + type LogLevel = Int with LogLevelType + final val ErrorLevel = 1.asInstanceOf[Int with LogLevelType] + def main(args: Array[String]): Unit = { + List(ErrorLevel, ErrorLevel) + } +} diff --git a/tests/run/t6150.scala b/tests/run/t6150.scala new file mode 100644 index 000000000..f3e83e154 --- /dev/null +++ b/tests/run/t6150.scala @@ -0,0 +1,36 @@ +object Test { + import collection.{ immutable, mutable, generic } + def TheOneTrueCBF = collection.IndexedSeq.ReusableCBF + + val cbf1 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, collection.IndexedSeq[Int]]] + val cbf2 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, collection.IndexedSeq[Int]]] + val cbf3 = implicitly[generic.CanBuildFrom[collection.IndexedSeq[Int], Int, collection.IndexedSeq[Int]]] + + val cbf4 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, immutable.IndexedSeq[Int]]] + val cbf5 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, immutable.Vector[Int]]] + val cbf6 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, immutable.IndexedSeq[Int]]] + + def check[C](v: C) = { + assert(v == Vector(1, 2, 3, 4)) + assert(v.isInstanceOf[Vector[_]]) + } + def checkRealMccoy(x: AnyRef) = { + assert(x eq TheOneTrueCBF, cbf1) + } + + val v = immutable.Vector(1, 2, 3) + val iiv: immutable.IndexedSeq[Int] = immutable.Vector(1, 2, 3) + val iv: IndexedSeq[Int] = immutable.Vector(1, 2, 3) + + def main(args: Array[String]): Unit = { + List(cbf1, cbf2, cbf3, cbf4, cbf5, cbf6) foreach checkRealMccoy + check(v.:+(4)(cbf1)) + check(v.:+(4)(cbf2)) + check(v.:+(4)(cbf3)) + + check(iiv.:+(4)(cbf2)) + check(iiv.:+(4)(cbf3)) + + check(iv.:+(4)(cbf3)) + } +} diff --git a/tests/run/t6188.check b/tests/run/t6188.check new file mode 100644 index 000000000..5d64afc47 --- /dev/null +++ b/tests/run/t6188.check @@ -0,0 +1 @@ +Failure(java.lang.Exception: this is an exception) diff --git a/tests/run/t6188.flags b/tests/run/t6188.flags new file mode 100644 index 000000000..0ebca3e7a --- /dev/null +++ b/tests/run/t6188.flags @@ -0,0 +1 @@ + -optimize diff --git a/tests/run/t6188.scala b/tests/run/t6188.scala new file mode 100644 index 000000000..b6261580e --- /dev/null +++ b/tests/run/t6188.scala @@ -0,0 +1,12 @@ +// SI-6188 Optimizer incorrectly removes method invocations containing throw expressions + +import scala.util.Success + +object Test { + def main(args: Array[String]): Unit = { + val e = new Exception("this is an exception") + val res = Success(1).flatMap[Int](x => throw e) + println(res) + } +} + diff --git a/tests/run/t6194.check b/tests/run/t6194.check new file mode 100644 index 000000000..b325f479d --- /dev/null +++ b/tests/run/t6194.check @@ -0,0 +1 @@ +C:\FooBar\Java\includes\*.jar diff --git a/tests/run/t6194.scala b/tests/run/t6194.scala new file mode 100644 index 000000000..ced325942 --- /dev/null +++ b/tests/run/t6194.scala @@ -0,0 +1,8 @@ +import scala.tools.nsc.util._ + +object Test { + def main(args: Array[String]): Unit = { + val cp = ClassPath.expandPath("""C:\FooBar\Java\includes\*.jar""") mkString java.io.File.pathSeparator + println(cp) + } +} diff --git a/tests/run/t6197.scala b/tests/run/t6197.scala new file mode 100644 index 000000000..f4f77594e --- /dev/null +++ b/tests/run/t6197.scala @@ -0,0 +1,21 @@ +import scala.collection.immutable._ + +object Test extends dotty.runtime.LegacyApp { + + // test that a HashTrieSet with one leaf element is not created! + val x = HashSet.empty + 1 + 2 + if(x.getClass.getSimpleName != "HashTrieSet") + println("A hash set containing two non-colliding values should be a HashTrieSet") + + val y = x - 1 + if(y.getClass.getSimpleName != "HashSet1") + println("A hash set containing one element should always use HashSet1") + + // it is pretty hard to test that the case where a HashTrieSet has one element which + // is itself of type HashTrieS t. That is because the improve hash function makes it very difficult + // to find keys that will have hashes that are close together. + // + // However, it is also not necessary. Removing the ability of a HashTrieSet to have + // one child of type HashTrieSet completely breaks the HashSet, so that many other + // tests fail +} diff --git a/tests/run/t6246.check b/tests/run/t6246.check new file mode 100644 index 000000000..9532185ea --- /dev/null +++ b/tests/run/t6246.check @@ -0,0 +1,90 @@ +runtimeClass = byte, toString = Byte +true +true +true +false +true +false +false +false +false +runtimeClass = short, toString = Short +true +true +true +false +true +false +false +false +false +runtimeClass = char, toString = Char +true +true +true +false +true +false +false +false +false +runtimeClass = int, toString = Int +true +true +true +false +true +false +false +false +false +runtimeClass = long, toString = Long +true +true +true +false +true +false +false +false +false +runtimeClass = float, toString = Float +true +true +true +false +true +false +false +false +false +runtimeClass = double, toString = Double +true +true +true +false +true +false +false +false +false +runtimeClass = void, toString = Unit +true +true +true +false +true +false +false +false +false +runtimeClass = boolean, toString = Boolean +true +true +true +false +true +false +false +false +false
\ No newline at end of file diff --git a/tests/run/t6246.scala b/tests/run/t6246.scala new file mode 100644 index 000000000..179ef8690 --- /dev/null +++ b/tests/run/t6246.scala @@ -0,0 +1,27 @@ +import scala.reflect.{ClassTag, classTag} + +@deprecated("Suppress warnings", since="2.11") +object Test extends dotty.runtime.LegacyApp { + def testValueClass(tag: ClassTag[_]): Unit = { + println(s"runtimeClass = ${tag.runtimeClass}, toString = ${tag.toString}") + println(tag <:< tag) + println(tag <:< ClassTag.AnyVal) + println(tag <:< ClassTag.Any) + println(tag <:< ClassTag.Nothing) + println(ClassTag.Nothing <:< tag) + println(tag <:< ClassTag.Null) + println(ClassTag.Null <:< tag) + println(tag <:< ClassTag.Object) + println(ClassTag.Object <:< tag) + } + + testValueClass(ClassTag.Byte) + testValueClass(ClassTag.Short) + testValueClass(ClassTag.Char) + testValueClass(ClassTag.Int) + testValueClass(ClassTag.Long) + testValueClass(ClassTag.Float) + testValueClass(ClassTag.Double) + testValueClass(ClassTag.Unit) + testValueClass(ClassTag.Boolean) +} diff --git a/tests/run/t627.check b/tests/run/t627.check new file mode 100644 index 000000000..39e641d98 --- /dev/null +++ b/tests/run/t627.check @@ -0,0 +1 @@ +WrappedArray(1, 2, 3, 4) diff --git a/tests/run/t627.scala b/tests/run/t627.scala new file mode 100644 index 000000000..7136169b0 --- /dev/null +++ b/tests/run/t627.scala @@ -0,0 +1,6 @@ +object Test { + def main(args: Array[String]): Unit = { + val s: Seq[Int] = Array(1, 2, 3, 4) + println(s) + } +} diff --git a/tests/run/t6271.scala b/tests/run/t6271.scala new file mode 100644 index 000000000..e8047a9be --- /dev/null +++ b/tests/run/t6271.scala @@ -0,0 +1,32 @@ +object Test extends dotty.runtime.LegacyApp { + def filterIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x filter (_ > 0) ) } + filtered.iterator.toIterable.flatten + } + def takenIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x take 0 ) } + filtered.iterator.toIterable.flatten + } + def droppedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x drop 1 ) } + filtered.iterator.toIterable.flatten + } + def flatMappedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x flatMap (_ => List()) ) } + filtered.iterator.toIterable.flatten + } + def slicedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x slice (2,3) ) } + filtered.iterator.toIterable.flatten + } + filterIssue + takenIssue + droppedIssue + flatMappedIssue + slicedIssue +} diff --git a/tests/run/t6272.check b/tests/run/t6272.check new file mode 100644 index 000000000..f00c965d8 --- /dev/null +++ b/tests/run/t6272.check @@ -0,0 +1,10 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/tests/run/t6272.scala b/tests/run/t6272.scala new file mode 100644 index 000000000..a43e42c47 --- /dev/null +++ b/tests/run/t6272.scala @@ -0,0 +1,62 @@ +// x1, x2, and x3 resulted in: symbol variable bitmap$0 does not exist in A.<init> +object A { + + try { + lazy val x1 = 1 + println(x1) + sys.error("!") + } catch { + case _: Throwable => + lazy val x2 = 2 + println(x2) + } finally { + lazy val x3 = 3 + println(x3) + } + + if ("".isEmpty) { + lazy val x4 = 4 + println(x4) + } + + var b = true + while(b) { + lazy val x5 = 5 + println(x5) + b = false + } + + + def method: Unit = { + try { + lazy val x6 = 6 + println(x6) + sys.error("!") + } catch { + case _: Throwable => + lazy val x7 = 7 + println(x7) + } finally { + lazy val x8 = 8 + println(x8) + } + + if ("".isEmpty) { + lazy val x9 = 9 + println(x9) + } + + var b = true + while(b) { + lazy val x10 = 10 + println(x10) + b = false + } + } +} + +object Test { + def main(args: Array[String]): Unit = { + A.method + } +} diff --git a/tests/run/t629.check b/tests/run/t629.check new file mode 100644 index 000000000..d86bac9de --- /dev/null +++ b/tests/run/t629.check @@ -0,0 +1 @@ +OK diff --git a/tests/run/t629.scala b/tests/run/t629.scala new file mode 100644 index 000000000..67baead5f --- /dev/null +++ b/tests/run/t629.scala @@ -0,0 +1,13 @@ +object Test +{ + def main(args : Array[String]) : Unit = Console.println(new C(1)) +} + +abstract class A(val x : Int) + +class C(x : Int) extends A(x) +{ + override def toString() = "OK" + val v = new D + class D { def value = x } +} diff --git a/tests/run/t6290.scala b/tests/run/t6290.scala new file mode 100644 index 000000000..6552a747c --- /dev/null +++ b/tests/run/t6290.scala @@ -0,0 +1,4 @@ +object Test { + implicit val foo: languageFeature.dynamics = language.dynamics + def main(args: Array[String]): Unit = () +} diff --git a/tests/run/t6370.scala b/tests/run/t6370.scala new file mode 100644 index 000000000..c86b87dc8 --- /dev/null +++ b/tests/run/t6370.scala @@ -0,0 +1,12 @@ +object Test { + + def main(args: Array[String]): Unit = { + val m = collection.immutable.ListMap( "x" -> 1 ) + try { + m("y") + } catch { + case e : NoSuchElementException => assert(e.getMessage() == "key not found: y") + } + + } +} diff --git a/tests/run/t6410.check b/tests/run/t6410.check new file mode 100644 index 000000000..051fe4995 --- /dev/null +++ b/tests/run/t6410.check @@ -0,0 +1,2 @@ +ParMap(0 -> 4, 1 -> 5) +ParMap(0 -> 4, 1 -> 5)
\ No newline at end of file diff --git a/tests/run/t6410.scala b/tests/run/t6410.scala new file mode 100644 index 000000000..0855ffecd --- /dev/null +++ b/tests/run/t6410.scala @@ -0,0 +1,9 @@ + + + +object Test extends dotty.runtime.LegacyApp { + val x = collection.parallel.mutable.ParArray.range(1,10) groupBy { _ % 2 } mapValues { _.size } + println(x) + val y = collection.parallel.immutable.ParVector.range(1,10) groupBy { _ % 2 } mapValues { _.size } + println(y) +} diff --git a/tests/run/t6443-by-name.check b/tests/run/t6443-by-name.check new file mode 100644 index 000000000..6f98fa4a2 --- /dev/null +++ b/tests/run/t6443-by-name.check @@ -0,0 +1,3 @@ +1 +foo +foo diff --git a/tests/run/t6443-by-name.scala b/tests/run/t6443-by-name.scala new file mode 100644 index 000000000..3060a22b4 --- /dev/null +++ b/tests/run/t6443-by-name.scala @@ -0,0 +1,18 @@ +object Test { + + def main(args: Array[String]): Unit = { + def foo = {println("foo"); 0} + lazyDep(X)(foo) + } + + trait T { + type U + } + object X extends T { type U = Int } + + def lazyDep(t: T)(u: => t.U): Unit = { + println("1") + u + u + } +} diff --git a/tests/run/t6443-varargs.check b/tests/run/t6443-varargs.check new file mode 100644 index 000000000..257cc5642 --- /dev/null +++ b/tests/run/t6443-varargs.check @@ -0,0 +1 @@ +foo diff --git a/tests/run/t6443-varargs.scala b/tests/run/t6443-varargs.scala new file mode 100644 index 000000000..006e33244 --- /dev/null +++ b/tests/run/t6443-varargs.scala @@ -0,0 +1,16 @@ +object Test { + + def main(args: Array[String]): Unit = { + def foo = {println("foo"); 0} + lazyDep(X)(foo) + } + + trait T { + type U + } + object X extends T { type U = Int } + + def lazyDep(t: T)(us: t.U*): Unit = { + List(us: _*) + } +} diff --git a/tests/run/t6467.scala b/tests/run/t6467.scala new file mode 100644 index 000000000..e02fb1669 --- /dev/null +++ b/tests/run/t6467.scala @@ -0,0 +1,20 @@ + + + + +import collection._ + + + +object Test extends dotty.runtime.LegacyApp { + + def compare(s1: String, s2: String): Unit = { + assert(s1 == s2, s1 + "\nvs.\n" + s2) + } + + compare(List(1, 2, 3, 4).aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, "1234") + compare(List(1, 2, 3, 4).par.aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, "1234") + compare(Seq(0 until 100: _*).aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, (0 until 100).mkString) + compare(Seq(0 until 100: _*).par.aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, (0 until 100).mkString) + +} diff --git a/tests/run/t6488.scala b/tests/run/t6488.scala new file mode 100644 index 000000000..559164044 --- /dev/null +++ b/tests/run/t6488.scala @@ -0,0 +1,64 @@ +import scala.sys.process._ +import scala.util.Try +import scala.util.Properties.{ javaHome, javaClassPath } +import java.io.{ File, IOException } +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit._ +import java.util.concurrent.atomic._ + +object Test { + /* + // Program that prints "Success" if the command was successfully run then destroyed + // It will silently pass if the command "/bin/ls" does not exist + // It will fail due to the uncatchable exception in t6488 race condition, + // i.e., if any uncaught exceptions on spawned threads are printed. + def main(args: Array[String]) { + try Process("/bin/ls").run(ProcessLogger { _ => () }).destroy + catch { case _ => () } + println("Success") + } + */ + + // Show that no uncaught exceptions are thrown on spawned I/O threads + // when the process is destroyed. The default handler will print + // stack traces in the failing case. + def main(args: Array[String]): Unit = { + if (args.nonEmpty && args(0) == "data") + data() + else + test() // args(0) == "jvm" + } + + // fork the data spewer, wait for input, then destroy the process + def test(): Unit = { + val f = new File(javaHome, "bin").listFiles.sorted filter (_.getName startsWith "java") find (_.canExecute) getOrElse { + // todo signal test runner that test is skipped + new File("/bin/ls") // innocuous + } + //Process(f.getAbsolutePath).run(ProcessLogger { _ => () }).destroy + val reading = new CountDownLatch(1) + val count = new AtomicInteger + def counted = count.get + val command = s"${f.getAbsolutePath} -classpath ${javaClassPath} Test data" + Try { + Process(command) run ProcessLogger { (s: String) => + //Console println s"[[$s]]" // java help + count.getAndIncrement + reading.countDown + Thread.`yield`() + } + } foreach { (p: Process) => + val ok = reading.await(10, SECONDS) + if (!ok) Console println "Timed out waiting for process output!" + p.destroy() + } + //Console println s"Read count $counted lines" + } + + // spew something + def data(): Unit = { + def filler = "." * 100 + for (i <- 1 to 1000) + Console println s"Outputting data line $i $filler" + } +} diff --git a/tests/run/t6500.scala b/tests/run/t6500.scala new file mode 100644 index 000000000..8df00592b --- /dev/null +++ b/tests/run/t6500.scala @@ -0,0 +1,13 @@ +object Test extends dotty.runtime.LegacyApp { + class Box(val value: Int) extends AnyVal + + trait Foo { + def append(box: Box): Foo + } + + class Bar extends Foo { + override def append(box: Box): Bar = this // produces bad forwarder + } + + ((new Bar): Foo).append(new Box(0)) +} diff --git a/tests/run/t6506.scala b/tests/run/t6506.scala new file mode 100644 index 000000000..64a097b6b --- /dev/null +++ b/tests/run/t6506.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]): Unit = { + new WL(new {} #:: S) with T + } + object S { def #::(a: Any): Any = () } + trait T + class WL(a: Any) +} diff --git a/tests/run/t6559.scala b/tests/run/t6559.scala new file mode 100644 index 000000000..5c671f727 --- /dev/null +++ b/tests/run/t6559.scala @@ -0,0 +1,17 @@ + +object Test { + + def main(args: Array[String]) = { + val one = "1" + val two = "2" + + val raw = raw"\n$one\n$two\n" + val escaped = s"\n$one\n$two\n" + val buggy = "\\n1\n2\n" + val correct = "\\n1\\n2\\n" + + assert(raw != escaped, "Raw strings should not be escaped.") + assert(raw != buggy, "Raw strings after variables should not be escaped.") + assert(raw == correct, "Raw strings should stay raw.") + } +} diff --git a/tests/run/t6584.check b/tests/run/t6584.check new file mode 100644 index 000000000..35c868875 --- /dev/null +++ b/tests/run/t6584.check @@ -0,0 +1,8 @@ +Array: 102400 +Vector: 102400 +List: 102400 +Stream: 102400 +Array: 102400 +Vector: 102400 +List: 102400 +Stream: 102400 diff --git a/tests/run/t6584.scala b/tests/run/t6584.scala new file mode 100644 index 000000000..24c236ef3 --- /dev/null +++ b/tests/run/t6584.scala @@ -0,0 +1,16 @@ +object Test { + def main(args: Array[String]): Unit = { + val size = 100 * 1024 + val doubled = (1 to size) ++ (1 to size) + + println("Array: " + Array.tabulate(size)(x => x).distinct.size) + println("Vector: " + Vector.tabulate(size)(x => x).distinct.size) + println("List: " + List.tabulate(size)(x => x).distinct.size) + println("Stream: " + Stream.tabulate(size)(x => x).distinct.size) + + println("Array: " + doubled.toArray.distinct.size) + println("Vector: " + doubled.toVector.distinct.size) + println("List: " + doubled.toList.distinct.size) + println("Stream: " + doubled.toStream.distinct.size) + } +} diff --git a/tests/run/t6614.check b/tests/run/t6614.check new file mode 100644 index 000000000..2e80ebda8 --- /dev/null +++ b/tests/run/t6614.check @@ -0,0 +1,11 @@ +(ArrayStack(),true) +(ArrayStack(0),true) +(ArrayStack(0, 1),true) +(ArrayStack(0, 1, 2),true) +(ArrayStack(0, 1, 2, 3),true) +(ArrayStack(0, 1, 2, 3, 4),true) +(ArrayStack(0, 1, 2, 3, 4, 5),true) +(ArrayStack(0, 1, 2, 3, 4, 5, 6),true) +(ArrayStack(0, 1, 2, 3, 4, 5, 6, 7),true) +(ArrayStack(0, 1, 2, 3, 4, 5, 6, 7, 8),true) +(ArrayStack(0, 1, 2, 3, 4, 5, 6, 7, 8, 9),true) diff --git a/tests/run/t6614.scala b/tests/run/t6614.scala new file mode 100644 index 000000000..b3044c9f0 --- /dev/null +++ b/tests/run/t6614.scala @@ -0,0 +1,8 @@ +object Test extends dotty.runtime.LegacyApp { + import scala.collection.mutable.ArrayStack + + println((for (i <- 0 to 10) yield { + val in = ArrayStack.tabulate(i)(_.toString) + (in, (in filter (_ => true)) == in) + }).mkString("\n")) +} diff --git a/tests/run/t6632.check b/tests/run/t6632.check new file mode 100644 index 000000000..26cf061b5 --- /dev/null +++ b/tests/run/t6632.check @@ -0,0 +1,5 @@ +java.lang.IndexOutOfBoundsException: -1 +java.lang.IndexOutOfBoundsException: -2 +java.lang.IndexOutOfBoundsException: -3 +java.lang.IndexOutOfBoundsException: -1 +java.lang.IndexOutOfBoundsException: 5 diff --git a/tests/run/t6632.scala b/tests/run/t6632.scala new file mode 100644 index 000000000..baf4e7309 --- /dev/null +++ b/tests/run/t6632.scala @@ -0,0 +1,22 @@ +object Test extends dotty.runtime.LegacyApp { + import collection.mutable.ListBuffer + + def newLB = ListBuffer('a, 'b, 'c, 'd, 'e) + + def iiobe[A](f: => A) = + try { f } + catch { case ex: IndexOutOfBoundsException => println(ex) } + + val lb0 = newLB + iiobe( lb0.insert(-1, 'x) ) + + val lb1 = newLB + iiobe( lb1.insertAll(-2, Array('x, 'y, 'z)) ) + + val lb2 = newLB + iiobe( lb2.update(-3, 'u) ) + + val lb3 = newLB + iiobe( lb3.updated(-1, 'u) ) + iiobe( lb3.updated(5, 'u) ) +} diff --git a/tests/run/t6633.check b/tests/run/t6633.check new file mode 100644 index 000000000..1ff8cdbc4 --- /dev/null +++ b/tests/run/t6633.check @@ -0,0 +1,3 @@ +java.lang.IndexOutOfBoundsException: 9 +replStringOf OK +length OK diff --git a/tests/run/t6633.scala b/tests/run/t6633.scala new file mode 100644 index 000000000..852fc5714 --- /dev/null +++ b/tests/run/t6633.scala @@ -0,0 +1,33 @@ +object Test extends dotty.runtime.LegacyApp { + import collection.mutable.ListBuffer + + def newLB = ListBuffer('a, 'b, 'c, 'd, 'e) + + val lb0 = newLB + + try { + lb0.insert(9, 'x) + } catch { + case ex: IndexOutOfBoundsException => println(ex) + } + + val lb1 = newLB + + try { + lb1.insert(9, 'x) + } catch { + case ex: IndexOutOfBoundsException => + } + + val replStr = scala.runtime.ScalaRunTime.replStringOf(lb1, 100) + if (replStr == "ListBuffer('a, 'b, 'c, 'd, 'e)\n") + println("replStringOf OK") + else + println("replStringOf FAILED: " + replStr) + + val len = lb1.length + if (len == 5) + println("length OK") + else + println("length FAILED: " + len) +} diff --git a/tests/run/t6634.check b/tests/run/t6634.check new file mode 100644 index 000000000..f6cbb30c6 --- /dev/null +++ b/tests/run/t6634.check @@ -0,0 +1,31 @@ +Trying lb0 ... +Checking ... +String OK. +Length OK. + +Trying lb1 ... +Checking ... +String OK. +Length OK. + +Trying lb2 ... +Checking ... +String OK. +Length OK. + +Trying lb3 ... +Checking ... +String OK. +Length OK. + +Trying lb4 ... +Checking ... +String OK. +Length OK. + +Trying lb5 ... +java.lang.IllegalArgumentException: removing negative number (-1) of elements +Checking ... +String OK. +Length OK. + diff --git a/tests/run/t6634.scala b/tests/run/t6634.scala new file mode 100644 index 000000000..bc2f00224 --- /dev/null +++ b/tests/run/t6634.scala @@ -0,0 +1,80 @@ +import collection.mutable.ListBuffer + +object Test extends dotty.runtime.LegacyApp { + def newLB = ListBuffer('a, 'b, 'c, 'd, 'e) + + val lb0 = newLB + println("Trying lb0 ...") + try { + lb0.remove(5, 0) + } catch { + // Not thrown in 2.10, will be thrown in 2.11 + case ex: IndexOutOfBoundsException => println(ex) + } + checkNotCorrupted(lb0) + + val lb1 = newLB + println("Trying lb1 ...") + try { + lb1.remove(6, 6) + } catch { + // Not thrown in 2.10, will be thrown in 2.11 + case ex: IndexOutOfBoundsException => println(ex) + } + checkNotCorrupted(lb1) + + val lb2 = newLB + println("Trying lb2 ...") + try { + lb2.remove(99, 6) + } catch { + // Not thrown in 2.10, will be thrown in 2.11 + case ex: IndexOutOfBoundsException => println(ex) + } + checkNotCorrupted(lb2) + + val lb3 = newLB + println("Trying lb3 ...") + try { + lb3.remove(1, 9) + } catch { + // Not thrown in 2.10, will be thrown in 2.11 + case ex: IllegalArgumentException => println(ex) + } + checkNotCorrupted(lb3, "ListBuffer('a)", 1) + + val lb4 = newLB + println("Trying lb4 ...") + try { + lb4.remove(-1, 1) + } catch { + // Not thrown in 2.10, will be thrown in 2.11 + case ex: IndexOutOfBoundsException => println(ex) + } + checkNotCorrupted(lb4, "ListBuffer('b, 'c, 'd, 'e)", 4) + + val lb5 = newLB + println("Trying lb5 ...") + try { + lb5.remove(1, -1) + } catch { + case ex: IllegalArgumentException => println(ex) + } + checkNotCorrupted(lb5) + + // buffer should neither be changed nor corrupted after calling remove with invalid arguments + def checkNotCorrupted( + lb: ListBuffer[Symbol], + expectedString: String = "ListBuffer('a, 'b, 'c, 'd, 'e)", + expectedLength: Int = 5) = { + println("Checking ...") + val replStr = scala.runtime.ScalaRunTime.replStringOf(lb, 100) + if (replStr == expectedString + "\n") println("String OK.") + else println("!!! replStringOf FAILED: " + replStr) + + val len = lb.length + if (len == expectedLength) println("Length OK.") + else println("!!! length FAILED: " + len) + println() + } +} diff --git a/tests/run/t6637.check b/tests/run/t6637.check new file mode 100644 index 000000000..9766475a4 --- /dev/null +++ b/tests/run/t6637.check @@ -0,0 +1 @@ +ok diff --git a/tests/run/t6637.scala b/tests/run/t6637.scala new file mode 100644 index 000000000..7f9c3cd61 --- /dev/null +++ b/tests/run/t6637.scala @@ -0,0 +1,8 @@ + +object Test extends dotty.runtime.LegacyApp { + try { + class A ; class B ; List().head.isInstanceOf[A with B] + } catch { + case _ :java.util.NoSuchElementException => println("ok") + } +} diff --git a/tests/run/t6644.scala b/tests/run/t6644.scala new file mode 100644 index 000000000..5a9850290 --- /dev/null +++ b/tests/run/t6644.scala @@ -0,0 +1,8 @@ +class Testable(val c: String) extends AnyVal { + def matching(cases: Boolean*) = cases contains true +} + +object Test extends dotty.runtime.LegacyApp { + assert(new Testable("").matching(true, false)) +} + diff --git a/tests/run/t6666a.scala b/tests/run/t6666a.scala new file mode 100644 index 000000000..1d208a32e --- /dev/null +++ b/tests/run/t6666a.scala @@ -0,0 +1,16 @@ +class A(a: Any) + +object Test { + def main(args: Array[String]): Unit = { + } + + val x: Unit = { + object InVal extends A({ + new {} // okay + val o = {new {}} // nesting triggers a VerifyError. + null + }); + InVal; + () + }; +} diff --git a/tests/run/t6673.check b/tests/run/t6673.check new file mode 100644 index 000000000..ef2aa551d --- /dev/null +++ b/tests/run/t6673.check @@ -0,0 +1 @@ +List(x) diff --git a/tests/run/t6673.scala b/tests/run/t6673.scala new file mode 100644 index 000000000..9baaed4a6 --- /dev/null +++ b/tests/run/t6673.scala @@ -0,0 +1,5 @@ +object Test extends dotty.runtime.LegacyApp { + def foo(f: String => Array[String])(s: String) = f(s) + val test = foo(Array(_)) _ + println(test("x").toList) +} diff --git a/tests/run/t6706.scala b/tests/run/t6706.scala new file mode 100644 index 000000000..905494ca8 --- /dev/null +++ b/tests/run/t6706.scala @@ -0,0 +1,14 @@ +object Test { + var name = "foo" + 1 + var s1 = Symbol(name) + s1 = null + System.gc + val s2 = Symbol("foo1") + name = null + System.gc + val s3 = Symbol("foo1") + + def main(args: Array[String]): Unit = { + assert(s2 eq s3, ((s2, System.identityHashCode(s2), s3, System.identityHashCode(s3)))) + } +} diff --git a/tests/run/t6732.check b/tests/run/t6732.check new file mode 100644 index 000000000..016c6e50c --- /dev/null +++ b/tests/run/t6732.check @@ -0,0 +1,4 @@ +scala#PK: true, false, true, false +scala#PKC: false, true, true, true +scala.collection.immutable.List#MOD: true, false, false, false +scala.collection.immutable.List#MODC: false, true, false, false diff --git a/tests/run/t6732.scala b/tests/run/t6732.scala new file mode 100644 index 000000000..ff0f0494d --- /dev/null +++ b/tests/run/t6732.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ +import definitions._ + +object Test extends dotty.runtime.LegacyApp { + def test(sym: Symbol): Unit = { + println(s"${showRaw(sym, printKinds = true)}: ${sym.isModule}, ${sym.isModuleClass}, ${sym.isPackage}, ${sym.isPackageClass}") + } + test(ScalaPackage) + test(ScalaPackageClass) + test(ListModule) + test(ListModule.moduleClass) +} diff --git a/tests/run/t6827.check b/tests/run/t6827.check new file mode 100644 index 000000000..3a3a71c67 --- /dev/null +++ b/tests/run/t6827.check @@ -0,0 +1,15 @@ +start at -5: java.lang.IllegalArgumentException: requirement failed: start -5 out of range 10 +start at -1: java.lang.IllegalArgumentException: requirement failed: start -1 out of range 10 +start at limit: java.lang.IllegalArgumentException: requirement failed: start 10 out of range 10 +start at limit-1: ok +first 10: ok +read all: ok +test huge len: ok +5 from 5: ok +20 from 5: ok +test len overflow: ok +start beyond limit: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 +read 0: ok +read -1: ok +invalid read 0: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 +invalid read -1: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 diff --git a/tests/run/t6827.scala b/tests/run/t6827.scala new file mode 100644 index 000000000..b7366c90a --- /dev/null +++ b/tests/run/t6827.scala @@ -0,0 +1,34 @@ +object Test extends dotty.runtime.LegacyApp { + val ns = (0 until 20) + val arr = new Array[Int](10) + + def tryit(label: String, start: Int, len: Int): Unit = { + val status = try { + val it = ns.toIterator + it.copyToArray(arr, start, len) + "ok" + } catch { + case e: Exception => e.toString + } + println("%s: %s" format (label, status)) + } + + tryit("start at -5", -5, 10) + tryit("start at -1", -1, 10) + tryit("start at limit", 10, 10) + tryit("start at limit-1", 9, 10) + tryit("first 10", 0, 10) + tryit("read all", 0, 20) + tryit("test huge len", 0, Int.MaxValue) + tryit("5 from 5", 5, 10) + tryit("20 from 5", 5, 20) + tryit("test len overflow", 5, Int.MaxValue) + tryit("start beyond limit", 30, 10) + tryit("read 0", 0, 0) + tryit("read -1", 0, -1) + tryit("invalid read 0", 30, 0) + tryit("invalid read -1", 30, -1) + + // okay, see SI-7128 + "...".toIterator.copyToArray(new Array[Char](0), 0, 0) +} diff --git a/tests/run/t6908.scala b/tests/run/t6908.scala new file mode 100644 index 000000000..da37cb0bb --- /dev/null +++ b/tests/run/t6908.scala @@ -0,0 +1,6 @@ +object Test { + def main(args: Array[String]): Unit = { + val set = collection.mutable.Set("1", null, "3").par + assert( set exists (_ eq null) ) + } +} diff --git a/tests/run/t6928-run.check b/tests/run/t6928-run.check new file mode 100644 index 000000000..a640c3e5f --- /dev/null +++ b/tests/run/t6928-run.check @@ -0,0 +1 @@ +3 As diff --git a/tests/run/t6928-run.scala b/tests/run/t6928-run.scala new file mode 100644 index 000000000..87a8884d6 --- /dev/null +++ b/tests/run/t6928-run.scala @@ -0,0 +1,10 @@ +abstract class A( val someAs: A* ) { + override def toString = someAs.length + " As" +} +object B extends A(null, null, null) + +object Test { + def main(args: Array[String]): Unit = { + println(B) + } +} diff --git a/tests/run/t6957.scala b/tests/run/t6957.scala new file mode 100644 index 000000000..4637d4337 --- /dev/null +++ b/tests/run/t6957.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]): Unit = { + class Foo + class Parent(f:Foo) + class Child extends Parent({val x=new Foo{}; x}) + new Child + } +} diff --git a/tests/run/t6968.check b/tests/run/t6968.check new file mode 100644 index 000000000..7a1894153 --- /dev/null +++ b/tests/run/t6968.check @@ -0,0 +1 @@ +1, 3, 5 diff --git a/tests/run/t6968.scala b/tests/run/t6968.scala new file mode 100644 index 000000000..c4e47ba0e --- /dev/null +++ b/tests/run/t6968.scala @@ -0,0 +1,7 @@ +object Test { + def main(args: Array[String]): Unit = { + val mixedList = List(1,(1,2),4,(3,1),(5,4),6) + val as = for((a,b) <- mixedList) yield a + println(as.mkString(", ")) + } +} diff --git a/tests/run/t7120b.check b/tests/run/t7120b.check new file mode 100644 index 000000000..aa2f5e7c9 --- /dev/null +++ b/tests/run/t7120b.check @@ -0,0 +1,2 @@ +public int C$D.foo(java.lang.String) +public int C$D.foo(java.lang.String) diff --git a/tests/run/t7120b.scala b/tests/run/t7120b.scala new file mode 100644 index 000000000..e5b546a90 --- /dev/null +++ b/tests/run/t7120b.scala @@ -0,0 +1,30 @@ + +import scala.language.higherKinds + +trait Base[A] { type B = A; } +class C extends Base[String] { + class D { + def foo[B1 <: B](b: B1) = 0 + } +} + +trait BaseHK[M[_], A] { type B = M[A]; } +object BaseHK { type Id[X] = X } +class CHK extends BaseHK[BaseHK.Id, String] { + class D { + def foo[B1 <: B](b: B1) = 0 + } +} + + +object Test extends dotty.runtime.LegacyApp { + val c = new C + val d = new c.D() + val meth = d.getClass.getMethods.find(_.getName == "foo").get + println(meth) + + val chk = new CHK + val dhk = new chk.D() + val methhk = d.getClass.getMethods.find(_.getName == "foo").get + println(methhk) +} diff --git a/tests/run/t7215.scala b/tests/run/t7215.scala new file mode 100644 index 000000000..7bc48de1f --- /dev/null +++ b/tests/run/t7215.scala @@ -0,0 +1,6 @@ +object Test extends dotty.runtime.LegacyApp { + List[List[Any]]().transpose.isEmpty + Array[Array[Any]]().transpose.isEmpty + Vector[Vector[Any]]().transpose.isEmpty + Stream[Stream[Any]]().transpose.isEmpty +} diff --git a/tests/run/t7231.check b/tests/run/t7231.check new file mode 100644 index 000000000..c1e4b6c17 --- /dev/null +++ b/tests/run/t7231.check @@ -0,0 +1,2 @@ +null +null diff --git a/tests/run/t7231.scala b/tests/run/t7231.scala new file mode 100644 index 000000000..63ed16097 --- /dev/null +++ b/tests/run/t7231.scala @@ -0,0 +1,11 @@ +object Test extends dotty.runtime.LegacyApp { + val bar: Null = null + + def foo(x: Array[Int]) = x + def baz(x: String) = x + + // first line was failing + println(foo(bar)) + // this line worked but good to have a double check + println(baz(bar)) +} diff --git a/tests/run/t7249.check b/tests/run/t7249.check new file mode 100644 index 000000000..7777e0a5a --- /dev/null +++ b/tests/run/t7249.check @@ -0,0 +1 @@ +Yup! diff --git a/tests/run/t7249.scala b/tests/run/t7249.scala new file mode 100644 index 000000000..6858fce1c --- /dev/null +++ b/tests/run/t7249.scala @@ -0,0 +1,7 @@ +object Test extends dotty.runtime.LegacyApp { + def bnToLambda(s: => String): () => String = () => s + var x: () => String = () => sys.error("Nope") + val y = bnToLambda { x() } + x = () => "Yup!" + println(y()) +} diff --git a/tests/run/t7269.scala b/tests/run/t7269.scala new file mode 100644 index 000000000..d6e11f4f7 --- /dev/null +++ b/tests/run/t7269.scala @@ -0,0 +1,32 @@ +import scala.collection.JavaConversions._ +import scala.collection.mutable + +object Test extends dotty.runtime.LegacyApp { + + def testMap(): Unit = { + val mapJ = new java.util.HashMap[Int, String] + val mapS: mutable.Map[Int, String] = mapJ + + (10 to 20).foreach(i => mapS += ((i, i.toString))) + assert(11 == mapS.size) + + // ConcurrentModificationException thrown in the following line + mapS.retain((i, str) => i % 2 == 0) + assert(6 == mapS.size) + } + + def testSet(): Unit = { + val mapJ = new java.util.HashSet[Int] + val mapS: mutable.Set[Int] = mapJ + + (10 to 20).foreach(i => mapS += i) + assert(11 == mapS.size) + + // ConcurrentModificationException thrown in the following line + mapS.retain((i) => i % 2 == 0) + assert(6 == mapS.size) + } + + testSet() + testMap() +} diff --git a/tests/run/t7291.check b/tests/run/t7291.check new file mode 100644 index 000000000..c07ba986a --- /dev/null +++ b/tests/run/t7291.check @@ -0,0 +1,2 @@ +conjure +traversable diff --git a/tests/run/t7291.scala b/tests/run/t7291.scala new file mode 100644 index 000000000..ee22b581e --- /dev/null +++ b/tests/run/t7291.scala @@ -0,0 +1,22 @@ + +import scala.language.{ higherKinds, implicitConversions } + +trait Fooable[T] +object Fooable { + implicit def conjure[T]: Fooable[T] = { + println("conjure") + new Fooable[T]{} + } + +} + +object Test { + implicit def traversable[T, Coll[_] <: Traversable[_]](implicit +elem: Fooable[T]): Fooable[Coll[T]] = { + println("traversable") + new Fooable[Coll[T]]{} + } + def main(args: Array[String]): Unit = { + implicitly[Fooable[List[Any]]] + } +} diff --git a/tests/run/t7336.scala b/tests/run/t7336.scala new file mode 100644 index 000000000..e2f17e115 --- /dev/null +++ b/tests/run/t7336.scala @@ -0,0 +1,31 @@ +import scala.concurrent.Await +import scala.concurrent.ExecutionContext.Implicits.global +import scala.concurrent.Future +import scala.concurrent.duration.Duration + +/** This test uses recursive calls to Future.flatMap to create arrays whose + * combined size is slightly greater than the JVM heap size. A previous + * implementation of Future.flatMap would retain references to each array, + * resulting in a speedy OutOfMemoryError. Now, each array should be freed soon + * after it is created and the test should complete without problems. + */ +object Test { + def main(args: Array[String]): Unit = { + def loop(i: Int, arraySize: Int): Future[Unit] = { + val array = new Array[Byte](arraySize) + Future.successful(i).flatMap { i => + if (i == 0) { + Future.successful(()) + } else { + array.size // Force closure to refer to array + loop(i - 1, arraySize) + } + + } + } + + val arraySize = 1000000 + val tooManyArrays = (Runtime.getRuntime().totalMemory() / arraySize).toInt + 1 + Await.ready(loop(tooManyArrays, arraySize), Duration.Inf) + } +} diff --git a/tests/run/t7341.flags b/tests/run/t7341.flags new file mode 100755 index 000000000..ae0844605 --- /dev/null +++ b/tests/run/t7341.flags @@ -0,0 +1 @@ +-Xcheckinit
\ No newline at end of file diff --git a/tests/run/t7341.scala b/tests/run/t7341.scala new file mode 100755 index 000000000..812b316f9 --- /dev/null +++ b/tests/run/t7341.scala @@ -0,0 +1,15 @@ +object Obj { + private var cache: Any = () + def returning(f: () => Unit) = () + def foo: Unit = { + returning(() => cache = ()) + } + + def apply(): Any = { + cache + } +} + +object Test extends dotty.runtime.LegacyApp { + Obj() +} diff --git a/tests/run/t7406.check b/tests/run/t7406.check new file mode 100644 index 000000000..f599e28b8 --- /dev/null +++ b/tests/run/t7406.check @@ -0,0 +1 @@ +10 diff --git a/tests/run/t7406.scala b/tests/run/t7406.scala new file mode 100644 index 000000000..a8b35c91c --- /dev/null +++ b/tests/run/t7406.scala @@ -0,0 +1,14 @@ +class Arne[@specialized(Long) T](x: T) { + val regularVal = x + lazy val lazyVal = x + + def apply(f: (T, T) => T): T = f(regularVal, lazyVal) +} + +object Test { + val arne = new Arne(5L) + def f = arne(_ + _) + def main(args: Array[String]): Unit = { + println(f) + } +} diff --git a/tests/run/t7407.check b/tests/run/t7407.check new file mode 100644 index 000000000..e965047ad --- /dev/null +++ b/tests/run/t7407.check @@ -0,0 +1 @@ +Hello diff --git a/tests/run/t7407.flags b/tests/run/t7407.flags new file mode 100644 index 000000000..c8547a27d --- /dev/null +++ b/tests/run/t7407.flags @@ -0,0 +1 @@ +-Ynooptimise -Ybackend:GenBCode diff --git a/tests/run/t7407.scala b/tests/run/t7407.scala new file mode 100644 index 000000000..51fb2214f --- /dev/null +++ b/tests/run/t7407.scala @@ -0,0 +1,11 @@ +// SI-7407 +object Test { + + def main(args: Array[String]): Unit = { println(foo) } + + def foo: String = { + try return "Hello" finally 10 match {case x => ()} + } + +} + diff --git a/tests/run/t7407b.check b/tests/run/t7407b.check new file mode 100644 index 000000000..f30294447 --- /dev/null +++ b/tests/run/t7407b.check @@ -0,0 +1,2 @@ +Hello +abc diff --git a/tests/run/t7407b.flags b/tests/run/t7407b.flags new file mode 100644 index 000000000..c8547a27d --- /dev/null +++ b/tests/run/t7407b.flags @@ -0,0 +1 @@ +-Ynooptimise -Ybackend:GenBCode diff --git a/tests/run/t7407b.scala b/tests/run/t7407b.scala new file mode 100644 index 000000000..79f52a6fc --- /dev/null +++ b/tests/run/t7407b.scala @@ -0,0 +1,20 @@ +object Test { + + def main(args: Array[String]): Unit = { + println(foo(true)) + println(foo(false)) + } + + def foo(b: Boolean): String = { + try { + if(b) + return "Hello" + else + "abc" + } finally { + 10 match {case x => ()} + } + } + +} + diff --git a/tests/run/t7436.scala b/tests/run/t7436.scala new file mode 100644 index 000000000..9627e38f5 --- /dev/null +++ b/tests/run/t7436.scala @@ -0,0 +1,9 @@ +class A(val p: Int*) + +class B(val p1: Int) extends A(p1) + +object Test { + def main(args: Array[String]): Unit = { + new B(1).p1 // threw java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofInt cannot be cast to java.lang.Integer + } +} diff --git a/tests/run/t7445.scala b/tests/run/t7445.scala new file mode 100644 index 000000000..25fc5d388 --- /dev/null +++ b/tests/run/t7445.scala @@ -0,0 +1,6 @@ +import scala.collection.immutable.ListMap + +object Test extends dotty.runtime.LegacyApp { + val a = ListMap(1 -> 1, 2 -> 2, 3 -> 3, 4 -> 4, 5 -> 5); + require(a.tail == ListMap(2 -> 2, 3 -> 3, 4 -> 4, 5 -> 5)); +} diff --git a/tests/run/t7475b.check b/tests/run/t7475b.check new file mode 100644 index 000000000..51993f072 --- /dev/null +++ b/tests/run/t7475b.check @@ -0,0 +1,2 @@ +2 +2 diff --git a/tests/run/t7475b.scala b/tests/run/t7475b.scala new file mode 100644 index 000000000..a205602b6 --- /dev/null +++ b/tests/run/t7475b.scala @@ -0,0 +1,11 @@ +trait A { private val x = 1 } +trait B { val x = 2 } +trait C1 extends B with A { println(x) } +trait C2 extends A with B { println(x) } + +object Test { + def main(args: Array[String]): Unit = { + new C1 { } + new C2 { } + } +} diff --git a/tests/run/t7498.scala b/tests/run/t7498.scala new file mode 100644 index 000000000..cab598405 --- /dev/null +++ b/tests/run/t7498.scala @@ -0,0 +1,20 @@ + + + + + + + +object Test extends dotty.runtime.LegacyApp { + import scala.collection.concurrent.TrieMap + + class Collision(val idx: Int) { + override def hashCode = idx % 10 + } + + val tm = TrieMap[Collision, Unit]() + for (i <- 0 until 1000) tm(new Collision(i)) = () + + tm.par.foreach(kv => ()) +} + diff --git a/tests/run/t7763.scala b/tests/run/t7763.scala new file mode 100644 index 000000000..a76f52b74 --- /dev/null +++ b/tests/run/t7763.scala @@ -0,0 +1,20 @@ +object Test { + class A; class B + def main(args: Array[String]): Unit = { + def noExpectedType(): Unit = { + a().asInstanceOf[B] // cast elided! + } + def withExpectedType(): B = { + a().asInstanceOf[B] + } + def test(a: => Any) = try { + a + sys.error("no CCE!") + } catch {case _: ClassCastException => } + + test(noExpectedType()) + test(withExpectedType()) + } + + def a(): Object = new A +} diff --git a/tests/run/t7775.scala b/tests/run/t7775.scala new file mode 100644 index 000000000..bc6a67d0e --- /dev/null +++ b/tests/run/t7775.scala @@ -0,0 +1,17 @@ +import scala.concurrent.{duration, Future, Await, ExecutionContext} +import scala.tools.nsc.Settings +import ExecutionContext.Implicits.global + +// Was failing pretty regularly with a ConcurrentModificationException as +// WrappedProperties#systemProperties iterated directly over the mutable +// global system properties map. +object Test { + def main(args: Array[String]): Unit = { + val tries = 1000 // YMMV + val compiler = Future { + for(_ <- 1 to tries) new Settings(_ => {}) + } + for(i <- 1 to tries * 10) System.setProperty(s"foo$i", i.toString) + Await.result(compiler, duration.Duration.Inf) + } +} diff --git a/tests/run/t7880.scala b/tests/run/t7880.scala new file mode 100644 index 000000000..106047bc8 --- /dev/null +++ b/tests/run/t7880.scala @@ -0,0 +1,7 @@ +object Test extends dotty.runtime.LegacyApp { + // This should terminate in one way or another, but it shouldn't loop forever. + try { + val buffer = collection.mutable.ArrayBuffer.fill(Int.MaxValue / 2 + 1)(0) + buffer append 1 + } catch { case _: OutOfMemoryError => } +} diff --git a/tests/run/t7899.scala b/tests/run/t7899.scala new file mode 100644 index 000000000..2720cb89c --- /dev/null +++ b/tests/run/t7899.scala @@ -0,0 +1,5 @@ +object Test extends dotty.runtime.LegacyApp { + def id[A](a: => A): A = null.asInstanceOf[A] + def foo(f: (=> Int) => Int) = () => f(???) + foo(id)() // should be allowed and not throw ??? +} diff --git a/tests/run/t7912.scala b/tests/run/t7912.scala new file mode 100644 index 000000000..3d603e0e9 --- /dev/null +++ b/tests/run/t7912.scala @@ -0,0 +1,16 @@ +case object A { override def toString = ??? } + +object Test { + def foo: Int = (A: Any) match { + case 0 => 0 + } + def main(args: Array[String]): Unit = { + try { + foo + sys.error("no exception") + } catch { + case me: MatchError => assert(me.getMessage == "an instance of class A$", me.getMessage) + case ex: Throwable => sys.error("not a match error: " + ex.getClass) + } + } +} diff --git a/tests/run/t7985.scala b/tests/run/t7985.scala new file mode 100644 index 000000000..3d8a9d51c --- /dev/null +++ b/tests/run/t7985.scala @@ -0,0 +1,3 @@ +object Test extends dotty.runtime.LegacyApp { + Array(1) match { case _: Array[scala.Int] => } +} diff --git a/tests/run/t7992.scala b/tests/run/t7992.scala new file mode 100644 index 000000000..9753765c0 --- /dev/null +++ b/tests/run/t7992.scala @@ -0,0 +1,20 @@ +class C { + def foo: Int = 0 +} + +class D extends C { + override def foo: Int = { + val f = () => { + class C // comment this line to fix. + D.super.foo // no super accessor generated here! + // java.lang.VerifyError: (class: D$$anonfun$1, method: apply$mcI$sp signature: ()I) Illegal use of nonvirtual function call + } + f() + } +} + +object Test { + def main(args: Array[String]): Unit = { + new D().foo + } +} diff --git a/tests/run/t7992b.scala b/tests/run/t7992b.scala new file mode 100644 index 000000000..78891fd69 --- /dev/null +++ b/tests/run/t7992b.scala @@ -0,0 +1,18 @@ +class C { + def foo: Int = 0 +} + +class E extends C { + override def foo: Int = { + (None: Option[Int]).getOrElse { + class C + E.super.foo + } + } +} + +object Test { + def main(args: Array[String]): Unit = { + new E().foo + } +} diff --git a/tests/run/t8010.scala b/tests/run/t8010.scala new file mode 100644 index 000000000..39d1d9284 --- /dev/null +++ b/tests/run/t8010.scala @@ -0,0 +1,22 @@ +trait Base { + def t = 1 + def t(n: Int) = n + def bt = 2 + def bt(n: Int) = n +} +trait Derived extends Base { + // was: double defintion error + override def t = 1 + super.t + override def t(n: Int) = 1 + super.t(n) + override def bt = 1 + super.bt + override def bt(n: Int) = 1 + super.bt(n) +} + +object Test extends dotty.runtime.LegacyApp { + val d = new Derived {} + // not the focus of thie bug, but let's just check the runtime behaviour while we're here. + assert(d.t == 2) + assert(d.t(1) == 2) + assert(d.bt == 3) + assert(d.bt(1) == 2) +} diff --git a/tests/run/t8015-ffc.scala b/tests/run/t8015-ffc.scala new file mode 100644 index 000000000..f458cc2ac --- /dev/null +++ b/tests/run/t8015-ffc.scala @@ -0,0 +1,7 @@ + +object Test extends dotty.runtime.LegacyApp { + val ms = """This is a long multiline string + with \u000d\u000a CRLF embedded.""" + assert(ms.lines.size == 3, s"lines.size ${ms.lines.size}") + assert(ms contains "\r\n CRLF", "no CRLF") +} diff --git a/tests/run/t8100.check b/tests/run/t8100.check new file mode 100644 index 000000000..cdd927fd8 --- /dev/null +++ b/tests/run/t8100.check @@ -0,0 +1 @@ +Success(0) diff --git a/tests/run/t8100.scala b/tests/run/t8100.scala new file mode 100644 index 000000000..b9d0fe500 --- /dev/null +++ b/tests/run/t8100.scala @@ -0,0 +1,8 @@ +object Test { + import scala.util.Try + + def main(args: Array[String]): Unit = { + def stream = Stream.from(0).take(100000).map(n => None) + println(Try(stream.flatten.length)) + } +} diff --git a/tests/run/t8133/A_1.scala b/tests/run/t8133/A_1.scala new file mode 100644 index 000000000..a2836cdb3 --- /dev/null +++ b/tests/run/t8133/A_1.scala @@ -0,0 +1,5 @@ +// a.scala +package object pkg { + class AnyOps(val x: Any) extends AnyVal + def AnyOps(x: Any) = new AnyOps(x) +} diff --git a/tests/run/t8133/B_2.scala b/tests/run/t8133/B_2.scala new file mode 100644 index 000000000..b80e10952 --- /dev/null +++ b/tests/run/t8133/B_2.scala @@ -0,0 +1,15 @@ +package pkg { + package object other + package other { + class Crash { + AnyOps(0) + () + } + } +} + +object Test { + def main(args: Array[String]): Unit = { + new pkg.other.Crash + } +} diff --git a/tests/run/t8133b/A_1.scala b/tests/run/t8133b/A_1.scala new file mode 100644 index 000000000..24bbfc118 --- /dev/null +++ b/tests/run/t8133b/A_1.scala @@ -0,0 +1,4 @@ +package object pkg { + def foo(x: Int): String = "a" + def foo(x: String): String = "b" +} diff --git a/tests/run/t8133b/B_2.scala b/tests/run/t8133b/B_2.scala new file mode 100644 index 000000000..865ca0c0b --- /dev/null +++ b/tests/run/t8133b/B_2.scala @@ -0,0 +1,9 @@ +// b.scala +package pkg { + package object other + package other { class Crash { foo("") } } +} + +object Test { + def main(args: Array[String]): Unit = new pkg.other.Crash +} diff --git a/tests/run/t8153.check b/tests/run/t8153.check new file mode 100644 index 000000000..0cfbf0888 --- /dev/null +++ b/tests/run/t8153.check @@ -0,0 +1 @@ +2 diff --git a/tests/run/t8153.scala b/tests/run/t8153.scala new file mode 100644 index 000000000..0cbfb5b5a --- /dev/null +++ b/tests/run/t8153.scala @@ -0,0 +1,14 @@ +object Test { + def f() = { + val lb = scala.collection.mutable.ListBuffer[Int](1, 2) + val it = lb.iterator + if (it.hasNext) it.next + val xs = lb.toList + lb += 3 + it.mkString + } + + def main(args: Array[String]): Unit = { + println(f()) + } +} diff --git a/tests/run/t8188.scala b/tests/run/t8188.scala new file mode 100644 index 000000000..9ee542f2a --- /dev/null +++ b/tests/run/t8188.scala @@ -0,0 +1,25 @@ +object Test { + def main(args: Array[String]): Unit = { + import java.io.ByteArrayInputStream + import java.io.ByteArrayOutputStream + import java.io.ObjectInputStream + import java.io.ObjectOutputStream + import scala.collection.concurrent.TrieMap + + def ser[T](o: T): Array[Byte] = { + val baos = new ByteArrayOutputStream() + new ObjectOutputStream(baos).writeObject(o) + baos.toByteArray() + } + + def deser[T](bs: Array[Byte]): T = + new ObjectInputStream(new ByteArrayInputStream(bs)).readObject().asInstanceOf[T] + + def cloneViaSerialization[T](t: T): T = deser(ser(t)) + + val f = cloneViaSerialization(_: TrieMap[Int, Int]) + val tm = TrieMap(1 -> 2) + assert( f(f(tm)) == tm ) + assert( ser(tm).length == ser(f(tm)).length ) + } +} diff --git a/tests/run/t8197b.scala b/tests/run/t8197b.scala new file mode 100644 index 000000000..a9012ddf9 --- /dev/null +++ b/tests/run/t8197b.scala @@ -0,0 +1,8 @@ +object O { + def foo[T](t: T) = 0 + def foo(s: String)(implicit i: DummyImplicit = null) = 1 +} + +object Test extends dotty.runtime.LegacyApp { + assert(O.foo("") == 1) +} diff --git a/tests/run/t8233-bcode.flags b/tests/run/t8233-bcode.flags new file mode 100644 index 000000000..c30091d3d --- /dev/null +++ b/tests/run/t8233-bcode.flags @@ -0,0 +1 @@ +-Ybackend:GenBCode diff --git a/tests/run/t8233-bcode.scala b/tests/run/t8233-bcode.scala new file mode 100644 index 000000000..771e4cf0c --- /dev/null +++ b/tests/run/t8233-bcode.scala @@ -0,0 +1,31 @@ +object Test { + def bar(s: String) = s; + val o: Option[Null] = None + def nullReference: Unit = { + val a: Null = o.get + bar(a) // Was: VerifyError under GenICode + } + + def literal: Unit = { + val a: Null = null + bar(a) + } + + /** Check SI-8330 for details */ + def expectedUnitInABranch(b: Boolean): Boolean = { + if (b) { + val x = 12 + () + } else { + // here expected type is (unboxed) Unit + null + } + true + } + + def main(args: Array[String]): Unit = { + try { nullReference } catch { case _: NoSuchElementException => } + literal + expectedUnitInABranch(true) + } +} diff --git a/tests/run/t8233.scala b/tests/run/t8233.scala new file mode 100644 index 000000000..3896a7cc6 --- /dev/null +++ b/tests/run/t8233.scala @@ -0,0 +1,31 @@ +object Test { + def bar(s: String) = s; + val o: Option[Null] = None + def nullReference: Unit = { + val a: Null = o.get + bar(a) // Was: VerifyError under GenICode + } + + def literal: Unit = { + val a: Null = null + bar(a) + } + + /** Check SI-8330 for details */ + def expectedUnitInABranch(b: Boolean): Boolean = { + if (b) { + val x = 12 + () + } else { + // here expected type is (unboxed) Unit + null + } + true + } + + def main(args: Array[String]): Unit = { + try { nullReference } catch { case _: NoSuchElementException => } + literal + expectedUnitInABranch(true) // Was: VerifyError under GenICode + } +} diff --git a/tests/run/t8346.check b/tests/run/t8346.check new file mode 100644 index 000000000..1ba5c31ab --- /dev/null +++ b/tests/run/t8346.check @@ -0,0 +1,6 @@ +BitSet: List(invariant, invariant, invariant, invariant) +HashSet: List(covariant (true), covariant (true), covariant (true), covariant (true)) +ListSet: List(covariant (true), covariant (true), covariant (true), covariant (true)) +SortedSet: List(invariant, invariant, invariant, invariant) +TreeSet: List(invariant, invariant, invariant, invariant) +ValueSet: invariant diff --git a/tests/run/t8346.scala b/tests/run/t8346.scala new file mode 100644 index 000000000..1c34ab35f --- /dev/null +++ b/tests/run/t8346.scala @@ -0,0 +1,34 @@ +object Test extends dotty.runtime.LegacyApp { + import reflect.ClassTag + + object SomeEnum extends Enumeration { + val one, two, three, four = Value + } + + def sctor[A <: Set[Int]](f: Int => A)(implicit A: ClassTag[A]) + : (String, Int => Set[Int]) = + (A.runtimeClass.getSimpleName, f) + + val inits: Seq[(String, Int => Set[Int])] = { + import collection.immutable.{Seq => _, _} + Seq(sctor(BitSet(_)), + sctor(HashSet(_)), + sctor(ListSet(_)), + sctor(SortedSet(_)), + sctor(TreeSet(_))) + } + + def sVarInfo[A](sa: Set[A]): String = { + val saa = sa.toSet[Any] + if (sa eq saa) s"""covariant (${(saa + "hi") contains "hi"})""" + else "invariant" + } + + inits foreach {case (name, singleton) => + print(s"${name}: ") + val one = singleton(1) + println(Seq(2,3,4).scanLeft(one)(_ + _) map sVarInfo toList) + } + + println(s"ValueSet: ${sVarInfo(SomeEnum.values)}") +} diff --git a/tests/run/t8395.scala b/tests/run/t8395.scala new file mode 100644 index 000000000..f2b687e2b --- /dev/null +++ b/tests/run/t8395.scala @@ -0,0 +1,9 @@ + object Test { + def baz(x: Object) = { + val s @ (_s: String) = x + x + } + def main(args: Array[String]): Unit = { + assert(baz("1") == "1") + } +} diff --git a/tests/run/t8428.scala b/tests/run/t8428.scala new file mode 100644 index 000000000..d79a698d4 --- /dev/null +++ b/tests/run/t8428.scala @@ -0,0 +1,12 @@ +object Test extends dotty.runtime.LegacyApp { + val xs = List.tabulate(4)(List(_)) + val i = xs.map(_.iterator).reduce { (a,b) => + a.hasNext + a ++ b + } + + val r1 = i.toList + val r2 = xs.flatten.toList + + assert(r1 == r2, r1) +} diff --git a/tests/run/t8601.flags b/tests/run/t8601.flags new file mode 100644 index 000000000..1182725e8 --- /dev/null +++ b/tests/run/t8601.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/tests/run/t8601.scala b/tests/run/t8601.scala new file mode 100644 index 000000000..feea6e6c3 --- /dev/null +++ b/tests/run/t8601.scala @@ -0,0 +1,15 @@ +object Test { + def idiv(x: Int): Unit = x / 0 + def ldiv(x: Long): Unit = x / 0 + def irem(x: Int): Unit = x % 0 + def lrem(x: Long): Unit = x % 0 + + def check(x: => Any) = try { x; sys.error("failed to throw divide by zero!") } catch { case _: ArithmeticException => } + + def main(args: Array[String]): Unit = { + check(idiv(1)) + check(ldiv(1L)) + check(irem(1)) + check(lrem(1L)) + } +} diff --git a/tests/run/t8601b.flags b/tests/run/t8601b.flags new file mode 100644 index 000000000..1182725e8 --- /dev/null +++ b/tests/run/t8601b.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/tests/run/t8601b.scala b/tests/run/t8601b.scala new file mode 100644 index 000000000..3816e0b83 --- /dev/null +++ b/tests/run/t8601b.scala @@ -0,0 +1,14 @@ +object Test { + def len(x: Array[String]): Unit = x.length + def load(x: Array[String]): Unit = x(0) + def newarray(i: Int): Unit = new Array[Int](i) + + def check(x: => Any) = try { x; sys.error("failed to throw NPE!") } catch { case _: NullPointerException => } + def checkNegSize(x: => Any) = try { x; sys.error("failed to throw NegativeArraySizeException!") } catch { case _: NegativeArraySizeException => } + + def main(args: Array[String]): Unit = { + check(len(null)) // bug: did not NPE + check(load(null)) + checkNegSize(newarray(-1)) + } +} diff --git a/tests/run/t8601c.flags b/tests/run/t8601c.flags new file mode 100644 index 000000000..1182725e8 --- /dev/null +++ b/tests/run/t8601c.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/tests/run/t8601c.scala b/tests/run/t8601c.scala new file mode 100644 index 000000000..946a4d4b6 --- /dev/null +++ b/tests/run/t8601c.scala @@ -0,0 +1,12 @@ +object Test { + def loadField(x: scala.runtime.IntRef): Unit = x.elem + def storeField(x: scala.runtime.IntRef): Unit = x.elem = 42 + + def check(x: => Any) = try { x; sys.error("failed to throw NPE!") } catch { case _: NullPointerException => } + + def main(args: Array[String]): Unit = { + check(loadField(null)) // bug: did not NPE under -Ydead-code + check(storeField(null)) + + } +} diff --git a/tests/run/t8601d.flags b/tests/run/t8601d.flags new file mode 100644 index 000000000..1182725e8 --- /dev/null +++ b/tests/run/t8601d.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/tests/run/t8601d.scala b/tests/run/t8601d.scala new file mode 100644 index 000000000..a6962847c --- /dev/null +++ b/tests/run/t8601d.scala @@ -0,0 +1,8 @@ +object Test { + def monitor(x: AnyRef): Unit = {x.synchronized(()); ()} + def check(x: => Any) = try { x; sys.error("failed to throw NPE") } catch { case _: NullPointerException => } + + def main(args: Array[String]): Unit = { + check(monitor(null)) + } +} diff --git a/tests/run/t8607.scala b/tests/run/t8607.scala new file mode 100644 index 000000000..5ee7e57d5 --- /dev/null +++ b/tests/run/t8607.scala @@ -0,0 +1,36 @@ +package p1 { + private[p1] trait B extends Any { + def a: Any = "" + } + + class C(val value: Int) extends AnyVal with B { + // def b = "" + } +} + +object Test { + def main(args: Array[String]): Unit = { + val c = new p1.C(42) + c.a + /* + new p1.C.<init>( + c.$asInstanceOf[scala.this.Int]() + ).a(); + + + new p1.C.<init>( + new p1.C.<init>( + c.$asInstanceOf[scala.this.Int]() + ).$asInstanceOf[ErasedValueType(class C, scala.this.Int)]() + .$asInstanceOf[scala.this.Int]() + ).a(); + + new p1.C.<init>( + new p1.C.<init>(c) + .$asInstanceOf[scala.this.Int]() + .$asInstanceOf[scala.this.Int]() + ).a(); + + */ + } +} diff --git a/tests/run/t8611a.flags b/tests/run/t8611a.flags new file mode 100644 index 000000000..85d8eb2ba --- /dev/null +++ b/tests/run/t8611a.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/tests/run/t8611a.scala b/tests/run/t8611a.scala new file mode 100644 index 000000000..4a0d6fb57 --- /dev/null +++ b/tests/run/t8611a.scala @@ -0,0 +1,16 @@ +trait K +trait L + +object O { + type LK = K with L + val A: LK = new K with L + val B: LK = new K with L +} + +object Test extends dotty.runtime.LegacyApp { + val scrut: O.LK = O.B + scrut match { + case O.A => ??? + case O.B => // spurious unreachable + } +} diff --git a/tests/run/t8611c.flags b/tests/run/t8611c.flags new file mode 100644 index 000000000..85d8eb2ba --- /dev/null +++ b/tests/run/t8611c.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/tests/run/t8611c.scala b/tests/run/t8611c.scala new file mode 100644 index 000000000..325070f4c --- /dev/null +++ b/tests/run/t8611c.scala @@ -0,0 +1,21 @@ +trait K +trait L + +object O { + type LK = K with L +} + +object Test extends dotty.runtime.LegacyApp { + local + + def local = { + val A: O.LK = new K with L + val B: O.LK = new K with L + val scrut: O.LK = A + scrut match { + case B if "".isEmpty => ??? + case A => + case B => ??? + } + } +} diff --git a/tests/run/t8680.scala b/tests/run/t8680.scala new file mode 100644 index 000000000..3c4bc8e7d --- /dev/null +++ b/tests/run/t8680.scala @@ -0,0 +1,53 @@ +object Test extends dotty.runtime.LegacyApp { + def pre(n: Int) = (-n to -1).toStream + + def cyc(m: Int) = { + lazy val s: Stream[Int] = (0 until m).toStream #::: s + s + } + + def precyc(n: Int, m: Int) = pre(n) #::: cyc(m) + + def str(s: Stream[Int]) = { + val b = new StringBuilder + s.addString(b, "", "", "") + b.toString + } + + def goal(n: Int, m: Int) = (-n until m).mkString + "..." + + // Check un-forced cyclic and non-cyclic streams + assert(str(pre(2)) == pre(2).take(1).toList.mkString + "?") + assert(str(cyc(2)) == cyc(2).take(1).toList.mkString + "?") + assert(str(precyc(2,2)) == precyc(2,2).take(1).toList.mkString + "?") + assert(!pre(2).hasDefiniteSize) + assert(!cyc(2).hasDefiniteSize) + assert(!precyc(2,2).hasDefiniteSize) + + // Check forced cyclic and non-cyclic streams + assert(str(pre(2).force) == (-2 to -1).mkString) + assert(str(cyc(2).force) == (0 until 2).mkString + "...") + assert(str(precyc(2,2).force) == (-2 until 2).mkString + "...") + assert(pre(2).force.hasDefiniteSize) + assert(!cyc(2).force.hasDefiniteSize) + assert(!precyc(2,2).force.hasDefiniteSize) + + // Special cases + assert(str(cyc(1).force) == goal(0,1)) + assert(str(precyc(1,6).force) == goal(1,6)) + assert(str(precyc(6,1).force) == goal(6,1)) + + // Make sure there are no odd/even problems + for (n <- 3 to 4; m <- 3 to 4) { + assert(precyc(n,m).mkString == goal(n,m), s"mkString $n $m") + assert(!precyc(n,m).force.hasDefiniteSize, s"hasDef $n$m") + } + + // Make sure there are no cycle/prefix modulus problems + for (i <- 6 to 8) { + assert(precyc(i,3).mkString == goal(i,3), s"mkString $i 3") + assert(precyc(3,i).mkString == goal(3,i), s"mkString 3 $i") + assert(!precyc(i,3).force.hasDefiniteSize, s"hasDef $i 3") + assert(!precyc(3,i).force.hasDefiniteSize, s"hasDef 3 $i") + } +} diff --git a/tests/run/t8690.check b/tests/run/t8690.check new file mode 100644 index 000000000..72f076c4d --- /dev/null +++ b/tests/run/t8690.check @@ -0,0 +1,2 @@ +non-empty iterator +abcdef diff --git a/tests/run/t8690.scala b/tests/run/t8690.scala new file mode 100644 index 000000000..cfa47b0e4 --- /dev/null +++ b/tests/run/t8690.scala @@ -0,0 +1,12 @@ +import scala.io.Source +import java.io.ByteArrayInputStream + +object Test extends dotty.runtime.LegacyApp { + val txt = "abcdef" + + val in = new ByteArrayInputStream(txt.getBytes()); + val source = Source.fromInputStream(in); + println(source.toString) // forces the BufferedSource to look at the head of the input + + println(source.mkString) // used to return "bcdef" ... +} diff --git a/tests/run/t8738.scala b/tests/run/t8738.scala new file mode 100644 index 000000000..1683b93b5 --- /dev/null +++ b/tests/run/t8738.scala @@ -0,0 +1,16 @@ +object Test { + def check(a: Range, b: Range) = (a == b) == (a.toList == b.toList) + def main(args: Array[String]): Unit = { + val lo = -2 to 2 + val hi = lo + val step = List(-6,-2,-1,1,2,6) + for (i <- lo; j <- hi; n <- step; k <- lo; l <- hi; m <- step) { + assert( + check(i until j by n, k until l by m) && + check(i until j by n, k to l by m) && + check(i to j by n, k until l by m) && + check(i to j by n, k to l by m) + ) + } + } +} diff --git a/tests/run/t8845.flags b/tests/run/t8845.flags new file mode 100644 index 000000000..aada25f80 --- /dev/null +++ b/tests/run/t8845.flags @@ -0,0 +1 @@ +-Ybackend:GenBCode -Ynooptimize diff --git a/tests/run/t8845.scala b/tests/run/t8845.scala new file mode 100644 index 000000000..bb68142e5 --- /dev/null +++ b/tests/run/t8845.scala @@ -0,0 +1,17 @@ +// crashes compiler under GenASM, works under GenBCode. +object Interpreter { + def mkDataProp(i: Int) = i + def break(n: Int): Unit = + try { + n match { + case _ => + val newDesc = mkDataProp(n) + n match { case _ => return } + } + } catch { case e: Throwable => } + finally { } +} + +object Test extends dotty.runtime.LegacyApp { + Interpreter.break(0) +} diff --git a/tests/run/t8888.flags b/tests/run/t8888.flags new file mode 100644 index 000000000..48b438ddf --- /dev/null +++ b/tests/run/t8888.flags @@ -0,0 +1 @@ +-Ydelambdafy:method diff --git a/tests/run/t8888.scala b/tests/run/t8888.scala new file mode 100644 index 000000000..0ddc2ae82 --- /dev/null +++ b/tests/run/t8888.scala @@ -0,0 +1,12 @@ +class C { + final def resume: Unit = (this: Any) match { + case x : C => (x: Any) match { + case y : C => + () => (x, y) // used to trigger a ClassFormatError under -Ydelambdafy:method + } + } +} + +object Test extends dotty.runtime.LegacyApp { + new C().resume +} diff --git a/tests/run/t8893.scala b/tests/run/t8893.scala new file mode 100644 index 000000000..5178226de --- /dev/null +++ b/tests/run/t8893.scala @@ -0,0 +1,40 @@ +import annotation.tailrec + +object Test { + def a(): Option[String] = Some("a") + + def test1: Any = { + a() match { + case Some(b1) => + a() match { + case Some(b2) => + @tailrec + def tick(i: Int): Unit = if (i < 0) () else tick(i - 1) + tick(10000000) // testing that this doesn't SOE + case None => None + } + case None => None + } + } + + def test2: Any = { + a() match { + case Some(b1) => + a() match { + case Some(b2) => + @tailrec + def tick(i: Int): Unit = if (i < 0) () else tick(i - 1) + tick(10000000) // testing that this doesn't SOE + case None => test1 + } + case None => + test1 // not a tail call + test1 + } + } + + def main(args: Array[String]): Unit = { + test1 + test2 + } +} diff --git a/tests/run/t8893b.scala b/tests/run/t8893b.scala new file mode 100644 index 000000000..19120871a --- /dev/null +++ b/tests/run/t8893b.scala @@ -0,0 +1,15 @@ +// Testing that recursive calls in tail positions are replaced with +// jumps, even though the method contains recursive calls outside +// of the tail position. +object Test { + def tick(i : Int): Unit = + if (i == 0) () + else if (i == 42) { + tick(0) /*not in tail posiiton*/ + tick(i - 1) + } else tick(i - 1) + + def main(args: Array[String]): Unit = { + tick(1000000) + } +} diff --git a/tests/run/t8933b/A.scala b/tests/run/t8933b/A.scala new file mode 100644 index 000000000..d25d893c6 --- /dev/null +++ b/tests/run/t8933b/A.scala @@ -0,0 +1,4 @@ +trait MixinWithSymbol { + self: MotherClass => + def symbolFromTrait: Any = 'traitSymbol +} diff --git a/tests/run/t8933b/Test.scala b/tests/run/t8933b/Test.scala new file mode 100644 index 000000000..7ce239b7d --- /dev/null +++ b/tests/run/t8933b/Test.scala @@ -0,0 +1,9 @@ +class MotherClass extends MixinWithSymbol { + def foo = 'sym1 +} + +object Test { + def main(args: Array[String]): Unit = { + (new MotherClass).symbolFromTrait + } +} diff --git a/tests/run/t8933c.scala b/tests/run/t8933c.scala new file mode 100644 index 000000000..22011bc32 --- /dev/null +++ b/tests/run/t8933c.scala @@ -0,0 +1,14 @@ +object Test { + def main(args: Array[String]): Unit = { + try { + {throw T; Symbol}.apply("a") + assert(false, "exception not thrown") + } catch { + case T => // ok + case t: Throwable => + assert(false, "wrong not thrown: " + t) + } + } +} + +object T extends Throwable diff --git a/tests/run/takeAndDrop.scala b/tests/run/takeAndDrop.scala new file mode 100644 index 000000000..8d2dff0bf --- /dev/null +++ b/tests/run/takeAndDrop.scala @@ -0,0 +1,14 @@ +object Test { + def main(args: Array[String]): Unit = { + val range = 1 to 10 + val target = (3 to 8).toList + val confirm = (xs: Seq[Int]) => assert(xs.toList == target, xs) + + confirm(range drop 2 dropRight 2) + confirm(range drop 1 dropRight 1 drop 1 dropRight 1) + confirm(range take 8 drop 2) + confirm(range takeRight 8 dropRight 2) + confirm(range drop 2 take 6) + confirm(range dropRight 1 take 8 takeRight 7 drop 1) + } +} diff --git a/tests/run/tcpoly_overriding.check b/tests/run/tcpoly_overriding.check new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/run/tcpoly_overriding.check @@ -0,0 +1 @@ +1 diff --git a/tests/run/tcpoly_overriding.scala b/tests/run/tcpoly_overriding.scala new file mode 100644 index 000000000..01b9c29ac --- /dev/null +++ b/tests/run/tcpoly_overriding.scala @@ -0,0 +1,19 @@ + +import scala.language.{ higherKinds } + +abstract class A[t[x]] { + def b: t[Int] +} + +class B extends A[List] { + // underlying functionality being tested is overriding, but bugs manifest itself during erasure + // erasure should generate two methods: one that returns an Object (to implement the method in A) + // one that is as close as possible to the original method and thus returns a List + // the problem only manifests itself here -- but it's really a problem with overriding + // the link between this method and the method in A isn't seen + def b: List[Int] = List(1) +} + +object Test extends dotty.runtime.LegacyApp { + Console.println((new B).b(0)) +} diff --git a/tests/run/transform.scala b/tests/run/transform.scala new file mode 100644 index 000000000..d73155cee --- /dev/null +++ b/tests/run/transform.scala @@ -0,0 +1,8 @@ +object Test { + val x = (1 to 10).toBuffer + + def main(args: Array[String]): Unit = { + x transform (_ * 2) + assert(x.sum == (1 to 10).sum * 2) + } +} diff --git a/tests/run/transpose.scala b/tests/run/transpose.scala new file mode 100644 index 000000000..2761a24ff --- /dev/null +++ b/tests/run/transpose.scala @@ -0,0 +1,12 @@ +object Test { + def wrap[T >: Null](body: => T) = + try body + catch { case _: IllegalArgumentException => null } + + def main(args: Array[String]): Unit = { + assert(wrap(Nil.transpose) == Nil) + assert(wrap(List(List(1, 2), List(1)).transpose) == null) + assert(wrap(List(List(1), List(1, 2)).transpose) == null) + assert(wrap(List(List(1, 2), List(1, 2)).transpose) == List(List(1, 1), List(2, 2))) + } +} diff --git a/tests/run/triemap-hash.scala b/tests/run/triemap-hash.scala new file mode 100644 index 000000000..902b80a01 --- /dev/null +++ b/tests/run/triemap-hash.scala @@ -0,0 +1,46 @@ + + + +import util.hashing.Hashing + + + +object Test { + + def main(args: Array[String]): Unit = { + hashing() + equality() + } + + def hashing(): Unit = { + import collection._ + + val tm = new concurrent.TrieMap[String, String](Hashing.fromFunction(x => x.length + x(0).toInt), Equiv.universal) + tm.put("a", "b") + tm.put("c", "d") + + assert(tm("a") == "b") + assert(tm("c") == "d") + + for (i <- 0 until 1000) tm(i.toString) = i.toString + for (i <- 0 until 1000) assert(tm(i.toString) == i.toString) + } + + def equality(): Unit = { + import collection._ + + val tm = new concurrent.TrieMap[String, String](Hashing.fromFunction(x => x(0).toInt), Equiv.fromFunction(_(0) == _(0))) + tm.put("a", "b") + tm.put("a1", "d") + tm.put("b", "c") + + assert(tm("a") == "d", tm) + assert(tm("b") == "c", tm) + + for (i <- 0 until 1000) tm(i.toString) = i.toString + assert(tm.size == 12, tm) + assert(tm("0") == "0", tm) + for (i <- 1 to 9) assert(tm(i.toString) == i.toString + "99", tm) + } + +} diff --git a/tests/run/triple-quoted-expr.check b/tests/run/triple-quoted-expr.check new file mode 100644 index 000000000..4e59695f3 --- /dev/null +++ b/tests/run/triple-quoted-expr.check @@ -0,0 +1,5 @@ + +hi +hi + +hi diff --git a/tests/run/triple-quoted-expr.scala b/tests/run/triple-quoted-expr.scala new file mode 100644 index 000000000..6d91ac588 --- /dev/null +++ b/tests/run/triple-quoted-expr.scala @@ -0,0 +1,26 @@ +class A { + def f1 = { + val x = 5 + +""" +hi""" + } + def f2 = { + val x = 5 + + """hi""" + } + def f3 = { + val x = 5 + + "\nhi" + } +} + +object Test { + def main(args: Array[String]): Unit = { + val x = new A + import x._ + List(f1, f2, f3) foreach println + } +} diff --git a/tests/run/tuple-match.check b/tests/run/tuple-match.check new file mode 100644 index 000000000..0c1ea0005 --- /dev/null +++ b/tests/run/tuple-match.check @@ -0,0 +1,8 @@ +4, #3 +4, #2 +4, #4 +3, #2 +2, #2 +1, #1 +FOUR +THREE diff --git a/tests/run/tuple-match.scala b/tests/run/tuple-match.scala new file mode 100644 index 000000000..fcaefbff5 --- /dev/null +++ b/tests/run/tuple-match.scala @@ -0,0 +1,27 @@ +object Test { + val FOUR = (-1, -2, -3, "bingo donkey vegas") + val THREE = (-1, -2, -3) + + def f(x: Any) = x match { + case FOUR => "FOUR" + case (_, _, 3, _) => "4, #3" + case (_, 2, _, _) => "4, #2" + case (_, 2, _) => "3, #2" + case Tuple1(1) => "1, #1" + case (_, _, _, 4) => "4, #4" + case THREE => "THREE" + case (_, 2) => "2, #2" + case _ => "default" + } + + def main(args: Array[String]): Unit = { + println(f((1, 2, 3, 4))) + println(f((1, 2, 30, 4))) + println(f((1, 20, 30, 4))) + println(f((1, 2, 3))) + println(f((1, 2))) + println(f(Tuple1(1))) + println(f((-1, -2, -3, "bingo donkey vegas"))) + println(f((-1, -2, -3))) + } +} diff --git a/tests/run/tuples.check b/tests/run/tuples.check new file mode 100644 index 000000000..3fc487815 --- /dev/null +++ b/tests/run/tuples.check @@ -0,0 +1,5 @@ +(1,abc,true) +OK +x = 2; y = xxx; z = 3.14159 +x = 2; y = xxx; z = 3.14159 +x = 2; y = xxx; z = 3.14159 diff --git a/tests/run/tuples.scala b/tests/run/tuples.scala new file mode 100644 index 000000000..e3fd85dc6 --- /dev/null +++ b/tests/run/tuples.scala @@ -0,0 +1,31 @@ +import Function._ + +object Test extends dotty.runtime.LegacyApp { + var xyz: (Int, String, Boolean) = _ + xyz = (1, "abc", true) + Console.println(xyz) + xyz match { + case (1, "abc", true) => Console.println("OK") + case _ => ??? + } + def func(x: Int, y: String, z: Double): Unit = { + Console.println("x = " + x + "; y = " + y + "; z = " + z); + } + + def params = (2, "xxx", 3.14159) // (*****) + + tupled(func _)(params) // call the function with all the params at once + func(2, "xxx", 3.14159) // the same call + (func _).apply(2, "xxx", 3.14159) // the same call + + // Composing a tuple + def t = (1, "Hello", false) + + // Decomposing a tuple + val (i, s, b) = t + + // all the assertions are passed + assert(i == 1) + assert(s == "Hello") + assert(b == false) +} diff --git a/tests/run/unboxingBug.check b/tests/run/unboxingBug.check new file mode 100644 index 000000000..d6aa7b90f --- /dev/null +++ b/tests/run/unboxingBug.check @@ -0,0 +1,6 @@ +97 +97 +97 +97 +1 +1 diff --git a/tests/run/unboxingBug.scala b/tests/run/unboxingBug.scala new file mode 100644 index 000000000..e3cef18b3 --- /dev/null +++ b/tests/run/unboxingBug.scala @@ -0,0 +1,8 @@ +object Test extends dotty.runtime.LegacyApp { + println(identity('a').toInt) + println('a'.toInt) + println(identity('a').asInstanceOf[Int]) + println('a'.asInstanceOf[Int]) + println(identity(1).asInstanceOf[Int]) + println(1.asInstanceOf[Int]) +} diff --git a/tests/run/unittest_iterator.scala b/tests/run/unittest_iterator.scala new file mode 100644 index 000000000..7c47e27e3 --- /dev/null +++ b/tests/run/unittest_iterator.scala @@ -0,0 +1,53 @@ +// Some iterator grouped/sliding unit tests +object Test { + def it = (1 to 10).iterator + def assertThat[T](expectedLength: Int, expectedLast: Seq[T])(it: Iterator[Seq[T]]): Unit = { + val xs = it.toList + def fail(msg: String) = "assertion failed on %s: %s".format(xs, msg) + assert(xs.size == expectedLength, fail("expected length " + expectedLength)) + assert(xs.last == expectedLast, fail("expected last " + expectedLast)) + } + + def main(args: Array[String]): Unit = { + val itSum = it.toStream.sum + for (i <- it) { + // sum of the groups == sum of the original + val thisSum = ((it grouped i) map (_.sum)).toStream.sum + assert(thisSum == itSum, thisSum + " != " + itSum) + } + + // grouped + assertThat(4, List(10)) { it grouped 3 } + assertThat(3, List(7, 8, 9)) { it grouped 3 withPartial false } + assertThat(4, List(10, -1, -1)) { it grouped 3 withPadding -1 } + + // testing by-name padding + val padIt = it + assertThat(4, List(10, 1, 2)) { it grouped 3 withPadding padIt.next } + + // sliding + assertThat(8, List(8, 9, 10)) { it sliding 3 } + assertThat(3, (3 to 10).toList) { it sliding 8 } + assertThat(2, List(9, 10)) { it.sliding(8, 8) } + assertThat(1, (1 to 8).toList) { it.sliding(8, 8) withPartial false } + assertThat(2, List(9, 10, -1, -1, -1)) { it.sliding(5, 8) withPadding -1 } + assertThat(1, (1 to 5).toList) { it.sliding(5, 8) withPartial false } + + // larger step than window + assertThat(5, List(9)) { it.sliding(1, 2) } + assertThat(3, List(9, 10)) { it.sliding(2, 4) } + + // make sure it throws past the end + val thrown = try { + val it = List(1,2,3).sliding(2) + it.next + it.next + it.next + false + } + catch { + case _: NoSuchElementException => true + } + assert(thrown) + } +} diff --git a/tests/run/unreachable.scala b/tests/run/unreachable.scala new file mode 100644 index 000000000..6a428c6ef --- /dev/null +++ b/tests/run/unreachable.scala @@ -0,0 +1,128 @@ +import scala.util.Random.nextInt +import scala.sys.error + +object Test extends dotty.runtime.LegacyApp { + def unreachableNormalExit: Int = { + return 42 + 0 + } + + def unreachableIf: Int = { + return 42 + if (nextInt % 2 == 0) + 0 + else + 1 + } + + def unreachableIfBranches: Int = { + if (nextInt % 2 == 0) + return 42 + else + return 42 + + return 0 + } + + def unreachableOneLegIf: Int = { + if (nextInt % 2 == 0) + return 42 + + return 42 + } + + def unreachableLeftBranch: Int = { + val result = if (nextInt % 2 == 0) + return 42 + else + 42 + + return result + } + + def unreachableRightBranch: Int = { + val result = if (nextInt % 2 == 0) + 42 + else + return 42 + + return result + } + + def unreachableTryCatchFinally: Int = { + return 42 + try { + return 0 + } catch { + case x: Throwable => return 1 + } finally { + return 2 + } + return 3 + } + + def unreachableAfterTry: Int = { + try { + return 42 + } catch { + case x: Throwable => return 2 + } + return 3 + } + + def unreachableAfterCatch: Int = { + try { + error("haha") + } catch { + case x: Throwable => return 42 + } + return 3 + } + + def unreachableAfterFinally: Int = { + try { + return 1 + } catch { + case x: Throwable => return 2 + } finally { + return 42 + } + return 3 + } + + def unreachableSwitch: Int = { + return 42 + val x = nextInt % 2 + x match { + case 0 => return 0 + case 1 => return 1 + case -1 => return 2 + } + 3 + } + + def unreachableAfterSwitch: Int = { + val x = nextInt % 2 + x match { + case 0 => return 42 + case 1 => return 41 + x + case -1 => return 43 + x + } + 2 + } + + def check(f: Int) = assert(f == 42, s"Expected 42 but got $f") + + check(unreachableNormalExit) + check(unreachableIf) + check(unreachableIfBranches) + check(unreachableOneLegIf) + check(unreachableLeftBranch) + check(unreachableRightBranch) + check(unreachableTryCatchFinally) + check(unreachableAfterTry) + check(unreachableAfterCatch) + check(unreachableAfterFinally) + check(unreachableSwitch) + check(unreachableAfterSwitch) +} diff --git a/tests/run/valueclasses-pavlov.check b/tests/run/valueclasses-pavlov.check new file mode 100644 index 000000000..b112e5507 --- /dev/null +++ b/tests/run/valueclasses-pavlov.check @@ -0,0 +1,2 @@ +box1: ok +box2: ok diff --git a/tests/run/valueclasses-pavlov.scala b/tests/run/valueclasses-pavlov.scala new file mode 100644 index 000000000..6ab5ff3e6 --- /dev/null +++ b/tests/run/valueclasses-pavlov.scala @@ -0,0 +1,26 @@ +trait Foo extends Any { + def box1(x: Box1): String + def box2(x: Box2): String +} + +class Box1(val value: String) extends AnyVal + +class Box2(val value: String) extends AnyVal with Foo { + def box1(x: Box1) = "box1: ok" + def box2(x: Box2) = "box2: ok" +} + +class C(x: String) { + def this() = this("") +} + +object Test { + + def main(args: Array[String]): Unit = { + val b1 = new Box1("") + val b2 = new Box2("") + val f: Foo = b2 + println(f.box1(b1)) + println(f.box2(b2)) + } +} diff --git a/tests/run/var-arity-class-symbol.scala b/tests/run/var-arity-class-symbol.scala new file mode 100644 index 000000000..2a7d32987 --- /dev/null +++ b/tests/run/var-arity-class-symbol.scala @@ -0,0 +1,19 @@ +import scala.reflect.runtime.universe._, definitions._ +object Test extends dotty.runtime.LegacyApp { + // Tuples + assert(TupleClass.seq.size == 22) + assert(TupleClass(0) == NoSymbol) + assert(TupleClass(23) == NoSymbol) + assert((1 to 22).forall { i => TupleClass(i).name.toString == s"Tuple$i" }) + // Functions + assert(FunctionClass.seq.size == 23) + assert(FunctionClass(-1) == NoSymbol) + assert(FunctionClass(23) == NoSymbol) + assert((0 to 22).forall { i => FunctionClass(i).name.toString == s"Function$i" }) + // Products + assert(ProductClass.seq.size == 23) + assert(ProductClass(-1) == NoSymbol) + assert(ProductClass(0) == UnitClass) + assert(ProductClass(23) == NoSymbol) + assert((1 to 22).forall { i => ProductClass(i).name.toString == s"Product$i" }) +} diff --git a/tests/run/view-headoption.check b/tests/run/view-headoption.check new file mode 100644 index 000000000..5c98b54b4 --- /dev/null +++ b/tests/run/view-headoption.check @@ -0,0 +1,28 @@ +fail +success +f1: Some(5) +fail +success +f2: 5 +fail +success +fail +fail +success +fail +fail +fail +success +f3: Some(5) +fail +success +fail +success +fail +fail +success +fail +fail +fail +success +f4: 5 diff --git a/tests/run/view-headoption.scala b/tests/run/view-headoption.scala new file mode 100644 index 000000000..659c7e6b8 --- /dev/null +++ b/tests/run/view-headoption.scala @@ -0,0 +1,18 @@ +object Test { + val failer = () => { println("fail") ; None } + val succeeder = () => { println("success") ; Some(5) } + val fs = List(failer, succeeder, failer, failer, succeeder, failer, failer, failer, succeeder) + + def f0 = fs.view flatMap (f => f()) + def f1 = f0.headOption + def f2 = f0.head + def f3 = f0.lastOption + def f4 = f0.last + + def main(args: Array[String]): Unit = { + println("f1: " + f1) + println("f2: " + f2) + println("f3: " + f3) + println("f4: " + f4) + } +} diff --git a/tests/run/viewtest.check b/tests/run/viewtest.check new file mode 100644 index 000000000..6e0fe81a6 --- /dev/null +++ b/tests/run/viewtest.check @@ -0,0 +1,12 @@ +SeqViewZ(...) +ys defined +mapping 1 +2 +SeqViewMS(...) +mapping 3 +4 +SeqViewM(...) +mapping 1 +mapping 2 +mapping 3 +List(2, 3, 4) diff --git a/tests/run/viewtest.scala b/tests/run/viewtest.scala new file mode 100755 index 000000000..398e0bd04 --- /dev/null +++ b/tests/run/viewtest.scala @@ -0,0 +1,45 @@ +object Test extends dotty.runtime.LegacyApp { + import collection._ + val xs: SeqView[(String, Int), Seq[_]] = List("x").view.zip(Stream.from(0)) + println(xs) + + val ys = List(1, 2, 3).view map { x => println("mapping "+x); x + 1 } + println("ys defined") + println(ys.head) + println(ys.tail) + println(ys(2)) + println(ys) + println(ys.force) + + val zs = Array(1, 2, 3).view + val as: SeqView[Int, Array[Int]] = zs map (_ + 1) + val bs: Array[Int] = as.force + val cs = zs.reverse + cs(0) += 1 + assert(cs.force.deep == Array(4, 2, 1).deep) + assert(zs(2) == 4) + assert(bs.deep == Array(2, 3, 4).deep) +} + +/* crash confirmed. +2.8 regression: CCE when zipping list projection with stream +Reported by: szeiger Owned by: odersky +Priority: normal Component: Standard Library +Keywords: collections, zip Cc: +Fixed in version: +Description + +Welcome to Scala version 2.8.0.r18784-b20090925021043 (Java HotSpot(TM) Client VM, Java 1.6.0_11). +Type in expressions to have them evaluated. +Type :help for more information. + +scala> List("x").view.zip(Stream.from(0))List("x").view.zip(Stream.from(0)) +java.lang.ClassCastException: scala.collection.generic.IterableViewTemplate$$anon$8 cannot be cast to scala.collection.generic.SequenceView + at .<init>(<console>:5) + at .<clinit>(<console>) + at RequestResult$.<init>(<console>:4) + at RequestResult$.<clinit>(<console>) + at RequestResult$result(<console>) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.Nat... +*/ diff --git a/tests/run/virtpatmat_apply.check b/tests/run/virtpatmat_apply.check new file mode 100644 index 000000000..e8e3b295e --- /dev/null +++ b/tests/run/virtpatmat_apply.check @@ -0,0 +1 @@ +OK 2 diff --git a/tests/run/virtpatmat_apply.flags b/tests/run/virtpatmat_apply.flags new file mode 100644 index 000000000..3f5a3100e --- /dev/null +++ b/tests/run/virtpatmat_apply.flags @@ -0,0 +1 @@ + -Xexperimental diff --git a/tests/run/virtpatmat_apply.scala b/tests/run/virtpatmat_apply.scala new file mode 100644 index 000000000..838d456cb --- /dev/null +++ b/tests/run/virtpatmat_apply.scala @@ -0,0 +1,7 @@ +object Test extends dotty.runtime.LegacyApp { + List(1, 2, 3) match { + case Nil => println("FAIL") + case x :: y :: xs if xs.length == 2 => println("FAIL") + case x :: y :: xs if xs.length == 1 => println("OK "+ y) + } +} diff --git a/tests/run/virtpatmat_casting.check b/tests/run/virtpatmat_casting.check new file mode 100644 index 000000000..b11425edc --- /dev/null +++ b/tests/run/virtpatmat_casting.check @@ -0,0 +1 @@ +List(1) diff --git a/tests/run/virtpatmat_casting.flags b/tests/run/virtpatmat_casting.flags new file mode 100644 index 000000000..3f5a3100e --- /dev/null +++ b/tests/run/virtpatmat_casting.flags @@ -0,0 +1 @@ + -Xexperimental diff --git a/tests/run/virtpatmat_casting.scala b/tests/run/virtpatmat_casting.scala new file mode 100644 index 000000000..81b52ee1b --- /dev/null +++ b/tests/run/virtpatmat_casting.scala @@ -0,0 +1,9 @@ +object Test extends dotty.runtime.LegacyApp { + println(List(1,2,3) match { + case Nil => List(0) +// since the :: extractor's argument must be a ::, there has to be a cast before its unapply is invoked + case x :: y :: z :: a :: xs => xs ++ List(x) + case x :: y :: z :: xs => xs ++ List(x) + case _ => List(0) + }) +} diff --git a/tests/run/virtpatmat_literal.check b/tests/run/virtpatmat_literal.check new file mode 100644 index 000000000..0eabe3671 --- /dev/null +++ b/tests/run/virtpatmat_literal.check @@ -0,0 +1,3 @@ +OK +OK +OK diff --git a/tests/run/virtpatmat_literal.flags b/tests/run/virtpatmat_literal.flags new file mode 100644 index 000000000..3f5a3100e --- /dev/null +++ b/tests/run/virtpatmat_literal.flags @@ -0,0 +1 @@ + -Xexperimental diff --git a/tests/run/virtpatmat_literal.scala b/tests/run/virtpatmat_literal.scala new file mode 100644 index 000000000..682e6b765 --- /dev/null +++ b/tests/run/virtpatmat_literal.scala @@ -0,0 +1,22 @@ +object Test extends dotty.runtime.LegacyApp { + val a = 1 + 1 match { + case 2 => println("FAILED") + case 1 => println("OK") + case `a` => println("FAILED") + } + + val one = 1 + 1 match { + case 2 => println("FAILED") + case `one` => println("OK") + case 1 => println("FAILED") + } + + 1 match { + case 2 => println("FAILED") + case Test.one => println("OK") + case 1 => println("FAILED") + } + +} diff --git a/tests/run/virtpatmat_switch.check b/tests/run/virtpatmat_switch.check new file mode 100644 index 000000000..6ded95c01 --- /dev/null +++ b/tests/run/virtpatmat_switch.check @@ -0,0 +1,7 @@ +zero +one +many +got a +got b +got some letter +scala.MatchError: 5 (of class java.lang.Integer)
\ No newline at end of file diff --git a/tests/run/virtpatmat_switch.flags b/tests/run/virtpatmat_switch.flags new file mode 100644 index 000000000..3f5a3100e --- /dev/null +++ b/tests/run/virtpatmat_switch.flags @@ -0,0 +1 @@ + -Xexperimental diff --git a/tests/run/virtpatmat_switch.scala b/tests/run/virtpatmat_switch.scala new file mode 100644 index 000000000..5cdf271d5 --- /dev/null +++ b/tests/run/virtpatmat_switch.scala @@ -0,0 +1,38 @@ +object Test extends dotty.runtime.LegacyApp { + def intSwitch(x: Int) = x match { + case 0 => "zero" + case 1 => "one" + case _ => "many" + } + + println(intSwitch(0)) + println(intSwitch(1)) + println(intSwitch(10)) + + def charSwitch(x: Char) = x match { + case 'a' => "got a" + case 'b' => "got b" + case _ => "got some letter" + } + + def byteSwitch(x: Byte) = x match { + case 'a' => "got a" + case 'b' => "got b" + case _ => "got some letter" + } + + println(charSwitch('a')) + println(byteSwitch('b')) + println(charSwitch('z')) + + def implicitDefault(x: Int) = x match { + case 0 => 0 + } + + try { + implicitDefault(5) + } catch { + case e: MatchError => println(e) + } + +} diff --git a/tests/run/virtpatmat_tailcalls_verifyerror.check b/tests/run/virtpatmat_tailcalls_verifyerror.check new file mode 100644 index 000000000..c508d5366 --- /dev/null +++ b/tests/run/virtpatmat_tailcalls_verifyerror.check @@ -0,0 +1 @@ +false diff --git a/tests/run/virtpatmat_tailcalls_verifyerror.flags b/tests/run/virtpatmat_tailcalls_verifyerror.flags new file mode 100644 index 000000000..3f5a3100e --- /dev/null +++ b/tests/run/virtpatmat_tailcalls_verifyerror.flags @@ -0,0 +1 @@ + -Xexperimental diff --git a/tests/run/virtpatmat_tailcalls_verifyerror.scala b/tests/run/virtpatmat_tailcalls_verifyerror.scala new file mode 100644 index 000000000..46c75cf9c --- /dev/null +++ b/tests/run/virtpatmat_tailcalls_verifyerror.scala @@ -0,0 +1,14 @@ +// shouldn't result in a verify error when run... +object Test extends dotty.runtime.LegacyApp { + @annotation.tailrec + final def test(meh: Boolean): Boolean = { + Some("a") match { + case x => + x match { + case Some(_) => if(meh) test(false) else false + case _ => test(false) + } + } + } + println(test(true)) +} diff --git a/tests/run/virtpatmat_unapply.check b/tests/run/virtpatmat_unapply.check new file mode 100644 index 000000000..2b89b77d1 --- /dev/null +++ b/tests/run/virtpatmat_unapply.check @@ -0,0 +1,2 @@ +1 +6 diff --git a/tests/run/virtpatmat_unapply.flags b/tests/run/virtpatmat_unapply.flags new file mode 100644 index 000000000..3f5a3100e --- /dev/null +++ b/tests/run/virtpatmat_unapply.flags @@ -0,0 +1 @@ + -Xexperimental diff --git a/tests/run/virtpatmat_unapply.scala b/tests/run/virtpatmat_unapply.scala new file mode 100644 index 000000000..9915b8d92 --- /dev/null +++ b/tests/run/virtpatmat_unapply.scala @@ -0,0 +1,32 @@ +class IntList(val hd: Int, val tl: IntList) +object NilIL extends IntList(0, null) +object IntList { + def unapply(il: IntList): Option[(Int, IntList)] = if(il eq NilIL) None else Some(il.hd, il.tl) + def apply(x: Int, xs: IntList) = new IntList(x, xs) +} + +object Test extends dotty.runtime.LegacyApp { + IntList(1, IntList(2, NilIL)) match { + case IntList(a1, IntList(a2, IntList(a3, y))) => println(a1 + a2 + a3) + case IntList(x, y) => println(x) + } + + IntList(1, IntList(2, IntList(3, NilIL))) match { + case IntList(a1, IntList(a2, IntList(a3, y))) => println(a1 + a2 + a3) + case IntList(x, y) => println(x) + } +} + +// ((x1: IntList) => IntList.unapply(x1).flatMap(((x4: (Int, IntList)) => IntList.unapply(x4._2).flatMap(((x5: (Int, IntList)) => IntList.unapply(x5._2).flatMap(((x6: (Int, IntList)) => implicitly[Predef.MatchingStrategy[Option]].success(Predef.println(x4._1.+(x5._1).+(x6._1))))))))).orElse(IntList.unapply(x1).flatMap(((x7: (Int, IntList)) => implicitly[scala.Predef.MatchingStrategy[Option]].success(Predef.println(x7._1))))).orElse(implicitly[scala.Predef.MatchingStrategy[Option]].fail))(IntList.apply(1, IntList.apply(2, IntList.apply(3, null)))) + +/* + ((x1: IntList) => + IntList.this.unapply(x1).flatMap[Int](((x4: (Int, IntList)) => + IntList.this.unapply(x4._2).flatMap[Int](((x5: (Int, IntList)) => + IntList.this.unapply(x5._2).flatMap[Int](((x6: (Int, IntList)) => + Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).success[Int](x6._1))))))).orElse[Int]( + IntList.this.unapply(x1).flatMap[Int](((x7: (Int, IntList)) => + Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).success[Int](x7._1)))).orElse[Int]( + Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).fail) + ).apply(IntList.apply(1, null)) +*/ diff --git a/tests/run/virtpatmat_unapplyseq.check b/tests/run/virtpatmat_unapplyseq.check new file mode 100644 index 000000000..62f945751 --- /dev/null +++ b/tests/run/virtpatmat_unapplyseq.check @@ -0,0 +1 @@ +6
\ No newline at end of file diff --git a/tests/run/virtpatmat_unapplyseq.flags b/tests/run/virtpatmat_unapplyseq.flags new file mode 100644 index 000000000..3f5a3100e --- /dev/null +++ b/tests/run/virtpatmat_unapplyseq.flags @@ -0,0 +1 @@ + -Xexperimental diff --git a/tests/run/virtpatmat_unapplyseq.scala b/tests/run/virtpatmat_unapplyseq.scala new file mode 100644 index 000000000..e202c8d27 --- /dev/null +++ b/tests/run/virtpatmat_unapplyseq.scala @@ -0,0 +1,5 @@ +object Test extends dotty.runtime.LegacyApp { + List(1,2,3) match { + case Seq(x, y, z) => println(x * y * z) + } +} diff --git a/tests/run/withIndex.check b/tests/run/withIndex.check new file mode 100644 index 000000000..6a9c7aaad --- /dev/null +++ b/tests/run/withIndex.check @@ -0,0 +1,8 @@ +List((a,0), (b,1), (c,2)) +List((a,0), (b,1), (c,2)) +List((a,0), (b,1), (c,2)) +List((a,0), (b,1), (c,2)) +List() +List() +List() +List() diff --git a/tests/run/withIndex.scala b/tests/run/withIndex.scala new file mode 100644 index 000000000..ebf1941c9 --- /dev/null +++ b/tests/run/withIndex.scala @@ -0,0 +1,29 @@ +object Test { + def main(args: Array[String]) = { + val ary: Array[String] = Array("a", "b", "c") + val lst: List[String] = List("a", "b", "c") + val itr: Iterator[String] = lst.iterator + val str: Stream[String] = lst.iterator.toStream + + Console.println(ary.zipWithIndex.toList) + Console.println(lst.zipWithIndex.toList) + Console.println(itr.zipWithIndex.toList) + Console.println(str.zipWithIndex.toList) + assert { + ary.zipWithIndex match { + case _: Array[Tuple2[_,_]] => true + case _ => false + } + } + + val emptyArray = new Array[String](0) + val emptyList: List[String] = Nil + val emptyIterator = emptyList.iterator + val emptyStream: Stream[String] = Stream.empty + + Console.println(emptyArray.zipWithIndex.toList) + Console.println(emptyList.zipWithIndex.toList) + Console.println(emptyIterator.zipWithIndex.toList) + Console.println(emptyStream.zipWithIndex.toList) + } +} |