From 64af689e6659ab170826508f37720ee6e54386fa Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 10 Feb 2009 23:46:39 +0000 Subject: moved most of the passing tests from pending to... moved most of the passing tests from pending to files ; reunited inner.scala with inner.check --- test/files/jvm/inner.scala | 126 +++++++++++++++++++++++++++++++ test/files/jvm/reactWithinZero.check | 2 + test/files/jvm/reactWithinZero.scala | 18 +++++ test/files/jvm/receiveWithinZero.check | 2 + test/files/jvm/receiveWithinZero.scala | 18 +++++ test/files/jvm/timeout.check | 1 + test/files/jvm/timeout.scala | 33 ++++++++ test/files/pos/bug1070.scala | 4 + test/files/pos/bug1087.scala | 2 + test/files/pos/t1164.scala | 29 +++++++ test/files/pos/t1438.scala | 10 +++ test/files/run/complicatedmatch.check | 6 ++ test/files/run/complicatedmatch.scala | 31 ++++++++ test/pending/jvm/inner.scala | 126 ------------------------------- test/pending/jvm/reactWithinZero.check | 2 - test/pending/jvm/reactWithinZero.scala | 18 ----- test/pending/jvm/receiveWithinZero.check | 2 - test/pending/jvm/receiveWithinZero.scala | 18 ----- test/pending/jvm/timeout.check | 1 - test/pending/jvm/timeout.scala | 33 -------- test/pending/pos/bug1070.scala | 4 - test/pending/pos/bug1087.scala | 2 - test/pending/pos/t1164.scala | 29 ------- test/pending/pos/t1438.scala | 10 --- test/pending/run/complicatedmatch.check | 6 -- test/pending/run/complicatedmatch.scala | 31 -------- 26 files changed, 282 insertions(+), 282 deletions(-) create mode 100644 test/files/jvm/inner.scala create mode 100644 test/files/jvm/reactWithinZero.check create mode 100644 test/files/jvm/reactWithinZero.scala create mode 100644 test/files/jvm/receiveWithinZero.check create mode 100644 test/files/jvm/receiveWithinZero.scala create mode 100644 test/files/jvm/timeout.check create mode 100644 test/files/jvm/timeout.scala create mode 100644 test/files/pos/bug1070.scala create mode 100644 test/files/pos/bug1087.scala create mode 100644 test/files/pos/t1164.scala create mode 100644 test/files/pos/t1438.scala create mode 100644 test/files/run/complicatedmatch.check create mode 100644 test/files/run/complicatedmatch.scala delete mode 100644 test/pending/jvm/inner.scala delete mode 100644 test/pending/jvm/reactWithinZero.check delete mode 100644 test/pending/jvm/reactWithinZero.scala delete mode 100644 test/pending/jvm/receiveWithinZero.check delete mode 100644 test/pending/jvm/receiveWithinZero.scala delete mode 100644 test/pending/jvm/timeout.check delete mode 100644 test/pending/jvm/timeout.scala delete mode 100644 test/pending/pos/bug1070.scala delete mode 100644 test/pending/pos/bug1087.scala delete mode 100644 test/pending/pos/t1164.scala delete mode 100644 test/pending/pos/t1438.scala delete mode 100644 test/pending/run/complicatedmatch.check delete mode 100644 test/pending/run/complicatedmatch.scala (limited to 'test') diff --git a/test/files/jvm/inner.scala b/test/files/jvm/inner.scala new file mode 100644 index 0000000000..4ad1f1e215 --- /dev/null +++ b/test/files/jvm/inner.scala @@ -0,0 +1,126 @@ +//############################################################################ +// Test Java interaction with scala inner classes +//############################################################################ +// $Id$ + +import java.io.{BufferedReader, File, FileWriter, InputStreamReader} + +class A { + val abc = "A.abc" + + protected class B(x: Int, y: String) { + println(abc); println(x) + println(y) + } + + trait Itf { + def method1(x: Int): Int + + trait Itf2 extends Itf { + def method2: Unit + } + } + + trait PlainTrait { + def method1(x: Int): Int + } + + class Impl(a: Int) extends Itf { + def method1(x: Int) = { + println(x) + println(a) + x + a + } + } + + class Impl2 extends Impl(1) with Itf#Itf2 { + def method2 = { + println(abc) + } + } + + def newImpl: Itf = new Impl(1) + def newImpl2: Itf#Itf2 = new Impl2 + + class Outer1(arg1: Int) { + class Outer2(arg2: Int) { + class Outer3(arg3: Int) { + println("Outer3: " + arg1 + " " + arg2 + " " + arg3); + } + } + } +} + +object Scalatest { + private val outputdir = System.getProperty("scalatest.output", "inner-jvm.obj") + private val scalalib = System.getProperty("scalatest.lib", "") + private val classpath = outputdir + File.pathSeparator + scalalib + private val javabin = { + val jhome = new File(System.getProperty("java.home")) + if (jhome.getName == "jre") + new File(jhome.getParent, "bin").getAbsolutePath + else + new File(jhome, "bin").getAbsolutePath + } + private val javacmd = javabin + File.separator + "java" + private val javac = javabin + File.separator + "javac" + + def javac(src: String, fname: String) { + val tmpfilename = outputdir + File.separator + fname + val tmpfile = new FileWriter(tmpfilename) + tmpfile.write(src) + tmpfile.close + exec(javac + " -d " + outputdir + " -classpath " + classpath + " " + tmpfilename) + } + + def java(cname: String) = + exec(javacmd + " -cp " + classpath + " " + cname) + + /** Execute cmd, wait for the process to end and pipe it's output to stdout */ + private def exec(cmd: String) { + val proc = Runtime.getRuntime().exec(cmd) + val inp = new BufferedReader(new InputStreamReader(proc.getInputStream)) + val errp = new BufferedReader(new InputStreamReader(proc.getErrorStream)) + proc.waitFor() + while (inp.ready) println(inp.readLine()) + while (errp.ready) println(errp.readLine()) + } +} + +object Test { + def main(args: Array[String]) { + val javaInteraction = """ +public class JavaInteraction { + public static void main(String[] args) { + A a = new A(); + A.B b = a.new B(1, "Hello"); + + A.Itf itf = a.newImpl(); + itf.method1(1); + + A.Itf.Itf2 itf2 = a.newImpl2(); + itf2.method2(); + + A.Outer1 o1 = a.new Outer1(1); + A.Outer1.Outer2 o2 = o1.new Outer2(2); + A.Outer1.Outer2.Outer3 or = o2.new Outer3(3); + } +} +""" + Scalatest.javac(javaInteraction, "JavaInteraction.java") + Scalatest.java("JavaInteraction") + + val accessingScala = """ +public class AccessingScala { + public static void main(String[] args) { + A a = new A(); + System.out.println(a.abc()); + } +} +""" + Scalatest.javac(accessingScala, "AccessingScala.java") + Scalatest.java("AccessingScala") + } +} + +//############################################################################ diff --git a/test/files/jvm/reactWithinZero.check b/test/files/jvm/reactWithinZero.check new file mode 100644 index 0000000000..cf2a2facf9 --- /dev/null +++ b/test/files/jvm/reactWithinZero.check @@ -0,0 +1,2 @@ +TIMEOUT +'ack diff --git a/test/files/jvm/reactWithinZero.scala b/test/files/jvm/reactWithinZero.scala new file mode 100644 index 0000000000..0786ce271d --- /dev/null +++ b/test/files/jvm/reactWithinZero.scala @@ -0,0 +1,18 @@ +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/files/jvm/receiveWithinZero.check b/test/files/jvm/receiveWithinZero.check new file mode 100644 index 0000000000..cf2a2facf9 --- /dev/null +++ b/test/files/jvm/receiveWithinZero.check @@ -0,0 +1,2 @@ +TIMEOUT +'ack diff --git a/test/files/jvm/receiveWithinZero.scala b/test/files/jvm/receiveWithinZero.scala new file mode 100644 index 0000000000..315dd9c86a --- /dev/null +++ b/test/files/jvm/receiveWithinZero.scala @@ -0,0 +1,18 @@ +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/files/jvm/timeout.check b/test/files/jvm/timeout.check new file mode 100644 index 0000000000..d86bac9de5 --- /dev/null +++ b/test/files/jvm/timeout.check @@ -0,0 +1 @@ +OK diff --git a/test/files/jvm/timeout.scala b/test/files/jvm/timeout.scala new file mode 100644 index 0000000000..12f1bd7bad --- /dev/null +++ b/test/files/jvm/timeout.scala @@ -0,0 +1,33 @@ + +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) + } + } + } +} diff --git a/test/files/pos/bug1070.scala b/test/files/pos/bug1070.scala new file mode 100644 index 0000000000..95b77184d7 --- /dev/null +++ b/test/files/pos/bug1070.scala @@ -0,0 +1,4 @@ +import scala.reflect.BeanProperty; +trait beanpropertytrait { + @BeanProperty var myVariable: Long = -1l; +} diff --git a/test/files/pos/bug1087.scala b/test/files/pos/bug1087.scala new file mode 100644 index 0000000000..19d62116c6 --- /dev/null +++ b/test/files/pos/bug1087.scala @@ -0,0 +1,2 @@ +case class Foo +case class Prd (pred : Char => Boolean) extends Foo diff --git a/test/files/pos/t1164.scala b/test/files/pos/t1164.scala new file mode 100644 index 0000000000..3acda88ba9 --- /dev/null +++ b/test/files/pos/t1164.scala @@ -0,0 +1,29 @@ + + +object test { + + class Foo[a](val arg : a) + + object Foo { + def apply [a](arg : a, right :a) = new Foo[a](arg) + def unapply [a](m : Foo[a]) = Some (m.arg) + } + + def matchAndGetArgFromFoo[a]( e:Foo[a]):a = {e match { case Foo(x) => x }} + + + // Try the same thing as above but use function as arguemnt to Bar + // constructor + + type FunIntToA [a] = (int) => a + class Bar[a] (var f: FunIntToA[a]) + + object Bar { + def apply[a](f: FunIntToA[a]) = new Bar[a](f) + def unapply[a](m: Bar[a]) = Some (m.f) + } + + def matchAndGetFunFromBar[a](b:Bar[a]) : FunIntToA[a] = { b match { case Bar(x) => x}} + + +} diff --git a/test/files/pos/t1438.scala b/test/files/pos/t1438.scala new file mode 100644 index 0000000000..221c3439dd --- /dev/null +++ b/test/files/pos/t1438.scala @@ -0,0 +1,10 @@ +class C[A] { + type CC[B] <: C[B] + def aio[T]: T = aio[T] +} +class D[A] extends C[A] { + protected def nv[B](elems: Iterator[B]): CC[B] = { + val x = new D[B] + x.aio[CC[B]] + } +} diff --git a/test/files/run/complicatedmatch.check b/test/files/run/complicatedmatch.check new file mode 100644 index 0000000000..501b7a32d6 --- /dev/null +++ b/test/files/run/complicatedmatch.check @@ -0,0 +1,6 @@ +1 +42 +42 +11 +7 +13 diff --git a/test/files/run/complicatedmatch.scala b/test/files/run/complicatedmatch.scala new file mode 100644 index 0000000000..c837c328b3 --- /dev/null +++ b/test/files/run/complicatedmatch.scala @@ -0,0 +1,31 @@ +object Bar{ + def unapply(x : String) = x == "bar"; +} + +object Even{ + def unapply(x : Int) = if (x % 2 == 0) Some(x / 2) else None; +} + +object Test extends Application{ + val LongWord = "supercalifragilisticexpialadocious"; + + def foo(x : Int, y : String) : Int = (x, y) match { + case (Even(i), "bar") => 1 + case (1 | 2 | 3, "foo") => 42; + case (x, y) if y.length < x => 11; + case (1 | 2 | 3, Bar()) => 7; + case (1 | 2 | 3, "bar") => 8 + case (Even(Even(3)), Bar()) => 13; + case (Even(Even(3)), LongWord) => 13; + case _ => 0; + } + + List( + 2 -> "bar", + 2 -> "foo", + 3 -> "foo", + 7 -> "flob", + 3 -> "bar", + 12 -> LongWord + ).foreach({case (x, y) => println(foo(x, y))}); +} diff --git a/test/pending/jvm/inner.scala b/test/pending/jvm/inner.scala deleted file mode 100644 index 4ad1f1e215..0000000000 --- a/test/pending/jvm/inner.scala +++ /dev/null @@ -1,126 +0,0 @@ -//############################################################################ -// Test Java interaction with scala inner classes -//############################################################################ -// $Id$ - -import java.io.{BufferedReader, File, FileWriter, InputStreamReader} - -class A { - val abc = "A.abc" - - protected class B(x: Int, y: String) { - println(abc); println(x) - println(y) - } - - trait Itf { - def method1(x: Int): Int - - trait Itf2 extends Itf { - def method2: Unit - } - } - - trait PlainTrait { - def method1(x: Int): Int - } - - class Impl(a: Int) extends Itf { - def method1(x: Int) = { - println(x) - println(a) - x + a - } - } - - class Impl2 extends Impl(1) with Itf#Itf2 { - def method2 = { - println(abc) - } - } - - def newImpl: Itf = new Impl(1) - def newImpl2: Itf#Itf2 = new Impl2 - - class Outer1(arg1: Int) { - class Outer2(arg2: Int) { - class Outer3(arg3: Int) { - println("Outer3: " + arg1 + " " + arg2 + " " + arg3); - } - } - } -} - -object Scalatest { - private val outputdir = System.getProperty("scalatest.output", "inner-jvm.obj") - private val scalalib = System.getProperty("scalatest.lib", "") - private val classpath = outputdir + File.pathSeparator + scalalib - private val javabin = { - val jhome = new File(System.getProperty("java.home")) - if (jhome.getName == "jre") - new File(jhome.getParent, "bin").getAbsolutePath - else - new File(jhome, "bin").getAbsolutePath - } - private val javacmd = javabin + File.separator + "java" - private val javac = javabin + File.separator + "javac" - - def javac(src: String, fname: String) { - val tmpfilename = outputdir + File.separator + fname - val tmpfile = new FileWriter(tmpfilename) - tmpfile.write(src) - tmpfile.close - exec(javac + " -d " + outputdir + " -classpath " + classpath + " " + tmpfilename) - } - - def java(cname: String) = - exec(javacmd + " -cp " + classpath + " " + cname) - - /** Execute cmd, wait for the process to end and pipe it's output to stdout */ - private def exec(cmd: String) { - val proc = Runtime.getRuntime().exec(cmd) - val inp = new BufferedReader(new InputStreamReader(proc.getInputStream)) - val errp = new BufferedReader(new InputStreamReader(proc.getErrorStream)) - proc.waitFor() - while (inp.ready) println(inp.readLine()) - while (errp.ready) println(errp.readLine()) - } -} - -object Test { - def main(args: Array[String]) { - val javaInteraction = """ -public class JavaInteraction { - public static void main(String[] args) { - A a = new A(); - A.B b = a.new B(1, "Hello"); - - A.Itf itf = a.newImpl(); - itf.method1(1); - - A.Itf.Itf2 itf2 = a.newImpl2(); - itf2.method2(); - - A.Outer1 o1 = a.new Outer1(1); - A.Outer1.Outer2 o2 = o1.new Outer2(2); - A.Outer1.Outer2.Outer3 or = o2.new Outer3(3); - } -} -""" - Scalatest.javac(javaInteraction, "JavaInteraction.java") - Scalatest.java("JavaInteraction") - - val accessingScala = """ -public class AccessingScala { - public static void main(String[] args) { - A a = new A(); - System.out.println(a.abc()); - } -} -""" - Scalatest.javac(accessingScala, "AccessingScala.java") - Scalatest.java("AccessingScala") - } -} - -//############################################################################ 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/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 12f1bd7bad..0000000000 --- a/test/pending/jvm/timeout.scala +++ /dev/null @@ -1,33 +0,0 @@ - -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) - } - } - } -} diff --git a/test/pending/pos/bug1070.scala b/test/pending/pos/bug1070.scala deleted file mode 100644 index 95b77184d7..0000000000 --- a/test/pending/pos/bug1070.scala +++ /dev/null @@ -1,4 +0,0 @@ -import scala.reflect.BeanProperty; -trait beanpropertytrait { - @BeanProperty var myVariable: Long = -1l; -} diff --git a/test/pending/pos/bug1087.scala b/test/pending/pos/bug1087.scala deleted file mode 100644 index 19d62116c6..0000000000 --- a/test/pending/pos/bug1087.scala +++ /dev/null @@ -1,2 +0,0 @@ -case class Foo -case class Prd (pred : Char => Boolean) extends Foo diff --git a/test/pending/pos/t1164.scala b/test/pending/pos/t1164.scala deleted file mode 100644 index 3acda88ba9..0000000000 --- a/test/pending/pos/t1164.scala +++ /dev/null @@ -1,29 +0,0 @@ - - -object test { - - class Foo[a](val arg : a) - - object Foo { - def apply [a](arg : a, right :a) = new Foo[a](arg) - def unapply [a](m : Foo[a]) = Some (m.arg) - } - - def matchAndGetArgFromFoo[a]( e:Foo[a]):a = {e match { case Foo(x) => x }} - - - // Try the same thing as above but use function as arguemnt to Bar - // constructor - - type FunIntToA [a] = (int) => a - class Bar[a] (var f: FunIntToA[a]) - - object Bar { - def apply[a](f: FunIntToA[a]) = new Bar[a](f) - def unapply[a](m: Bar[a]) = Some (m.f) - } - - def matchAndGetFunFromBar[a](b:Bar[a]) : FunIntToA[a] = { b match { case Bar(x) => x}} - - -} diff --git a/test/pending/pos/t1438.scala b/test/pending/pos/t1438.scala deleted file mode 100644 index 221c3439dd..0000000000 --- a/test/pending/pos/t1438.scala +++ /dev/null @@ -1,10 +0,0 @@ -class C[A] { - type CC[B] <: C[B] - def aio[T]: T = aio[T] -} -class D[A] extends C[A] { - protected def nv[B](elems: Iterator[B]): CC[B] = { - val x = new D[B] - x.aio[CC[B]] - } -} diff --git a/test/pending/run/complicatedmatch.check b/test/pending/run/complicatedmatch.check deleted file mode 100644 index 501b7a32d6..0000000000 --- a/test/pending/run/complicatedmatch.check +++ /dev/null @@ -1,6 +0,0 @@ -1 -42 -42 -11 -7 -13 diff --git a/test/pending/run/complicatedmatch.scala b/test/pending/run/complicatedmatch.scala deleted file mode 100644 index c837c328b3..0000000000 --- a/test/pending/run/complicatedmatch.scala +++ /dev/null @@ -1,31 +0,0 @@ -object Bar{ - def unapply(x : String) = x == "bar"; -} - -object Even{ - def unapply(x : Int) = if (x % 2 == 0) Some(x / 2) else None; -} - -object Test extends Application{ - val LongWord = "supercalifragilisticexpialadocious"; - - def foo(x : Int, y : String) : Int = (x, y) match { - case (Even(i), "bar") => 1 - case (1 | 2 | 3, "foo") => 42; - case (x, y) if y.length < x => 11; - case (1 | 2 | 3, Bar()) => 7; - case (1 | 2 | 3, "bar") => 8 - case (Even(Even(3)), Bar()) => 13; - case (Even(Even(3)), LongWord) => 13; - case _ => 0; - } - - List( - 2 -> "bar", - 2 -> "foo", - 3 -> "foo", - 7 -> "flob", - 3 -> "bar", - 12 -> LongWord - ).foreach({case (x, y) => println(foo(x, y))}); -} -- cgit v1.2.3