diff options
Diffstat (limited to 'test/files')
159 files changed, 1136 insertions, 2570 deletions
diff --git a/test/files/filters b/test/files/filters index 51a7507848..e91ca0eb36 100644 --- a/test/files/filters +++ b/test/files/filters @@ -1,6 +1,7 @@ # #Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 28). Java HotSpot\(TM\) .* warning: +OpenJDK .* warning: # Hotspot receiving VM options through the $_JAVA_OPTIONS # env variable outputs them on stderr Picked up _JAVA_OPTIONS: diff --git a/test/files/jvm/actor-exceptions.check b/test/files/jvm/actor-exceptions.check deleted file mode 100644 index d86bac9de5..0000000000 --- a/test/files/jvm/actor-exceptions.check +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/test/files/jvm/actor-exceptions.scala b/test/files/jvm/actor-exceptions.scala deleted file mode 100644 index bdd983a0e8..0000000000 --- a/test/files/jvm/actor-exceptions.scala +++ /dev/null @@ -1,67 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors.{Actor, Exit} -import Actor._ - -case class MyException(text: String) extends Exception { - override def fillInStackTrace() = this -} - -case class MyOtherException(text: String) extends Exception { - override def fillInStackTrace() = this -} - -object Master extends Actor { - trapExit = true - def act() { - try { - link(Slave) - Slave.start() - 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] => - e.printStackTrace() - } - } -} - -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 { - var cnt = 0 - loop { - react { - case A => - cnt += 1 - if (cnt % 2 != 0) throw MyException("problem") - if (cnt == 10) { - throw MyOtherException("unhandled") - } - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] && - !e.isInstanceOf[MyException] && - !e.isInstanceOf[MyOtherException] => - e.printStackTrace() - } - } -} - -case object A - - def main(args: Array[String]) { - Master.start() - } -} diff --git a/test/files/jvm/actor-executor.check b/test/files/jvm/actor-executor.check deleted file mode 100644 index bdbdb5c6a2..0000000000 --- a/test/files/jvm/actor-executor.check +++ /dev/null @@ -1,20 +0,0 @@ -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK diff --git a/test/files/jvm/actor-executor.scala b/test/files/jvm/actor-executor.scala deleted file mode 100644 index 0fc28b4d85..0000000000 --- a/test/files/jvm/actor-executor.scala +++ /dev/null @@ -1,78 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import java.util.concurrent.Executors -import scala.actors.{Actor, SchedulerAdapter} -import Actor._ - -trait AdaptedActor extends Actor { - override def scheduler = - Test.scheduler -} - -object One extends AdaptedActor { - def act() { - try { - Two.start() - var i = 0 - loopWhile (i < 10000) { - i += 1 - Two ! 'MsgForTwo - react { - case 'MsgForOne => - if (i % 1000 == 0) - println("One: OK") - if (i == 10000) - Test.executor.shutdown() - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - -object Two extends AdaptedActor { - def act() { - try { - var i = 0 - loopWhile (i < 10000) { - i += 1 - react { - case 'MsgForTwo => - if (i % 1000 == 0) - println("Two: OK") - One ! 'MsgForOne - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - - val executor = - Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) - - val scheduler = - new SchedulerAdapter { - def execute(block: => Unit) { - val task = new Runnable { - def run() { block } - } - try { - executor.execute(task) - } catch { - case ree: java.util.concurrent.RejectedExecutionException => - task.run() - } - } - } - - def main(args: Array[String]) { - One.start() - } -} diff --git a/test/files/jvm/actor-executor2.check b/test/files/jvm/actor-executor2.check deleted file mode 100644 index da78f45836..0000000000 --- a/test/files/jvm/actor-executor2.check +++ /dev/null @@ -1,21 +0,0 @@ -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -One exited diff --git a/test/files/jvm/actor-executor2.scala b/test/files/jvm/actor-executor2.scala deleted file mode 100644 index 5badf2ae7e..0000000000 --- a/test/files/jvm/actor-executor2.scala +++ /dev/null @@ -1,92 +0,0 @@ - - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors.{Actor, SchedulerAdapter, Exit} -import Actor._ -import java.util.concurrent.{Executors, RejectedExecutionException} - -object One extends AdaptedActor { - def act() { - try { - Two.start() - var i = 0 - loopWhile (i < Test.NUM_MSG) { - i += 1 - Two ! 'MsgForTwo - react { - case 'MsgForOne => - if (i % (Test.NUM_MSG/10) == 0) - println("One: OK") - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - -object Two extends AdaptedActor { - def act() { - try { - var i = 0 - loopWhile (i < Test.NUM_MSG) { - i += 1 - react { - case 'MsgForTwo => - if (i % (Test.NUM_MSG/10) == 0) - println("Two: OK") - One ! 'MsgForOne - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - -trait AdaptedActor extends Actor { - override def scheduler = - Test.scheduler -} - - val NUM_MSG = 100000 - - val executor = - Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) - - val scheduler = - new SchedulerAdapter { - def execute(block: => Unit) { - val task = new Runnable { - def run() { block } - } - try { - executor.execute(task) - } catch { - case ree: RejectedExecutionException => - task.run() // run task on current thread - } - } - } - - def main(args: Array[String]) { - try { - self.trapExit = true - link(One) - One.start() - - receive { - case Exit(from, reason) => - println("One exited") - Test.executor.shutdown() - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} diff --git a/test/files/jvm/actor-executor3.check b/test/files/jvm/actor-executor3.check deleted file mode 100644 index bdbdb5c6a2..0000000000 --- a/test/files/jvm/actor-executor3.check +++ /dev/null @@ -1,20 +0,0 @@ -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK diff --git a/test/files/jvm/actor-executor3.scala b/test/files/jvm/actor-executor3.scala deleted file mode 100644 index f8b57d84b3..0000000000 --- a/test/files/jvm/actor-executor3.scala +++ /dev/null @@ -1,66 +0,0 @@ - - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors.Actor -import scala.actors.scheduler.ExecutorScheduler -import java.util.concurrent.Executors - -object One extends AdaptedActor { - def act() { - try { - Two.start() - var i = 0 - loopWhile (i < Test.NUM_MSG) { - i += 1 - Two ! 'MsgForTwo - react { - case 'MsgForOne => - if (i % (Test.NUM_MSG/10) == 0) - println("One: OK") - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - -object Two extends AdaptedActor { - def act() { - try { - var i = 0 - loopWhile (i < Test.NUM_MSG) { - i += 1 - react { - case 'MsgForTwo => - if (i % (Test.NUM_MSG/10) == 0) - println("Two: OK") - One ! 'MsgForOne - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - -trait AdaptedActor extends Actor { - override def scheduler = - Test.scheduler -} - - val NUM_MSG = 100000 - - val executor = - Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) - - val scheduler = ExecutorScheduler(executor) - - def main(args: Array[String]) { - One.start() - } -} diff --git a/test/files/jvm/actor-getstate.check b/test/files/jvm/actor-getstate.check deleted file mode 100644 index 2c94e48371..0000000000 --- a/test/files/jvm/actor-getstate.check +++ /dev/null @@ -1,2 +0,0 @@ -OK -OK diff --git a/test/files/jvm/actor-getstate.scala b/test/files/jvm/actor-getstate.scala deleted file mode 100644 index 425efbe5e6..0000000000 --- a/test/files/jvm/actor-getstate.scala +++ /dev/null @@ -1,87 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.{Reactor, Actor, TIMEOUT} - import Actor._ - - def assert(cond: => Boolean, hint: String) { - if (!cond) - println("FAIL ["+hint+"]") - } - - def expectActorState(a: Reactor[T] forSome { type T }, s: Actor.State.Value) { - var done = false - var i = 0 - while (!done) { - i = i + 1 - if (i == 10) { // only wait for 2 seconds total - println("FAIL ["+a+": expected "+s+"]") - done = true - } - - Thread.sleep(200) - if (a.getState == s) // success - done = true - } - } - - def main(args: Array[String]) { - actor { - val a = new Reactor[Any] { - def act() { - assert(getState == Actor.State.Runnable, "runnable1") - react { - case 'go => - println("OK") - } - } - } - expectActorState(a, Actor.State.New) - - a.start() - expectActorState(a, Actor.State.Suspended) - - a ! 'go - expectActorState(a, Actor.State.Terminated) - - val b = new Actor { - def act() { - assert(getState == Actor.State.Runnable, "runnable2: "+getState) - react { - case 'go => - reactWithin(100000) { - case TIMEOUT => - case 'go => - receive { - case 'go => - } - receiveWithin(100000) { - case TIMEOUT => - case 'go => - println("OK") - } - } - } - } - } - expectActorState(b, Actor.State.New) - - b.start() - expectActorState(b, Actor.State.Suspended) - - b ! 'go - expectActorState(b, Actor.State.TimedSuspended) - - b ! 'go - expectActorState(b, Actor.State.Blocked) - - b ! 'go - expectActorState(b, Actor.State.TimedBlocked) - - b ! 'go - expectActorState(b, Actor.State.Terminated) - } - } - -} diff --git a/test/files/jvm/actor-link-getstate.check b/test/files/jvm/actor-link-getstate.check deleted file mode 100644 index 9755447320..0000000000 --- a/test/files/jvm/actor-link-getstate.check +++ /dev/null @@ -1,2 +0,0 @@ -Done -Terminated diff --git a/test/files/jvm/actor-link-getstate.scala b/test/files/jvm/actor-link-getstate.scala deleted file mode 100644 index d8b8ada1e6..0000000000 --- a/test/files/jvm/actor-link-getstate.scala +++ /dev/null @@ -1,65 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.{Actor, Exit} - import scala.actors.Actor._ - -case class MyException(text: String) extends Exception(text) { - override def fillInStackTrace() = this -} - -object Slave extends Actor { - def act() { - try { - loop { - react { - case 'doWork => - Console.out.println("Done") - reply('done) - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - -object Master extends Actor { - override def toString = "Master" - def act() { - try { - link(Slave) - Slave ! 'doWork - react { - case 'done => - throw new MyException("Master crashed") - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - - - def main(args: Array[String]) { - actor { - try { - self.trapExit = true - link(Slave) - Slave.start() - Master.start() - react { - case Exit(from, reason) if (from == Slave) => - Console.out.println(Slave.getState) - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - -} diff --git a/test/files/jvm/actor-looping.check b/test/files/jvm/actor-looping.check deleted file mode 100644 index a6f5c2e73a..0000000000 --- a/test/files/jvm/actor-looping.check +++ /dev/null @@ -1,5 +0,0 @@ -received A -received A -received A -received A -received last A diff --git a/test/files/jvm/actor-looping.scala b/test/files/jvm/actor-looping.scala deleted file mode 100644 index 7bc6f1e5c5..0000000000 --- a/test/files/jvm/actor-looping.scala +++ /dev/null @@ -1,33 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.Actor._ - case object A - - def main(args: Array[String]) { - val a = actor { - try { - var cnt = 0 - loop { - react { - case A => - cnt += 1 - if (cnt % 2 != 0) continue - if (cnt < 10) - println("received A") - else { - println("received last A") - exit() - } - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - - for (i <- 0 until 10) a ! A - } -} diff --git a/test/files/jvm/actor-normal-exit.check b/test/files/jvm/actor-normal-exit.check deleted file mode 100644 index 6865f83b90..0000000000 --- a/test/files/jvm/actor-normal-exit.check +++ /dev/null @@ -1,2 +0,0 @@ -Done -slave exited for reason 'normal diff --git a/test/files/jvm/actor-normal-exit.scala b/test/files/jvm/actor-normal-exit.scala deleted file mode 100644 index 90495866e2..0000000000 --- a/test/files/jvm/actor-normal-exit.scala +++ /dev/null @@ -1,38 +0,0 @@ - - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.{Actor, Exit} - object Master extends Actor { - trapExit = true - def act() { - try { - Slave.start() - react { - case Exit(from, reason) => - println("slave exited for reason " + reason) - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - object Slave extends Actor { - def act() { - try { - link(Master) - println("Done") - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - def main(args: Array[String]) { - Master.start() - } -} diff --git a/test/files/jvm/actor-receivewithin.check b/test/files/jvm/actor-receivewithin.check deleted file mode 100644 index a6a3e88c61..0000000000 --- a/test/files/jvm/actor-receivewithin.check +++ /dev/null @@ -1,16 +0,0 @@ -'msg -'msg -'msg -'msg -'msg -TIMEOUT -TIMEOUT -TIMEOUT -TIMEOUT -TIMEOUT -'msg2 -'msg2 -'msg2 -'msg2 -'msg2 -TIMEOUT diff --git a/test/files/jvm/actor-receivewithin.scala b/test/files/jvm/actor-receivewithin.scala deleted file mode 100644 index 5982462502..0000000000 --- a/test/files/jvm/actor-receivewithin.scala +++ /dev/null @@ -1,72 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors.{Actor, TIMEOUT} - -object A extends Actor { - def act() { - receive { - case 'done => - var cnt = 0 - while (cnt < 500) { - cnt += 1 - receiveWithin (0) { - case 'msg => - if (cnt % 100 == 0) - println("'msg") - case TIMEOUT => - // should not happen - println("FAIL1") - } - } - cnt = 0 - while (cnt < 500) { - cnt += 1 - receiveWithin (0) { - case 'msg => - // should not happen - println("FAIL2") - case TIMEOUT => - if (cnt % 100 == 0) - println("TIMEOUT") - } - } - B ! 'next - receive { case 'done => } - cnt = 0 - while (cnt < 501) { - cnt += 1 - receiveWithin (500) { - case 'msg2 => - if (cnt % 100 == 0) - println("'msg2") - case TIMEOUT => - println("TIMEOUT") - } - } - } - } -} - -object B extends Actor { - def act() { - A.start() - for (_ <- 1 to 500) { - A ! 'msg - } - A ! 'done - receive { - case 'next => - for (_ <- 1 to 500) { - A ! 'msg2 - } - A ! 'done - } - } -} - - def main(args:Array[String]) { - B.start() - } -} diff --git a/test/files/jvm/actor-sync-send-timeout.scala b/test/files/jvm/actor-sync-send-timeout.scala deleted file mode 100644 index 66a0b0a6ff..0000000000 --- a/test/files/jvm/actor-sync-send-timeout.scala +++ /dev/null @@ -1,48 +0,0 @@ -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors.Actor - -/* This test is a regression test for SI-4759. - */ - val Runs = 5 - - def main(args: Array[String]) = { - var i = 0 - while (i < Runs) { - i += 1 - A1 ! 1 - Thread.sleep(500) - } - //println("done sending to A1") - } - -object A2 extends Actor { - this.start() - def act() { - loop { - react { - case 'stop => - //println("A2 exiting") - exit() - case _ => - } - } - } -} - -object A1 extends Actor { - this.start() - def act() { - var i = 0 - loopWhile(i < Test.Runs) { - i += 1 - react { - case any => - A2 !? (500, any) - if (i == Test.Runs) - A2 ! 'stop - } - } - } -} -} diff --git a/test/files/jvm/actor-termination.check b/test/files/jvm/actor-termination.check deleted file mode 100644 index e3f44d8b18..0000000000 --- a/test/files/jvm/actor-termination.check +++ /dev/null @@ -1,2 +0,0 @@ -I'm going to make you wait. -Ok, I'm done. diff --git a/test/files/jvm/actor-termination.scala b/test/files/jvm/actor-termination.scala deleted file mode 100644 index 4a6bf92d48..0000000000 --- a/test/files/jvm/actor-termination.scala +++ /dev/null @@ -1,19 +0,0 @@ - -/* Test that an actor that hasn't finished prevents termination */ - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.Actor - def main(args: Array[String]) { - Actor.actor { - try { - println("I'm going to make you wait.") - Thread.sleep(5000) - println("Ok, I'm done.") - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } -} diff --git a/test/files/jvm/actor-uncaught-exception.check b/test/files/jvm/actor-uncaught-exception.check deleted file mode 100644 index 2c94e48371..0000000000 --- a/test/files/jvm/actor-uncaught-exception.check +++ /dev/null @@ -1,2 +0,0 @@ -OK -OK diff --git a/test/files/jvm/actor-uncaught-exception.scala b/test/files/jvm/actor-uncaught-exception.scala deleted file mode 100644 index c28ad2fa3c..0000000000 --- a/test/files/jvm/actor-uncaught-exception.scala +++ /dev/null @@ -1,64 +0,0 @@ -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors.{Actor, Exit} - -class MyException(msg: String) extends Exception(msg) { - override def fillInStackTrace() = this -} - - - case object StartError extends Actor { - def act() { - try { - throw new MyException("I don't want to run!") - } catch { - case e: Throwable if (!e.isInstanceOf[scala.util.control.ControlThrowable] && - !e.isInstanceOf[MyException]) => - e.printStackTrace() - } - } - } - - case object MessageError extends Actor { - def act() { - try { - react { - case _ => throw new MyException("No message for me!") - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - case object Supervisor extends Actor { - def act() { - try { - trapExit = true - link(StartError) - link(MessageError) - StartError.start() - MessageError.start() - - Actor.loop { - react { - case Exit(actor, reason) => - println("OK") - if (actor == StartError) - MessageError ! 'ping - else - exit() - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - def main(args: Array[String]) { - Supervisor.start() - } -} diff --git a/test/files/jvm/actor-uncaught-exception2.check b/test/files/jvm/actor-uncaught-exception2.check deleted file mode 100644 index a54f374aed..0000000000 --- a/test/files/jvm/actor-uncaught-exception2.check +++ /dev/null @@ -1,2 +0,0 @@ -UncaughtException(StartError,None,None,Test$MyException: I don't want to run!) -UncaughtException(MessageError,Some('ping),Some(Supervisor),Test$MyException: No message for me!) diff --git a/test/files/jvm/actor-uncaught-exception2.scala b/test/files/jvm/actor-uncaught-exception2.scala deleted file mode 100644 index 8327b4e19d..0000000000 --- a/test/files/jvm/actor-uncaught-exception2.scala +++ /dev/null @@ -1,63 +0,0 @@ -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors.{Actor, Exit, Debug} - -class MyException(msg: String) extends Exception(msg) { - override def fillInStackTrace() = this -} - - case object StartError extends Actor { - def act() { - try { - throw new MyException("I don't want to run!") - } catch { - case e: Throwable if (!e.isInstanceOf[scala.util.control.ControlThrowable] && - !e.isInstanceOf[MyException]) => - e.printStackTrace() - } - } - } - - case object MessageError extends Actor { - def act() { - try { - react { - case _ => throw new MyException("No message for me!") - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - case object Supervisor extends Actor { - def act() { - try { - trapExit = true - link(StartError) - link(MessageError) - StartError.start() - MessageError.start() - - Actor.loop { - react { - case Exit(actor, reason) => - println(reason) - if (actor == StartError) - MessageError ! 'ping - else - exit() - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - def main(args: Array[String]) { - Supervisor.start() - } -} diff --git a/test/files/jvm/daemon-actor-termination.check b/test/files/jvm/daemon-actor-termination.check deleted file mode 100644 index b2ff72fd0b..0000000000 --- a/test/files/jvm/daemon-actor-termination.check +++ /dev/null @@ -1,2 +0,0 @@ -MSG1 -MSG2 diff --git a/test/files/jvm/daemon-actor-termination.scala b/test/files/jvm/daemon-actor-termination.scala deleted file mode 100644 index 9bac6340ba..0000000000 --- a/test/files/jvm/daemon-actor-termination.scala +++ /dev/null @@ -1,40 +0,0 @@ - -/* Test that a daemon Actor that hasn't finished does not prevent termination */ - -@deprecated("Suppress warnings", since="2.11") -object Test { - - import scala.actors.{Actor, DaemonActor} - class MyDaemon extends DaemonActor { - def act() { - try { - react { - case 'hello => - println("MSG1") - reply(()) - react { - case 'bye => - println("done") - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - def main(args: Array[String]) { - val daemon = new MyDaemon - daemon.start() - Actor.actor { - try { - daemon !? 'hello - println("MSG2") - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } -} diff --git a/test/files/jvm/future-alarm.check b/test/files/jvm/future-alarm.check deleted file mode 100644 index 01a87d1c4c..0000000000 --- a/test/files/jvm/future-alarm.check +++ /dev/null @@ -1,20 +0,0 @@ -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK diff --git a/test/files/jvm/future-alarm.scala b/test/files/jvm/future-alarm.scala deleted file mode 100644 index 3e71fa681c..0000000000 --- a/test/files/jvm/future-alarm.scala +++ /dev/null @@ -1,23 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.Futures - def main(args: Array[String]) { - try { - for (i <- 1 to 100000) { - Futures.alarm(0) - if (i % 10000 == 0) - println("OK") - } - for (_ <- 1 to 10) { - val ft = Futures.alarm(100) - ft() - println("OK") - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} diff --git a/test/files/jvm/future-awaitall-zero.check b/test/files/jvm/future-awaitall-zero.check deleted file mode 100644 index d86bac9de5..0000000000 --- a/test/files/jvm/future-awaitall-zero.check +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/test/files/jvm/future-awaitall-zero.scala b/test/files/jvm/future-awaitall-zero.scala deleted file mode 100644 index 56f4bab16f..0000000000 --- a/test/files/jvm/future-awaitall-zero.scala +++ /dev/null @@ -1,24 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.Futures._ - import scala.actors.Actor._ - def main(args: Array[String]) { - try { - val ft1 = future { reactWithin(10000) { - case _ => println("FAIL") - } } - - val ft2 = future { reactWithin(20000) { - case _ => println("FAIL") - } } - - val res = awaitAll(0, ft1, ft2) - println("OK") - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} diff --git a/test/files/jvm/future-spec.check b/test/files/jvm/future-spec.check index df1629dd7e..5c80aa5586 100644 --- a/test/files/jvm/future-spec.check +++ b/test/files/jvm/future-spec.check @@ -1 +1 @@ -warning: there was one deprecation warning; re-run with -deprecation for details +warning: there were 21 deprecation warnings; re-run with -deprecation for details diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala index a290af9cd3..6b34d5bfaa 100644 --- a/test/files/jvm/future-spec/FutureTests.scala +++ b/test/files/jvm/future-spec/FutureTests.scala @@ -17,6 +17,19 @@ class FutureTests extends MinimalScalaTest { case "NoReply" => Promise[String]().future } + def fail(msg: String): Nothing = throw new AssertionError(msg) + + def ECNotUsed[T](f: ExecutionContext => T): T = { + val p = Promise[Runnable]() + val unusedEC: ExecutionContext = new ExecutionContext { + def execute(r: Runnable) = p.success(r) + def reportFailure(t: Throwable): Unit = p.failure(t) + } + val t = f(unusedEC) + assert(p.future.value == None, "Future executed logic!") + t + } + val defaultTimeout = 5 seconds /* future specification */ @@ -68,6 +81,60 @@ class FutureTests extends MinimalScalaTest { } } + "Futures" should { + "have proper toString representations" in { + import ExecutionContext.Implicits.global + val s = 5 + val f = new Exception("foo") + val t = Try(throw f) + + val expectFailureString = "Future(Failure("+f+"))" + val expectSuccessString = "Future(Success(5))" + val expectNotCompleteString = "Future(<not completed>)" + + Future.successful(s).toString mustBe expectSuccessString + Future.failed(f).toString mustBe expectFailureString + Future.fromTry(t).toString mustBe expectFailureString + val p = Promise[Int]() + p.toString mustBe expectNotCompleteString + Promise[Int]().success(s).toString mustBe expectSuccessString + Promise[Int]().failure(f).toString mustBe expectFailureString + Await.ready(Future { throw f }, 2000 millis).toString mustBe expectFailureString + Await.ready(Future { s }, 2000 millis).toString mustBe expectSuccessString + + Future.never.toString mustBe "Future(<never>)" + Future.unit.toString mustBe "Future(Success(()))" + } + + "have proper const representation for success" in { + val s = "foo" + val f = Future.successful(s) + + ECNotUsed(ec => f.onFailure({ case _ => fail("onFailure should not have been called") })(ec)) + assert( ECNotUsed(ec => f.recover({ case _ => fail("recover should not have been called")})(ec)) eq f) + assert( ECNotUsed(ec => f.recoverWith({ case _ => fail("flatMap should not have been called")})(ec)) eq f) + assert(f.fallbackTo(f) eq f, "Future.fallbackTo must be the same instance as Future.fallbackTo") + } + + "have proper const representation for failure" in { + val e = new Exception("foo") + val f = Future.failed[Future[String]](e) + + assert(f.mapTo[String] eq f, "Future.mapTo must be the same instance as Future.mapTo") + assert(f.zip(f) eq f, "Future.zip must be the same instance as Future.zip") + assert(f.flatten eq f, "Future.flatten must be the same instance as Future.flatten") + assert(f.failed eq f, "Future.failed must be the same instance as Future.failed") + + ECNotUsed(ec => f.foreach(_ => fail("foreach should not have been called"))(ec)) + ECNotUsed(ec => f.onSuccess({ case _ => fail("onSuccess should not have been called") })(ec)) + assert( ECNotUsed(ec => f.map(_ => fail("map should not have been called"))(ec)) eq f) + assert( ECNotUsed(ec => f.flatMap(_ => fail("flatMap should not have been called"))(ec)) eq f) + assert( ECNotUsed(ec => f.filter(_ => fail("filter should not have been called"))(ec)) eq f) + assert( ECNotUsed(ec => f.collect({ case _ => fail("collect should not have been called")})(ec)) eq f) + assert( ECNotUsed(ec => f.zipWith(f)({ (_,_) => fail("zipWith should not have been called")})(ec)) eq f) + } + } + "The Future companion object" should { "call ExecutionContext.prepare on apply" in { val p = Promise[Boolean]() @@ -85,6 +152,49 @@ class FutureTests extends MinimalScalaTest { Await.result(f, defaultTimeout) mustBe ("foo") Await.result(p.future, defaultTimeout) mustBe (true) } + + "have a unit member representing an already completed Future containing Unit" in { + assert(Future.unit ne null, "Future.unit must not be null") + assert(Future.unit eq Future.unit, "Future.unit must be the same instance as Future.unit") + assert(Future.unit.isCompleted, "Future.unit must already be completed") + assert(Future.unit.value.get == Success(()), "Future.unit must contain a Success(())") + } + + "have a never member representing a never completed Future of Nothing" in { + + val test: Future[Nothing] = Future.never + + //Verify stable identifier + test match { + case Future.`never` => + case _ => fail("Future.never did not match Future.`never`") + } + + assert(test eq Future.never, "Future.never must be the same instance as Future.never") + assert(test ne null, "Future.never must not be null") + assert(!test.isCompleted && test.value.isEmpty, "Future.never must never be completed") + assert(test.failed eq test) + assert(test.asInstanceOf[Future[Future[Nothing]]].flatten eq test) + assert(test.zip(test) eq test) + assert(test.fallbackTo(test) eq test) + assert(test.mapTo[String] eq test) + + ECNotUsed(ec => test.foreach(_ => fail("foreach should not have been called"))(ec)) + ECNotUsed(ec => test.onSuccess({ case _ => fail("onSuccess should not have been called") })(ec)) + ECNotUsed(ec => test.onFailure({ case _ => fail("onFailure should not have been called") })(ec)) + ECNotUsed(ec => test.onComplete({ case _ => fail("onComplete should not have been called") })(ec)) + ECNotUsed(ec => test.transform(identity, identity)(ec) eq test) + ECNotUsed(ec => test.transform(identity)(ec) eq test) + ECNotUsed(ec => test.transformWith(_ => fail("transformWith should not have been called"))(ec) eq test) + ECNotUsed(ec => test.map(identity)(ec) eq test) + ECNotUsed(ec => test.flatMap(_ => fail("flatMap should not have been called"))(ec) eq test) + ECNotUsed(ec => test.filter(_ => fail("filter should not have been called"))(ec) eq test) + ECNotUsed(ec => test.collect({ case _ => fail("collect should not have been called")})(ec) eq test) + ECNotUsed(ec => test.recover({ case _ => fail("recover should not have been called")})(ec) eq test) + ECNotUsed(ec => test.recoverWith({ case _ => fail("recoverWith should not have been called")})(ec) eq test) + ECNotUsed(ec => test.andThen({ case _ => fail("andThen should not have been called")})(ec) eq test) + ECNotUsed(ec => test.zipWith(test)({ (_,_) => fail("zipWith should not have been called")})(ec) eq test) + } } "The default ExecutionContext" should { @@ -218,6 +328,142 @@ class FutureTests extends MinimalScalaTest { } mustBe (r) } + "transform results to results" in { + val f1 = Future.successful("foo").transform(_.map(_.toUpperCase)) + val f2 = Future("bar").transform(_.map(_.toUpperCase)) + Await.result(f1, defaultTimeout) mustBe "FOO" + Await.result(f2, defaultTimeout) mustBe "BAR" + } + + "transform failures to failures" in { + val initial = new Exception("Initial") + val expected1 = new Exception("Expected1") + val expected2 = new Exception("Expected2") + val f1 = Future(throw initial) transform { + case Failure(`initial`) => Failure(expected1) + case x => x + } + val f2 = Future.failed(initial) transform { + case Failure(`initial`) => Failure(expected2) + case x => x + } + + intercept[Exception] { Await.result(f1, defaultTimeout) } mustBe expected1 + intercept[Exception] { Await.result(f2, defaultTimeout) } mustBe expected2 + } + + "transform failures to results" in { + val initial1 = new Exception("Initial1") + val initial2 = new Exception("Initial2") + val f1 = Future.failed[String](initial1) transform { + case Failure(`initial1`) => Success("foo") + case x => x + } + val f2 = Future[String](throw initial2) transform { + case Failure(`initial2`) => Success("bar") + case x => x + } + Await.result(f1, defaultTimeout) mustBe "foo" + Await.result(f2, defaultTimeout) mustBe "bar" + } + + "transform results to failures" in { + val expected1 = new Exception("Expected1") + val expected2 = new Exception("Expected2") + val expected3 = new Exception("Expected3") + val f1 = Future.successful("foo") transform { + case Success("foo") => Failure(expected1) + case x => x + } + val f2 = Future("bar") transform { + case Success("bar") => Failure(expected2) + case x => x + } + val f3 = Future("bar") transform { + case Success("bar") => throw expected3 + case x => x + } + intercept[Exception] { Await.result(f1, defaultTimeout) } mustBe expected1 + intercept[Exception] { Await.result(f2, defaultTimeout) } mustBe expected2 + intercept[Exception] { Await.result(f3, defaultTimeout) } mustBe expected3 + } + + "transformWith results" in { + val f1 = Future.successful("foo").transformWith { + case Success(r) => Future(r.toUpperCase) + case f @ Failure(_) => Future.fromTry(f) + } + val f2 = Future("bar").transformWith { + case Success(r) => Future(r.toUpperCase) + case f @ Failure(_) => Future.fromTry(f) + } + Await.result(f1, defaultTimeout) mustBe "FOO" + Await.result(f2, defaultTimeout) mustBe "BAR" + } + + "transformWith failures" in { + val initial = new Exception("Initial") + val expected1 = new Exception("Expected1") + val expected2 = new Exception("Expected2") + val expected3 = new Exception("Expected3") + + val f1 = Future[Int](throw initial).transformWith { + case Failure(`initial`) => Future failed expected1 + case x => Future fromTry x + } + val f2 = Future.failed[Int](initial).transformWith { + case Failure(`initial`) => Future failed expected2 + case x => Future fromTry x + } + val f3 = Future[Int](throw initial).transformWith { + case Failure(`initial`) => throw expected3 + case x => Future fromTry x + } + + intercept[Exception] { Await.result(f1, defaultTimeout) } mustBe expected1 + intercept[Exception] { Await.result(f2, defaultTimeout) } mustBe expected2 + intercept[Exception] { Await.result(f3, defaultTimeout) } mustBe expected3 + } + + "transformWith failures to future success" in { + val initial = new Exception("Initial") + val f1 = Future.failed[String](initial).transformWith { + case Failure(`initial`) => Future("FOO") + case _ => Future failed initial + } + val f2 = Future[String](throw initial).transformWith { + case Failure(`initial`) => Future("BAR") + case _ => Future failed initial + } + Await.result(f1, defaultTimeout) mustBe "FOO" + Await.result(f2, defaultTimeout) mustBe "BAR" + } + + "transformWith results to future failures" in { + val initial = new Exception("Initial") + val expected1 = new Exception("Expected1") + val expected2 = new Exception("Expected2") + val expected3 = new Exception("Expected3") + + val f1 = Future[String]("FOO") transformWith { + case Success("FOO") => Future failed expected1 + case _ => Future successful "FOO" + } + val f2 = Future.successful("FOO") transformWith { + case Success("FOO") => Future failed expected2 + case _ => Future successful "FOO" + } + val f3 = Future.successful("FOO") transformWith { + case Success("FOO") => throw expected3 + case _ => Future successful "FOO" + } + + + intercept[Exception] { Await.result(f1, defaultTimeout) } mustBe expected1 + intercept[Exception] { Await.result(f2, defaultTimeout) } mustBe expected2 + intercept[Exception] { Await.result(f3, defaultTimeout) } mustBe expected3 + } + "andThen like a boss" in { val q = new java.util.concurrent.LinkedBlockingQueue[Int] for (i <- 1 to 1000) { @@ -281,6 +527,33 @@ class FutureTests extends MinimalScalaTest { Await.result(successful, timeout) mustBe (("foo", "foo")) } + "zipWith" in { + val timeout = 10000 millis + val f = new IllegalStateException("test") + intercept[IllegalStateException] { + val failed = Future.failed[String](f).zipWith(Future.successful("foo")) { _ -> _ } + Await.result(failed, timeout) + } mustBe (f) + + intercept[IllegalStateException] { + val failed = Future.successful("foo").zipWith(Future.failed[String](f)) { _ -> _ } + Await.result(failed, timeout) + } mustBe (f) + + intercept[IllegalStateException] { + val failed = Future.failed[String](f).zipWith(Future.failed[String](f)) { _ -> _ } + Await.result(failed, timeout) + } mustBe (f) + + val successful = Future.successful("foo").zipWith(Future.successful("foo")) { _ -> _ } + Await.result(successful, timeout) mustBe (("foo", "foo")) + + val failure = Future.successful("foo").zipWith(Future.successful("foo")) { (_,_) => throw f } + intercept[IllegalStateException] { + Await.result(failure, timeout) + } mustBe (f) + } + "fold" in { val timeout = 10000 millis def async(add: Int, wait: Int) = Future { diff --git a/test/files/jvm/future-termination.check b/test/files/jvm/future-termination.check deleted file mode 100644 index dc335465d4..0000000000 --- a/test/files/jvm/future-termination.check +++ /dev/null @@ -1 +0,0 @@ -I can't wait that long, bye. diff --git a/test/files/jvm/future-termination.scala b/test/files/jvm/future-termination.scala deleted file mode 100644 index 90ea336ce8..0000000000 --- a/test/files/jvm/future-termination.scala +++ /dev/null @@ -1,21 +0,0 @@ - -/* Test that unevaluated futures do not prevent program termination */ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.Futures - def main(args: Array[String]) { - try { - val meaningOfLife = Futures.future { - Thread.sleep(5000) // pretend this is a harder problem than it is - println("I have the answer!") - 42 - } - println("I can't wait that long, bye.") - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} diff --git a/test/files/jvm/reactor-exceptionOnSend.check b/test/files/jvm/reactor-exceptionOnSend.check deleted file mode 100644 index 45d62e26a7..0000000000 --- a/test/files/jvm/reactor-exceptionOnSend.check +++ /dev/null @@ -1,2 +0,0 @@ -receiver handles exception -process diff --git a/test/files/jvm/reactor-exceptionOnSend.scala b/test/files/jvm/reactor-exceptionOnSend.scala deleted file mode 100644 index 6d79fc9d13..0000000000 --- a/test/files/jvm/reactor-exceptionOnSend.scala +++ /dev/null @@ -1,58 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors.Reactor -import scala.actors.Actor._ - -case class MyException(text: String) extends Exception(text) - -object A extends Reactor[Any] { - override def exceptionHandler = { - case MyException(text) => - println("receiver handles exception") - } - - def guard(): Boolean = - if (state == 0) { - state = 1 - throw MyException("illegal state") - } else - true - - var state = 0 - - def act() { - try { - loop { - react { - case 'hello if guard() => - println("process") - exit() - } - } - } catch { - case e: Throwable if (!e.isInstanceOf[scala.util.control.ControlThrowable] && - !e.isInstanceOf[MyException]) => - e.printStackTrace() - } - } -} - -object B extends Reactor[Any] { - def act() { - try { - A.start() - A ! 'hello - A ! 'hello - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - - def main(args: Array[String]) { - B.start() - } -} diff --git a/test/files/jvm/reactor-producer-consumer.check b/test/files/jvm/reactor-producer-consumer.check deleted file mode 100644 index d971cea19e..0000000000 --- a/test/files/jvm/reactor-producer-consumer.check +++ /dev/null @@ -1,10 +0,0 @@ -42 -42 -42 -42 -42 -42 -42 -42 -42 -42 diff --git a/test/files/jvm/reactor-producer-consumer.scala b/test/files/jvm/reactor-producer-consumer.scala deleted file mode 100644 index ec34febe01..0000000000 --- a/test/files/jvm/reactor-producer-consumer.scala +++ /dev/null @@ -1,97 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.Reactor - case class Stop() - case class Get(from: Reactor[Any]) - case class Put(x: Int) - - class UnboundedBuffer extends Reactor[Any] { - def act() { - try { - react { - case Stop() => - case Get(from) => - val consumer = from - react { - case msg @ Put(x) => - consumer ! x - act() - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - class Producer(buf: UnboundedBuffer, n: Int, delay: Long, parent: Reactor[Any]) extends Reactor[Any] { - def act() { - try { - var i = 0 - while (i < n) { - i += 1 - if (delay > 0) Thread.sleep(delay) - buf ! Put(42) - } - parent ! Stop() - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - class Consumer(buf: UnboundedBuffer, n: Int, delay: Long, parent: Reactor[Any]) extends Reactor[Any] { - val step = n / 10 - var i = 0 - def act() { - try { - if (i < n) { - i += 1 - if (delay > 0) Thread.sleep(delay) - buf ! Get(this) - react { - case res => - if (i % step == 0) - println(res) - act() - } - } else { - parent ! Stop() - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - def main(args: Array[String]) { - val parent = new Reactor[Any] { - def act() { - try { - val buffer = new UnboundedBuffer - buffer.start() - val producer = new Producer(buffer, 10000, 0, this) - producer.start() - val consumer = new Consumer(buffer, 10000, 0, this) - consumer.start() - react { - case Stop() => - react { - case Stop() => - buffer ! Stop() - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - parent.start() - } -} diff --git a/test/files/jvm/reactor.check b/test/files/jvm/reactor.check deleted file mode 100644 index 7b16085797..0000000000 --- a/test/files/jvm/reactor.check +++ /dev/null @@ -1,22 +0,0 @@ -Pong: ping 0 -Ping: pong -Pong: ping 10000 -Ping: pong -Pong: ping 20000 -Ping: pong -Pong: ping 30000 -Ping: pong -Pong: ping 40000 -Ping: pong -Pong: ping 50000 -Ping: pong -Pong: ping 60000 -Ping: pong -Pong: ping 70000 -Ping: pong -Pong: ping 80000 -Ping: pong -Pong: ping 90000 -Ping: pong -Ping: stop -Pong: stop diff --git a/test/files/jvm/reactor.scala b/test/files/jvm/reactor.scala deleted file mode 100644 index 91ded27f07..0000000000 --- a/test/files/jvm/reactor.scala +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Ping pong example for Reactor. - * - * @author Philipp Haller - */ - -@deprecated("Suppress warnings", since="2.11") -object Test { - -import scala.actors.Reactor - -case class Ping(from: Reactor[Any]) -case object Pong -case object Stop - - def main(args: Array[String]) { - val pong = new PongActor - val ping = new PingActor(100000, pong) - ping.start - pong.start - } - -class PingActor(count: Int, pong: Reactor[Any]) extends Reactor[Any] { - def act() { - try { - var pingsLeft = count - 1 - pong ! Ping(this) - loop { - react { - case Pong => - if (pingsLeft % 10000 == 0) - println("Ping: pong") - if (pingsLeft > 0) { - pong ! Ping(this) - pingsLeft -= 1 - } else { - println("Ping: stop") - pong ! Stop - exit() - } - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - -class PongActor extends Reactor[Any] { - def act() { - try { - var pongCount = 0 - loop { - react { - case Ping(from) => - if (pongCount % 10000 == 0) - println("Pong: ping "+pongCount) - from ! Pong - pongCount += 1 - case Stop => - println("Pong: stop") - exit() - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} -} diff --git a/test/files/jvm/replyablereactor.check b/test/files/jvm/replyablereactor.check deleted file mode 100644 index 0944b17279..0000000000 --- a/test/files/jvm/replyablereactor.check +++ /dev/null @@ -1,5 +0,0 @@ -'hello -'hello -'hello -'hello -'hello diff --git a/test/files/jvm/replyablereactor.scala b/test/files/jvm/replyablereactor.scala deleted file mode 100644 index 4c4e13d9ab..0000000000 --- a/test/files/jvm/replyablereactor.scala +++ /dev/null @@ -1,59 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors.ReplyReactor - -class MyActor extends ReplyReactor { - def act() { - try { - loop { - react { - case 'hello => - sender ! 'hello - case 'stop => - exit() - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - - def main(args: Array[String]) { - val a = new MyActor - a.start() - - val b = new ReplyReactor { - def act() { - try { - react { - case r: MyActor => - var i = 0 - loop { - i += 1 - val ft = r !! 'hello - ft.inputChannel.react { - case msg => - if (i % 10000 == 0) - println(msg) - if (i >= 50000) { - r ! 'stop - exit() - } - } - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - b.start() - - b ! a - } -} diff --git a/test/files/jvm/replyablereactor2.check b/test/files/jvm/replyablereactor2.check deleted file mode 100644 index 0944b17279..0000000000 --- a/test/files/jvm/replyablereactor2.check +++ /dev/null @@ -1,5 +0,0 @@ -'hello -'hello -'hello -'hello -'hello diff --git a/test/files/jvm/replyablereactor2.scala b/test/files/jvm/replyablereactor2.scala deleted file mode 100644 index 21f33cce56..0000000000 --- a/test/files/jvm/replyablereactor2.scala +++ /dev/null @@ -1,58 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors._ -import scala.actors.Actor._ - -class MyActor extends ReplyReactor { - def act() { - try { - loop { - react { - case 'hello => - sender ! 'hello - case 'stop => - exit() - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - - def main(args: Array[String]) { - val a = new MyActor - a.start() - - val b = new Reactor[Any] { - def act() { - try { - react { - case r: MyActor => - var i = 0 - loop { - i += 1 - val ft = r !! 'hello - val msg = ft() - if (i % 10000 == 0) - println(msg) - if (i >= 50000) { - r ! 'stop - exit() - } - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - b.start() - - b ! a - } -} diff --git a/test/files/jvm/replyablereactor3.check b/test/files/jvm/replyablereactor3.check deleted file mode 100644 index 0944b17279..0000000000 --- a/test/files/jvm/replyablereactor3.check +++ /dev/null @@ -1,5 +0,0 @@ -'hello -'hello -'hello -'hello -'hello diff --git a/test/files/jvm/replyablereactor3.scala b/test/files/jvm/replyablereactor3.scala deleted file mode 100644 index 5810ed053f..0000000000 --- a/test/files/jvm/replyablereactor3.scala +++ /dev/null @@ -1,57 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors._ -import scala.actors.Actor._ - -class MyActor extends ReplyReactor { - def act() { - try { - loop { - react { - case 'hello => - sender ! 'hello - case 'stop => - exit() - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - - def main(args: Array[String]) { - val a = new MyActor - a.start() - - val b = new Reactor[Any] { - def act() { - try { - react { - case r: MyActor => - var i = 0 - loop { - i += 1 - val msg = r !? 'hello - if (i % 10000 == 0) - println(msg) - if (i >= 50000) { - r ! 'stop - exit() - } - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - b.start() - - b ! a - } -} diff --git a/test/files/jvm/replyablereactor4.check b/test/files/jvm/replyablereactor4.check deleted file mode 100644 index cac0fffe3b..0000000000 --- a/test/files/jvm/replyablereactor4.check +++ /dev/null @@ -1,5 +0,0 @@ -Some('hello) -Some('hello) -Some('hello) -Some('hello) -Some('hello) diff --git a/test/files/jvm/replyablereactor4.scala b/test/files/jvm/replyablereactor4.scala deleted file mode 100644 index 95d63684dd..0000000000 --- a/test/files/jvm/replyablereactor4.scala +++ /dev/null @@ -1,57 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors._ -import scala.actors.Actor._ - -class MyActor extends ReplyReactor { - def act() { - try { - loop { - react { - case 'hello => - sender ! 'hello - case 'stop => - exit() - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - - def main(args: Array[String]) { - val a = new MyActor - a.start() - - val b = new Reactor[Any] { - def act() { - try { - react { - case r: MyActor => - var i = 0 - loop { - i += 1 - val msg = r !? (500, 'hello) - if (i % 200000 == 0) - println(msg) - if (i >= 1000000) { - r ! 'stop - exit() - } - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - b.start() - - b ! a - } -} diff --git a/test/files/jvm/replyreactor-react-sender.check b/test/files/jvm/replyreactor-react-sender.check deleted file mode 100644 index d86bac9de5..0000000000 --- a/test/files/jvm/replyreactor-react-sender.check +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/test/files/jvm/replyreactor-react-sender.scala b/test/files/jvm/replyreactor-react-sender.scala deleted file mode 100644 index fdcea09035..0000000000 --- a/test/files/jvm/replyreactor-react-sender.scala +++ /dev/null @@ -1,53 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.ReplyReactor - import scala.actors.Actor._ - - val NUM = 2000 - - def main(args: Array[String]) { - var b: ReplyReactor = null - - val a = new ReplyReactor { - def act() { - try { - var i = 0 - loopWhile (i < NUM) { - i += 1 - react { - case 'hello if sender == this => b ! 'fail - case 'hello if sender == b => // do nothing - } - } andThen { - b ! 'ok - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - a.start() - - b = new ReplyReactor { - def act() { - try { - for (_ <- 0 until NUM) - a ! 'hello - react { - case 'fail => println("FAIL") - case 'ok => println("OK") - case other => println(other) - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - b.start() - } - -} diff --git a/test/files/jvm/replyreactor.check b/test/files/jvm/replyreactor.check deleted file mode 100644 index 4b2fea867a..0000000000 --- a/test/files/jvm/replyreactor.check +++ /dev/null @@ -1 +0,0 @@ -'hello diff --git a/test/files/jvm/replyreactor.scala b/test/files/jvm/replyreactor.scala deleted file mode 100644 index 7512fb0eb2..0000000000 --- a/test/files/jvm/replyreactor.scala +++ /dev/null @@ -1,43 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.ReplyReactor - def main(args: Array[String]) { - val a = new ReplyReactor { - def act() { - try { - react { - case 'hello => - sender ! 'hello - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - a.start() - - val b = new ReplyReactor { - def act() { - try { - react { - case r: ReplyReactor => - r ! 'hello - react { - case any => - println(any) - } - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - b.start() - - b ! a - } -} diff --git a/test/files/jvm/scala-concurrent-tck.check b/test/files/jvm/scala-concurrent-tck.check new file mode 100644 index 0000000000..bbe73c9982 --- /dev/null +++ b/test/files/jvm/scala-concurrent-tck.check @@ -0,0 +1 @@ +warning: there were 74 deprecation warnings; re-run with -deprecation for details diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index ce86d4aef0..ba405e97bd 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -165,6 +165,100 @@ def testTransformFailure(): Unit = once { g onFailure { case e => done(e eq transformed) } } + def testTransformResultToResult(): Unit = once { + done => + Future("foo").transform { + case Success(s) => Success(s.toUpperCase) + case Failure(f) => throw new Exception("test failed") + } onComplete { + case Success("FOO") => done(true) + case _ => done(false) + } + } + + def testTransformResultToFailure(): Unit = once { + done => + val e = new Exception("expected") + Future("foo").transform { + case Success(s) => Failure(e) + case Failure(f) => throw new Exception("test failed") + } onComplete { + case Failure(`e`) => done(true) + case _ => done(false) + } + } + + def testTransformFailureToResult(): Unit = once { + done => + val e = "foo" + Future(throw new Exception("initial")).transform { + case Success(s) => throw new Exception("test failed") + case Failure(f) => Success(e) + } onComplete { + case Success(`e`) => done(true) + case _ => done(false) + } + } + + def testTransformFailureToFailure(): Unit = once { + done => + val e = new Exception("expected") + Future(throw new Exception("initial")).transform { + case Success(s) => throw new Exception("test failed") + case Failure(f) => Failure(e) + } onComplete { + case Failure(`e`) => done(true) + case _ => done(false) + } + } + + def testTransformWithResultToResult(): Unit = once { + done => + Future("foo").transformWith { + case Success(s) => Future(s.toUpperCase) + case Failure(f) => throw new Exception("test failed") + } onComplete { + case Success("FOO") => done(true) + case _ => done(false) + } + } + + def testTransformWithResultToFailure(): Unit = once { + done => + val e = new Exception("expected") + Future("foo").transformWith { + case Success(s) => Future(throw e) + case Failure(f) => throw new Exception("test failed") + } onComplete { + case Failure(`e`) => done(true) + case _ => done(false) + } + } + + def testTransformWithFailureToResult(): Unit = once { + done => + val e = "foo" + Future(throw new Exception("initial")).transformWith { + case Success(s) => throw new Exception("test failed") + case Failure(f) => Future(e) + } onComplete { + case Success(`e`) => done(true) + case _ => done(false) + } + } + + def testTransformWithFailureToFailure(): Unit = once { + done => + val e = new Exception("expected") + Future(throw new Exception("initial")).transformWith { + case Success(s) => throw new Exception("test failed") + case Failure(f) => Future(throw e) + } onComplete { + case Failure(`e`) => done(true) + case _ => done(false) + } + } + def testFoldFailure(): Unit = once { done => val f = Future[Unit] { throw new Exception("expected") } @@ -352,6 +446,14 @@ def testTransformFailure(): Unit = once { h onFailure { case e => done(e eq cause) } } + def testFallbackToThis(): Unit = { + def check(f: Future[Int]) = assert((f fallbackTo f) eq f) + + check(Future { 1 }) + check(Future.successful(1)) + check(Future.failed[Int](new Exception)) + } + testMapSuccess() testMapFailure() testFlatMapSuccess() @@ -373,6 +475,16 @@ def testTransformFailure(): Unit = once { testFallbackToFailure() testTransformSuccess() testTransformSuccessPF() + testTransformFailure() + testTransformFailurePF() + testTransformResultToResult() + testTransformResultToFailure() + testTransformFailureToResult() + testTransformFailureToFailure() + testTransformWithResultToResult() + testTransformWithResultToFailure() + testTransformWithFailureToResult() + testTransformWithFailureToFailure() } @@ -593,6 +705,17 @@ trait Exceptions extends TestBase { } +trait GlobalExecutionContext extends TestBase { + def testNameOfGlobalECThreads(): Unit = once { + done => Future({ + val expectedName = "scala-execution-context-global-"+ Thread.currentThread.getId + done(expectedName == Thread.currentThread.getName) + })(ExecutionContext.global) + } + + testNameOfGlobalECThreads() +} + trait CustomExecutionContext extends TestBase { import scala.concurrent.{ ExecutionContext, Awaitable } @@ -772,6 +895,7 @@ with FutureProjections with Promises with BlockContexts with Exceptions +with GlobalExecutionContext with CustomExecutionContext with ExecutionContextPrepare { diff --git a/test/files/jvm/scheduler-adapter.check b/test/files/jvm/scheduler-adapter.check deleted file mode 100644 index b278674cf0..0000000000 --- a/test/files/jvm/scheduler-adapter.check +++ /dev/null @@ -1,6 +0,0 @@ -before -before -before -Two: received msg -before -One: received msg diff --git a/test/files/jvm/scheduler-adapter.scala b/test/files/jvm/scheduler-adapter.scala deleted file mode 100644 index 1c9cfe7019..0000000000 --- a/test/files/jvm/scheduler-adapter.scala +++ /dev/null @@ -1,54 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -import scala.actors.{Actor, SchedulerAdapter} - -trait AdaptedActor extends Actor { - override def scheduler = - Test.adapted -} - -object One extends AdaptedActor { - def act() { - try { - Two.start() - Two ! 'MsgForTwo - react { - case 'MsgForOne => - println("One: received msg") - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - -object Two extends AdaptedActor { - def act() { - try { - react { - case 'MsgForTwo => - println("Two: received msg") - One ! 'MsgForOne - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} - - val adapted = - new SchedulerAdapter { - def execute(block: => Unit) { - println("before") - block - } - } - - def main(args: Array[String]) { - One.start() - } -} diff --git a/test/files/jvm/t1449.check b/test/files/jvm/t1449.check deleted file mode 100644 index d81cc0710e..0000000000 --- a/test/files/jvm/t1449.check +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/test/files/jvm/t1449.scala b/test/files/jvm/t1449.scala deleted file mode 100644 index 7917d6f6d5..0000000000 --- a/test/files/jvm/t1449.scala +++ /dev/null @@ -1,28 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.Actor._ - import scala.actors.Future - import scala.actors.Futures._ - def main(args: Array[String]) { - val a = actor { - try { - react { - case ft: Future[a] => - println(ft()) - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - try { - val ft = future { 42 } - a ! ft - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } -} diff --git a/test/files/jvm/t1948.scala b/test/files/jvm/t1948.scala deleted file mode 100644 index 95777b8037..0000000000 --- a/test/files/jvm/t1948.scala +++ /dev/null @@ -1,26 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors._ - import scala.actors.Actor._ - - def main (args: Array[String]) { - val actors = (1 to 1000).toList map { x => actor { - try { - loop { react { - case x: Array[Int] => reply ("OK"); exit }} - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } } - try { - actors foreach { x => x !? new Array[Int] (1000000) } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - -} diff --git a/test/files/jvm/t2359.check b/test/files/jvm/t2359.check deleted file mode 100644 index 8a1218a102..0000000000 --- a/test/files/jvm/t2359.check +++ /dev/null @@ -1,5 +0,0 @@ -1 -2 -3 -4 -5 diff --git a/test/files/jvm/t2359.scala b/test/files/jvm/t2359.scala deleted file mode 100644 index 76b78d44f7..0000000000 --- a/test/files/jvm/t2359.scala +++ /dev/null @@ -1,48 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.Futures._ - def main(args: Array[String]) { - val x = future { - try { - System.out.println(1) - future { - try { - System.out.println(2) - future { - try { - System.out.println(3) - future { - try { - System.out.println(4) - future { - try { - System.out.println(5) - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - }() - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - }() - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - }() - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - }() - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - }() - } -} diff --git a/test/files/jvm/t2530.check b/test/files/jvm/t2530.check deleted file mode 100644 index 0f1c02158d..0000000000 --- a/test/files/jvm/t2530.check +++ /dev/null @@ -1,21 +0,0 @@ - Iteration 1 succeeded - Iteration 2 succeeded - Iteration 3 succeeded - Iteration 4 succeeded - Iteration 5 succeeded - Iteration 6 succeeded - Iteration 7 succeeded - Iteration 8 succeeded - Iteration 9 succeeded - Iteration 10 succeeded - Iteration 11 succeeded - Iteration 12 succeeded - Iteration 13 succeeded - Iteration 14 succeeded - Iteration 15 succeeded - Iteration 16 succeeded - Iteration 17 succeeded - Iteration 18 succeeded - Iteration 19 succeeded - Iteration 20 succeeded -Test done with no deadlock. Try again, it will not occur... diff --git a/test/files/jvm/t2530.scala b/test/files/jvm/t2530.scala deleted file mode 100644 index b41661e623..0000000000 --- a/test/files/jvm/t2530.scala +++ /dev/null @@ -1,98 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.{Future, Futures} - - def main(args:Array[String]) : Unit = { - //scala.actors.Debug.level = 3 - val size = /*if (args.length > 0) Integer.parseInt(args(0)) else*/ 8 - val (m,n) = (size, size) - def random = (for (i <- 0 until m*n) yield java.lang.Math.random).toArray - val A = Matrix(m, n, random) - val B = Matrix(m, n, random) - val format = new java.text.DecimalFormat("000.00'ms'"); - var iter = 1 - val done = 21 - while (iter < done) { - val start = System.nanoTime() - val result = A * B - val time = System.nanoTime() - start - result match { - case Some(result) => { - printf(" Iteration %2d succeeded %n", iter/*, format.format(time / 1e6)*/) - iter += 1 - } - case None => { - printf(">>>> Iteration %2d failed after %s <<<<< %n", iter, format.format(time / 1e6)) - iter = done - } - } - } - println("Test done with no deadlock. Try again, it will not occur...") - } - -case class Matrix(numRows: Int, numCols: Int, values: Array[Double]) { - - def this(m:Int, n:Int) = this(m, n, new Array[Double](m*n)) - - def offset(i:Int, j:Int) = i * numCols + j - def apply(i:Int, j:Int) = values( offset(i,j) ) - def update(i:Int, j:Int, value:Double) = values(offset(i, j)) = value; - - def *(by:Matrix) = { - val aM = numRows - val aN = numCols - assert(aM == by.numCols) - assert(aN == by.numRows) - val resultMatrix = new Matrix(aM, aM) - val m = aM.asInstanceOf[Int] - val n = aN.asInstanceOf[Int] - - val rows = for (j <- 0 until m) yield { - Futures.future { - try { - val b_j = new Array[Double](n) - var k = 0 - while (k < n) { // sadly, while loops are still faster than for loops - b_j(k) = by(k,j) - k += 1 - } - var i = 0 - while (i < m) { - var s = 0.0d; - k = 0 - while (k < n) { - s += Matrix.this(i,k) * b_j(k) - k += 1 - } - resultMatrix(i,j) = s - i += 1 - } - //printf("future %d of %d completed.%n", j, m) - j - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } - - // rows.foreach { x=> x() } // This appears to force sequential execution, so use: - // timeout is 10 years; see http://lampsvn.epfl.ch/trac/scala/ticket/2515 - val done: List[Option[Any]] = try { - Futures.awaitAll(10*365*24*60*60*1000, rows.toArray : _*) // list to array, as varargs. - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - List() - } - - if (done.contains(None)) - None - else - Some(resultMatrix) - } - -} -} diff --git a/test/files/jvm/t3102.check b/test/files/jvm/t3102.check deleted file mode 100644 index d705e0b20e..0000000000 --- a/test/files/jvm/t3102.check +++ /dev/null @@ -1,2 +0,0 @@ -42 -OK diff --git a/test/files/jvm/t3102.scala b/test/files/jvm/t3102.scala deleted file mode 100644 index d0e0704859..0000000000 --- a/test/files/jvm/t3102.scala +++ /dev/null @@ -1,39 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.{Actor, TIMEOUT} - import Actor._ - - def main(args: Array[String]) { - val a = actor { - try { - react { - case 'hello => - reply(42) - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - - val b = actor { - try { - self.trapExit = true - val ft = a !! 'hello - println(ft()) - // no message should be left over in mailbox - reactWithin(0) { - case TIMEOUT => - println("OK") - case any => - println(any) - } - } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => - e.printStackTrace() - } - } - } -} diff --git a/test/files/jvm/t3356.check b/test/files/jvm/t3356.check deleted file mode 100644 index 25f47b70c9..0000000000 --- a/test/files/jvm/t3356.check +++ /dev/null @@ -1,3 +0,0 @@ -sending download requests -Couldn't download image because of java.lang.Exception: no connection -Couldn't download image because of java.lang.Exception: no connection diff --git a/test/files/jvm/t3356.scala b/test/files/jvm/t3356.scala deleted file mode 100644 index 53bfd737cd..0000000000 --- a/test/files/jvm/t3356.scala +++ /dev/null @@ -1,58 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -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) - - - 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 because of "+cause) - } - } - println("OK, all images rendered.") - } - - def main(args: Array[String]) { - actor { - self.trapExit = true - renderImages("panorama.epfl.ch") - } - } - -} diff --git a/test/files/jvm/t3365.check b/test/files/jvm/t3365.check deleted file mode 100644 index 0944b17279..0000000000 --- a/test/files/jvm/t3365.check +++ /dev/null @@ -1,5 +0,0 @@ -'hello -'hello -'hello -'hello -'hello diff --git a/test/files/jvm/t3365.scala b/test/files/jvm/t3365.scala deleted file mode 100644 index 8321428093..0000000000 --- a/test/files/jvm/t3365.scala +++ /dev/null @@ -1,68 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { -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() - } - } -} - - 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/jvm/t3407.check b/test/files/jvm/t3407.check deleted file mode 100644 index a133c88bbe..0000000000 --- a/test/files/jvm/t3407.check +++ /dev/null @@ -1,10 +0,0 @@ -result: 42 -result: 42 -result: 42 -result: 42 -result: 42 -result: 42 -result: 42 -result: 42 -result: 42 -result: 42 diff --git a/test/files/jvm/t3407.scala b/test/files/jvm/t3407.scala deleted file mode 100644 index 757fa3a438..0000000000 --- a/test/files/jvm/t3407.scala +++ /dev/null @@ -1,21 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors._, scala.actors.Actor._ - - def main(args: Array[String]) { - for (i <- 1 to 10) { - val ft = Futures.future { 42 } - println("result: " + ft()) - } - - for (i <- 1 to 10) { - receiveWithin(0) { - case TIMEOUT => - case msg => println("unexpected: " + msg) - } - } - } - -} diff --git a/test/files/jvm/t3412-channel.check b/test/files/jvm/t3412-channel.check deleted file mode 100644 index 954c6e835d..0000000000 --- a/test/files/jvm/t3412-channel.check +++ /dev/null @@ -1,10 +0,0 @@ -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 diff --git a/test/files/jvm/t3412-channel.scala b/test/files/jvm/t3412-channel.scala deleted file mode 100644 index af319d2303..0000000000 --- a/test/files/jvm/t3412-channel.scala +++ /dev/null @@ -1,40 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors._, scala.actors.Actor._, scala.actors.Futures._ - - def main(args: Array[String]) { - - actor { - val C: Channel[Int] = new Channel[Int](self) - - def respondAll(fts: List[Future[Int]], cnt: Int): Unit = - fts match { - case List() => C ! 0 - case ft :: rest => - if (cnt % 100 == 0) - println(ft()) - respondAll(rest, cnt + 1) - } - - actor { - val fts = for (_ <- 1 to 1000) - yield C !! (3, {case x: Int => x}) - - actor { - respondAll(fts.toList, 0) - } - } - - loop { - C.react { - case 0 => exit() - case i => reply(i * 2) - } - } - } - - } - -} diff --git a/test/files/jvm/t3412.check b/test/files/jvm/t3412.check deleted file mode 100644 index 954c6e835d..0000000000 --- a/test/files/jvm/t3412.check +++ /dev/null @@ -1,10 +0,0 @@ -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 diff --git a/test/files/jvm/t3412.scala b/test/files/jvm/t3412.scala deleted file mode 100644 index fde6c04cb7..0000000000 --- a/test/files/jvm/t3412.scala +++ /dev/null @@ -1,34 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors._, scala.actors.Actor._, scala.actors.Futures._ - - def main(args: Array[String]) { - - val a = actor { - loop { react { - case i: Int => reply(i * 2) - case 'stop => exit() - } } - } - - val fts = for (_ <- 1 to 1000) - yield a !! (3, {case x: Int => x}) - - def respondAll(fts: List[Future[Int]], cnt: Int): Unit = - fts match { - case List() => a ! 'stop - case ft :: rest => - if (cnt % 100 == 0) - println(ft()) - respondAll(rest, cnt + 1) - } - - actor { - respondAll(fts.toList, 0) - } - - } - -} diff --git a/test/files/jvm/t3470.check b/test/files/jvm/t3470.check deleted file mode 100644 index 94cb526756..0000000000 --- a/test/files/jvm/t3470.check +++ /dev/null @@ -1,3 +0,0 @@ -A: started: 1 -A: started: 2 -A: started: 3 diff --git a/test/files/jvm/t3470.scala b/test/files/jvm/t3470.scala deleted file mode 100644 index bcb1d4f8de..0000000000 --- a/test/files/jvm/t3470.scala +++ /dev/null @@ -1,32 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors._ - - def expectActorState(a: Reactor[T] forSome { type T }, s: Actor.State.Value) { - var done = false - var i = 0 - while (!done) { - i = i + 1 - if (i == 10) { // only wait for 2 seconds total - println("FAIL ["+a+": expected "+s+"]") - done = true - } - - Thread.sleep(200) - if (a.getState == s) // success - done = true - } - } - - def main(args: Array[String]) { - val a = new Actor { var c = 0; def act() = { c += 1; println("A: started: " + c) } } - a.start() - expectActorState(a, Actor.State.Terminated) - a.restart() - expectActorState(a, Actor.State.Terminated) - a.restart() - } - -} diff --git a/test/files/jvm/t3838.check b/test/files/jvm/t3838.check deleted file mode 100644 index 154227a350..0000000000 --- a/test/files/jvm/t3838.check +++ /dev/null @@ -1 +0,0 @@ -caught java.lang.RuntimeException: unhandled timeout diff --git a/test/files/jvm/t3838.scala b/test/files/jvm/t3838.scala deleted file mode 100644 index a1a71d1049..0000000000 --- a/test/files/jvm/t3838.scala +++ /dev/null @@ -1,17 +0,0 @@ - - -@deprecated("Suppress warnings", since="2.11") -object Test { - import scala.actors.Actor._ - def main(args: Array[String]) { - actor { - try { - receiveWithin(1) { - case str: String => println(str) - } - } catch { - case e: Exception => println("caught "+e) - } - } - } -} diff --git a/test/files/jvm/t7146.scala b/test/files/jvm/t7146.scala index aaa3dc7ca4..ea734472d5 100644 --- a/test/files/jvm/t7146.scala +++ b/test/files/jvm/t7146.scala @@ -10,7 +10,7 @@ object Test { ExecutionContext.global.toString.startsWith("scala.concurrent.impl.ExecutionContextImpl")) val i = ExecutionContext.global.asInstanceOf[{ def executor: Executor }] println("should be scala.concurrent.forkjoin.ForkJoinPool == " + - i.executor.toString.startsWith("scala.concurrent.forkjoin.ForkJoinPool")) + (i.executor.getClass.getSuperclass.getName == "scala.concurrent.forkjoin.ForkJoinPool")) val u = i.executor. asInstanceOf[{ def getUncaughtExceptionHandler: Thread.UncaughtExceptionHandler }]. getUncaughtExceptionHandler diff --git a/test/files/jvm/t8582.check b/test/files/jvm/t8582.check index e388366270..0e4da90398 100644 --- a/test/files/jvm/t8582.check +++ b/test/files/jvm/t8582.check @@ -1,3 +1,6 @@ +t8582.scala:17: warning: class BeanInfo in package beans is deprecated: the generation of BeanInfo classes is no longer supported + class C1 + ^ getClass on module gives module class class p1.p2.Singleton$Singleton$ diff --git a/test/files/jvm/t8582.flags b/test/files/jvm/t8582.flags new file mode 100644 index 0000000000..dcc59ebe32 --- /dev/null +++ b/test/files/jvm/t8582.flags @@ -0,0 +1 @@ +-deprecation diff --git a/test/files/jvm/try-type-tests.scala b/test/files/jvm/try-type-tests.scala index 962afbd30f..b3926020f0 100644 --- a/test/files/jvm/try-type-tests.scala +++ b/test/files/jvm/try-type-tests.scala @@ -118,6 +118,44 @@ trait TryStandard { assert(f.transform(succ, fail).get == 0) } + def testSuccessEither(): Unit = { + val t = Success(1) + assert(t.toEither.isRight) + } + + def testFailureEither(): Unit = { + val t = Failure(new Exception("foo")) + assert(t.toEither.isLeft) + } + + def testFoldSuccess(): Unit = { + val t = Success(1) + val res = t.fold("Throws " + _, "Returns " + _) + assert(res == "Returns 1") + } + + def testFoldFailure(): Unit = { + val t = Failure(new Exception("foo")) + val res = t.fold("Throws " + _, "Returns " + _) + assert(res == "Throws java.lang.Exception: foo") + } + + def testFoldSuccessFailure(): Unit = { + val t = Success(1) + val res = t.fold("Throws " + _, _ => throw new Exception("foo")) + assert(res == "Throws java.lang.Exception: foo") + } + + def testFoldFailureFailure(): Unit = { + val t = Failure(new Exception("foo")) + val res = try { + t.fold(_ => throw new Exception("bar"), "Returns " + _) + } catch { + case e: Throwable => "Throws " + e + } + assert(res == "Throws java.lang.Exception: bar") + } + testForeachSuccess() testForeachFailure() testFlatMapSuccess() @@ -136,6 +174,11 @@ trait TryStandard { testFailedFailure() testSuccessTransform() testFailureTransform() + testSuccessEither() + testFailureEither() + testFoldSuccess() + testFoldFailure() + testFoldSuccessFailure() } object Test diff --git a/test/files/neg/beanInfoDeprecation.check b/test/files/neg/beanInfoDeprecation.check new file mode 100644 index 0000000000..788b277818 --- /dev/null +++ b/test/files/neg/beanInfoDeprecation.check @@ -0,0 +1,6 @@ +beanInfoDeprecation.scala:2: warning: class BeanInfo in package beans is deprecated: the generation of BeanInfo classes is no longer supported +class C + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/beanInfoDeprecation.flags b/test/files/neg/beanInfoDeprecation.flags new file mode 100644 index 0000000000..c6bfaf1f64 --- /dev/null +++ b/test/files/neg/beanInfoDeprecation.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings diff --git a/test/files/neg/beanInfoDeprecation.scala b/test/files/neg/beanInfoDeprecation.scala new file mode 100644 index 0000000000..c7e3a86202 --- /dev/null +++ b/test/files/neg/beanInfoDeprecation.scala @@ -0,0 +1,2 @@ +@scala.beans.BeanInfo +class C diff --git a/test/files/neg/deprecated-target.check b/test/files/neg/deprecated-target.check new file mode 100644 index 0000000000..307d3d25ab --- /dev/null +++ b/test/files/neg/deprecated-target.check @@ -0,0 +1,4 @@ +warning: -target is deprecated: -target:jvm-1.7 is deprecated, forcing use of jvm-1.8 +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/deprecated-target.flags b/test/files/neg/deprecated-target.flags new file mode 100644 index 0000000000..458ded8123 --- /dev/null +++ b/test/files/neg/deprecated-target.flags @@ -0,0 +1 @@ +-target:jvm-1.7 -deprecation -Xfatal-warnings diff --git a/test/files/neg/deprecated-target.scala b/test/files/neg/deprecated-target.scala new file mode 100644 index 0000000000..9dccdd5e59 --- /dev/null +++ b/test/files/neg/deprecated-target.scala @@ -0,0 +1 @@ +class C
\ No newline at end of file diff --git a/test/files/neg/logImplicits.check b/test/files/neg/logImplicits.check index 270882b71a..df7b359767 100644 --- a/test/files/neg/logImplicits.check +++ b/test/files/neg/logImplicits.check @@ -1,10 +1,10 @@ -logImplicits.scala:2: applied implicit conversion from xs.type to ?{def size: ?} = implicit def byteArrayOps(xs: Array[Byte]): scala.collection.mutable.ArrayOps[Byte] +logImplicits.scala:2: applied implicit conversion from xs.type to ?{def size: ?} = implicit def _byteArrayOps(xs: Array[Byte]): scala.collection.mutable.ArrayOps.ofByte def f(xs: Array[Byte]) = xs.size ^ logImplicits.scala:7: applied implicit conversion from String("abc") to ?{def map: ?} = implicit def augmentString(x: String): scala.collection.immutable.StringOps def f = "abc" map (_ + 1) ^ -logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String("abc"))Int +logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String)Int math.max(122, x: Int) ^ logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def ArrowAssoc[A](self: A): ArrowAssoc[A] diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index a43bf66811..8a6aafd67a 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -118,68 +118,74 @@ names-defaults-neg.scala:93: warning: the parameter name y has been deprecated. names-defaults-neg.scala:93: error: parameter 'b' is already specified at parameter position 1 deprNam3(y = 10, b = 2) ^ -names-defaults-neg.scala:98: error: unknown parameter name: m +names-defaults-neg.scala:96: warning: naming parameter deprNam4Arg has been deprecated. + deprNam4(deprNam4Arg = null) + ^ +names-defaults-neg.scala:98: warning: naming parameter deprNam5Arg has been deprecated. + deprNam5(deprNam5Arg = null) + ^ +names-defaults-neg.scala:102: error: unknown parameter name: m f3818(y = 1, m = 1) ^ -names-defaults-neg.scala:131: error: reference to var2 is ambiguous; it is both a method parameter and a variable in scope. +names-defaults-neg.scala:135: error: reference to var2 is ambiguous; it is both a method parameter and a variable in scope. delay(var2 = 40) ^ -names-defaults-neg.scala:134: error: missing parameter type for expanded function ((x$1) => a = x$1) +names-defaults-neg.scala:138: error: missing parameter type for expanded function ((x$1) => a = x$1) val taf2: Int => Unit = testAnnFun(a = _, b = get("+")) ^ -names-defaults-neg.scala:134: error: not found: value a +names-defaults-neg.scala:138: error: not found: value a val taf2: Int => Unit = testAnnFun(a = _, b = get("+")) ^ -names-defaults-neg.scala:134: error: not found: value get +names-defaults-neg.scala:138: error: not found: value get val taf2: Int => Unit = testAnnFun(a = _, b = get("+")) ^ -names-defaults-neg.scala:135: error: parameter 'a' is already specified at parameter position 1 +names-defaults-neg.scala:139: error: parameter 'a' is already specified at parameter position 1 val taf3 = testAnnFun(b = _: String, a = get(8)) ^ -names-defaults-neg.scala:136: error: missing parameter type for expanded function ((x$3) => testAnnFun(x$3, ((x$4) => b = x$4))) +names-defaults-neg.scala:140: error: missing parameter type for expanded function ((x$3) => testAnnFun(x$3, ((x$4) => b = x$4))) val taf4: (Int, String) => Unit = testAnnFun(_, b = _) ^ -names-defaults-neg.scala:136: error: missing parameter type for expanded function ((x$4) => b = x$4) +names-defaults-neg.scala:140: error: missing parameter type for expanded function ((x$4) => b = x$4) val taf4: (Int, String) => Unit = testAnnFun(_, b = _) ^ -names-defaults-neg.scala:136: error: not found: value b +names-defaults-neg.scala:140: error: not found: value b val taf4: (Int, String) => Unit = testAnnFun(_, b = _) ^ -names-defaults-neg.scala:144: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:148: error: variable definition needs type because 'x' is used as a named argument in its body. def t3 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:147: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:151: error: variable definition needs type because 'x' is used as a named argument in its body. object t6 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:147: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. +names-defaults-neg.scala:151: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. an explicit type is required for the definition mentioned in the error message above. object t6 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:150: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:154: error: variable definition needs type because 'x' is used as a named argument in its body. class t9 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:150: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. +names-defaults-neg.scala:154: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. an explicit type is required for the definition mentioned in the error message above. class t9 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:164: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:168: error: variable definition needs type because 'x' is used as a named argument in its body. def u3 { var x = u.f(x = 1) } ^ -names-defaults-neg.scala:167: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:171: error: variable definition needs type because 'x' is used as a named argument in its body. def u6 { var x = u.f(x = "32") } ^ -names-defaults-neg.scala:170: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. +names-defaults-neg.scala:174: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. def u9 { var x: Int = u.f(x = 1) } ^ -names-defaults-neg.scala:177: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:181: error: variable definition needs type because 'x' is used as a named argument in its body. class u15 { var x = u.f(x = 1) } ^ -names-defaults-neg.scala:177: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. +names-defaults-neg.scala:181: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. an explicit type is required for the definition mentioned in the error message above. class u15 { var x = u.f(x = 1) } ^ -names-defaults-neg.scala:180: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. +names-defaults-neg.scala:184: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. class u18 { var x: Int = u.f(x = 1) } ^ -four warnings found +6 warnings found 46 errors found diff --git a/test/files/neg/names-defaults-neg.scala b/test/files/neg/names-defaults-neg.scala index a97b590bf2..b326d3b5bd 100644 --- a/test/files/neg/names-defaults-neg.scala +++ b/test/files/neg/names-defaults-neg.scala @@ -92,6 +92,10 @@ object Test extends App { def deprNam3(@deprecatedName('x) a: Int, @deprecatedName('y) b: Int) = a + b deprNam3(y = 10, b = 2) + def deprNam4(@deprecatedName('deprNam4Arg) deprNam4Arg: String) = 0 + deprNam4(deprNam4Arg = null) + def deprNam5(@deprecatedName deprNam5Arg: String) = 0 + deprNam5(deprNam5Arg = null) // t3818 def f3818(x: Int = 1, y: Int, z: Int = 1) = 0 diff --git a/test/files/neg/t6289.check b/test/files/neg/t6289.check index 989932750f..7b2b4b2d32 100644 --- a/test/files/neg/t6289.check +++ b/test/files/neg/t6289.check @@ -1,9 +1,3 @@ -#partest java6 -t6289/J.java:2: method does not override or implement a method from a supertype - @Override public void foo() { } - ^ -1 error -#partest !java6 t6289/J.java:2: error: method does not override or implement a method from a supertype @Override public void foo() { } ^ diff --git a/test/files/neg/t8764.check b/test/files/neg/t8764.check deleted file mode 100644 index 6d89ebe106..0000000000 --- a/test/files/neg/t8764.check +++ /dev/null @@ -1,6 +0,0 @@ -t8764.scala:8: error: type mismatch; - found : AnyVal - required: Double - val d: Double = a.productElement(0) - ^ -one error found diff --git a/test/files/neg/t8764.flags b/test/files/neg/t8764.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/neg/t8764.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/neg/t8764.scala b/test/files/neg/t8764.scala deleted file mode 100644 index dc5bfb0160..0000000000 --- a/test/files/neg/t8764.scala +++ /dev/null @@ -1,9 +0,0 @@ -object Main { - - case class IntAndDouble(i: Int, d: Double) - - // a.productElement used to be Int => Double - // now: Int => AnyVal - val a = IntAndDouble(1, 5.0) - val d: Double = a.productElement(0) -} diff --git a/test/files/neg/t8849.check b/test/files/neg/t8849.check new file mode 100644 index 0000000000..15b00aee8b --- /dev/null +++ b/test/files/neg/t8849.check @@ -0,0 +1,7 @@ +t8849.scala:8: error: ambiguous implicit values: + both value global in object Implicits of type => scala.concurrent.ExecutionContext + and value dummy of type scala.concurrent.ExecutionContext + match expected type scala.concurrent.ExecutionContext + require(implicitly[ExecutionContext] eq dummy) + ^ +one error found diff --git a/test/files/neg/t8849.scala b/test/files/neg/t8849.scala new file mode 100644 index 0000000000..336f16b40f --- /dev/null +++ b/test/files/neg/t8849.scala @@ -0,0 +1,10 @@ +import scala.concurrent.ExecutionContext +import ExecutionContext.Implicits.global + +object Test { + def main(args: Array[String]): Unit = { + implicit val dummy: ExecutionContext = null + require(scala.concurrent.ExecutionContext.Implicits.global ne null) + require(implicitly[ExecutionContext] eq dummy) + } +}
\ No newline at end of file diff --git a/test/files/pos/MailBox.scala b/test/files/pos/MailBox.scala index 8e27bd362d..6bb25adb19 100644 --- a/test/files/pos/MailBox.scala +++ b/test/files/pos/MailBox.scala @@ -1,6 +1,6 @@ package test; -import scala.actors.TIMEOUT; +object TIMEOUT class MailBox { diff --git a/test/files/pos/alladin763.scala b/test/files/pos/alladin763.scala new file mode 100644 index 0000000000..29c9b25318 --- /dev/null +++ b/test/files/pos/alladin763.scala @@ -0,0 +1,37 @@ +// Test from http://lrytz.github.io/scala-aladdin-bugtracker/displayItem.do%3Fid=763.html +// and expanded with package object variants + + +trait Foo { type T; def apply() : T } +object e extends Foo { type T = Int; def apply() = 42 } + +package p { + trait T[X] { def O : { def apply(): X } } + object `package` extends T[Int] { + def O: { def apply(): Int } = new { def apply(): Int = 42 } + } + + object Test { + val x: Int = O() + } +} + +object Test { + + val f = new Foo { type T = Int; def apply() = 42 } + + def main(args: Array[String]): Unit = { + val g = new Foo { type T = Int; def apply() = 42 } + + (e: Foo)() + val ee: Int = e() + + (f: Foo)() + val ff: Int = f() + + (g: Foo)() + val gg: Int = g() + + val pp: Int = p.O() + } +} diff --git a/test/files/pos/functions.scala b/test/files/pos/functions.scala index 0207523dde..25d1c46eac 100644 --- a/test/files/pos/functions.scala +++ b/test/files/pos/functions.scala @@ -1,4 +1,6 @@ -import scala.actors.Actor +object Actor { + def receive[A](f: PartialFunction[Any, A]): A = ??? +} object Test { diff --git a/test/files/pos/t533.scala b/test/files/pos/t533.scala deleted file mode 100644 index 0a6515fed3..0000000000 --- a/test/files/pos/t533.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.actors._ - -object test extends Actor { - def act() { - receive { - case TIMEOUT => Console.println("TIMEOUT") - //case _ => Console.println("_") - } - } -} - diff --git a/test/files/pos/t6778.scala b/test/files/pos/t6778.scala new file mode 100644 index 0000000000..b7483c8fce --- /dev/null +++ b/test/files/pos/t6778.scala @@ -0,0 +1,5 @@ +object test extends AnyRef with App { + // Check that random can be called with parenthesis. + scala.math.random() +} + diff --git a/test/files/pos/t7784.scala b/test/files/pos/t7784.scala new file mode 100644 index 0000000000..e6824a4203 --- /dev/null +++ b/test/files/pos/t7784.scala @@ -0,0 +1,13 @@ +object Test { + final val a = "" + var b: a.type = a + b = a + + final val x = classOf[Object] + var y: x.type = x + y = x + + final val e = Thread.State.NEW + var e1: e.type = e + e1 = e +} diff --git a/test/files/pos/t8462.scala b/test/files/pos/t8462.scala new file mode 100644 index 0000000000..6946cf8e5e --- /dev/null +++ b/test/files/pos/t8462.scala @@ -0,0 +1,11 @@ + +trait ConstantOps { + def exprs = ( + 1 << 2L : Int, // was: error: type mismatch; found : Long(4L) + 64 >> 2L : Int, // was: error: type mismatch; found : Long(4L) + 64 >>> 2L : Int, // was: error: type mismatch; found : Long(4L) + 'a' << 2L : Int, + 'a' >> 2L : Int, + 'a'>>> 2L : Int + ) +} diff --git a/test/files/pos/t8862a.scala b/test/files/pos/t8862a.scala new file mode 100644 index 0000000000..f9576707ba --- /dev/null +++ b/test/files/pos/t8862a.scala @@ -0,0 +1,47 @@ +package p { + + abstract class C[A] { + def x: A + implicit def oops: A = x + implicit def oopso: Option[A] = None + } + + package q { + + class Oops + + object `package` extends C[Oops] { + override def x = new Oops + } + + object Blah { + oops + oopso + + // implicits found in enclosing context + implicitly[Oops] + implicitly[Option[Oops]] + } + } +} + +package other { + + object Blah { + // implicits found through this import + import p.q._ + + oops + oopso + + implicitly[Oops] + implicitly[Option[Oops]] + } + + + object Blee { + // implicits found through the companion implicits + implicitly[p.q.Oops] + implicitly[Option[p.q.Oops]] + } +} diff --git a/test/files/pos/t8862b.scala b/test/files/pos/t8862b.scala new file mode 100644 index 0000000000..8be7fb5fab --- /dev/null +++ b/test/files/pos/t8862b.scala @@ -0,0 +1,12 @@ +package p { + trait T[X] { def O : { def apply(): X } } + object `package` extends T[Int] { + def O: { def apply(): Int } = new { def apply(): Int = 42 } + } + + object Test { + def main(args: Array[String]): Unit = { + val x: Int = O() + } + } +} diff --git a/test/files/pos/t9074.scala b/test/files/pos/t9074.scala new file mode 100644 index 0000000000..67db281f54 --- /dev/null +++ b/test/files/pos/t9074.scala @@ -0,0 +1,24 @@ +package blam { + + package foo { + + trait F[T] { + def f(d: Double, t: T): T = ??? + def f(d: Int, t: T): T = ??? + def f(d: String, t: T): T = ??? + + def g[A](a: T): T = ??? + def g(a: Int) = ??? + } + } + + package object foo extends foo.F[Double] { + override def f(d: Double, t: Double): Double = ??? + } +} + +object Test { + import blam._ + foo.f("3", 4.0) + foo.g[Any](1d) : Double +} diff --git a/test/files/pos/t9074b.scala b/test/files/pos/t9074b.scala new file mode 100644 index 0000000000..dadcebf399 --- /dev/null +++ b/test/files/pos/t9074b.scala @@ -0,0 +1,15 @@ +trait Echo [T] { + def echo(t: T): Unit +} + +trait IntEcho extends Echo[Int] { + def echo(t: Int) = println(t) +} + +object echo extends IntEcho +package object echo1 extends IntEcho + +object App extends App { + echo.echo(1) + echo1.echo(1) +} diff --git a/test/files/pos/t9131.scala b/test/files/pos/t9131.scala new file mode 100644 index 0000000000..1a186a0a24 --- /dev/null +++ b/test/files/pos/t9131.scala @@ -0,0 +1,12 @@ +class Test { + + def byNameFunc(f: (=> (() => Any)) => Any): Unit = () + + def test = { + // "value apply is not a member of => () => Any" + byNameFunc(z => z()) + // okay + byNameFunc(z => z.apply()) + byNameFunc(z => {val f = z; f()}) + } +} diff --git a/test/files/pos/t9326a.scala b/test/files/pos/t9326a.scala new file mode 100644 index 0000000000..aefc735585 --- /dev/null +++ b/test/files/pos/t9326a.scala @@ -0,0 +1,6 @@ +package p + +trait M[A] + +class C extends M[Tuple1[X] forSome { type X }] + diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check index 9803465ddc..1bb7c6ceab 100644 --- a/test/files/run/analyzerPlugins.check +++ b/test/files/run/analyzerPlugins.check @@ -19,7 +19,7 @@ canAdaptAnnotations(Trees$Typed, Any) [1] canAdaptAnnotations(Trees$Typed, Int) [1] lub(List(Int @testAnn, Int)) [1] pluginsPt(?, Trees$Annotated) [7] -pluginsPt(?, Trees$Apply) [8] +pluginsPt(?, Trees$Apply) [11] pluginsPt(?, Trees$ApplyImplicitView) [2] pluginsPt(?, Trees$Assign) [7] pluginsPt(?, Trees$Block) [4] @@ -31,7 +31,7 @@ pluginsPt(?, Trees$Literal) [16] pluginsPt(?, Trees$New) [5] pluginsPt(?, Trees$PackageDef) [1] pluginsPt(?, Trees$Return) [1] -pluginsPt(?, Trees$Select) [47] +pluginsPt(?, Trees$Select) [50] pluginsPt(?, Trees$Super) [2] pluginsPt(?, Trees$This) [20] pluginsPt(?, Trees$TypeApply) [3] @@ -93,6 +93,7 @@ pluginsTypeSigAccessor(value x) [1] pluginsTypeSigAccessor(value y) [1] pluginsTypeSigAccessor(variable count) [2] pluginsTyped( <: Int, Trees$TypeBoundsTree) [2] +pluginsTyped(()Double, Trees$Select) [6] pluginsTyped(()Object, Trees$Select) [1] pluginsTyped(()String, Trees$Ident) [1] pluginsTyped(()String, Trees$TypeApply) [1] @@ -112,7 +113,7 @@ pluginsTyped(<notype>, Trees$PackageDef) [1] pluginsTyped(<notype>, Trees$TypeDef) [1] pluginsTyped(<notype>, Trees$ValDef) [21] pluginsTyped(=> Boolean @testAnn, Trees$Select) [1] -pluginsTyped(=> Double, Trees$Select) [4] +pluginsTyped(=> Double, Trees$Select) [1] pluginsTyped(=> Int, Trees$Select) [5] pluginsTyped(=> Int, Trees$TypeApply) [1] pluginsTyped(=> String @testAnn, Trees$Select) [1] @@ -131,6 +132,7 @@ pluginsTyped(Boolean(false), Trees$Literal) [2] pluginsTyped(Boolean, Trees$Apply) [1] pluginsTyped(Boolean, Trees$Select) [4] pluginsTyped(Char('c'), Trees$Literal) [2] +pluginsTyped(Double, Trees$Apply) [3] pluginsTyped(Double, Trees$Select) [6] pluginsTyped(Int @testAnn, Trees$TypeTree) [2] pluginsTyped(Int @testAnn, Trees$Typed) [2] diff --git a/test/files/run/classfile-format-51.scala b/test/files/run/classfile-format-51.scala index 7523130afa..da322bb5d9 100644 --- a/test/files/run/classfile-format-51.scala +++ b/test/files/run/classfile-format-51.scala @@ -1,6 +1,5 @@ import java.io.{File, FileOutputStream} -import scala.tools.nsc.settings.ScalaVersion import scala.tools.partest._ import scala.tools.asm import asm.{AnnotationVisitor, ClassWriter, FieldVisitor, Handle, MethodVisitor, Opcodes} diff --git a/test/files/run/classfile-format-52.scala b/test/files/run/classfile-format-52.scala index 453f61ac84..e278d40b8b 100644 --- a/test/files/run/classfile-format-52.scala +++ b/test/files/run/classfile-format-52.scala @@ -1,6 +1,5 @@ import java.io.{File, FileOutputStream} -import scala.tools.nsc.settings.ScalaVersion import scala.tools.partest._ import scala.tools.asm import asm.{AnnotationVisitor, ClassWriter, FieldVisitor, Handle, MethodVisitor, Opcodes} diff --git a/test/files/run/concurrent-stream.check b/test/files/run/concurrent-stream.check deleted file mode 100644 index d4adf84490..0000000000 --- a/test/files/run/concurrent-stream.check +++ /dev/null @@ -1,3 +0,0 @@ -Testing standard cons. -Evaluation 0: List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) -Evaluation 1: List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) diff --git a/test/files/run/concurrent-stream.scala b/test/files/run/concurrent-stream.scala deleted file mode 100644 index 9d5ba0428e..0000000000 --- a/test/files/run/concurrent-stream.scala +++ /dev/null @@ -1,37 +0,0 @@ -// test concurrent calls to Stream.tail -@deprecated("Suppress warnings", since="2.11") -object Test { - - def slowRange(from: Int, until: Int, cons: (Int, => Stream[Int]) => Stream[Int]): Stream[Int] = { - var current = from - def next: Stream[Int] = { - Thread.sleep(100) - if (current >= until) Stream.empty - else { - val stream = cons(current, next) - current += 1 - stream - } - } - next - } - - def testCons(cons: (Int, => Stream[Int]) => Stream[Int]): Unit = { - import scala.actors.Actor._ - - val stream = slowRange(0, 10, cons) - val main = self - actor { main ! stream.toList } - actor { main ! stream.toList } - val eval0 = receive { case list: List[Int @unchecked] => list } - val eval1 = receive { case list: List[Int @unchecked] => list } - println("Evaluation 0: " + eval0) - println("Evaluation 1: " + eval1) - } - - def main(args: Array[String]) { - println("Testing standard cons.") - testCons(Stream.cons.apply(_, _)) - } -} - diff --git a/test/files/run/duration-coarsest.scala b/test/files/run/duration-coarsest.scala index 51cb79287a..81fbb3cc84 100644 --- a/test/files/run/duration-coarsest.scala +++ b/test/files/run/duration-coarsest.scala @@ -25,4 +25,7 @@ object Test extends App { 23 hours, 40 days ) foreach (x => assert(x == x.toCoarsest, x)) -}
\ No newline at end of file + + // toCoarsest on a FiniteDuration should return a FiniteDuration + val finite: FiniteDuration = 1.second.toCoarsest +} diff --git a/test/files/run/future-flatmap-exec-count.check b/test/files/run/future-flatmap-exec-count.check index dd9dce64ed..7065c133e0 100644 --- a/test/files/run/future-flatmap-exec-count.check +++ b/test/files/run/future-flatmap-exec-count.check @@ -1,3 +1,4 @@ +warning: there was one deprecation warning; re-run with -deprecation for details mapping execute() flatmapping diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check index 7c885d2cc9..27a277d314 100644 --- a/test/files/run/inline-ex-handlers.check +++ b/test/files/run/inline-ex-handlers.check @@ -123,12 +123,12 @@ 300 RETURN(UNIT) @@ -583,6 +603,6 @@ with finalizer: null -- catch (Throwable) in ArrayBuffer(7, 9, 10) starting at: 6 -+ catch (Throwable) in ArrayBuffer(7, 9, 10, 11) starting at: 6 +- catch (Throwable) in Vector(7, 9, 10) starting at: 6 ++ catch (Throwable) in Vector(7, 9, 10, 11) starting at: 6 consisting of blocks: List(6) with finalizer: null -- catch (Throwable) in ArrayBuffer(4, 6, 7, 9, 10) starting at: 3 -+ catch (Throwable) in ArrayBuffer(4, 6, 7, 9, 10, 11, 12) starting at: 3 +- catch (Throwable) in Vector(4, 6, 7, 9, 10) starting at: 3 ++ catch (Throwable) in Vector(4, 6, 7, 9, 10, 11, 12) starting at: 3 consisting of blocks: List(3) @@ -618,3 +638,3 @@ startBlock: 1 @@ -171,8 +171,8 @@ } @@ -690,3 +730,3 @@ with finalizer: null -- catch (<none>) in ArrayBuffer(4, 5, 6, 8) starting at: 3 -+ catch (<none>) in ArrayBuffer(4, 5, 6, 8, 10) starting at: 3 +- catch (<none>) in Vector(4, 5, 6, 8) starting at: 3 ++ catch (<none>) in Vector(4, 5, 6, 8, 10) starting at: 3 consisting of blocks: List(3) @@ -714,5 +754,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { @@ -276,12 +276,12 @@ } @@ -852,6 +918,6 @@ with finalizer: null -- catch (Throwable) in ArrayBuffer(13, 14, 15, 18, 20, 21, 23) starting at: 4 -+ catch (Throwable) in ArrayBuffer(13, 14, 15, 18, 20, 21, 23, 25) starting at: 4 +- catch (Throwable) in Vector(13, 14, 15, 18, 20, 21, 23) starting at: 4 ++ catch (Throwable) in Vector(13, 14, 15, 18, 20, 21, 23, 25) starting at: 4 consisting of blocks: List(9, 8, 6, 5, 4) with finalizer: null -- catch (<none>) in ArrayBuffer(4, 5, 6, 9, 13, 14, 15, 18, 20, 21, 23) starting at: 3 -+ catch (<none>) in ArrayBuffer(4, 5, 6, 9, 13, 14, 15, 18, 20, 21, 23, 25, 26) starting at: 3 +- catch (<none>) in Vector(4, 5, 6, 9, 13, 14, 15, 18, 20, 21, 23) starting at: 3 ++ catch (<none>) in Vector(4, 5, 6, 9, 13, 14, 15, 18, 20, 21, 23, 25, 26) starting at: 3 consisting of blocks: List(3) @@ -879,5 +945,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { @@ -317,8 +317,8 @@ 127 CALL_METHOD scala.Predef.println (dynamic) @@ -964,3 +1034,3 @@ with finalizer: null -- catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 13, 14, 16) starting at: 3 -+ catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 13, 14, 16, 17) starting at: 3 +- catch (IllegalArgumentException) in Vector(6, 7, 8, 11, 13, 14, 16) starting at: 3 ++ catch (IllegalArgumentException) in Vector(6, 7, 8, 11, 13, 14, 16, 17) starting at: 3 consisting of blocks: List(3) @@ -988,5 +1058,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { diff --git a/test/files/run/lub-visibility.check b/test/files/run/lub-visibility.check index 70734966f0..135cb3cb76 100644 --- a/test/files/run/lub-visibility.check +++ b/test/files/run/lub-visibility.check @@ -6,6 +6,6 @@ scala> // should infer List[scala.collection.immutable.Seq[Nothing]] scala> // but reverted that for SI-5534. scala> val x = List(List(), Vector()) -x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing] with java.io.Serializable] = List(List(), Vector()) +x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing] with Serializable] = List(List(), Vector()) scala> :quit diff --git a/test/files/run/nothingTypeDce.flags b/test/files/run/nothingTypeDce.flags index d85321ca0e..fde52cc7df 100644 --- a/test/files/run/nothingTypeDce.flags +++ b/test/files/run/nothingTypeDce.flags @@ -1 +1 @@ --target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code +-Ybackend:GenBCode -Yopt:unreachable-code diff --git a/test/files/run/nothingTypeDce.scala b/test/files/run/nothingTypeDce.scala index 5f3692fd33..92d3ca6f89 100644 --- a/test/files/run/nothingTypeDce.scala +++ b/test/files/run/nothingTypeDce.scala @@ -1,7 +1,6 @@ // See comment in BCodeBodyBuilder -// -target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code -// target enables stack map frames generation +// -Ybackend:GenBCode -Yopt:unreachable-code class C { // can't just emit a call to ???, that returns value of type Nothing$ (not Int). diff --git a/test/files/run/nothingTypeNoFramesNoDce.check b/test/files/run/nothingTypeNoFramesNoDce.check deleted file mode 100644 index b1d08b45ff..0000000000 --- a/test/files/run/nothingTypeNoFramesNoDce.check +++ /dev/null @@ -1 +0,0 @@ -warning: -target:jvm-1.5 is deprecated: use target for Java 1.6 or above. diff --git a/test/files/run/nothingTypeNoFramesNoDce.flags b/test/files/run/nothingTypeNoFramesNoDce.flags deleted file mode 100644 index a035c86179..0000000000 --- a/test/files/run/nothingTypeNoFramesNoDce.flags +++ /dev/null @@ -1 +0,0 @@ --target:jvm-1.5 -Ybackend:GenBCode -Yopt:l:none -deprecation diff --git a/test/files/run/nothingTypeNoFramesNoDce.scala b/test/files/run/nothingTypeNoFramesNoDce.scala deleted file mode 100644 index 3d1298303a..0000000000 --- a/test/files/run/nothingTypeNoFramesNoDce.scala +++ /dev/null @@ -1,61 +0,0 @@ -// See comment in BCodeBodyBuilder - -// -target:jvm-1.5 -Ybackend:GenBCode -Yopt:l:none -// target disables stack map frame generation. in this mode, the ClssWriter just emits dead code as is. - -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 App { - new C() -} diff --git a/test/files/run/nothingTypeNoOpt.flags b/test/files/run/nothingTypeNoOpt.flags index b3b518051b..d3e4d61e19 100644 --- a/test/files/run/nothingTypeNoOpt.flags +++ b/test/files/run/nothingTypeNoOpt.flags @@ -1 +1 @@ --target:jvm-1.6 -Ybackend:GenBCode -Yopt:l:none +-Ybackend:GenBCode -Yopt:l:none diff --git a/test/files/run/repl-javap-app.check b/test/files/run/repl-javap-app.check deleted file mode 100644 index eb3718f44b..0000000000 --- a/test/files/run/repl-javap-app.check +++ /dev/null @@ -1,63 +0,0 @@ -#partest java6 -Welcome to Scala -Type in expressions to have them evaluated. -Type :help for more information. - -scala> :javap -app MyApp$ -public final void delayedEndpoint$MyApp$1(); - Code: - Stack=2, Locals=1, Args_size=1 - 0: getstatic #XX; //Field scala/Console$.MODULE$:Lscala/Console$; - 3: ldc #XX; //String Hello, delayed world. - 5: invokevirtual #XX; //Method scala/Console$.println:(Ljava/lang/Object;)V - 8: return - LocalVariableTable: - Start Length Slot Name Signature - 0 9 0 this LMyApp$; - -scala> :quit -#partest java7 -Welcome to Scala -Type in expressions to have them evaluated. -Type :help for more information. - -scala> :javap -app MyApp$ - public final void delayedEndpoint$MyApp$1(); - flags: ACC_PUBLIC, ACC_FINAL - Code: - stack=2, locals=1, args_size=1 - 0: getstatic #XX // Field scala/Console$.MODULE$:Lscala/Console$; - 3: ldc #XX // String Hello, delayed world. - 5: invokevirtual #XX // Method scala/Console$.println:(Ljava/lang/Object;)V - 8: return - LocalVariableTable: - Start Length Slot Name Signature - 0 9 0 this LMyApp$; - LineNumberTable: - line 5: 0 -} - -scala> :quit -#partest java8 -Welcome to Scala -Type in expressions to have them evaluated. -Type :help for more information. - -scala> :javap -app MyApp$ - public final void delayedEndpoint$MyApp$1(); - descriptor: ()V - flags: ACC_PUBLIC, ACC_FINAL - Code: - stack=2, locals=1, args_size=1 - 0: getstatic #XX // Field scala/Console$.MODULE$:Lscala/Console$; - 3: ldc #XX // String Hello, delayed world. - 5: invokevirtual #XX // Method scala/Console$.println:(Ljava/lang/Object;)V - 8: return - LocalVariableTable: - Start Length Slot Name Signature - 0 9 0 this LMyApp$; - LineNumberTable: - line 5: 0 -} - -scala> :quit diff --git a/test/files/run/repl-javap-app.scala b/test/files/run/repl-javap-app.scala deleted file mode 100644 index ad6076c2d5..0000000000 --- a/test/files/run/repl-javap-app.scala +++ /dev/null @@ -1,21 +0,0 @@ - -import scala.tools.partest.ReplTest - -object MyApp extends App { - Console println "Hello, delayed world." -} - -object Test extends ReplTest { - def code = ":javap -app MyApp$" - - override def welcoming = true - - // The constant pool indices are not the same for GenASM / GenBCode, so - // replacing the exact numbers by XX. - lazy val hasConstantPoolRef = """(.*)(#\d\d)(.*)""".r - - override def normalize(s: String) = s match { - case hasConstantPoolRef(start, ref, end) => start + "#XX" + end - case _ => super.normalize(s) - } -} diff --git a/test/files/run/t2251b.check b/test/files/run/t2251b.check index 4231fc6ea6..b60698d605 100644 --- a/test/files/run/t2251b.check +++ b/test/files/run/t2251b.check @@ -1,4 +1,4 @@ -TypeTag[List[scala.collection.immutable.LinearSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with java.io.Serializable]] +TypeTag[List[scala.collection.immutable.LinearSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with Serializable]] TypeTag[List[scala.collection.immutable.Iterable[B[_ >: F with E with D with C <: B[_ >: F with E with D with C <: A]]] with F with Int => Any]] TypeTag[List[scala.collection.immutable.Seq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with Serializable]] TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] @@ -6,6 +6,6 @@ TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G w TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] TypeTag[List[scala.collection.Map[_ >: F with C <: B[_ >: F with C <: B[_ >: F with C <: A]], B[_ >: G with D <: B[_ >: G with D <: A]]]]] -TypeTag[List[scala.collection.AbstractSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with scala.collection.LinearSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with java.io.Serializable]] +TypeTag[List[scala.collection.AbstractSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with scala.collection.LinearSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with Serializable]] TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] diff --git a/test/files/run/t4332.scala b/test/files/run/t4332.scala index 5a67922911..1c7e7d73de 100644 --- a/test/files/run/t4332.scala +++ b/test/files/run/t4332.scala @@ -12,7 +12,7 @@ object Test extends DirectTest { } def isExempt(sym: Symbol) = { - val exempt = Set("view", "repr", "sliceWithKnownDelta", "sliceWithKnownBound", "transform") + val exempt = Set("view", "repr", "sliceWithKnownDelta", "sliceWithKnownBound", "transform", "filterImpl") (exempt contains sym.name.decoded) } diff --git a/test/files/run/t6827.check b/test/files/run/t6827.check index 3a3a71c67d..4889e05be8 100644 --- a/test/files/run/t6827.check +++ b/test/files/run/t6827.check @@ -1,6 +1,6 @@ -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 -5: java.lang.ArrayIndexOutOfBoundsException: -5 +start at -1: java.lang.ArrayIndexOutOfBoundsException: -1 +start at limit: ok start at limit-1: ok first 10: ok read all: ok @@ -8,8 +8,8 @@ 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 +start beyond limit: ok 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 +invalid read 0: ok +invalid read -1: ok diff --git a/test/files/run/t6827.scala b/test/files/run/t6827.scala index 8e17af09e2..eb020711bb 100644 --- a/test/files/run/t6827.scala +++ b/test/files/run/t6827.scala @@ -31,4 +31,24 @@ object Test extends App { // okay, see SI-7128 "...".toIterator.copyToArray(new Array[Char](0), 0, 0) + + + // Bonus test from @som-snytt to check for overflow in + // index calculations. + def testOverflow(start: Int, len: Int, expected: List[Char]) { + def copyFromIterator = { + val arr = Array.fill[Char](3)('-') + "abc".toIterator.copyToArray(arr, start, len) + arr.toList + } + def copyFromArray = { + val arr = Array.fill[Char](3)('-') + "abc".toArray.copyToArray(arr, start, len) + arr.toList + } + assert(copyFromIterator == expected) + assert(copyFromArray == expected) + } + testOverflow(1, Int.MaxValue - 1, "-ab".toList) + testOverflow(1, Int.MaxValue, "-ab".toList) } diff --git a/test/files/run/t7521/Test.scala b/test/files/run/t7521/Test.scala new file mode 100644 index 0000000000..e9816ad6cb --- /dev/null +++ b/test/files/run/t7521/Test.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + new Wrapper(new Array[Int](1)) + } +} diff --git a/test/files/run/t7521/Wrapper.scala b/test/files/run/t7521/Wrapper.scala new file mode 100644 index 0000000000..0b923f8924 --- /dev/null +++ b/test/files/run/t7521/Wrapper.scala @@ -0,0 +1 @@ +class Wrapper[Repr](val xs: Repr) extends AnyVal diff --git a/test/files/run/t7521b.check b/test/files/run/t7521b.check new file mode 100644 index 0000000000..4d96df106d --- /dev/null +++ b/test/files/run/t7521b.check @@ -0,0 +1,7 @@ += Java Erased Signatures = +public int C.a(Wrapper) +public int C.b(Wrapper) + += Java Generic Signatures = +public int C.a(Wrapper<int[]>) +public int C.b(Wrapper<java.lang.Object>) diff --git a/test/files/run/t7521b.scala b/test/files/run/t7521b.scala new file mode 100644 index 0000000000..c9e27f28b4 --- /dev/null +++ b/test/files/run/t7521b.scala @@ -0,0 +1,20 @@ +class Wrapper[X](x: X) + +class C { + def a(w: Wrapper[Array[Int]]) = 0 + def b(w: Wrapper[Int]) = 0 +} + +object Test { + def main(args: Array[String]): Unit = { + val c = new C + c.a(new Wrapper(Array(1, 2))) + c.b(new Wrapper(1)) + + val methods = classOf[C].getDeclaredMethods.sortBy(_.getName) + println("= Java Erased Signatures =") + println(methods.mkString("\n")) + println("\n= Java Generic Signatures =") + println(methods.map(_.toGenericString).mkString("\n")) + } +} diff --git a/test/files/run/t7775.scala b/test/files/run/t7775.scala index 48b0d89974..bc69064e17 100644 --- a/test/files/run/t7775.scala +++ b/test/files/run/t7775.scala @@ -1,3 +1,45 @@ +import scala.concurrent._, duration._ +import ExecutionContext.Implicits.global +import scala.tools.reflect.WrappedProperties.AccessControl._ +import java.util.concurrent.CyclicBarrier + +object Test extends App { + @volatile var done = false + val barrier = new CyclicBarrier(2) + + val probe = Future { + val attempts = 1024 // previously, failed after a few + def fail(i: Int) = s"Failed at $i" + barrier.await() + for (i <- 1 to attempts ; p <- systemProperties) + p match { case (k, v) => assert (k != null && v != null, fail(i)) } + } + probe onComplete { + case _ => done = true + } + + System.setProperty("foo", "fooz") + System.setProperty("bar", "barz") + barrier.await() // just for fun, wait to start mucking with properties + + // continually modify properties trying to break live iteration over sys props + // hint: don't iterate lively over sys props + var alt = true + while (!done) { + if (alt) { + System.getProperties.remove("foo") + System.setProperty("bar", "barz") + alt = false + } else { + System.getProperties.remove("bar") + System.setProperty("foo", "fooz") + alt = true + } + } + Await.result(probe, Duration.Inf) +} + +/* import scala.concurrent.{duration, Future, Await, ExecutionContext} import scala.tools.nsc.Settings import ExecutionContext.Implicits.global @@ -15,3 +57,4 @@ object Test { Await.result(compiler, duration.Duration.Inf) } } +*/ diff --git a/test/files/run/t8575.scala b/test/files/run/t8575.scala new file mode 100644 index 0000000000..fb8f603f3e --- /dev/null +++ b/test/files/run/t8575.scala @@ -0,0 +1,32 @@ +class E[F] +class A +class B +class C + +trait TypeMember { + type X + + // This call throws an AbstractMethodError, because it invokes the erasure of + // consume(X): Unit that is consume(Object): Unit. But the corresponding + // bridge method is not generated. + consume(value) + + def value: X + def consume(x: X): Unit +} + +object Test extends TypeMember { + type F = A with B + + // works if replaced by type X = E[A with B with C] + type X = E[F with C] + + def value = new E[F with C] + + // This call passes, since it invokes consume(E): Unit + def consume(x: X) {} + + def main(args: Array[String]) { + consume(value) + } +} diff --git a/test/files/run/t8575b.scala b/test/files/run/t8575b.scala new file mode 100644 index 0000000000..0d731ccf9f --- /dev/null +++ b/test/files/run/t8575b.scala @@ -0,0 +1,17 @@ +class A +class B +class C + +object Test { + type F = A with B + + def main(args: Array[String]) { + import reflect.runtime.universe._ + val t1 = typeOf[F with C] + val t2 = typeOf[(A with B) with C] + val t3 = typeOf[A with B with C] + assert(t1 =:= t2) + assert(t2 =:= t3) + assert(t3 =:= t1) + } +} diff --git a/test/files/run/t8575c.scala b/test/files/run/t8575c.scala new file mode 100644 index 0000000000..8219952299 --- /dev/null +++ b/test/files/run/t8575c.scala @@ -0,0 +1,23 @@ +class C + +trait TypeMember { + type X + type Y + type Z +} + +object Test extends TypeMember { + type A = X with Y + type B = Z with A + type F = A with B + + def main(args: Array[String]) { + import reflect.runtime.universe._ + val t1 = typeOf[F with C] + val t2 = typeOf[(A with B) with C] + val t3 = typeOf[A with B with C] + assert(t1 =:= t2) + assert(t2 =:= t3) + assert(t3 =:= t1) + } +} diff --git a/test/files/run/t8710.scala b/test/files/run/t8710.scala new file mode 100644 index 0000000000..15aab5b8a4 --- /dev/null +++ b/test/files/run/t8710.scala @@ -0,0 +1,17 @@ +class Bar(val x: Int) extends AnyVal { + def f: String = f(0) + private def f(x: Int): String = "" +} + +class Baz(val x: Int) extends AnyVal { + def f: String = "123" + private def f(x: Int): String = "" +} +object Baz { + def x(b: Baz) = b.f(0) +} + +object Test extends App { + new Bar(23).f + new Baz(23).f +} diff --git a/test/files/run/t8764.check b/test/files/run/t8764.check deleted file mode 100644 index 6260069602..0000000000 --- a/test/files/run/t8764.check +++ /dev/null @@ -1,5 +0,0 @@ -IntOnly: should return an unboxed int -Int: int -IntAndDouble: should just box and return Anyval -Double: class java.lang.Double -Int: class java.lang.Integer diff --git a/test/files/run/t8764.flags b/test/files/run/t8764.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/run/t8764.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/t8764.scala b/test/files/run/t8764.scala deleted file mode 100644 index decc658f6e..0000000000 --- a/test/files/run/t8764.scala +++ /dev/null @@ -1,16 +0,0 @@ -object Test extends App { -case class IntOnly(i: Int, j: Int) - -println("IntOnly: should return an unboxed int") -val a = IntOnly(1, 2) -val i: Int = a.productElement(0) -println(s"Int: ${a.productElement(0).getClass}") - -case class IntAndDouble(i: Int, d: Double) - -println("IntAndDouble: should just box and return Anyval") -val b = IntAndDouble(1, 2.0) -val j: AnyVal = b.productElement(0) -println(s"Double: ${b.productElement(1).getClass}") -println(s"Int: ${b.productElement(0).getClass}") -} diff --git a/test/files/run/t8918-unary-ids.scala b/test/files/run/t8918-unary-ids.scala new file mode 100644 index 0000000000..3aa990f72c --- /dev/null +++ b/test/files/run/t8918-unary-ids.scala @@ -0,0 +1,49 @@ + + +import scala.tools.partest.SessionTest + +// Taking unary ids as plain +object Test extends SessionTest { + def session = +"""Type in expressions to have them evaluated. +Type :help for more information. + +scala> val - = 42 +-: Int = 42 + +scala> val i = - +i: Int = 42 + +scala> - { 42 } +res0: Int = -42 + +scala> - if (true) 1 else 2 +<console>:1: error: illegal start of simple expression +- if (true) 1 else 2 + ^ + +scala> - - 1 +<console>:1: error: ';' expected but integer literal found. +- - 1 + ^ + +scala> -.-(1) +res1: Int = 41 + +scala> - +res2: Int = 42 + +scala> - - +res3: Int = -42 + +scala> + - +res4: Int = 42 + +scala> object X { def -(i: Int) = 42 - i ; def f(g: Int => Int) = g(7) ; def j = f(-) } +defined object X + +scala> X.j +res5: Int = 35 + +scala> :quit""" +} diff --git a/test/files/run/t8944/A_1.scala b/test/files/run/t8944/A_1.scala new file mode 100644 index 0000000000..7ff80327b0 --- /dev/null +++ b/test/files/run/t8944/A_1.scala @@ -0,0 +1 @@ +case class A(private val x: String) diff --git a/test/files/run/t8944/A_2.scala b/test/files/run/t8944/A_2.scala new file mode 100644 index 0000000000..3dcdea1583 --- /dev/null +++ b/test/files/run/t8944/A_2.scala @@ -0,0 +1,6 @@ +case class Other(private val x: String) // consume a fresh name suffix + +// the param accessor will now be called "x$2", +// whereas the previously compiled client expects it to be called +// x$1 +case class A(private val x: String) diff --git a/test/files/run/t8944/Test_1.scala b/test/files/run/t8944/Test_1.scala new file mode 100644 index 0000000000..fe466693cf --- /dev/null +++ b/test/files/run/t8944/Test_1.scala @@ -0,0 +1,3 @@ +object Test extends App { + val A("") = new A("") +} diff --git a/test/files/run/t8944b.scala b/test/files/run/t8944b.scala new file mode 100644 index 0000000000..f469122ce6 --- /dev/null +++ b/test/files/run/t8944b.scala @@ -0,0 +1,9 @@ +case class A(private var foo: Any) { + def m = { def foo = 42 /*will be lamba lifted to `A#foo$1`*/ } +} +object Test { + def main(args: Array[String]): Unit = { + val A("") = new A("") + new A("").m + } +} diff --git a/test/files/run/t8944c.check b/test/files/run/t8944c.check new file mode 100644 index 0000000000..7738f76980 --- /dev/null +++ b/test/files/run/t8944c.check @@ -0,0 +1,5 @@ +private java.lang.Object Foo.ant() +public java.lang.Object Foo.ant$access$0() +private scala.collection.Seq Foo.cat() +public scala.collection.Seq Foo.cat$access$2() +public java.lang.Object Foo.elk() diff --git a/test/files/run/t8944c.scala b/test/files/run/t8944c.scala new file mode 100644 index 0000000000..95c2143851 --- /dev/null +++ b/test/files/run/t8944c.scala @@ -0,0 +1,8 @@ +case class Foo[A](private val ant: Any, elk: Any, private val cat: A*) + +object Test { + def main(args: Array[String]): Unit = { + def pred(name: String) = Set("ant", "elk", "cat").exists(name contains _) + println(classOf[Foo[_]].getDeclaredMethods.filter(m => pred(m.getName)).sortBy(_.getName).mkString("\n")) + } +} diff --git a/test/files/run/t8955.scala b/test/files/run/t8955.scala new file mode 100644 index 0000000000..afa31aa5d7 --- /dev/null +++ b/test/files/run/t8955.scala @@ -0,0 +1,12 @@ +import scala.collection.parallel.immutable.ParSet + +object Test { + def main(args: Array[String]): Unit = { + for (i <- 1 to 2000) test() + } + + def test() { + ParSet[Int]((1 to 10000): _*) foreach (x => ()) // hangs non deterministically + } +} + diff --git a/test/files/run/t9174.check b/test/files/run/t9174.check new file mode 100644 index 0000000000..9320a081ff --- /dev/null +++ b/test/files/run/t9174.check @@ -0,0 +1,19 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> import scala.util.{Success, Failure} +import scala.util.{Success, Failure} + +scala> def f1(b: Boolean) = if (b) Left(1) else Right(2) +f1: (b: Boolean)scala.util.Either[Int,Int] + +scala> def f2(b: Boolean) = if (b) Nil else 1 :: Nil +f2: (b: Boolean)List[Int] + +scala> def f3(b: Boolean) = if (b) Stream.Empty else new Stream.Cons(1, Stream.Empty) +f3: (b: Boolean)scala.collection.immutable.Stream[Int] + +scala> def f4(b: Boolean) = if (b) Success(1) else Failure(new Exception("")) +f4: (b: Boolean)scala.util.Try[Int] + +scala> :quit diff --git a/test/files/run/t9174.scala b/test/files/run/t9174.scala new file mode 100644 index 0000000000..0c70e9bca9 --- /dev/null +++ b/test/files/run/t9174.scala @@ -0,0 +1,11 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + |import scala.util.{Success, Failure} + |def f1(b: Boolean) = if (b) Left(1) else Right(2) + |def f2(b: Boolean) = if (b) Nil else 1 :: Nil + |def f3(b: Boolean) = if (b) Stream.Empty else new Stream.Cons(1, Stream.Empty) + |def f4(b: Boolean) = if (b) Success(1) else Failure(new Exception("")) + |""".stripMargin +} diff --git a/test/files/run/t9200/Test.java b/test/files/run/t9200/Test.java new file mode 100644 index 0000000000..8ff0314f6c --- /dev/null +++ b/test/files/run/t9200/Test.java @@ -0,0 +1,6 @@ +public class Test { + public static void main(String[] args) { + new C1(new C2()); // Was NoSuchMethodError + } +} + diff --git a/test/files/run/t9200/test.scala b/test/files/run/t9200/test.scala new file mode 100644 index 0000000000..6fa7e91571 --- /dev/null +++ b/test/files/run/t9200/test.scala @@ -0,0 +1,12 @@ +trait W + +trait T1 +trait T2 extends T1 + +object O1 { + type t = T1 with T2 +} + +class C1[w<:W](o: O1.t) + +class C2 extends T1 with T2 diff --git a/test/files/scalacheck/concurrent-map.scala b/test/files/scalacheck/concurrent-map.scala new file mode 100755 index 0000000000..7c9b8d4169 --- /dev/null +++ b/test/files/scalacheck/concurrent-map.scala @@ -0,0 +1,76 @@ + + + +import java.util.concurrent._ +import scala.collection._ +import scala.collection.JavaConverters._ +import org.scalacheck._ +import org.scalacheck.Prop._ +import org.scalacheck.Gen._ + + + +case class Wrap(i: Int) { + override def hashCode = i * 0x9e3775cd +} + + +object Test extends Properties("concurrent.TrieMap") { + + /* generators */ + + val sizes = choose(0, 20000) + + val threadCounts = choose(2, 16) + + val threadCountsAndSizes = for { + p <- threadCounts + sz <- sizes + } yield (p, sz); + + + /* helpers */ + + def inParallel[T](totalThreads: Int)(body: Int => T): Seq[T] = { + val threads = for (idx <- 0 until totalThreads) yield new Thread { + setName("ParThread-" + idx) + private var res: T = _ + override def run() { + res = body(idx) + } + def result = { + this.join() + res + } + } + + threads foreach (_.start()) + threads map (_.result) + } + + property("concurrent getOrElseUpdate insertions") = forAll(threadCounts, sizes) { + (p, sz) => + val chm = new ConcurrentHashMap[Wrap, Int]().asScala + + val results = inParallel(p) { + idx => + for (i <- 0 until sz) yield chm.getOrElseUpdate(new Wrap(i), idx) + } + + val resultSets = for (i <- 0 until sz) yield results.map(_(i)).toSet + val largerThanOne = resultSets.zipWithIndex.find(_._1.size != 1) + val allThreadsAgreeOnWhoInserted = { + largerThanOne == None + } :| s"$p threads agree on who inserted [disagreement (differentResults, position) = $largerThanOne]" + + allThreadsAgreeOnWhoInserted + } + + +} + + + + + + |