diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/bug3376.check | 13 | ||||
-rw-r--r-- | test/files/run/bug4080.check | 1 | ||||
-rw-r--r-- | test/files/run/bug4080.scala | 12 | ||||
-rw-r--r-- | test/files/run/bug4279.scala | 38 | ||||
-rw-r--r-- | test/files/run/bug4285.check | 11 | ||||
-rw-r--r-- | test/files/run/bug4387.scala | 12 | ||||
-rw-r--r-- | test/files/run/constrained-types.check | 132 | ||||
-rw-r--r-- | test/files/run/constrained-types.scala | 146 | ||||
-rw-r--r-- | test/files/run/programmatic-main.scala | 2 | ||||
-rw-r--r-- | test/files/run/repl-assign.check | 20 | ||||
-rw-r--r-- | test/files/run/repl-assign.scala | 10 | ||||
-rw-r--r-- | test/files/run/repl-paste-2.check | 56 | ||||
-rw-r--r-- | test/files/run/repl-paste-2.scala | 17 | ||||
-rw-r--r-- | test/files/run/repl-paste.check | 16 | ||||
-rw-r--r-- | test/files/run/repl-transcript.check | 27 | ||||
-rw-r--r-- | test/files/run/t3361.scala | 6 | ||||
-rw-r--r-- | test/files/run/t4396.check | 5 | ||||
-rw-r--r-- | test/files/run/t4396.scala | 35 | ||||
-rw-r--r-- | test/files/run/treePrint.scala | 2 |
19 files changed, 347 insertions, 214 deletions
diff --git a/test/files/run/bug3376.check b/test/files/run/bug3376.check index 7286096022..3a1d7d581b 100644 --- a/test/files/run/bug3376.check +++ b/test/files/run/bug3376.check @@ -2,12 +2,17 @@ Type in expressions to have them evaluated. Type :help for more information. scala> -scala> defined class M -scala> m1: M[Int] = mmm +scala> class M[@specialized T] { override def toString = "mmm" } +defined class M -scala> m2: M[Float] = mmm +scala> val m1 = new M[Int]() +m1: M[Int] = mmm -scala> m3: M[String] = mmm +scala> val m2 = new M[Float]() +m2: M[Float] = mmm + +scala> val m3 = new M[String]() +m3: M[String] = mmm scala> diff --git a/test/files/run/bug4080.check b/test/files/run/bug4080.check new file mode 100644 index 0000000000..66ce31bb43 --- /dev/null +++ b/test/files/run/bug4080.check @@ -0,0 +1 @@ +LinkedList(1, 0, 2, 3) diff --git a/test/files/run/bug4080.scala b/test/files/run/bug4080.scala new file mode 100644 index 0000000000..92740ed776 --- /dev/null +++ b/test/files/run/bug4080.scala @@ -0,0 +1,12 @@ +import scala.collection.mutable.LinkedList + +object Test { + def main(args: Array[String]) { + val ll = LinkedList(1, 2, 3) + ll.insert(LinkedList(0)) + println(ll) + val ll2 = LinkedList[Int]() + try println(ll2.head) + catch { case _ => () } + } +} diff --git a/test/files/run/bug4279.scala b/test/files/run/bug4279.scala deleted file mode 100644 index 89a27fc065..0000000000 --- a/test/files/run/bug4279.scala +++ /dev/null @@ -1,38 +0,0 @@ -import scala.tools.partest._ - -// Attempting to verify slice isn't 100,000x slower -// with views than non-views. -class Runner(num: Int, reps: Int) extends TestUtil { - var dummy = 0 - val range = Array.range(0, num) - - def iteratorSlice = { - def it = range.iterator.slice(num - 2, num) - for (i <- 1 to reps) - it foreach (dummy = _) - } - def viewSlice = { - val view = range.view.slice(num - 2, num) - for (i <- 1 to reps) - view foreach (dummy = _) - } - def straightSlice = { - val xs = range.slice(num - 2, num) - for (i <- 1 to reps) - xs foreach (dummy = _) - } - def run(multiple: Double) = { - verifySpeed(straightSlice, iteratorSlice, multiple) - verifySpeed(straightSlice, viewSlice, multiple) - } -} - -object Test { - def main(args: Array[String]): Unit = { - // warmup - { val r = new Runner(1000000, 10) ; r.straightSlice ; r.iteratorSlice ; r.viewSlice } - - new Runner(10000000, 10) run 100 - new Runner(10000000, 50) run 50 - } -} diff --git a/test/files/run/bug4285.check b/test/files/run/bug4285.check index 5a3c9811c3..84f8929e43 100644 --- a/test/files/run/bug4285.check +++ b/test/files/run/bug4285.check @@ -2,11 +2,16 @@ Type in expressions to have them evaluated. Type :help for more information. scala> -scala> x: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7) -scala> y: scala.collection.mutable.WrappedArray[Int] = WrappedArray(2, 4, 6, 8, 10, 12, 14) +scala> val x = Array(1,2,3,4,5,6,7) +x: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7) -scala> 56 +scala> val y = x transform (_ * 2) +y: scala.collection.mutable.WrappedArray[Int] = WrappedArray(2, 4, 6, 8, 10, 12, 14) + +scala> println(y.sum) +56 scala> + scala> diff --git a/test/files/run/bug4387.scala b/test/files/run/bug4387.scala new file mode 100644 index 0000000000..f51c9b0572 --- /dev/null +++ b/test/files/run/bug4387.scala @@ -0,0 +1,12 @@ +object Test { + import xml.XML.loadString + def mkElem(arg: String) = <foo a="1" b="2" c="3" d="4" e={arg} /> + + val x1 = mkElem("5") + val x2 = mkElem("50") + + def main(args: Array[String]): Unit = { + assert(x1 == loadString("" + x1)) + assert(x2 != loadString("" + x1)) + } +} diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index e22e3a58d5..6919eca9bc 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -1,102 +1,110 @@ -class Annot(obj: Any) extends annotation.Annotation with annotation.TypeConstraint +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> + +scala> class Annot(obj: Any) extends annotation.Annotation with annotation.TypeConstraint defined class Annot ------ -class A { +scala> + +scala> class A { val x = "hello" val y: Int @Annot(x) = 10 override def toString = "an A" } defined class A ------ -val a = new A +scala> + +scala> val a = new A a: A = an A ------ -val y = a.y // should rewrite "this.x" to "a.x" +scala> val y = a.y // should rewrite "this.x" to "a.x" y: Int @Annot(a.x) = 10 ------ -var a2 = new A +scala> var a2 = new A a2: A = an A ------ -val y2 = a2.y // should drop the annotation +scala> val y2 = a2.y // should drop the annotation y2: Int = 10 ------ -object Stuff { +scala> + +scala> object Stuff { val x = "hello" val y : Int @Annot(x) = 10 } defined module Stuff ------ -val y = Stuff.y // should rewrite the annotation +scala> + +scala> val y = Stuff.y // should rewrite the annotation y: Int @Annot(Stuff.x) = 10 ------ -class B { +scala> + +scala> class B { val y: Int @Annot(Stuff.x) = 10 override def toString = "a B" } defined class B ------ -val b = new B +scala> + +scala> val b = new B b: B = a B ------ -val y = b.y // should keep the annotation +scala> val y = b.y // should keep the annotation y: Int @Annot(Stuff.x) = 10 ------ -def m(x: String): String @Annot(x) = x +scala> def m(x: String): String @Annot(x) = x m: (x: String)String @Annot(x) ------ -val three = "three" +scala> + +scala> val three = "three" three: java.lang.String = three ------ -val three2 = m(three:three.type) // should change x to three +scala> val three2 = m(three:three.type) // should change x to three three2: String @Annot(three) = three ------ -var four = "four" +scala> var four = "four" four: java.lang.String = four ------ -val four2 = m(four) // should have an existential bound +scala> val four2 = m(four) // should have an existential bound four2: java.lang.String @Annot(x) forSome { val x: java.lang.String } = four ------ -val four3 = four2 // should have the same type as four2 +scala> val four3 = four2 // should have the same type as four2 four3: java.lang.String @Annot(x) forSome { val x: java.lang.String } = four ------ -val stuff = m("stuff") // should not crash +scala> val stuff = m("stuff") // should not crash stuff: String @Annot("stuff") = stuff ------ -class peer extends annotation.Annotation // should not crash +scala> + +scala> class peer extends annotation.Annotation // should not crash defined class peer ------ -class NPE[T <: NPE[T] @peer] // should not crash +scala> + +scala> class NPE[T <: NPE[T] @peer] // should not crash defined class NPE ------ -def m = { +scala> + +scala> def m = { val x = "three" val y : String @Annot(x) = x y } // x should not escape the local scope with a narrow type m: String @Annot("three") ------ -def n(y: String) = { +scala> + +scala> def n(y: String) = { def m(x: String) : String @Annot(x) = { (if (x == "") m("default") @@ -107,30 +115,40 @@ def n(y: String) = { } // x should be existentially bound n: (y: String)java.lang.String @Annot(x) forSome { val x: String } ------ -class rep extends annotation.Annotation +scala> + +scala> class rep extends annotation.Annotation { } defined class rep ------ -object A { val x = "hello" : String @ rep } +scala> + +scala> object A { val x = "hello" : String @ rep } defined module A +warning: previously defined class A is not a companion to object A. +Companions must be defined together; you may wish to use :paste mode for this. ------ -val y = a.x // should drop the annotation +scala> + +scala> val y = a.x // should drop the annotation y: java.lang.String = hello ------ -val x = 3 : Int @Annot(e+f+g+h) //should have a graceful error message +scala> + +scala> val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message <console>:8: error: not found: value e - val x = 3 : Int @Annot(e+f+g+h) //should have a graceful error message + val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message ^ ------ -class Where(condition: Boolean) extends annotation.Annotation +scala> + +scala> class Where(condition: Boolean) extends annotation.Annotation defined class Where ------ -val x : Int @Where(self > 0 && self < 100) = 3 +scala> + +scala> val x : Int @Where(self > 0 && self < 100) = 3 x: Int @Where(self.>(0).&&(self.<(100))) = 3 ------ +scala> + +scala> diff --git a/test/files/run/constrained-types.scala b/test/files/run/constrained-types.scala index 86fcaade6e..5f7eb7adde 100644 --- a/test/files/run/constrained-types.scala +++ b/test/files/run/constrained-types.scala @@ -3,103 +3,91 @@ * of DeBruijn's . It runs the test using the interpreter so that * the resulting annotated types can be printed out. */ -import scala.tools.nsc._ -import java.io._ -import scala.Console +import scala.tools.nsc.Settings +import scala.tools.partest.ReplTest -object Test { +object Test extends ReplTest { + def code = """ - val testCode = List( - "class Annot(obj: Any) extends annotation.Annotation with annotation.TypeConstraint", +class Annot(obj: Any) extends annotation.Annotation with annotation.TypeConstraint - """class A { - | val x = "hello" - | val y: Int @Annot(x) = 10 - | override def toString = "an A" - |} """, - - - - "val a = new A", - - """val y = a.y // should rewrite "this.x" to "a.x" """, - - - "var a2 = new A", - "val y2 = a2.y // should drop the annotation", - - - """object Stuff { - | val x = "hello" - | val y : Int @Annot(x) = 10 - |}""", - - "val y = Stuff.y // should rewrite the annotation", +class A { + val x = "hello" + val y: Int @Annot(x) = 10 + override def toString = "an A" +} - """class B { - | val y: Int @Annot(Stuff.x) = 10 - | override def toString = "a B" - |}""", +val a = new A +val y = a.y // should rewrite "this.x" to "a.x" +var a2 = new A +val y2 = a2.y // should drop the annotation - "val b = new B", - "val y = b.y // should keep the annotation", +object Stuff { + val x = "hello" + val y : Int @Annot(x) = 10 +} +val y = Stuff.y // should rewrite the annotation - "def m(x: String): String @Annot(x) = x", - "val three = \"three\"", - "val three2 = m(three:three.type) // should change x to three", - "var four = \"four\"", - "val four2 = m(four) // should have an existential bound", - "val four3 = four2 // should have the same type as four2", +class B { + val y: Int @Annot(Stuff.x) = 10 + override def toString = "a B" +} - """val stuff = m("stuff") // should not crash""", +val b = new B +val y = b.y // should keep the annotation +def m(x: String): String @Annot(x) = x + +val three = "three" +val three2 = m(three:three.type) // should change x to three +var four = "four" +val four2 = m(four) // should have an existential bound +val four3 = four2 // should have the same type as four2 +val stuff = m("stuff") // should not crash + +class peer extends annotation.Annotation // should not crash + +class NPE[T <: NPE[T] @peer] // should not crash + +def m = { + val x = "three" + val y : String @Annot(x) = x + y +} // x should not escape the local scope with a narrow type + +def n(y: String) = { + def m(x: String) : String @Annot(x) = { + (if (x == "") + m("default") + else + x) + } + m("stuff".stripMargin) +} // x should be existentially bound - """class peer extends annotation.Annotation // should not crash""", // reported by Manfred Stock - """class NPE[T <: NPE[T] @peer] // should not crash""", // reported by Manfred Stock +class rep extends annotation.Annotation { } - """def m = { - | val x = "three" - | val y : String @Annot(x) = x - | y - |} // x should not escape the local scope with a narrow type""", +object A { val x = "hello" : String @ rep } - """def n(y: String) = { - | def m(x: String) : String @Annot(x) = { - | (if (x == "") - | m("default") - | else - | x) - | } - | m("stuff".stripMargin) - |} // x should be existentially bound""", +val y = a.x // should drop the annotation - "class rep extends annotation.Annotation", - """object A { val x = "hello" : String @ rep }""", - "val y = a.x // should drop the annotation", +val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message - "val x = 3 : Int @Annot(e+f+g+h) //should have a graceful error message", +class Where(condition: Boolean) extends annotation.Annotation - "class Where(condition: Boolean) extends annotation.Annotation", - "val x : Int @Where(self > 0 && self < 100) = 3" - ).map(_.stripMargin) +val x : Int @Where(self > 0 && self < 100) = 3 +""" + override def settings: Settings = { + val s = new Settings - def main(args: Array[String]) { - val settings = new Settings - settings.Xexperimental.value = true - settings.selfInAnnots.value = true - settings.deprecation.value = true + s.Xexperimental.value = true + s.selfInAnnots.value = true + s.deprecation.value = true // when running that compiler, give it a scala-library to the classpath - settings.classpath.value = System.getProperty("java.class.path") - - val interp = new Interpreter(settings) + s.classpath.value = sys.props("java.class.path") - for (cmd <- testCode) { - println(cmd) - interp.interpret(cmd) - println() - println("-----") - } + s } } diff --git a/test/files/run/programmatic-main.scala b/test/files/run/programmatic-main.scala index 3a88252fd3..7fec0f3f98 100644 --- a/test/files/run/programmatic-main.scala +++ b/test/files/run/programmatic-main.scala @@ -8,7 +8,7 @@ object Test { def main(args: Array[String]): Unit = { Console.withErr(Console.out) { - Main process (baseargs ++ Array("-Xshow-phases")) + Main process (baseargs ++ "-Xpluginsdir /does/not/exist/foo/quux -Xshow-phases".split(' ')) } } } diff --git a/test/files/run/repl-assign.check b/test/files/run/repl-assign.check new file mode 100644 index 0000000000..c6b0458f04 --- /dev/null +++ b/test/files/run/repl-assign.check @@ -0,0 +1,20 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> var x = 10 +x: Int = 10 + +scala> var y = 11 +y: Int = 11 + +scala> x = 12 +x: Int = 12 + +scala> y = 13 +y: Int = 13 + +scala> + +scala> diff --git a/test/files/run/repl-assign.scala b/test/files/run/repl-assign.scala new file mode 100644 index 0000000000..ee3c1649d8 --- /dev/null +++ b/test/files/run/repl-assign.scala @@ -0,0 +1,10 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ +var x = 10 +var y = 11 +x = 12 +y = 13 + """ +}
\ No newline at end of file diff --git a/test/files/run/repl-paste-2.check b/test/files/run/repl-paste-2.check index fb7a818f1a..435592567d 100644 --- a/test/files/run/repl-paste-2.check +++ b/test/files/run/repl-paste-2.check @@ -2,30 +2,60 @@ Type in expressions to have them evaluated. Type :help for more information. scala> -scala> // Replaying 7 commands from transcript. -val res0 = { 123 } -res0: Int = 123 +scala> scala> 0123 +res4: Int = 0123 -val res1 = { 567 } -res1: Int = 567 +scala> 123 +res5: Int = 123 -val res2 = { res0 + res1 } -res2: Int = 690 +scala> 567 +res6: Int = 567 -val x = dingus +scala> res5 + res6 +res7: Int = 690 + +scala> val x = dingus +<console>:7: error: not found: value dingus + val x = dingus + ^ + +scala> val x = "dingus" +x: java.lang.String = dingus + +scala> x.length +res9: Int = 6 + +scala> x.length + res5 +res10: Int = 12 + +// Replaying 8 commands from transcript. + +scala> 0123 +res0: Int = 83 + +scala> val res5 = { 123 } +res5: Int = 123 + +scala> val res6 = { 567 } +res6: Int = 567 + +scala> res5 + res6 +res1: Int = 690 + +scala> val x = dingus <console>:7: error: not found: value dingus val x = dingus ^ -val x = "dingus" +scala> val x = "dingus" x: java.lang.String = dingus -val res3 = { x.length } -res3: Int = 6 +scala> x.length +res2: Int = 6 -val res4 = { x.length + res3 } -res4: Int = 12 +scala> x.length + res5 +res3: Int = 129 scala> diff --git a/test/files/run/repl-paste-2.scala b/test/files/run/repl-paste-2.scala index 802c627701..f62927791d 100644 --- a/test/files/run/repl-paste-2.scala +++ b/test/files/run/repl-paste-2.scala @@ -2,14 +2,17 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ +scala> 0123 +res4: Int = 0123 + scala> 123 -res0: Int = 123 +res5: Int = 123 scala> 567 -res1: Int = 567 +res6: Int = 567 -scala> res0 + res1 -res2: Int = 690 +scala> res5 + res6 +res7: Int = 690 scala> val x = dingus <console>:7: error: not found: value dingus @@ -20,9 +23,9 @@ scala> val x = "dingus" x: java.lang.String = dingus scala> x.length -res3: Int = 6 +res9: Int = 6 -scala> x.length + res3 -res4: Int = 12 +scala> x.length + res5 +res10: Int = 12 """ }
\ No newline at end of file diff --git a/test/files/run/repl-paste.check b/test/files/run/repl-paste.check index 4c9de85e67..50589433cd 100644 --- a/test/files/run/repl-paste.check +++ b/test/files/run/repl-paste.check @@ -1,7 +1,21 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> // Entering paste mode (ctrl-D to finish) +scala> :paste +// Entering paste mode (ctrl-D to finish) + + + class Dingus + { + private val x = 5 + def y = Dingus.x * 2 + } + object Dingus + { + private val x = 55 + } + + val x = (new Dingus).y // Exiting paste mode, now interpreting. diff --git a/test/files/run/repl-transcript.check b/test/files/run/repl-transcript.check index b2a8d2e156..03162451b6 100644 --- a/test/files/run/repl-transcript.check +++ b/test/files/run/repl-transcript.check @@ -2,21 +2,36 @@ Type in expressions to have them evaluated. Type :help for more information. scala> -scala> // Replaying 5 commands from transcript. -class Bippity +scala> scala> class Bippity defined class Bippity -def f = new Bippity +scala> def f = new Bippity f: Bippity -val res5 = { 123 } +scala> 123 res5: Int = 123 -val res6 = { 1 to 100 map (_ + 1) } +scala> 1 to 100 map (_ + 1) res6: scala.collection.immutable.IndexedSeq[Int] = Vector(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, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101) -res6.sum + res5 +scala> res6.sum + res5 + +// Replaying 5 commands from transcript. + +scala> class Bippity +defined class Bippity + +scala> def f = new Bippity +f: Bippity + +scala> val res5 = { 123 } +res5: Int = 123 + +scala> val res6 = { 1 to 100 map (_ + 1) } +res6: scala.collection.immutable.IndexedSeq[Int] = Vector(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, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101) + +scala> res6.sum + res5 res0: Int = 5273 diff --git a/test/files/run/t3361.scala b/test/files/run/t3361.scala index 17af89a67c..892e36dbd9 100644 --- a/test/files/run/t3361.scala +++ b/test/files/run/t3361.scala @@ -39,10 +39,8 @@ object Test extends App { def insert_1 { val ten = DoubleLinkedList(1 to 10: _*) - ten.insert(DoubleLinkedList(11)) match { - case _: Unit => require(true) - case _ => require(false) - } + ten.append(DoubleLinkedList(11)) + // Post-insert size test require(11 == ten.size) // Post-insert data test diff --git a/test/files/run/t4396.check b/test/files/run/t4396.check new file mode 100644 index 0000000000..58f4fc5138 --- /dev/null +++ b/test/files/run/t4396.check @@ -0,0 +1,5 @@ +hallo +constructor +out:22 +bye +foo diff --git a/test/files/run/t4396.scala b/test/files/run/t4396.scala new file mode 100644 index 0000000000..d67eaa378e --- /dev/null +++ b/test/files/run/t4396.scala @@ -0,0 +1,35 @@ +// #43896 +trait M extends DelayedInit { + def delayedInit(body : => Unit) { + println("hallo") + body + println("bye") + } +} + +class C(init : Int) extends M { + def foo = init + println("constructor") + var x = init + println("out:"+x) +} + +// #4380 +object Main { + def main(argv: Array[String]) { + class Bip { + class Foo { override def toString() = "foo" } + object Main extends App { + val cbn = new Foo() + } + Main.main(Array()) + println(Main.cbn) + } + new Bip + } +} + +object Test extends App { + new C(22) + Main.main(Array()) +} diff --git a/test/files/run/treePrint.scala b/test/files/run/treePrint.scala index ce7dd04499..452aaf390d 100644 --- a/test/files/run/treePrint.scala +++ b/test/files/run/treePrint.scala @@ -35,7 +35,7 @@ object Test { settings.Ycompacttrees.value = true val intp = new IMain(settings, new PrintWriter(new NullOutputStream)) - val power = new Power(intp) + val power = Power(intp) intp.interpret("""def initialize = "Have to interpret something or we get errors." """) power trees code foreach println } |