diff options
Diffstat (limited to 'test/files')
51 files changed, 562 insertions, 45 deletions
diff --git a/test/files/buildmanager/t2790/t2790.check b/test/files/buildmanager/t2790/t2790.check index 065956765a..3a57d28817 100644 --- a/test/files/buildmanager/t2790/t2790.check +++ b/test/files/buildmanager/t2790/t2790.check @@ -9,6 +9,6 @@ compiling Set(B.scala) B.scala:2: error: type mismatch; found : Int(5) required: String -Error occured in an application involving default arguments. +Error occurred in an application involving default arguments. val y = A.x(5) ^ diff --git a/test/files/jvm/actor-exceptions.check b/test/files/jvm/actor-exceptions.check index bd44b968cc..d86bac9de5 100644 --- a/test/files/jvm/actor-exceptions.check +++ b/test/files/jvm/actor-exceptions.check @@ -1,3 +1 @@ -Uncaught exception in Slave -Message: A -MyOtherException +OK diff --git a/test/files/jvm/actor-exceptions.scala b/test/files/jvm/actor-exceptions.scala index 384226d777..3ee4db9ed2 100644 --- a/test/files/jvm/actor-exceptions.scala +++ b/test/files/jvm/actor-exceptions.scala @@ -19,6 +19,7 @@ object Master extends Actor { for (i <- 0 until 10) Slave ! A react { case Exit(from, reason) => + println("OK") } } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => @@ -31,6 +32,7 @@ object Slave extends Actor { override def toString = "Slave" override def exceptionHandler: PartialFunction[Exception, Unit] = { case MyException(text) => + case other if !other.isInstanceOf[scala.util.control.ControlThrowable] => super.exceptionHandler(other) } def act() { try { @@ -41,12 +43,14 @@ object Slave extends Actor { cnt += 1 if (cnt % 2 != 0) throw MyException("problem") if (cnt == 10) { - throw new MyOtherException("unhandled") + throw MyOtherException("unhandled") } } } } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => + case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] && + !e.isInstanceOf[MyException] && + !e.isInstanceOf[MyOtherException] => e.printStackTrace() } } diff --git a/test/files/jvm/actor-link-getstate.check b/test/files/jvm/actor-link-getstate.check index 45967222e6..9755447320 100644 --- a/test/files/jvm/actor-link-getstate.check +++ b/test/files/jvm/actor-link-getstate.check @@ -1,5 +1,2 @@ Done -Uncaught exception in Master -Message: 'done -MyException: Master crashed Terminated diff --git a/test/files/jvm/actor-uncaught-exception.check b/test/files/jvm/actor-uncaught-exception.check index 3e669779df..2c94e48371 100644 --- a/test/files/jvm/actor-uncaught-exception.check +++ b/test/files/jvm/actor-uncaught-exception.check @@ -1,5 +1,2 @@ -Uncaught exception in StartError -MyException: I don't want to run! -Uncaught exception in MessageError -Message: 'ping -MyException: No message for me! +OK +OK diff --git a/test/files/jvm/actor-uncaught-exception.scala b/test/files/jvm/actor-uncaught-exception.scala index 9dbd36dd82..882362272d 100644 --- a/test/files/jvm/actor-uncaught-exception.scala +++ b/test/files/jvm/actor-uncaught-exception.scala @@ -43,6 +43,7 @@ object Test { Actor.loop { react { case Exit(actor, reason) => + println("OK") if (actor == StartError) MessageError ! 'ping else diff --git a/test/files/jvm/actor-uncaught-exception2.scala b/test/files/jvm/actor-uncaught-exception2.scala index 626ce5da92..36b6f0c52e 100644 --- a/test/files/jvm/actor-uncaught-exception2.scala +++ b/test/files/jvm/actor-uncaught-exception2.scala @@ -58,7 +58,6 @@ object Test { } def main(args: Array[String]) { - Debug.level = 1 // decrease level so that it does not print warnings Supervisor.start() } } diff --git a/test/files/jvm/annotations.scala b/test/files/jvm/annotations.scala index 227bd919c1..12760beb4e 100644 --- a/test/files/jvm/annotations.scala +++ b/test/files/jvm/annotations.scala @@ -160,6 +160,9 @@ object Test5 { } } +// #3345 +class A3345(@volatile private var i:Int) + object Test { def main(args: Array[String]) { Test1.run diff --git a/test/files/jvm/t3356.check b/test/files/jvm/t3356.check new file mode 100644 index 0000000000..6a9284d0aa --- /dev/null +++ b/test/files/jvm/t3356.check @@ -0,0 +1 @@ +sending download requests diff --git a/test/files/jvm/t3356.scala b/test/files/jvm/t3356.scala new file mode 100644 index 0000000000..5626281e7d --- /dev/null +++ b/test/files/jvm/t3356.scala @@ -0,0 +1,54 @@ +import scala.actors.{Actor, Exit, !, UncaughtException} +import Actor._ + +case class ImageInfo(text: String) { + def downloadImage(): ImageData = { + ImageData(text) + } +} + +case class ImageData(text: String) +case class Download(info: ImageInfo) + +object Test { + + def scanForImageInfo(url: String): List[ImageInfo] = + List(ImageInfo("A"), ImageInfo("B")) + + def renderImage(data: ImageData) { + println("rendering image "+data.text) + } + + def renderImages(url: String) { + val imageInfos = scanForImageInfo(url) + println("sending download requests") + val dataFutures = for (info <- imageInfos) yield { + val loader = link { + react { case Download(info) => + throw new Exception("no connection") + reply(info.downloadImage()) + }; {} + } + loader !! Download(info) + } + var i = 0 + loopWhile (i < imageInfos.size) { + i += 1 + val FutureInput = dataFutures(i-1).inputChannel + react { + case FutureInput ! (data @ ImageData(_)) => + renderImage(data) + case Exit(from, UncaughtException(_, Some(Download(info)), _, _, cause)) => + println("Couldn't download image "+info+" because of "+cause) + } + } + println("OK, all images rendered.") + } + + def main(args: Array[String]) { + actor { + renderImages("panorama.epfl.ch") + } + } + +} diff --git a/test/files/jvm/t3365.check b/test/files/jvm/t3365.check new file mode 100644 index 0000000000..0944b17279 --- /dev/null +++ b/test/files/jvm/t3365.check @@ -0,0 +1,5 @@ +'hello +'hello +'hello +'hello +'hello diff --git a/test/files/jvm/t3365.scala b/test/files/jvm/t3365.scala new file mode 100644 index 0000000000..b94e804e63 --- /dev/null +++ b/test/files/jvm/t3365.scala @@ -0,0 +1,65 @@ +import scala.actors.{ReplyReactor, Channel, Actor, Future} + +case class ChannelMsg(chan: Channel[Any]) + +class MyActor extends Actor { + def act() { + try { + val chan = new Channel[Any](this) + loop { + react { + case other: ReplyReactor => + other ! ChannelMsg(chan) + loop { + chan.react { + case 'hello => + reply('hello) + case 'stop => + exit() + } + } + } + } + } catch { + case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => + e.printStackTrace() + } + } +} + +object Test { + def main(args: Array[String]) { + val a = new MyActor + a.start() + + val b = new Actor { + def act() { + try { + react { + case ChannelMsg(c) => + var i = 0 + loop { + i += 1 + val ft: Future[Any] = c !! 'hello + ft.inputChannel.react { + case msg => + if (i % 10000 == 0) + println(msg) + if (i >= 50000) { + c ! 'stop + exit() + } + } + } + } + } catch { + case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => + e.printStackTrace() + } + } + } + b.start() + + a ! b + } +} diff --git a/test/files/neg/bug2206.check b/test/files/neg/bug2206.check new file mode 100644 index 0000000000..3deb4d99ef --- /dev/null +++ b/test/files/neg/bug2206.check @@ -0,0 +1,5 @@ +bug2206.scala:10: error: value f is not a member of o.A + Note: implicit method ax is not applicable here because it comes after the application point and it lacks an explicit result type + a.f() + ^ +one error found diff --git a/test/files/neg/bug2206.scala b/test/files/neg/bug2206.scala new file mode 100644 index 0000000000..cd2ec225e9 --- /dev/null +++ b/test/files/neg/bug2206.scala @@ -0,0 +1,15 @@ +object o { + class A + + class AX { + def f() { } + } + + import Implicits._ + val a = new A + a.f() + + object Implicits { + implicit def ax(a: A) = new AX + } +}
\ No newline at end of file diff --git a/test/files/neg/bug278.check b/test/files/neg/bug278.check index a3d44f6508..ad0a97371e 100644 --- a/test/files/neg/bug278.check +++ b/test/files/neg/bug278.check @@ -1,4 +1,7 @@ -bug278.scala:5: error: overloaded method value a with alternatives => (C.this.A) => Unit <and> => () => Unit does not take type parameters +bug278.scala:5: error: overloaded method value a with alternatives: + => (C.this.A) => Unit <and> + => () => Unit + does not take type parameters a[A] ^ bug278.scala:4: error: method a is defined twice diff --git a/test/files/neg/illegal-stmt-start.check b/test/files/neg/illegal-stmt-start.check new file mode 100644 index 0000000000..01747524f8 --- /dev/null +++ b/test/files/neg/illegal-stmt-start.check @@ -0,0 +1,4 @@ +illegal-stmt-start.scala:3: error: illegal start of statement (no modifiers allowed here) + private def bar {} + ^ +one error found diff --git a/test/files/neg/illegal-stmt-start.scala b/test/files/neg/illegal-stmt-start.scala new file mode 100644 index 0000000000..48ae0a8b0a --- /dev/null +++ b/test/files/neg/illegal-stmt-start.scala @@ -0,0 +1,5 @@ +class Test { + def foo { + private def bar {} + } +}
\ No newline at end of file diff --git a/test/files/neg/migration28.flags b/test/files/neg/migration28.flags index f7025d0226..197b3198c8 100644 --- a/test/files/neg/migration28.flags +++ b/test/files/neg/migration28.flags @@ -1 +1 @@ --Yfatal-warnings -Xmigration +-Xfatal-warnings -Xmigration diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index 39347cd5db..644aad4a89 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -90,7 +90,7 @@ names-defaults-neg.scala:76: error: no type parameters for method test4: (x: T[T argument expression's type is not compatible with formal parameter type; found : List[Int] required: ?T[ ?T[ scala.List[?T[ X forSome { type X } ]] ] ] -Error occured in an application involving default arguments. +Error occurred in an application involving default arguments. test4() ^ names-defaults-neg.scala:79: error: type mismatch; @@ -101,7 +101,7 @@ names-defaults-neg.scala:79: error: type mismatch; names-defaults-neg.scala:82: error: type mismatch; found : Int required: String -Error occured in an application involving default arguments. +Error occurred in an application involving default arguments. new A2[String]() ^ 24 errors found diff --git a/test/files/neg/overload-msg.check b/test/files/neg/overload-msg.check new file mode 100644 index 0000000000..780830bff9 --- /dev/null +++ b/test/files/neg/overload-msg.check @@ -0,0 +1,13 @@ +overload-msg.scala:3: error: overloaded method value + with alternatives: + (Double)Double <and> + (Float)Float <and> + (Long)Long <and> + (scala.Int)scala.Int <and> + (Char)scala.Int <and> + (Short)scala.Int <and> + (Byte)scala.Int <and> + (java.lang.String)java.lang.String + cannot be applied to (Int(in method f)) + def f[Int](y: Int) = x + y + ^ +one error found diff --git a/test/files/neg/overload-msg.scala b/test/files/neg/overload-msg.scala new file mode 100644 index 0000000000..8715c156a2 --- /dev/null +++ b/test/files/neg/overload-msg.scala @@ -0,0 +1,4 @@ +// type parameter shadows actual type, massive overload error confuses. +class A(x: Int) { + def f[Int](y: Int) = x + y +} diff --git a/test/files/neg/t3115.flags b/test/files/neg/t3115.flags index bf8f88334b..d1b831ea87 100644 --- a/test/files/neg/t3115.flags +++ b/test/files/neg/t3115.flags @@ -1 +1 @@ --deprecation -Yfatal-warnings
\ No newline at end of file +-deprecation -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/tailrec.check b/test/files/neg/tailrec.check index 22d70e82a0..27d99f632e 100644 --- a/test/files/neg/tailrec.check +++ b/test/files/neg/tailrec.check @@ -1,10 +1,16 @@ -tailrec.scala:6: error: could not optimize @tailrec annotated method +tailrec.scala:43: error: could not optimize @tailrec annotated method: it contains a recursive call not in tail position def facfail(n: Int): Int = ^ -tailrec.scala:42: error: could not optimize @tailrec annotated method +tailrec.scala:50: error: could not optimize @tailrec annotated method: it is neither private nor final so can be overridden @tailrec def fail1(x: Int): Int = fail1(x) ^ -tailrec.scala:45: error: could not optimize @tailrec annotated method - @tailrec def fail2[T](xs: List[T]): List[T] = xs match { - ^ -three errors found +tailrec.scala:53: error: could not optimize @tailrec annotated method: it contains a recursive call not in tail position + @tailrec final def fail2[T](xs: List[T]): List[T] = xs match { + ^ +tailrec.scala:59: error: could not optimize @tailrec annotated method: it is called recursively with different type arguments + @tailrec final def fail3[T](x: Int): Int = fail3(x - 1) + ^ +tailrec.scala:63: error: could not optimize @tailrec annotated method: it changes type of 'this' on a polymorphic recursive call + @tailrec final def fail4[U](other: Tom[U], x: Int): Int = other.fail4[U](other, x - 1) + ^ +5 errors found diff --git a/test/files/neg/tailrec.scala b/test/files/neg/tailrec.scala index 4c45672f93..a77f439cfe 100644 --- a/test/files/neg/tailrec.scala +++ b/test/files/neg/tailrec.scala @@ -1,53 +1,65 @@ import scala.annotation.tailrec // putting @tailrec through the paces -object Main { - @tailrec - def facfail(n: Int): Int = - if (n == 0) 1 - else n * facfail(n - 1) - +object Winners { @tailrec def facsucc(n: Int, acc: Int): Int = if (n == 0) acc else facsucc(n - 1, n * acc) - @tailrec def loopy1(x: Int): Int = loopy1(x - 1) + @tailrec def loopsucc1(x: Int): Int = loopsucc1(x - 1) + @tailrec def loopsucc2[T](x: Int): Int = loopsucc2[T](x - 1) def ding { object dong { - @tailrec def loopy2(x: Int): Int = loopy2(x) + @tailrec def loopsucc3(x: Int): Int = loopsucc3(x) } () } def inner(q: Int) = { @tailrec - def loopy3(x: Int): Int = loopy3(x + 1) + def loopsucc4(x: Int): Int = loopsucc4(x + 1) - loopy3(q) + loopsucc4(q) + } + + object innerBob { + @tailrec def loopsucc5(x: Int): Int = loopsucc5(x) } } -class Bob { - // these should work +class Winners { @tailrec private def succ1(x: Int): Int = succ1(x) @tailrec final def succ2(x: Int): Int = succ2(x) @tailrec final def succ3[T](in: List[T], acc: List[T]): List[T] = in match { case Nil => Nil case x :: xs => succ3(xs, x :: acc) } +} +object Failures { + @tailrec + def facfail(n: Int): Int = + if (n == 0) 1 + else n * facfail(n - 1) +} + +class Failures { // not private, not final @tailrec def fail1(x: Int): Int = fail1(x) // a typical between-chair-and-keyboard error - @tailrec def fail2[T](xs: List[T]): List[T] = xs match { + @tailrec final def fail2[T](xs: List[T]): List[T] = xs match { case Nil => Nil - case x :: xs => x :: fail2(xs) + case x :: xs => x :: fail2[T](xs) } - object innerBob { - @tailrec def succ4(x: Int): Int = succ4(x) + // unsafe + @tailrec final def fail3[T](x: Int): Int = fail3(x - 1) + + // unsafe + class Tom[T](x: Int) { + @tailrec final def fail4[U](other: Tom[U], x: Int): Int = other.fail4[U](other, x - 1) } } diff --git a/test/files/neg/typeerror.check b/test/files/neg/typeerror.check index 3e21a79ad5..3ce11dad8a 100644 --- a/test/files/neg/typeerror.check +++ b/test/files/neg/typeerror.check @@ -1,6 +1,6 @@ typeerror.scala:6: error: type mismatch; found : Long(in method add) - required: Long(in package scala) + required: scala.Long else add2(x.head, y.head) :: add(x.tail, y.tail) ^ one error found diff --git a/test/files/pos/bug2018.scala b/test/files/pos/bug2018.scala new file mode 100644 index 0000000000..1736c394c9 --- /dev/null +++ b/test/files/pos/bug2018.scala @@ -0,0 +1,15 @@ +class A { + val b = new B + + def getChildren = List(new A).iterator + + class B { + private def check = true + + private def getAncestor(p: A): A = { + val c = (p.getChildren.find(_.b.check)) match {case Some(d) => d case None => p} + + if (c == p) p else c.b.getAncestor(c) + } + } +}
\ No newline at end of file diff --git a/test/files/pos/bug3097.flags b/test/files/pos/bug3097.flags index 570b15929d..144ddac9d3 100644 --- a/test/files/pos/bug3097.flags +++ b/test/files/pos/bug3097.flags @@ -1 +1 @@ --unchecked -Yfatal-warnings +-unchecked -Xfatal-warnings diff --git a/test/files/pos/bug3278.scala b/test/files/pos/bug3278.scala new file mode 100644 index 0000000000..788ec75d26 --- /dev/null +++ b/test/files/pos/bug3278.scala @@ -0,0 +1,15 @@ +class Foo +class Test { + def update[B](x : B, b : Int) {} + def apply[B](x : B) = 1 +} + +object Test { + def main(a : Array[String]) { + val a = new Test + val f = new Foo + a(f) = 1 //works + a(f) = a(f) + 1 //works + a(f) += 1 //error: reassignment to val + } +}
\ No newline at end of file diff --git a/test/files/pos/implicits.scala b/test/files/pos/implicits.scala index 3939a28398..960c265e55 100644 --- a/test/files/pos/implicits.scala +++ b/test/files/pos/implicits.scala @@ -82,3 +82,8 @@ package foo2709 { } } } + +// Problem with specs +object specsProblem { + println(implicitly[Manifest[Class[_]]]) +} diff --git a/test/files/pos/spec-traits.scala b/test/files/pos/spec-traits.scala new file mode 100644 index 0000000000..9e339a14ad --- /dev/null +++ b/test/files/pos/spec-traits.scala @@ -0,0 +1,83 @@ +trait A[@specialized(Int) T] { def foo: T } +class B extends A[Int] { val foo = 10 } +class C extends B + +// issue 3309 +class Lazy { + def test[U](block: => U): Unit = { block } + + test { lazy val x = 1 } +} + +// issue 3307 +class Bug3307 { + def f[Z](block: String => Z) { + block("abc") + } + + ({ () => + f { implicit x => println(x) } })() +} + +// issue 3301 + trait T[X] + +class Bug3301 { + def t[A]: T[A] = error("stub") + + () => { + type X = Int + + def foo[X] = t[X] + () + } +} +// issue 3299 +object Failure { + def thunk() { + for (i <- 1 to 2) { + val Array(a, b) = Array(1,2) + () + } + } +} + +// issue 3296 + +object AA +{ + def f(block: => Unit) {} + + object BB + { + f { + object CC + + () + } + } + + def foo[T](x: T) = { object A; false } +} + +// issue 3292 +import scala.swing._ +import scala.swing.GridBagPanel._ + +object Grid { + + def later(code : => Unit) = + javax.swing.SwingUtilities.invokeLater(new Runnable { def run { code }}) + + def test = later { + val frame = new Dialog { + contents = new GridBagPanel { + val c = new Constraints + } + } + } + +} + +// issue 3325 +object O { def f[@specialized T] { for(k <- Nil: List[T]) { } } } diff --git a/test/files/pos/t3108.scala b/test/files/pos/t3108.scala new file mode 100644 index 0000000000..6a1da73220 --- /dev/null +++ b/test/files/pos/t3108.scala @@ -0,0 +1,5 @@ +object A { + val a: NotNull = "" + val b: NotNull = 41 +} + diff --git a/test/files/pos/t3349/AbstractTupleSet.java b/test/files/pos/t3349/AbstractTupleSet.java new file mode 100644 index 0000000000..38e4743ef4 --- /dev/null +++ b/test/files/pos/t3349/AbstractTupleSet.java @@ -0,0 +1,9 @@ +public abstract class AbstractTupleSet implements TupleSet { + public void addColumn(String name, Class type) { + throw new UnsupportedOperationException(); + } + + public void addColumn(String name, String expr) { + throw new UnsupportedOperationException(); + } +} diff --git a/test/files/pos/t3349/Table.java b/test/files/pos/t3349/Table.java new file mode 100644 index 0000000000..1609367623 --- /dev/null +++ b/test/files/pos/t3349/Table.java @@ -0,0 +1,9 @@ +public class Table extends AbstractTupleSet { + public void addColumn(String name, Class type) { + throw new UnsupportedOperationException(); + } + + public void addColumn(String name, String expr) { + throw new UnsupportedOperationException(); + } +}
\ No newline at end of file diff --git a/test/files/pos/t3349/Test.scala b/test/files/pos/t3349/Test.scala new file mode 100644 index 0000000000..8174e4c4f8 --- /dev/null +++ b/test/files/pos/t3349/Test.scala @@ -0,0 +1,5 @@ +object Test { + val label = "name" + val table: Table = error("") + table.addColumn( label, label.getClass ) +}
\ No newline at end of file diff --git a/test/files/pos/t3349/TupleSet.java b/test/files/pos/t3349/TupleSet.java new file mode 100644 index 0000000000..14a073a950 --- /dev/null +++ b/test/files/pos/t3349/TupleSet.java @@ -0,0 +1,4 @@ +public interface TupleSet { + public void addColumn(String name, Class type); + public void addColumn(String name, String expr); +}
\ No newline at end of file diff --git a/test/files/run/adding-growing-set.scala b/test/files/run/adding-growing-set.scala new file mode 100644 index 0000000000..5903813ed1 --- /dev/null +++ b/test/files/run/adding-growing-set.scala @@ -0,0 +1,11 @@ +/** This will run a 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/test/files/run/bug3004.scala b/test/files/run/bug3004.scala new file mode 100644 index 0000000000..a1e9c6c72f --- /dev/null +++ b/test/files/run/bug3004.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/test/files/run/bug3327.check b/test/files/run/bug3327.check new file mode 100644 index 0000000000..980a0d5f19 --- /dev/null +++ b/test/files/run/bug3327.check @@ -0,0 +1 @@ +Hello World! diff --git a/test/files/run/bug3327.scala b/test/files/run/bug3327.scala new file mode 100644 index 0000000000..7e6d3fc210 --- /dev/null +++ b/test/files/run/bug3327.scala @@ -0,0 +1,8 @@ +object Test { + def main (args : Array[String]) { + val b = new StringBuilder + b.append ("Hello World!") + b.lastIndexOf ('e') + println (b.toString) + } +}
\ No newline at end of file diff --git a/test/files/run/distinct.check b/test/files/run/distinct.check new file mode 100644 index 0000000000..b0883f382e --- /dev/null +++ b/test/files/run/distinct.check @@ -0,0 +1 @@ +abcdefghijklmnopqrstuvwxyz diff --git a/test/files/run/distinct.scala b/test/files/run/distinct.scala new file mode 100644 index 0000000000..698d31f1e9 --- /dev/null +++ b/test/files/run/distinct.scala @@ -0,0 +1,15 @@ +/** This is a test to make sure distinct always + * returns the first of any duplicated element. + */ +object Test { + val alphabet = 'a' to 'z' mkString "" + val alphaList = 'a' to 'z' toList + def shuffled = util.Random.shuffle(alphaList) + + def main(args: Array[String]): Unit = { + val longList = alphaList ++ (1 to 9 flatMap (_ => shuffled)) + val result = longList.distinct mkString "" + + println(result) + } +} diff --git a/test/files/run/iterator-iterate-lazy.scala b/test/files/run/iterator-iterate-lazy.scala new file mode 100644 index 0000000000..73886f192b --- /dev/null +++ b/test/files/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/test/files/run/mapValues.scala b/test/files/run/mapValues.scala new file mode 100644 index 0000000000..d3266bd18f --- /dev/null +++ b/test/files/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/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index 3442ecafc3..ee9186c35f 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -324,6 +324,27 @@ object Test extends Application { } } + // #3344 + def m3344_1 = { case class C(x: Int); C(1).copy(2).x } + m3344_1 + def m3344_2 = { class C(val x: Int = 1); new C().x } + m3344_2 + + // #3338 + object t3338 { + class Container { + class GenericClass[T](arg: String = "") + } + + object Container extends Container + + class Test { + val a = new Container.GenericClass() + } + } + (new t3338.Test).a + + // DEFINITIONS def test1(a: Int, b: String) = println(a +": "+ b) diff --git a/test/files/run/spec-early.check b/test/files/run/spec-early.check new file mode 100644 index 0000000000..414aacc419 --- /dev/null +++ b/test/files/run/spec-early.check @@ -0,0 +1,4 @@ +a +abc +42 +abc diff --git a/test/files/run/spec-early.scala b/test/files/run/spec-early.scala new file mode 100644 index 0000000000..84a8983f8c --- /dev/null +++ b/test/files/run/spec-early.scala @@ -0,0 +1,15 @@ +trait Tr + +class Foo[@specialized(Int) T](_x: T) extends { + val bar = "abc" + val baz = "bbc" +} with Tr { + val x = _x + println(x) + println(bar) +} + +object Test extends Application { + new Foo("a") + new Foo(42) +} diff --git a/test/files/run/spec-init.check b/test/files/run/spec-init.check new file mode 100644 index 0000000000..8a659f868c --- /dev/null +++ b/test/files/run/spec-init.check @@ -0,0 +1,9 @@ +abc +abc +null +shouldn't see two initialized values and one uninitialized +42 +42 +0 +ok +ok diff --git a/test/files/run/spec-init.scala b/test/files/run/spec-init.scala new file mode 100644 index 0000000000..bd3428f4ea --- /dev/null +++ b/test/files/run/spec-init.scala @@ -0,0 +1,41 @@ +class Foo[@specialized(Int) T](_x: T) { + val x = _x + def bar {} + + val y = x + println(x) + println(y) + println(z) + + def baz {} + val z = y + +} + +class Bar[@specialized(Int) T] { + def foo(x: T) = print(x) +} + +object Global { + var msg = "ok" +} + +class TouchGlobal[@specialized(Int) T](_x: T) { + println(Global.msg) + val x = { + Global.msg = "not ok" + _x + } +} + +object Test { + def main(args: Array[String]) { + (new Foo("abc")) + println("shouldn't see two initialized values and one uninitialized") + (new Foo(42)) + + (new TouchGlobal(new Object)) + Global.msg = "ok" // reset the value + (new TouchGlobal(42)) + } +} diff --git a/test/files/run/stream_length.scala b/test/files/run/stream_length.scala new file mode 100644 index 0000000000..68e9cad5ac --- /dev/null +++ b/test/files/run/stream_length.scala @@ -0,0 +1,15 @@ + + +object Test { + def walk(depth: Int, bias: String): Stream[String] = { + if (depth == 0) + Stream(bias) + else { + Stream.concat(Stream.range(1, 100).map((x: Int) => walk(depth-1, bias + x))) + } + } + + def main(args: Array[String]) { + println("Length: " + walk(3, "---").length) + } +} diff --git a/test/files/run/stringbuilder.scala b/test/files/run/stringbuilder.scala index c669f1c3db..28ddc653a5 100644 --- a/test/files/run/stringbuilder.scala +++ b/test/files/run/stringbuilder.scala @@ -1,5 +1,7 @@ object Test extends Application { val str = "ABCDEFGHIJKLMABCDEFGHIJKLM" + val surrogateStr = "an old Turkic letter: \uD803\uDC22" + type SB = { def indexOf(str: String): Int def indexOf(str: String, fromIndex: Int): Int @@ -29,4 +31,10 @@ object Test extends Application { sameAnswers(_.lastIndexOf("QZV")) sameAnswers(_.lastIndexOf("GHI", 22)) sameAnswers(_.lastIndexOf("KLM", 22)) + + // testing that the "reverse" implementation avoids reversing surrogate pairs + val jsb = new JavaStringBuilder(surrogateStr) reverse + val ssb = new ScalaStringBuilder(surrogateStr) reverseContents ; + + assert(jsb.toString == ssb.toString) } diff --git a/test/files/run/treePrint.scala b/test/files/run/treePrint.scala index ffe9a392d4..1fd1394e25 100644 --- a/test/files/run/treePrint.scala +++ b/test/files/run/treePrint.scala @@ -35,6 +35,6 @@ object Test { val repl = new Interpreter(settings, new PrintWriter(new NullOutputStream)) repl.interpret("""def initialize = "Have to interpret something or we get errors." """) - println(repl mkTree code) + println(repl.power mkTree code) } } |