summaryrefslogtreecommitdiff
path: root/test/pending/jvm
diff options
context:
space:
mode:
Diffstat (limited to 'test/pending/jvm')
-rw-r--r--test/pending/jvm/actor-executor4.check21
-rw-r--r--test/pending/jvm/actor-executor4.scala64
-rw-r--r--test/pending/jvm/actor-receive-sender.check2
-rw-r--r--test/pending/jvm/actor-receive-sender.scala51
-rw-r--r--test/pending/jvm/actorgc_leak.check1
-rw-r--r--test/pending/jvm/actorgc_leak.scala63
-rw-r--r--test/pending/jvm/constant-optimization/Foo_1.flags1
-rw-r--r--test/pending/jvm/constant-optimization/Foo_1.scala9
-rw-r--r--test/pending/jvm/constant-optimization/Test.scala27
-rw-r--r--test/pending/jvm/reactWithinZero.check2
-rw-r--r--test/pending/jvm/reactWithinZero.scala18
-rw-r--r--test/pending/jvm/receiveWithinZero.check2
-rw-r--r--test/pending/jvm/receiveWithinZero.scala18
-rw-r--r--test/pending/jvm/t1801.check6
-rw-r--r--test/pending/jvm/t1801.scala31
-rw-r--r--test/pending/jvm/t2515.check10
-rw-r--r--test/pending/jvm/t2515.scala43
-rw-r--r--test/pending/jvm/terminateLinked.check1
-rw-r--r--test/pending/jvm/terminateLinked.scala24
-rw-r--r--test/pending/jvm/timeout.check1
-rw-r--r--test/pending/jvm/timeout.scala38
21 files changed, 37 insertions, 396 deletions
diff --git a/test/pending/jvm/actor-executor4.check b/test/pending/jvm/actor-executor4.check
deleted file mode 100644
index da78f45836..0000000000
--- a/test/pending/jvm/actor-executor4.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/pending/jvm/actor-executor4.scala b/test/pending/jvm/actor-executor4.scala
deleted file mode 100644
index a912d76094..0000000000
--- a/test/pending/jvm/actor-executor4.scala
+++ /dev/null
@@ -1,64 +0,0 @@
-import scala.actors.{Actor, Exit}
-import scala.actors.scheduler.ExecutorScheduler
-import java.util.concurrent.Executors
-
-object One extends AdaptedActor {
- def act() {
- 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")
- }
- }
- }
-}
-
-object Two extends AdaptedActor {
- def act() {
- 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
- }
- }
- }
-}
-
-trait AdaptedActor extends Actor {
- override def scheduler =
- Test.scheduler
-}
-
-object Test {
- val NUM_MSG = 100000
-
- val scheduler =
- ExecutorScheduler(
- Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()),
- false)
-
- def main(args: Array[String]) {
- (new AdaptedActor {
- def act() {
- trapExit = true
- link(One)
- One.start()
-
- receive {
- case Exit(from, reason) =>
- println("One exited")
- Test.scheduler.shutdown()
- }
- }
- }).start()
- }
-}
diff --git a/test/pending/jvm/actor-receive-sender.check b/test/pending/jvm/actor-receive-sender.check
deleted file mode 100644
index 2c94e48371..0000000000
--- a/test/pending/jvm/actor-receive-sender.check
+++ /dev/null
@@ -1,2 +0,0 @@
-OK
-OK
diff --git a/test/pending/jvm/actor-receive-sender.scala b/test/pending/jvm/actor-receive-sender.scala
deleted file mode 100644
index ea7c40cced..0000000000
--- a/test/pending/jvm/actor-receive-sender.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-import scala.actors.{Actor, TIMEOUT, Exit}
-import scala.actors.Actor._
-
-object Test {
-
- val NUM = 2000
-
- def main(args: Array[String]) {
- var b: Actor = null
- var c: Actor = null
-
- val a = actor {
- for (_ <- 0 until NUM)
- receive {
- case 'hello if sender == b => // do nothing
- }
- b ! 'ok
- for (_ <- 0 until NUM)
- receiveWithin (1000) {
- case 'bye if sender == b => // do nothing
- case TIMEOUT => b ! 'fail
- }
- b ! 'ok
- }
-
- b = actor {
- self.trapExit = true
- link(a)
-
- for (_ <- 0 until NUM)
- a ! 'hello
-
- val proceed = receive {
- case Exit(from, reason) => println("FAIL"); false
- case 'ok => println("OK"); true
- case other => println(other); false
- }
-
- if (proceed) {
- for (_ <- 0 until NUM)
- a ! 'bye
- receive {
- case Exit(from, reason) => println("FAIL")
- case 'ok => println("OK")
- case other => println(other)
- }
- }
- }
- }
-
-}
diff --git a/test/pending/jvm/actorgc_leak.check b/test/pending/jvm/actorgc_leak.check
deleted file mode 100644
index a965a70ed4..0000000000
--- a/test/pending/jvm/actorgc_leak.check
+++ /dev/null
@@ -1 +0,0 @@
-Done
diff --git a/test/pending/jvm/actorgc_leak.scala b/test/pending/jvm/actorgc_leak.scala
deleted file mode 100644
index de3e04f1e8..0000000000
--- a/test/pending/jvm/actorgc_leak.scala
+++ /dev/null
@@ -1,63 +0,0 @@
-
-import scala.actors.Actor
-
-object Test {
- class FatActorFactory extends Actor {
- def act() {
- var cnt = 0
- Actor.loopWhile(cnt < fatActors) {
- //if ((cnt % 5) == 0) println(cnt)
- val fa = new FatActor()
- fa.start()
- cnt += 1
- if (cnt == fatActors) Monitor ! 'done
- }
- }
- }
-
- class FatActor extends Actor {
- def act() {
- fat = new Array[Int](fatness)
- react {
- case 'hi => exit()
- }
- }
- private var fat: Array[Int] = _
- }
-
- object Monitor extends Actor {
- private var cnt = 0
- def act() {
- Actor.loop {
- react {
- case 'done => {
- cnt += 1
- if (cnt == factories) System.exit(0) // once GC pressure stops FatActors stop being collected, and as
- } // a result ActorGC never finds out that they are defunct
- }
- }
- }
- }
-
- val factories = 4 // the number of factories to start
- val fatActors = 50 // the number of FatActors for each factory to produce
- val fatness = 1024*1024*10
-
- def main(args: Array[String]) {
- scala.actors.Scheduler.impl.shutdown()
- val sched = {
- val s = new scala.actors.FJTaskScheduler2
- s.start()
- s
- }
- scala.actors.Scheduler.impl = sched
-
- Monitor.start()
- for(i <- 1 to factories) {
- //if ((i % 50) == 0) println(i)
- val fa = new FatActorFactory()
- fa.start()
- }
- println("Done")
- }
-}
diff --git a/test/pending/jvm/constant-optimization/Foo_1.flags b/test/pending/jvm/constant-optimization/Foo_1.flags
new file mode 100644
index 0000000000..9691c0985d
--- /dev/null
+++ b/test/pending/jvm/constant-optimization/Foo_1.flags
@@ -0,0 +1 @@
+// constant otimization not there yet, -Yopt:nullness-tracking not enough.
diff --git a/test/pending/jvm/constant-optimization/Foo_1.scala b/test/pending/jvm/constant-optimization/Foo_1.scala
new file mode 100644
index 0000000000..6f408044d7
--- /dev/null
+++ b/test/pending/jvm/constant-optimization/Foo_1.scala
@@ -0,0 +1,9 @@
+class Foo_1 {
+ def foo() {
+ // constant optimization should eliminate all branches
+ val i = 1
+ val x = if (i != 1) null else "good"
+ val y = if (x == null) "good" else x + ""
+ println(y)
+ }
+} \ No newline at end of file
diff --git a/test/pending/jvm/constant-optimization/Test.scala b/test/pending/jvm/constant-optimization/Test.scala
new file mode 100644
index 0000000000..dc0f8f6103
--- /dev/null
+++ b/test/pending/jvm/constant-optimization/Test.scala
@@ -0,0 +1,27 @@
+
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ val comparisons = Set(asm.Opcodes.IF_ACMPEQ, asm.Opcodes.IF_ACMPNE, asm.Opcodes.IF_ICMPEQ, asm.Opcodes.IF_ICMPGE, asm.Opcodes.IF_ICMPGT, asm.Opcodes.IF_ICMPLE,
+ asm.Opcodes.IF_ICMPLT, asm.Opcodes.IF_ICMPNE, asm.Opcodes.IFEQ, asm.Opcodes.IFGE, asm.Opcodes.IFGT, asm.Opcodes.IFLE, asm.Opcodes.IFLT,
+ asm.Opcodes.IFNE, asm.Opcodes.IFNONNULL, asm.Opcodes.IFNULL)
+
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ val methodNode = getMethod(classNode, "foo")
+ // after optimization there should be no comparisons left
+ val expected = 0
+
+ val got = countComparisons(methodNode.instructions)
+ assert(got == expected, s"expected $expected but got $got comparisons")
+ }
+
+ def countComparisons(insnList: InsnList): Int = {
+ def isComparison(node: asm.tree.AbstractInsnNode): Boolean =
+ (comparisons contains node.getOpcode)
+ insnList.iterator.asScala count isComparison
+ }
+} \ No newline at end of file
diff --git a/test/pending/jvm/reactWithinZero.check b/test/pending/jvm/reactWithinZero.check
deleted file mode 100644
index cf2a2facf9..0000000000
--- a/test/pending/jvm/reactWithinZero.check
+++ /dev/null
@@ -1,2 +0,0 @@
-TIMEOUT
-'ack
diff --git a/test/pending/jvm/reactWithinZero.scala b/test/pending/jvm/reactWithinZero.scala
deleted file mode 100644
index 0786ce271d..0000000000
--- a/test/pending/jvm/reactWithinZero.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-import scala.actors.{Actor, TIMEOUT}
-
-class A extends Actor {
- def act() = reactWithin(0) {
- case TIMEOUT =>
- println("TIMEOUT")
- reply('ack)
- act()
- case x => println(x)
- }
-}
-
-object Test {
- def main(args: Array[String]): Unit = {
- val a = new A
- a.start()
- }
-}
diff --git a/test/pending/jvm/receiveWithinZero.check b/test/pending/jvm/receiveWithinZero.check
deleted file mode 100644
index cf2a2facf9..0000000000
--- a/test/pending/jvm/receiveWithinZero.check
+++ /dev/null
@@ -1,2 +0,0 @@
-TIMEOUT
-'ack
diff --git a/test/pending/jvm/receiveWithinZero.scala b/test/pending/jvm/receiveWithinZero.scala
deleted file mode 100644
index 315dd9c86a..0000000000
--- a/test/pending/jvm/receiveWithinZero.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-import scala.actors.{Actor, TIMEOUT}
-
-class A extends Actor {
- def act() = receiveWithin(0) {
- case TIMEOUT =>
- println("TIMEOUT")
- reply('ack)
- act()
- case x => println(x)
- }
-}
-
-object Test {
- def main(args: Array[String]): Unit = {
- val a = new A
- a.start()
- }
-}
diff --git a/test/pending/jvm/t1801.check b/test/pending/jvm/t1801.check
deleted file mode 100644
index bf78a99db9..0000000000
--- a/test/pending/jvm/t1801.check
+++ /dev/null
@@ -1,6 +0,0 @@
-0
-100
-200
-300
-400
-done!
diff --git a/test/pending/jvm/t1801.scala b/test/pending/jvm/t1801.scala
deleted file mode 100644
index 6ed7c56336..0000000000
--- a/test/pending/jvm/t1801.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-import scala.actors.Actor._
-
-object Test {
- val rt = Runtime.getRuntime()
- val sender = actor {
- var cnt = 0
- while(cnt < 500) {
- if ((cnt % 100) == 0) println(cnt)
- receiver ! new Array[Int] (148576)
- cnt += 1
- //println ("Used Mem: " + (((rt.totalMemory() - rt.freeMemory()) / 1048576.) formatted "%.2f") + " Mb")
- }
- receiver ! 'exit
- }
-
- val receiver = actor {
- loop {
- react {
- case x: Array[Int] => ()//println ("received " + x.length)
- case 'exit => {
- println("done!")
- exit()
- }
- }
- }
- }
-
- def main (args: Array[String]) {
- sender
- }
-}
diff --git a/test/pending/jvm/t2515.check b/test/pending/jvm/t2515.check
deleted file mode 100644
index 8cb8bde11e..0000000000
--- a/test/pending/jvm/t2515.check
+++ /dev/null
@@ -1,10 +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
diff --git a/test/pending/jvm/t2515.scala b/test/pending/jvm/t2515.scala
deleted file mode 100644
index ee655967f3..0000000000
--- a/test/pending/jvm/t2515.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-import scala.actors.{Futures, TIMEOUT}
-import scala.actors.Actor._
-
-object Test {
-
- def compute(): Option[Boolean] = {
- val fts = for (j <- 0 until 5) yield Futures.future {
- receiveWithin (100) {
- case TIMEOUT => true
- case other => false
- }
- }
- val done = Futures.awaitAll(2000, fts.toArray: _*) // list to array, as varargs
- if (done.contains(None))
- None
- else
- Some(true)
- }
-
- def main(args:Array[String]) : Unit = {
- val ft = Futures.future {
- val format = new java.text.DecimalFormat("000.00'ms'")
- var iter = 1
- val done = 11
- while (iter < done) {
- val start = System.nanoTime()
- val result = compute()
- val time = System.nanoTime() - start
- result match {
- case Some(result) =>
- //printf("Iteration %2d succeeded after %s %n", iter, format.format(time / 1e6))
- printf("Iteration %2d succeeded%n", iter)
- iter += 1
- case None =>
- printf(">>>> Iteration %2d failed after %s <<<<< %n", iter, format.format(time / 1e6))
- iter = done
- }
- }
- }
- ft()
- }
-
-}
diff --git a/test/pending/jvm/terminateLinked.check b/test/pending/jvm/terminateLinked.check
deleted file mode 100644
index a965a70ed4..0000000000
--- a/test/pending/jvm/terminateLinked.check
+++ /dev/null
@@ -1 +0,0 @@
-Done
diff --git a/test/pending/jvm/terminateLinked.scala b/test/pending/jvm/terminateLinked.scala
deleted file mode 100644
index 2a3b7fb49e..0000000000
--- a/test/pending/jvm/terminateLinked.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-import scala.actors.Actor
-import Actor._
-
-object Test {
- def main(args: Array[String]) {
- val a = actor {
- for (_ <- 1 to 10)
- receive {
- case b: Actor => link(b)
- }
- throw new Exception
- }
-
- for (_ <- 1 to 10)
- actor {
- a ! self
- react {
- case _ =>
- }
- }
-
- println("Done")
- }
-}
diff --git a/test/pending/jvm/timeout.check b/test/pending/jvm/timeout.check
deleted file mode 100644
index d86bac9de5..0000000000
--- a/test/pending/jvm/timeout.check
+++ /dev/null
@@ -1 +0,0 @@
-OK
diff --git a/test/pending/jvm/timeout.scala b/test/pending/jvm/timeout.scala
deleted file mode 100644
index 8f29f8ddbe..0000000000
--- a/test/pending/jvm/timeout.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-// Test is in pending because although it succeeds locally,
-// it takes too long on the machine which runs nightly tests.
-//
-// [partest] EXPECTED: 100 < x < 900
-// [partest] ACTUAL: 1519
-
-import scala.actors.Actor._
-import scala.actors.TIMEOUT
-
-object Test extends Application {
- case class Timing(time: Long)
-
- actor {
- val a = actor {
- react {
- case 'doTiming =>
- val s = sender
- reactWithin(500) {
- case TIMEOUT =>
- s ! Timing(System.currentTimeMillis)
- }
- }
- }
-
- val start = System.currentTimeMillis
- (a !? 'doTiming) match {
- case Timing(end) =>
- val delay = end - start
-
- if (delay > 100 && delay < 900)
- println("OK")
- else {
- println("EXPECTED: 100 < x < 900")
- println("ACTUAL: "+delay)
- }
- }
- }
-}