diff options
Diffstat (limited to 'test/pending')
382 files changed, 7842 insertions, 2527 deletions
diff --git a/test/pending/buildmanager/t2443/BitSet.scala b/test/pending/buildmanager/t2443/BitSet.scala new file mode 100644 index 0000000000..8d7c8dcd23 --- /dev/null +++ b/test/pending/buildmanager/t2443/BitSet.scala @@ -0,0 +1,2 @@ +import scala.collection.BitSet +//class BitSet diff --git a/test/pending/buildmanager/t2443/t2443.changes/BitSet2.scala b/test/pending/buildmanager/t2443/t2443.changes/BitSet2.scala new file mode 100644 index 0000000000..27a5d4de9f --- /dev/null +++ b/test/pending/buildmanager/t2443/t2443.changes/BitSet2.scala @@ -0,0 +1 @@ +import scala.collection.BitSet diff --git a/test/pending/buildmanager/t2443/t2443.check b/test/pending/buildmanager/t2443/t2443.check new file mode 100644 index 0000000000..dd88e1ceb9 --- /dev/null +++ b/test/pending/buildmanager/t2443/t2443.check @@ -0,0 +1,6 @@ +builder > BitSet.scala +compiling Set(BitSet.scala) +builder > BitSet.scala +Changes: Map(class BitSet -> List(Removed(Class(BitSet)))) + + diff --git a/test/pending/buildmanager/t2443/t2443.test b/test/pending/buildmanager/t2443/t2443.test new file mode 100644 index 0000000000..a1d61ff5a3 --- /dev/null +++ b/test/pending/buildmanager/t2443/t2443.test @@ -0,0 +1,3 @@ +>>compile BitSet.scala +>>update BitSet.scala=>BitSet2.scala +>>compile BitSet.scala diff --git a/test/pending/continuations-pos/t3620.scala b/test/pending/continuations-pos/t3620.scala new file mode 100644 index 0000000000..8496ae2858 --- /dev/null +++ b/test/pending/continuations-pos/t3620.scala @@ -0,0 +1,73 @@ +import scala.collection.mutable.HashMap +import scala.util.continuations._ + +object Test extends Application { + + class Store[K,V] { + + trait Waiting { + def key: K + def inform(value: V): Unit + } + + private val map = new HashMap[K, V] + private var waiting: List[Waiting] = Nil + + def waitFor(k: K, f: (V => Unit)) { + map.get(k) match { + case Some(v) => f(v) + case None => { + val w = new Waiting { + def key = k + def inform(v: V) = f(v) + } + waiting = w :: waiting + } + } + } + + + def add(key: K, value: V) { + map(key) = value + val p = waiting.partition(_.key == key) + waiting = p._2 + p._1.foreach(_.inform(value)) + } + + def required(key: K) = { + shift { + c: (V => Unit) => { + waitFor(key, c) + } + } + } + + def option(key: Option[K]) = { + shift { + c: (Option[V] => Unit) => { + key match { + case Some(key) => waitFor(key, (v: V) => c(Some(v))) + case None => c(None) + } + + } + } + } + + } + + val store = new Store[String, Int] + + def test(p: Option[String]): Unit = { + reset { + // uncommenting the following two lines makes the compiler happy! +// val o = store.option(p) +// println(o) + val i = store.option(p).getOrElse(1) + println(i) + } + } + + test(Some("a")) + +} diff --git a/test/pending/continuations-run/example0.scala b/test/pending/continuations-run/example0.scala new file mode 100644 index 0000000000..de5ea54e9d --- /dev/null +++ b/test/pending/continuations-run/example0.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test0.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example1.scala b/test/pending/continuations-run/example1.scala new file mode 100644 index 0000000000..e31d6af88c --- /dev/null +++ b/test/pending/continuations-run/example1.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test1.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example16.scala b/test/pending/continuations-run/example16.scala new file mode 100644 index 0000000000..561f0ab0eb --- /dev/null +++ b/test/pending/continuations-run/example16.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test16Printf.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example2.scala b/test/pending/continuations-run/example2.scala new file mode 100644 index 0000000000..730f7cc63e --- /dev/null +++ b/test/pending/continuations-run/example2.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test2.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example3.scala b/test/pending/continuations-run/example3.scala new file mode 100644 index 0000000000..41cf1cce0c --- /dev/null +++ b/test/pending/continuations-run/example3.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test3.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example4.scala b/test/pending/continuations-run/example4.scala new file mode 100644 index 0000000000..adcc7aa90e --- /dev/null +++ b/test/pending/continuations-run/example4.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test4.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example5.scala b/test/pending/continuations-run/example5.scala new file mode 100644 index 0000000000..241e8cd069 --- /dev/null +++ b/test/pending/continuations-run/example5.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test5.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example6.scala b/test/pending/continuations-run/example6.scala new file mode 100644 index 0000000000..00f84fcd6c --- /dev/null +++ b/test/pending/continuations-run/example6.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test6.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example7.scala b/test/pending/continuations-run/example7.scala new file mode 100644 index 0000000000..64abc6d9a6 --- /dev/null +++ b/test/pending/continuations-run/example7.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test7.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example8.scala b/test/pending/continuations-run/example8.scala new file mode 100644 index 0000000000..a5f953d3fc --- /dev/null +++ b/test/pending/continuations-run/example8.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test8.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example9.scala b/test/pending/continuations-run/example9.scala new file mode 100644 index 0000000000..09d792c427 --- /dev/null +++ b/test/pending/continuations-run/example9.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test9Monads.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/foreach.check b/test/pending/continuations-run/foreach.check new file mode 100644 index 0000000000..9bab7a2eed --- /dev/null +++ b/test/pending/continuations-run/foreach.check @@ -0,0 +1,4 @@ +1 +2 +3 +enough is enough
\ No newline at end of file diff --git a/test/pending/continuations-run/foreach.scala b/test/pending/continuations-run/foreach.scala new file mode 100644 index 0000000000..76823e7604 --- /dev/null +++ b/test/pending/continuations-run/foreach.scala @@ -0,0 +1,33 @@ +// $Id$ + +import scala.util.continuations._ + +import scala.util.continuations.Loops._ + +object Test { + + def main(args: Array[String]): Any = { + + + reset { + + val list = List(1,2,3,4,5) + + for (x <- list.suspendable) { + + shift { k: (Unit => Unit) => + println(x) + if (x < 3) + k() + else + println("enough is enough") + } + + } + + } + + + } + +}
\ No newline at end of file diff --git a/test/pending/jvm/actor-executor4.check b/test/pending/jvm/actor-executor4.check new file mode 100644 index 0000000000..da78f45836 --- /dev/null +++ b/test/pending/jvm/actor-executor4.check @@ -0,0 +1,21 @@ +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 new file mode 100644 index 0000000000..a912d76094 --- /dev/null +++ b/test/pending/jvm/actor-executor4.scala @@ -0,0 +1,64 @@ +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/actorgc_leak.scala b/test/pending/jvm/actorgc_leak.scala index 5e2b9d51e1..de3e04f1e8 100644 --- a/test/pending/jvm/actorgc_leak.scala +++ b/test/pending/jvm/actorgc_leak.scala @@ -14,7 +14,7 @@ object Test { } } } - + class FatActor extends Actor { def act() { fat = new Array[Int](fatness) diff --git a/test/pending/jvm/annotations.scala b/test/pending/jvm/annotations.scala deleted file mode 100644 index 98b82edad4..0000000000 --- a/test/pending/jvm/annotations.scala +++ /dev/null @@ -1,159 +0,0 @@ -object Test1 { - class Foo { - @remote - def foo: Unit = () - } - def run { - val method = classOf[Foo].getMethod("foo", Array()) - method.getExceptionTypes foreach println - } -} - -object Test2 { - import java.io.{BufferedReader,FileReader, IOException} - class Reader(fname: String) { - private val in = new BufferedReader(new FileReader(fname)) - - @throws(classOf[IOException]) - def read() = in.read() - } - def run { - val method = classOf[Reader].getMethod("read", Array()) - method.getExceptionTypes foreach println - } -} - -/* Java: -public class Main { - @Deprecated - public void foo() {} - public static void main(String[] args) throws Exception { - Method method = Class.forName("test.Main").getMethod("foo", new Class[]{}); - Annotation annotation = method.getAnnotation(Deprecated.class); - System.out.println(annotation); // @java.lang.Deprecated() - } -} -*/ -object Test3 { - import java.lang.Deprecated - class Foo { - @Deprecated - def foo: Unit = () - } - def run { - val method = classOf[Foo].getMethod("foo", Array()) - val annotation = method.getAnnotation(classOf[Deprecated]) - println(annotation) - } -} - -/* Java: -@Retention(value=RetentionPolicy.RUNTIME) -@interface Source { - public String url(); - public String mail(); -} -@Source(url="http://scala.epfl.ch", mail="scala@lists.epfl.ch") -class Foo {} -public class Main { - public static void main(String[] args) throws Exception { - Class clazz = Class.forName("test.Foo"); - Annotation[] annotations = clazz.getAnnotations(); - for (int i = 0; i < annotations.length; i++) - System.out.println(annotations[i]); - // @test.Main$Source(url=http://scala-lang.org, mail=scala@lists.epfl.ch) - } -} -*/ -object Test4 { - import test.SourceAnnotation // defined in SourceAnnotation.java - @SourceAnnotation{val value = "http://scala-lang.org", - val mails = Array("scala@lists.epfl.ch", "scala-lounge@lists.epfl.ch")} - class Foo1 - @SourceAnnotation("http://bloodsuckers.com") { val mails = Array("you@bloodsuckers.com") } - class Foo2 - @SourceAnnotation("http://bloodsuckers.com") - class Foo3 - class Foo4 { - @SourceAnnotation("file:///dev/null") - val x = 1 - } - class Foo5 { - @SourceAnnotation("file:///dev/zero") - def bar: Int = 0 - } - class Foo6 @SourceAnnotation("primary constructor")(s: String) { - // to guarantee that primary constructor annotations - // are not applied to secondary constructors - def this() = this("") - } - class Foo7(s: String) { - @SourceAnnotation("secondary constructor") - def this() = this("") - } - class Foo8(@SourceAnnotation("constructor val") val n: Int) {} - def run { - import java.lang.annotation.Annotation - import java.lang.reflect.AnnotatedElement - def printSourceAnnotations(target: AnnotatedElement) { - //print SourceAnnotation in a predefined way to insure - // against difference in the JVMs (e.g. Sun's vs IBM's) - def printSourceAnnotation(a: Annotation) { - val ann = a.asInstanceOf[SourceAnnotation] - println("@test.SourceAnnotation(mails=" + ann.mails.deepMkString("{", ",", "}") + - ", value=" + ann.value + ")") - } - val anns = target.getAnnotations() - anns foreach printSourceAnnotation - if (anns.length > 0) { - println(target) - println - } - } - printSourceAnnotations(classOf[Foo1]) - printSourceAnnotations(classOf[Foo2]) - printSourceAnnotations(classOf[Foo3]) - classOf[Foo4].getDeclaredFields foreach printSourceAnnotations - classOf[Foo4].getDeclaredMethods foreach printSourceAnnotations - classOf[Foo5].getDeclaredMethods foreach printSourceAnnotations - classOf[Foo6].getDeclaredConstructors foreach printSourceAnnotations - classOf[Foo7].getDeclaredConstructors foreach printSourceAnnotations - classOf[Foo8].getDeclaredFields foreach printSourceAnnotations - classOf[Foo8].getDeclaredMethods foreach printSourceAnnotations - } -} - -object Test5 { - import scala.reflect.BeanProperty - import java.lang.Integer - - class Count { - // we use "Integer" instead of "Int" because of Java reflection - @BeanProperty - private var count: Integer = 0 - - private val getter = - getClass().getMethod("getCount", Array[java.lang.Class[T] forSome { type T }]()) - private val setter = - getClass().getMethod("setCount", Array(classOf[Integer])) - - def get = getter.invoke(this, Array()).asInstanceOf[Integer].intValue - def set(n: Int) = setter.invoke(this, Array(new Integer(n))) - } - def run { - val count = new Count - println(count.get) - count.set(99) - println(count.get) - } -} - -object Test { - def main(args: Array[String]) { - Test1.run - Test2.run - Test3.run // requires the use of -target:jvm-1.5 - Test4.run - Test5.run - } -} diff --git a/test/pending/jvm/backendBugUnapply.scala b/test/pending/jvm/backendBugUnapply.scala deleted file mode 100644 index f8abfeb713..0000000000 --- a/test/pending/jvm/backendBugUnapply.scala +++ /dev/null @@ -1,9 +0,0 @@ -object Test { import scala.xml.{Node,HasKeyValue} - def domatch(x:Node): Node = { - val hasBar = new HasKeyValue("bar") - x match { - case Node("foo", hasBar(z), _*) => z - case _ => null - } - } -} diff --git a/test/pending/jvm/cf-attributes.check b/test/pending/jvm/cf-attributes.check new file mode 100644 index 0000000000..018febb81b --- /dev/null +++ b/test/pending/jvm/cf-attributes.check @@ -0,0 +1,50 @@ + +{{ anonymousFunctions$ }} + +{{ anonymousFunctions$bar$ }} + public final class anonymousFunctions$bar$$anonfun$4 of class anonymousFunctions$bar$ +anonymousClasses$$anon$1 + +{{ anonymousClasses$ }} + +[[ anonymousFunctions$ ]] + InnerClass: + public final #66 of #90; //class anonymousFunctions$$anonfun$1 of class anonymousFunctions + public final #77; //class anonymousFunctions$$anonfun$2 + public final #24; //class anonymousFunctions$$anonfun$3 + public final #49; //class anonymousFunctions$$anonfun$foo$1 + + +[[ anonymousFunctions$bar$ ]] + InnerClass: + public final #28 of #9; //class anonymousFunctions$bar$$anonfun$4 of class anonymousFunctions$bar$ + public final #52; //class anonymousFunctions$bar$$anonfun$5 + + +[[ anonymousClasses$ ]] + InnerClass: + public abstract #33= #30 of #32; //Foo=class anonymousClasses$Foo of class anonymousClasses + public final #25 of #32; //class anonymousClasses$$anon$1 of class anonymousClasses + public abstract #36= #35 of #32; //Foo$class=class anonymousClasses$Foo$class of class anonymousClasses + + +[[ anonymousFunctions$$anonfun$3 ]] + InnerClass: + public final #8; //class anonymousFunctions$$anonfun$3 + + +[[ anonymousFunctions$$anonfun$foo$1 ]] + InnerClass: + public final #8; //class anonymousFunctions$$anonfun$foo$1 + + +[[ anonymousFunctions$bar$$anonfun$4 ]] + InnerClass: + public final #8 of #41; //class anonymousFunctions$bar$$anonfun$4 of class anonymousFunctions$bar$ + + +[[ anonymousClasses$$anon$1 ]] + InnerClass: + public abstract #46= #43 of #45; //Foo=class anonymousClasses$Foo of class anonymousClasses + public final #48 of #45; //class anonymousClasses$$anon$1 of class anonymousClasses + diff --git a/test/pending/jvm/cf-attributes.scala b/test/pending/jvm/cf-attributes.scala new file mode 100644 index 0000000000..9e0e9d95de --- /dev/null +++ b/test/pending/jvm/cf-attributes.scala @@ -0,0 +1,146 @@ +object Test extends Application { + InnerClassTest1 + InnerClassTest2 +} + +object InnerClassTest1 extends Test1 { + printClass(anonymousFunctions.getClass) + printClass(anonymousFunctions.bar.getClass) + println(anonymousClasses.x) // see run/t1167.scala + printClass(anonymousClasses.getClass) +} + +object InnerClassTest2 extends Test2 { + printClass(anonymousFunctions.getClass) + printClass(anonymousFunctions.bar.getClass) + printClass(anonymousClasses.getClass) + // not accessible via the Java reflection API + printClass("anonymousFunctions$$anonfun$3") + printClass("anonymousFunctions$$anonfun$foo$1") + printClass("anonymousFunctions$bar$$anonfun$4") + printClass("anonymousClasses$$anon$1") +} + +object anonymousFunctions { + //InnerClass: + // public final #_ of #_; //class anonymousFunctions$$anonfun$1 of class InnerClass$ + val twice = (x: Int) => 2*x + + //InnerClass: + // public final #_ of #_; //class anonymousFunctions$$anonfun$2 + List(0).map(x => x+1) + + def foo { + //InnerClass: + // public final #_ of #_; class anonymousFunctions$$anonfun$3 + val square = (x: Int) => x*x + + //InnerClass: + // public final #_ of #_; class anonymousFunctions$$anonfun$foo$1 + Array(1).filter(_ % 2 == 0) + } + + object bar { + //InnerClass: + // public final #_ of #_; class anonymousFunctions$bar$$anonfun$4 of class anonymousFunctions$bar$ + val cube = (x: Int) => x*x*x + + //InnerClass: + // public final #_ of #_; class anonymousFunctions$bar$$anonfun$5 + Set(1, 2, 3).exists(_ == 2) + } +} + +object anonymousClasses { + //InnerClass: + // public abstract #_= #_ of #_; //Foo=class anonymousClasses$Foo of class anonymousClasses$ + // public abstract #_= #_ of #_; //Foo$class=class anonymousClasses$Foo$class of class anonymousClasses$ + trait Foo { + def foo() { println("foo"); } + override def toString = getClass.getName + } + //InnerClass: + // public final #_; //class anonymousClasses$$anon$1 of class anonymousClasses$ + val x = new Foo() { + override def foo() { println("foo (overriden)"); } + def dummy = 0 + } +} + +// Auxiliary functions + +trait Test1 { + private var kind: String = _ + private var mods: String = _ + def printInnerClasses(cls: Class[_]) { + for (c <- cls.getDeclaredClasses) { + mods = AccessFlags.asString(c.getModifiers) + kind = if (c.isInterface) "interface" else "class" + println(" "+mods+kind+" "+c.getName+ + " of class "+c.getEnclosingClass.getName) + } + } + def printClass(cls: Class[_]) { + println("\n{{ "+cls.getName+" }}") + printInnerClasses(cls) + } +} + +trait Test2 { + @throws(classOf[Exception]) + def printInnerClasses(cls: Class[_]) { + import java.io._, ch.epfl.lamp.fjbg._ + val fjbgContext = new FJBGContext(49, 0) + val outDir = System.getProperty("partest.output", "cf-attributes.obj") + val fileName = outDir+File.separator+cls.getName+".class" + val in = new DataInputStream(new FileInputStream(fileName)) + val jclass = fjbgContext.JClass(in) + println(jclass.getInnerClasses) + in.close() + } + def printClass(name: String) { + try { printClass(Class.forName(name)) } + catch { case e: Exception => println(e) } + } + def printClass(cls: Class[_]) { + println("\n[[ "+cls.getName+" ]]"); + try { printInnerClasses(cls) } + catch { case e: Exception => println(e) } + } +} + +object AccessFlags { + val ACC_PUBLIC = 0x0001 + val ACC_PRIVATE = 0x0002 + val ACC_PROTECTED = 0x0004 + val ACC_STATIC = 0x0008 + val ACC_FINAL = 0x0010 + val ACC_ABSTRACT = 0x0400 + + def asString(accessFlags: Int): String = { + val buf = new StringBuilder() + if ((accessFlags & ACC_PUBLIC) != 0) buf.append("public ") + else if ((accessFlags & ACC_PROTECTED) != 0) buf.append("protected ") + else if ((accessFlags & ACC_PRIVATE) != 0) buf.append("private ") + if ((accessFlags & ACC_ABSTRACT) != 0) buf.append("abstract ") + else if ((accessFlags & ACC_FINAL) != 0) buf.append("final ") + buf.toString + } +} + +/* + implicit def stringToLines(s: String) = new { + def lines(n: Int): String = { + val buf = new StringBuilder(); + var i = 0 + var from = 0 + while (i < n && 0 <= from && from < s.length) { + val pos = s.indexOf('\n', from) + if (pos >= 0) { i += 1; buf.append(s.substring(from, pos + 1)); } + from = pos + 1 + } + buf.toString() + } + } +*/ + diff --git a/test/pending/jvm/javasigs.check b/test/pending/jvm/javasigs.check new file mode 100644 index 0000000000..299bec5e08 --- /dev/null +++ b/test/pending/jvm/javasigs.check @@ -0,0 +1,321 @@ + +@scala.reflect.ScalaSignature(bytes="\006\001i2A!\001\002\001\013\t\t\021IC\001\004\003\035aT-\0349usz\032\001!\006\002\0079M\031\001aB\b\021\005!iQ\"A\005\013\005)Y\021\001\0027b]\036T\021\001D\001\005U\0064\030-\003\002\017\023\t1qJ\0316fGR\004\"\001E\n\016\003EQ\021AE\001\006g\016\fG.Y\005\003)E\0211bU2bY\006|%M[3di\")a\003\001C\001/\0051A(\0338jiz\"\022\001\007\t\0043\001QR\"\001\002\021\005maB\002\001\003\006;\001\021\rA\b\002\002+F\021qD\t\t\003!\001J!!I\t\003\0179{G\017[5oOB\021\001cI\005\003IE\0211!\0218z\021\0251\003\001\"\001(\003\r\021\027M]\013\003Q)\"\"!\013\027\021\005mQC!B\026&\005\004q\"!\001\"\t\r5*C\0211\001/\003\005A\bc\001\t0S%\021\001\'\005\002\ty\tLh.Y7f}!)!\007\001C\001g\005\031am\\8\026\005Q2DCA\0339!\tYb\007B\0038c\t\007aDA\001D\021\025I\024\0071\0016\003\005\031\007") +public class A<U> implements scala.ScalaObject { + + public <B> B bar(scala.Function0<B> x); + + public <C> C foo(C c$1); + + public A(); +} + +@scala.reflect.ScalaSignature(bytes="\006\001\005;Q!\001\002\t\006\025\t\021A\021\006\002\007\0059A(Z7qift4\001\001\t\003\r\035i\021A\001\004\006\021\tA)!\003\002\002\005N\031qA\003\n\021\005-\001R\"\001\007\013\0055q\021\001\0027b]\036T\021aD\001\005U\0064\030-\003\002\022\031\t1qJ\0316fGR\004\"a\005\f\016\003QQ\021!F\001\006g\016\fG.Y\005\003/Q\0211bU2bY\006|%M[3di\")\021d\002C\0015\0051A(\0338jiz\"\022!\002\005\0069\035!\t!H\001\004E\006\024XC\001\020\")\ty\022\006\005\002!C1\001A!\002\005\034\005\004\021\023CA\022\'!\t\031B%\003\002&)\t9aj\034;iS:<\007CA\n(\023\tACCA\002B]fDaAK\016\005\002\004Y\023!\001=\021\007Mas$\003\002.)\tAAHY=oC6,g\bC\0030\017\021\005\001\'A\002g_>,\"!M\032\025\005I*\004C\001\0214\t\025!dF1\001#\005\005\031\005\"\002\034/\001\004\021\024!A2\007\t!\021\001\001O\n\004o)\021\002\"B\r8\t\003QD#A\036\021\005\0319\004\"B\0308\t\003iT#\001 \021\005My\024B\001!\025\005\021)f.\033;") +public class B implements scala.ScalaObject { + + public static final <B> B bar(scala.Function0<B> arg0); + + public void foo(); + + public B(); +} + +public final class $anonfun$foo$1 extends scala.runtime.AbstractFunction0 implements java.io.Serializable { + public static final long serialVersionUID; + private final java.lang.Object c$1; + + public final C apply(); + + public $anonfun$foo$1(A<U> $outer); +} +package scala.actors; + +@scala.reflect.ScalaSignature(bytes="\006\001\021Eu!B\001\003\021\0139\021!B!di>\024(BA\002\005\003\031\t7\r^8sg*\tQ!A\003tG\006d\027m\001\001\021\005!IQ\"\001\002\007\013)\021\001RA\006\003\013\005\033Go\034:\024\t%aAc\006\t\003\033Ii\021A\004\006\003\037A\tA\001\\1oO*\t\021#\001\003kCZ\f\027BA\n\017\005\031y%M[3diB\021\001\"F\005\003-\t\0211bQ8nE&t\027\r^8sgB\021\001$G\007\002\t%\021!\004\002\002\f\'\016\fG.Y(cU\026\034G\017C\003\035\023\021\005Q$\001\004=S:LGO\020\013\002\017\035)q$\003E\003A\005)1\013^1uKB\021\021EI\007\002\023\031)1%\003E\003I\t)1\013^1uKN\031!%J\f\021\005a1\023BA\024\005\005-)e.^7fe\006$\030n\0348\t\013q\021C\021A\025\025\003\001Bqa\013\022C\002\023\005A&A\002OK^,\022!\f\t\003]=j\021AI\005\003a\031\022QAV1mk\026DaA\r\022!\002\023i\023\001\002(fo\002Bq\001\016\022C\002\023\005A&\001\005Sk:t\027M\0317f\021\0311$\005)A\005[\005I!+\0368oC\ndW\r\t\005\bq\t\022\r\021\"\001-\003%\031Vo\0359f]\022,G\r\003\004;E\001\006I!L\001\013\'V\034\b/\0328eK\022\004\003b\002\037#\005\004%\t\001L\001\017)&lW\rZ*vgB,g\016Z3e\021\031q$\005)A\005[\005yA+[7fIN+8\017]3oI\026$\007\005C\004AE\t\007I\021\001\027\002\017\tcwnY6fI\"1!I\tQ\001\n5\n\001B\0217pG.,G\r\t\005\b\t\n\022\r\021\"\001-\0031!\026.\\3e\0052|7m[3e\021\0311%\005)A\005[\005iA+[7fI\ncwnY6fI\002Bq\001\023\022C\002\023\005A&\001\006UKJl\027N\\1uK\022DaA\023\022!\002\023i\023a\003+fe6Lg.\031;fI\002B\001\002T\005C\002\023\005!!T\001\003i2,\022A\024\t\004\033=\013\026B\001)\017\005-!\006N]3bI2{7-\0317\021\005!\021\026BA*\003\0051\021V\r\0357z%\026\f7\r^8s\021\031)\026\002)A\005\035\006\031A\017\034\021\t\021]K!\031!C\001\005a\013Q\001^5nKJ,\022!\027\t\0035vk\021a\027\006\0039B\tA!\036;jY&\021al\027\002\006)&lWM\035\005\007A&\001\013\021B-\002\rQLW.\032:!\021!\021\027B1A\005\002\t\031\027\001E:vgB,g\016Z#yG\026\004H/[8o+\005!\007C\001\005f\023\t1\'AA\nTkN\004XM\0343BGR|\'oQ8oiJ|G\016\003\004i\023\001\006I\001Z\001\022gV\034\b/\0328e\013b\034W\r\035;j_:\004\003\"\0026\n\t\003Y\027\001B:fY\032,\022\001\034\t\003\02154qA\003\002\021\002\007\005anE\004n\031=\f&/^\f\021\005!\001\030BA9\003\0055\t%m\035;sC\016$\030i\031;peB\021\001b]\005\003i\n\021Q\"Q2u_J\034\025M\034*fa2L\bc\001\005wq&\021qO\001\002\r\023:\004X\017^\"iC:tW\r\034\t\0031eL!A\037\003\003\007\005s\027\020C\003}[\022\005Q0\001\004%S:LG\017\n\013\002}B\021\001d`\005\004\003\003!!\001B+oSRD\021\"!\002n\001\004%I!a\002\002\027%\0348+^:qK:$W\rZ\013\003\003\023\0012\001GA\006\023\r\ti\001\002\002\b\005>|G.Z1o\021%\t\t\"\034a\001\n\023\t\031\"A\bjgN+8\017]3oI\026$w\fJ3r)\rq\030Q\003\005\013\003/\ty!!AA\002\005%\021a\001=%c!A\0211D7!B\023\tI!\001\007jgN+8\017]3oI\026$\007\005\013\003\002\032\005}\001c\001\r\002\"%\031\0211\005\003\003\021Y|G.\031;jY\026D\021\"a\nn\001\004%I!!\013\002\021I,7-Z5wK\022,\"!a\013\021\ta\ti\003_\005\004\003_!!AB(qi&|g\016C\005\00245\004\r\021\"\003\0026\005a!/Z2fSZ,Gm\030\023fcR\031a0a\016\t\025\005]\021\021GA\001\002\004\tY\003\003\005\002<5\004\013\025BA\026\003%\021XmY3jm\026$\007\005\013\003\002:\005}\001\002CA![\022E#!a\021\002\023M\034\007.\0323vY\026\024XCAA#!\rA\021qI\005\004\003\023\022!AC%TG\",G-\0367fe\"A\021QJ7\005B\t\ty%A\006ti\006\024HoU3be\016DG\003CA)\003/\nY&!\032\021\ta\t\031F`\005\004\003+\"!!\003$v]\016$\030n\03481\021\035\tI&a\023A\002a\f1!\\:h\021!\ti&a\023A\002\005}\023a\002:fa2LHk\034\t\005\021\005\005\0040C\002\002d\t\021QbT;uaV$8\t[1o]\026d\007\002CA4\003\027\002\r!!\033\002\017!\fg\016\0327feB)\001$a\033yq&\031\021Q\016\003\003\037A\013\'\017^5bY\032+hn\031;j_:D\001\"!\035n\t\003\022\0211O\001\016g\026\f\'o\0315NC&d\'m\034=\025\017y\f)(a \002\002\"A\021qOA8\001\004\tI(A\005ti\006\024H/\0242pqB!\001\"a\037y\023\r\tiH\001\002\007\033F+X-^3\t\021\005\035\024q\016a\001\003SB\001\"a!\002p\001\007\021\021B\001\023e\026\034X/\\3P]N\013W.\032+ie\026\fG\r\003\005\002\b6$\tEAAE\0031i\027m[3SK\006\034G/[8o)!\tY)!%\002\026\006]\005cA\007\002\016&\031\021q\022\b\003\021I+hN\\1cY\026D\001\"a%\002\006\002\007\021\021K\001\004MVt\007\002CA4\003\013\003\r!!\033\t\017\005e\023Q\021a\001q\"9\0211T7\005\002\005u\025a\002:fG\026Lg/Z\013\005\003?\013)\013\006\003\002\"\006E\006\003BAR\003Kc\001\001\002\005\002(\006e%\031AAU\005\005\021\026cAAVqB\031\001$!,\n\007\005=FAA\004O_RD\027N\\4\t\021\005M\026\021\024a\001\003k\013\021A\032\t\0071\005-\0040!)\t\017\005eV\016\"\001\002<\006i!/Z2fSZ,w+\033;iS:,B!!0\002DR!\021qXAe)\021\t\t-!2\021\t\005\r\0261\031\003\t\003O\0139L1\001\002*\"A\0211WA\\\001\004\t9\r\005\004\031\003WB\030\021\031\005\t\003\027\f9\f1\001\002N\006!Qn]3d!\rA\022qZ\005\004\003#$!\001\002\'p]\036Dq!!6n\t\003\n9.A\003sK\006\034G\017\006\003\002,\006e\007\002CA4\003\'\004\r!a7\021\013a\tY\007\037@\t\017\005}W\016\"\021\002b\006Y!/Z1di^KG\017[5o)\021\t\031/a:\025\t\005-\026Q\035\005\t\003O\ni\0161\001\002\\\"A\0211ZAo\001\004\ti\rC\004\002l6$\t!!<\002\r\021\nX.\031:l+\005A\b\002CAy[\022\005#!a=\002\033M\034\007.\0323vY\026\f5\r^8s)\025q\030Q_A|\021!\t\031,a<A\002\005%\004bBA-\003_\004\r\001_\004\b\003wl\007RBA\177\003\035\021Gn\\2lKJ\004B!a@\003\0025\tQNB\004\003\0045DiA!\002\003\017\tdwnY6feN1!\021\001\007\003\b]\001BA!\003\003\0205\021!1\002\006\004\005\033!\021AC2p]\016,(O]3oi&!!\021\003B\006\0059i\025M\\1hK\022\024En\\2lKJDq\001\bB\001\t\003\021)\002\006\002\002~\"A!\021\004B\001\t\003\021Y\"A\003cY>\0347\016\006\002\002\n!A!q\004B\001\t\003\t9!\001\007jgJ+G.Z1tC\ndW\r\003\004\003$5$I!`\001\rgV\034\b/\0328e\003\016$xN\035\005\007\005OiG\021B?\002\027I,7/^7f\003\016$xN\035\005\t\005WiG\021\t\002\002\b\0059Q\r_5uS:<\007b\002B\030[\022\005#!`\001\bI>\034H/\031:u\021\035\021\031$\034C!\005k\tQa\035;beR$\022\001\034\005\b\005siG\021\tB\036\003!9W\r^*uCR,WC\001B\037!\r\021yd\f\b\004\005\003rbB\001\005\001\021)\021)%\034a\001\n\003\021!qI\001\006Y&t7n]\013\003\005\023\002RAa\023\003\\=tAA!\024\003X9!!q\nB+\033\t\021\tFC\002\003T\031\ta\001\020:p_Rt\024\"A\003\n\007\teC!A\004qC\016\\\027mZ3\n\t\tu#q\f\002\005\031&\034HOC\002\003Z\021A!Ba\031n\001\004%\tA\001B3\003%a\027N\\6t?\022*\027\017F\002\177\005OB!\"a\006\003b\005\005\t\031\001B%\021!\021Y\'\034Q!\n\t%\023A\0027j].\034\b\005C\004\003p5$\tA!\035\002\t1Lgn\033\013\004_\nM\004b\002B;\005[\002\ra\\\001\003i>DqAa\034n\t\003\021I\bF\002m\005wB\021B! \003x\021\005\rAa \002\t\t|G-\037\t\0051\t\005e0C\002\003\004\022\021\001\002\0202z]\006lWM\020\005\t\005\017kG\021\001\002\003\n\0061A.\0338l)>$2A BF\021\035\021)H!\"A\002=DqAa$n\t\003\021\t*\001\004v]2Lgn\033\013\004}\nM\005b\002BK\005\033\003\ra\\\001\005MJ|W\016\003\005\003\0326$\tA\001BN\003))h\016\\5oW\032\023x.\034\013\004}\nu\005b\002BK\005/\003\ra\034\005\n\005Ck\007\031!C\001\003\017\t\001\002\036:ba\026C\030\016\036\005\n\005Kk\007\031!C\001\005O\013A\002\036:ba\026C\030\016^0%KF$2A BU\021)\t9Ba)\002\002\003\007\021\021\002\005\t\005[k\007\025)\003\002\n\005IAO]1q\013bLG\017\t\025\005\005W\013y\002C\005\00346\004\r\021\"\003\0036\006QQ\r_5u%\026\f7o\0348\026\005\t]\006c\001\r\003:&\031!1\030\003\003\r\005s\027PU3g\021%\021y,\034a\001\n\023\021\t-\001\bfq&$(+Z1t_:|F%Z9\025\007y\024\031\r\003\006\002\030\tu\026\021!a\001\005oC\001Ba2nA\003&!qW\001\fKbLGOU3bg>t\007\005\003\006\003L6\004\r\021\"\001\003\003\017\t!b\0355pk2$W\t_5u\021)\021y-\034a\001\n\003\021!\021[\001\017g\"|W\017\0343Fq&$x\fJ3r)\rq(1\033\005\013\003/\021i-!AA\002\005%\001\002\003Bl[\002\006K!!\003\002\027MDw.\0367e\013bLG\017\t\005\t\0057lG\021\003\002\003^\006!Q\r_5u)\021\tYKa8\t\021\t\005(\021\034a\001\005o\013aA]3bg>t\007\002\003Bn[\022E#A!:\025\005\005-\006\002\003Bu[\022\005!Aa;\002\025\025D\030\016\036\'j].,G\r\006\002\002R!A!\021^7\005\002\t\021y\017\006\003\002R\tE\b\002\003Bq\005[\004\rAa.\t\021\tmW\016\"\001\003\005k$RA B|\005sDqA!&\003t\002\007q\016\003\005\003b\nM\b\031\001B\\\021!\021i0\034C\001\005\t}\030aC8o)\026\024X.\0338bi\026$2A`B\001\021%\t\031La?\005\002\004\021y\b\003\007\004\0065\f\t\021!C\005\007\017\031y!A\ttkB,\'\017J:uCJ$8+Z1sG\"$\002\"!\025\004\n\r-1Q\002\005\b\0033\032\031\0011\001y\021!\tifa\001A\002\005}\003\002CA4\007\007\001\r!!\033\n\t\00553\021C\005\004\007\'\021!a\002*fC\016$xN\035\005\r\007/i\027\021!A\005\n\re1QD\001\fgV\004XM\035\023sK\006\034G\017\006\003\002,\016m\001\002CA4\007+\001\r!a7\n\007\005U\'\013\003\007\004\"5\f\t\021!C\005\007G\031Y#A\ttkB,\'\017\n:fC\016$x+\033;iS:$Ba!\n\004*Q!\0211VB\024\021!\t9ga\bA\002\005m\007\002CAf\007?\001\r!!4\n\007\005}\'\013C\006\00405\f\t\021!C\005{\016E\022!D:va\026\024H\005Z8ti\006\024H/\003\003\0030\rE\001\002DB\033[\006\005\t\021\"\003\0048\rm\022aC:va\026\024He\035;beR$\"a!\017\021\t!\031\t\002_\005\005\005g\031\t\002\003\007\004@5\f\t\021!C\005\005w\031\t%\001\btkB,\'\017J4fiN#\030\r^3\n\007\te\"\013\003\007\004F5\f\t\021!C\005\005K\0349%\001\006tkB,\'\017J3ySRLAAa7\004\022!*Qna\023\004RA\031\001d!\024\n\007\r=CA\001\tTKJL\027\r\034,feNLwN\\+J\tzAQ\037\013e\004,[\003}\022K\002n\007+\0022\001GB,\023\r\031I\006\002\002\rg\026\024\030.\0317ju\006\024G.\032\005\bU&!\tAAB/)\ra7q\f\005\t\007C\032Y\0061\001\002F\005)1o\0315fI\"A1QM\005\005\002\t\0319\'A\004sC^\034V\r\0344\026\003EC\001b!\032\n\t\003\02111\016\013\004#\0165\004\002CB1\007S\002\r!!\022\t\017\rE\024\002\"\003\002D\005y\001/\031:f]R\0346\r[3ek2,\'\017C\004\004v%!\taa\036\002\025I,7/\032;Qe>D\0300F\001\177\021\035\031Y(\003C\001\007o\n\021b\0317fCJ\034V\r\0344\t\017\r}\024\002\"\001\004\002\006)\021m\031;peR\031Ana!\t\023\tu4Q\020CA\002\t}\004bBBD\023\021\0051\021R\001\be\026\f7\r^8s)\ra71\022\005\n\005{\032)\t\"a\001\007\033\003R\001\007BA\007\037\003B\001GBI}&\03111\023\003\003\023I+7\017]8oI\026\024\bbBAv\023\021\005\021Q\036\005\b\0037KA\021ABM+\021\031Yja(\025\t\ru51\025\t\005\003G\033y\n\002\005\004\"\016]%\031AAU\005\005\t\005\002CAZ\007/\003\ra!*\021\ra\tY\007_BO\021\035\tI,\003C\001\007S+Baa+\0042R!1QVB\\)\021\031yka-\021\t\005\r6\021\027\003\t\003O\0339K1\001\002*\"A\0211WBT\001\004\031)\f\005\004\031\003WB8q\026\005\t\003\027\0349\0131\001\002N\"9\021Q[\005\005\002\rmF\003BAV\007{C\001\"a-\004:\002\007\0211\034\005\b\003?LA\021ABa)\021\031\031ma2\025\t\005-6Q\031\005\t\003g\033y\f1\001\002\\\"A\0211ZB`\001\004\ti\rC\004\004L&!\ta!4\002\023\0254XM\034;m_>\004H\003BAV\007\037D\001\"a-\004J\002\007\0211\034\004\007\007\'LAa!6\003+I+7-\036:tSZ,\007K]8ys\"\013g\016\0327feN11\021\033\007\002\\^A!b!7\004R\n\005\t\025!\003R\003\005\t\007bCAZ\007#\024\t\021)A\005\0037Dq\001HBi\t\003\031y\016\006\004\004b\016\r8Q\035\t\004C\rE\007bBBm\007;\004\r!\025\005\t\003g\033i\0161\001\002\\\"A1\021^Bi\t\003\031Y/A\006jg\022+g-\0338fI\006#H\003BA\005\007[Dqaa<\004h\002\007\0010A\001n\021!\031\031p!5\005\002\rU\030!B1qa2LHc\001@\004x\"91q^By\001\004A\bbBB~\023\021\0051Q`\001\007g\026tG-\032:\026\005\005}\003b\002C\001\023\021\005A1A\001\006e\026\004H.\037\013\004}\022\025\001bBA-\007\177\004\r\001\037\005\007\t\003IA\021A?\t\017\021-\021\002\"\001\005\016\005YQ.Y5mE>D8+\033>f+\t!y\001E\002\031\t#I1\001b\005\005\005\rIe\016\036\005\b\t/IA\021\001C\r\003%\021Xm\0359p]\022|e.\006\004\005\034\021\035B1\006\013\005\t;!\t\004E\004\031\t?!\031\003b\f\n\007\021\005BAA\005Gk:\034G/[8ocA9\001$a\033\005&\021%\002\003BAR\tO!\001b!)\005\026\t\007\021\021\026\t\005\003G#Y\003\002\005\005.\021U!\031AAU\005\005\021\005#\002\r\004\022\022%\002\002CAJ\t+\001\r\001b\r\021\017a!y\002\"\016\002,B1\001$a\033\005&y4!\002\"\017\n!\003\r\nA\001C\036\005\021\021u\016Z=\026\t\021uB1K\n\004\toa\001\002\003C!\to1\t\001b\021\002\017\005tG\r\0265f]V!AQ\tC()\rqHq\t\005\n\t\023\"y\004\"a\001\t\027\nQa\034;iKJ\004R\001\007BA\t\033\002B!a)\005P\021AA\021\013C \005\004\tIKA\001c\t!!)\006b\016C\002\005%&!A1\t\017\021e\023\002b\001\005\\\0051Qn\033\"pIf,B\001\"\030\005jQ!Aq\fC6%\025!\t\007\004C3\r\035!\031\007b\026\001\t?\022A\002\020:fM&tW-\\3oiz\002R!\tC\034\tO\002B!a)\005j\021AAQ\013C,\005\004\tI\013C\005\003~\021]C\0211\001\005nA)\001D!!\005h!9!qN\005\005\002\021EDcA8\005t!9!Q\017C8\001\004y\007b\002B8\023\021\005Aq\017\013\004Y\022e\004\"\003B?\tk\"\t\031\001B@\021\035\021y)\003C\001\t{\"2A C@\021\035\021)\nb\037A\002=DqAa7\n\t\003!\031\t\006\003\002,\022\025\005\002\003Bq\t\003\003\rAa.\t\017\tm\027\002\"\001\003f\"QA1R\005\005\002\003%\t\002\"$\002\027I,\027\r\032*fg>dg/\032\013\002\031!\032\021b!\026") +public interface Actor extends scala.actors.AbstractActor, scala.actors.ReplyReactor, scala.actors.ActorCanReply, scala.actors.InputChannel<java.lang.Object>, scala.ScalaObject { + + public static interface Body<a> { + + <b> void andThen(scala.Function0<b> arg0); + } + + public static class RecursiveProxyHandler implements scala.PartialFunction<java.lang.Object,java.lang.Object>, scala.ScalaObject { + private final scala.actors.ReplyReactor a; + private final scala.PartialFunction<java.lang.Object,java.lang.Object> f; + + public <A1B1> scala.PartialFunction<A1,B1> orElse(scala.PartialFunction<A1,B1> that); + + public <C> scala.PartialFunction<java.lang.Object,C> andThen(scala.Function1<java.lang.Object,C> k); + + public scala.Function1<java.lang.Object,scala.Option<java.lang.Object>> lift(); + + public void apply$mcVI$sp(int v1); + + public boolean apply$mcZI$sp(int v1); + + public int apply$mcII$sp(int v1); + + public float apply$mcFI$sp(int v1); + + public long apply$mcJI$sp(int v1); + + public double apply$mcDI$sp(int v1); + + public void apply$mcVJ$sp(long v1); + + public boolean apply$mcZJ$sp(long v1); + + public int apply$mcIJ$sp(long v1); + + public float apply$mcFJ$sp(long v1); + + public long apply$mcJJ$sp(long v1); + + public double apply$mcDJ$sp(long v1); + + public void apply$mcVF$sp(float v1); + + public boolean apply$mcZF$sp(float v1); + + public int apply$mcIF$sp(float v1); + + public float apply$mcFF$sp(float v1); + + public long apply$mcJF$sp(float v1); + + public double apply$mcDF$sp(float v1); + + public void apply$mcVD$sp(double v1); + + public boolean apply$mcZD$sp(double v1); + + public int apply$mcID$sp(double v1); + + public float apply$mcFD$sp(double v1); + + public long apply$mcJD$sp(double v1); + + public double apply$mcDD$sp(double v1); + + public java.lang.String toString(); + + public <A> scala.Function1<A,java.lang.Object> compose(scala.Function1<A,java.lang.Object> g); + + public <A> scala.Function1<A,java.lang.Object> compose$mcVI$sp(scala.Function1<A,java.lang.Integer> g); + + public <A> scala.Function1<A,java.lang.Boolean> compose$mcZI$sp(scala.Function1<A,java.lang.Integer> g); + + public <A> scala.Function1<A,java.lang.Integer> compose$mcII$sp(scala.Function1<A,java.lang.Integer> g); + + public <A> scala.Function1<A,java.lang.Float> compose$mcFI$sp(scala.Function1<A,java.lang.Integer> g); + + public <A> scala.Function1<A,java.lang.Long> compose$mcJI$sp(scala.Function1<A,java.lang.Integer> g); + + public <A> scala.Function1<A,java.lang.Double> compose$mcDI$sp(scala.Function1<A,java.lang.Integer> g); + + public <A> scala.Function1<A,java.lang.Object> compose$mcVJ$sp(scala.Function1<A,java.lang.Long> g); + + public <A> scala.Function1<A,java.lang.Boolean> compose$mcZJ$sp(scala.Function1<A,java.lang.Long> g); + + public <A> scala.Function1<A,java.lang.Integer> compose$mcIJ$sp(scala.Function1<A,java.lang.Long> g); + + public <A> scala.Function1<A,java.lang.Float> compose$mcFJ$sp(scala.Function1<A,java.lang.Long> g); + + public <A> scala.Function1<A,java.lang.Long> compose$mcJJ$sp(scala.Function1<A,java.lang.Long> g); + + public <A> scala.Function1<A,java.lang.Double> compose$mcDJ$sp(scala.Function1<A,java.lang.Long> g); + + public <A> scala.Function1<A,java.lang.Object> compose$mcVF$sp(scala.Function1<A,java.lang.Float> g); + + public <A> scala.Function1<A,java.lang.Boolean> compose$mcZF$sp(scala.Function1<A,java.lang.Float> g); + + public <A> scala.Function1<A,java.lang.Integer> compose$mcIF$sp(scala.Function1<A,java.lang.Float> g); + + public <A> scala.Function1<A,java.lang.Float> compose$mcFF$sp(scala.Function1<A,java.lang.Float> g); + + public <A> scala.Function1<A,java.lang.Long> compose$mcJF$sp(scala.Function1<A,java.lang.Float> g); + + public <A> scala.Function1<A,java.lang.Double> compose$mcDF$sp(scala.Function1<A,java.lang.Float> g); + + public <A> scala.Function1<A,java.lang.Object> compose$mcVD$sp(scala.Function1<A,java.lang.Double> g); + + public <A> scala.Function1<A,java.lang.Boolean> compose$mcZD$sp(scala.Function1<A,java.lang.Double> g); + + public <A> scala.Function1<A,java.lang.Integer> compose$mcID$sp(scala.Function1<A,java.lang.Double> g); + + public <A> scala.Function1<A,java.lang.Float> compose$mcFD$sp(scala.Function1<A,java.lang.Double> g); + + public <A> scala.Function1<A,java.lang.Long> compose$mcJD$sp(scala.Function1<A,java.lang.Double> g); + + public <A> scala.Function1<A,java.lang.Double> compose$mcDD$sp(scala.Function1<A,java.lang.Double> g); + + public <A> scala.Function1<java.lang.Integer,A> andThen$mcVI$sp(scala.Function1<java.lang.Object,A> g); + + public <A> scala.Function1<java.lang.Integer,A> andThen$mcZI$sp(scala.Function1<java.lang.Boolean,A> g); + + public <A> scala.Function1<java.lang.Integer,A> andThen$mcII$sp(scala.Function1<java.lang.Integer,A> g); + + public <A> scala.Function1<java.lang.Integer,A> andThen$mcFI$sp(scala.Function1<java.lang.Float,A> g); + + public <A> scala.Function1<java.lang.Integer,A> andThen$mcJI$sp(scala.Function1<java.lang.Long,A> g); + + public <A> scala.Function1<java.lang.Integer,A> andThen$mcDI$sp(scala.Function1<java.lang.Double,A> g); + + public <A> scala.Function1<java.lang.Long,A> andThen$mcVJ$sp(scala.Function1<java.lang.Object,A> g); + + public <A> scala.Function1<java.lang.Long,A> andThen$mcZJ$sp(scala.Function1<java.lang.Boolean,A> g); + + public <A> scala.Function1<java.lang.Long,A> andThen$mcIJ$sp(scala.Function1<java.lang.Integer,A> g); + + public <A> scala.Function1<java.lang.Long,A> andThen$mcFJ$sp(scala.Function1<java.lang.Float,A> g); + + public <A> scala.Function1<java.lang.Long,A> andThen$mcJJ$sp(scala.Function1<java.lang.Long,A> g); + + public <A> scala.Function1<java.lang.Long,A> andThen$mcDJ$sp(scala.Function1<java.lang.Double,A> g); + + public <A> scala.Function1<java.lang.Float,A> andThen$mcVF$sp(scala.Function1<java.lang.Object,A> g); + + public <A> scala.Function1<java.lang.Float,A> andThen$mcZF$sp(scala.Function1<java.lang.Boolean,A> g); + + public <A> scala.Function1<java.lang.Float,A> andThen$mcIF$sp(scala.Function1<java.lang.Integer,A> g); + + public <A> scala.Function1<java.lang.Float,A> andThen$mcFF$sp(scala.Function1<java.lang.Float,A> g); + + public <A> scala.Function1<java.lang.Float,A> andThen$mcJF$sp(scala.Function1<java.lang.Long,A> g); + + public <A> scala.Function1<java.lang.Float,A> andThen$mcDF$sp(scala.Function1<java.lang.Double,A> g); + + public <A> scala.Function1<java.lang.Double,A> andThen$mcVD$sp(scala.Function1<java.lang.Object,A> g); + + public <A> scala.Function1<java.lang.Double,A> andThen$mcZD$sp(scala.Function1<java.lang.Boolean,A> g); + + public <A> scala.Function1<java.lang.Double,A> andThen$mcID$sp(scala.Function1<java.lang.Integer,A> g); + + public <A> scala.Function1<java.lang.Double,A> andThen$mcFD$sp(scala.Function1<java.lang.Float,A> g); + + public <A> scala.Function1<java.lang.Double,A> andThen$mcJD$sp(scala.Function1<java.lang.Long,A> g); + + public <A> scala.Function1<java.lang.Double,A> andThen$mcDD$sp(scala.Function1<java.lang.Double,A> g); + + public <R1> scala.PartialFunction<java.lang.Object,R1> unlift(scala.Predef.$less$colon$less<java.lang.Object,scala.Option<R1>> ev); + + public boolean isDefinedAt(java.lang.Object m); + + public void apply(java.lang.Object m); + + public scala.Function1 andThen(scala.Function1 g); + + public java.lang.Object apply(java.lang.Object v1); + + public RecursiveProxyHandler(scala.actors.ReplyReactor a, + scala.PartialFunction<java.lang.Object,java.lang.Object> f); + } + long serialVersionUID; + + scala.Function0<java.lang.Object> scala$actors$Actor$$super$startSearch(java.lang.Object arg0, + scala.actors.OutputChannel<java.lang.Object> arg1, + scala.PartialFunction<java.lang.Object,java.lang.Object> arg2); + + scala.runtime.Nothing$ scala$actors$Actor$$super$react(scala.PartialFunction<java.lang.Object,java.lang.Object> arg0); + + scala.runtime.Nothing$ scala$actors$Actor$$super$reactWithin(long arg0, + scala.PartialFunction<java.lang.Object,java.lang.Object> arg1); + + void scala$actors$Actor$$super$dostart(); + + scala.actors.Reactor<java.lang.Object> scala$actors$Actor$$super$start(); + + scala.Enumeration.Value scala$actors$Actor$$super$getState(); + + scala.runtime.Nothing$ scala$actors$Actor$$super$exit(); + + boolean scala$actors$Actor$$isSuspended(); + + @scala.runtime.TraitSetter + void scala$actors$Actor$$isSuspended_$eq(boolean arg0); + + scala.Option<java.lang.Object> scala$actors$Actor$$received(); + + @scala.runtime.TraitSetter + void scala$actors$Actor$$received_$eq(scala.Option<java.lang.Object> arg0); + + scala.actors.IScheduler scheduler(); + + scala.Function0<java.lang.Object> startSearch(java.lang.Object arg0, + scala.actors.OutputChannel<java.lang.Object> arg1, + scala.PartialFunction<java.lang.Object,java.lang.Object> arg2); + + void searchMailbox(scala.actors.MQueue<java.lang.Object> arg0, + scala.PartialFunction<java.lang.Object,java.lang.Object> arg1, + boolean arg2); + + java.lang.Runnable makeReaction(scala.Function0<java.lang.Object> arg0, + scala.PartialFunction<java.lang.Object,java.lang.Object> arg1, + java.lang.Object arg2); + + <R> R receive(scala.PartialFunction<java.lang.Object,R> arg0); + + <R> R receiveWithin(long arg0, + scala.PartialFunction<java.lang.Object,R> arg1); + + scala.runtime.Nothing$ react(scala.PartialFunction<java.lang.Object,java.lang.Object> arg0); + + scala.runtime.Nothing$ reactWithin(long arg0, + scala.PartialFunction<java.lang.Object,java.lang.Object> arg1); + + java.lang.Object $qmark(); + + void scheduleActor(scala.PartialFunction<java.lang.Object,java.lang.Object> arg0, + java.lang.Object arg1); + + scala.actors.Actor$blocker$ scala$actors$Actor$$blocker(); + + boolean exiting(); + + void dostart(); + + scala.actors.Actor start(); + + scala.Enumeration.Value getState(); + + scala.collection.immutable.List<scala.actors.AbstractActor> links(); + + @scala.runtime.TraitSetter + void links_$eq(scala.collection.immutable.List<scala.actors.AbstractActor> arg0); + + scala.actors.AbstractActor link(scala.actors.AbstractActor arg0); + + scala.actors.Actor link(scala.Function0<java.lang.Object> arg0); + + void linkTo(scala.actors.AbstractActor arg0); + + void unlink(scala.actors.AbstractActor arg0); + + void unlinkFrom(scala.actors.AbstractActor arg0); + + boolean trapExit(); + + @scala.runtime.TraitSetter + void trapExit_$eq(boolean arg0); + + java.lang.Object scala$actors$Actor$$exitReason(); + + @scala.runtime.TraitSetter + void scala$actors$Actor$$exitReason_$eq(java.lang.Object arg0); + + boolean shouldExit(); + + @scala.runtime.TraitSetter + void shouldExit_$eq(boolean arg0); + + scala.runtime.Nothing$ exit(java.lang.Object arg0); + + scala.runtime.Nothing$ exit(); + + scala.Function0<java.lang.Object> exitLinked(); + + scala.Function0<java.lang.Object> exitLinked(java.lang.Object arg0); + + void exit(scala.actors.AbstractActor arg0, + java.lang.Object arg1); + + void onTerminate(scala.Function0<java.lang.Object> arg0); +} diff --git a/test/pending/jvm/javasigs.scala b/test/pending/jvm/javasigs.scala new file mode 100644 index 0000000000..8da59ab0a0 --- /dev/null +++ b/test/pending/jvm/javasigs.scala @@ -0,0 +1,78 @@ +import java.io._ + +object Scalatest { + val outputdir = System.getProperty("partest.output", "inner.obj") + val scalalib = System.getProperty("partest.lib", "") + val classpath = outputdir + File.pathSeparator + scalalib + val javacmd = System.getProperty("javacmd", "java") + val javac = System.getProperty("javaccmd", "javac") + + def javac(src: String, opts: 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 + " " + opts + tmpfilename) + } + + def java(cname: String) = + exec(javacmd + " -cp " + classpath + " " + cname) + + class Slurp(in: BufferedReader) extends Thread("slurper") { + var done = false + override def run() { + while (!done) if (in.ready) println(in.readLine()) + } + } + + def slurp(in: BufferedReader): Slurp = { + val s = new Slurp(in) + s.start() + s + } + + + /** Execute cmd, wait for the process to end and pipe it's output to stdout */ + 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)) + val t1 = slurp(inp) + val t2 = slurp(errp) + proc.waitFor() + t1.done = true + t2.done = true + t1.join() + t2.join() + } +} + +// Test correct java signatures for anonymous classes. Enclosing method attributes should +// allow javac to see the type parameters in foo. See #3249. + +class A[U] { + def bar[B](x : => B) = x + def foo[C](c : C) : C = bar(c) +} + +object B { + def bar[B](x : => B) = x + def foo[C](c : C) : C = { + class InnerB(x: C) + c + } +} + +class B { + def foo {} +} + +object Test { + def main(args: Array[String]) { + import Scalatest._ + exec("%s -Xprint -cp %s A".format(javac, classpath)) + exec("%s -Xprint -cp %s B".format(javac, classpath)) + exec("%s -Xprint -cp %s A$$anonfun$foo$1".format(javac, classpath)) + exec("%s -Xprint -cp %s scala.actors.Actor".format(javac, classpath)) + } +} diff --git a/test/pending/jvm/serialization.check b/test/pending/jvm/serialization.check deleted file mode 100644 index 397578bcba..0000000000 --- a/test/pending/jvm/serialization.check +++ /dev/null @@ -1,198 +0,0 @@ -x0 = List(1, 2, 3) -y0 = List(1, 2, 3) -x0 eq y0: false, y0 eq x0: false -x0 equals y0: true, y0 equals x0: true - -x1 = List() -y1 = List() -x1 eq y1: true, y1 eq x1: true - -x2 = None -y2 = None -x2 eq y2: true, y2 eq x2: true - -x3 = Array[1,2,3] -y3 = Array[1,2,3] -arrayEquals(x3, y3): true - -x4 = <na> -y4 = <na> -x4(2): 4 - y4(2): 4 - -x5 = 'hello -y5 = 'hello -x5 eq y5: true, y5 eq x5: true -x5 equals y5: true, y5 equals x5: true - -x6 = (BannerLimit,12345) -y6 = (BannerLimit,12345) -x6 eq y6: false, y6 eq x6: false -x6 equals y6: true, y6 equals x6: true - -x7 = RoundingMode -y7 = RoundingMode -x7 eq y7: true, y7 eq x7: true -x7 equals y7: true, y7 equals x7: true - -x8 = WeekDay -y8 = WeekDay -x8 eq y8: true, y8 eq x8: true -x8 equals y8: true, y8 equals x8: true - -x9 = UP -y9 = UP -x9 eq y9: true, y9 eq x9: true -x9 equals y9: true, y9 equals x9: true - -x10 = WeekDay(0) -y10 = WeekDay(0) -x10 eq y10: true, y10 eq x10: true -x10 equals y10: true, y10 equals x10: true - -x9 eq x10: false, x10 eq x9: false -x9 equals x10: false, x10 equals x9: false -x9 eq y10: false, y10 eq x9: false -x9 equals y10: false, y10 equals x9: false - -x = List((buffers,20), (layers,2), (title,3)) -y = List((buffers,20), (layers,2), (title,3)) -x equals y: true, y equals x: true - -x = Map(2 -> C, 1 -> B, 0 -> A) -y = Map(2 -> C, 1 -> B, 0 -> A) -x equals y: true, y equals x: true - -x = Map(buffers -> 20, layers -> 2, title -> 3) -y = Map(buffers -> 20, layers -> 2, title -> 3) -x equals y: true, y equals x: true - -x = Set(2, 3) -y = Set(2, 3) -x equals y: true, y equals x: true - -x = Set(5, 3) -y = Set(5, 3) -x equals y: true, y equals x: true - -x = Queue(a, b, c) -y = Queue(a, b, c) -x equals y: true, y equals x: true - -x = Stack(a, b, c) -y = Stack(a, b, c) -x equals y: true, y equals x: true - -x = Map(42 -> FortyTwo) -y = Map(42 -> FortyTwo) -x equals y: true, y equals x: true - -x = TreeSet(0, 2) -y = TreeSet(0, 2) -x equals y: true, y equals x: true - -x = Vector(1, 2, 3) -y = Vector(1, 2, 3) -x equals y: true, y equals x: true - -x = ArrayBuffer(one, two) -y = ArrayBuffer(one, two) -x equals y: true, y equals x: true - -x = Map(title -> 3, buffers -> 20, layers -> 2) -y = Map(title -> 3, buffers -> 20, layers -> 2) -x equals y: true, y equals x: true - -x = Set(0, 8, 9) -y = Set(0, 8, 9) -x equals y: true, y equals x: true - -x = Set(layers, buffers, title) -y = Set(layers, buffers, title) -x equals y: true, y equals x: true - -x = LinkedList(2, 3) -y = LinkedList(2, 3) -x equals y: true, y equals x: true - -x = Queue(20, 2, 3) -y = Queue(20, 2, 3) -x equals y: true, y equals x: true - -x = Stack(3, 2, 20) -y = Stack(3, 2, 20) -x equals y: true, y equals x: true - -x = ListBuffer(white, black) -y = ListBuffer(white, black) -x equals y: true, y equals x: true - -x = History((Feed,hello)) -y = History((Feed,hello)) -x equals y: true, y equals x: true - -x = <html><title>title</title><body></body></html> -y = <html><title>title</title><body></body></html> -x equals y: true, y equals x: true - -x = <html> - <body> - <table cellpadding="2" cellspacing="0"> - <tr> - <th>Last Name</th> - <th>First Name</th> - </tr> - <tr> - <td> Tom </td> - <td> 20 </td> - </tr><tr> - <td> Bob </td> - <td> 22 </td> - </tr><tr> - <td> James </td> - <td> 19 </td> - </tr> - </table> - </body> - </html> -y = <html> - <body> - <table cellpadding="2" cellspacing="0"> - <tr> - <th>Last Name</th> - <th>First Name</th> - </tr> - <tr> - <td> Tom </td> - <td> 20 </td> - </tr><tr> - <td> Bob </td> - <td> 22 </td> - </tr><tr> - <td> James </td> - <td> 19 </td> - </tr> - </table> - </body> - </html> -x equals y: true, y equals x: true - -x = Tim -y = Tim -x equals y: true, y equals x: true - -x = Bob -y = Bob -x equals y: true, y equals x: true - -x = John -y = John -x equals y: true, y equals x: true - -x = Bill -y = Bill -x equals y: true, y equals x: true - -x = Paul -y = Paul -x equals y: true, y equals x: true - diff --git a/test/pending/jvm/serialization.scala b/test/pending/jvm/serialization.scala deleted file mode 100644 index ff9413ae4b..0000000000 --- a/test/pending/jvm/serialization.scala +++ /dev/null @@ -1,411 +0,0 @@ -//############################################################################ -// Serialization -//############################################################################ - -import java.lang.System - -object Serialize { - @throws(classOf[java.io.IOException]) - def write[A](o: A): Array[Byte] = { - val ba = new java.io.ByteArrayOutputStream(512) - val out = new java.io.ObjectOutputStream(ba) - out.writeObject(o) - out.close() - ba.toByteArray() - } - @throws(classOf[java.io.IOException]) - @throws(classOf[ClassNotFoundException]) - def read[A](buffer: Array[Byte]): A = { - val in = - new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(buffer)) - in.readObject().asInstanceOf[A] - } - def check[A, B](x: A, y: B) { - println("x = " + x) - println("y = " + y) - println("x equals y: " + (x equals y) + ", y equals x: " + (y equals x)) - println() - } -} -import Serialize._ - -//############################################################################ -// Test classes in package "scala" - -object Test1_scala { - - private def arrayToString[A](arr: Array[A]): String = - arr.mkString("Array[",",","]") - - private def arrayEquals[A, B](a1: Array[A], a2: Array[B]): Boolean = - (a1.length == a2.length) && - (Iterator.range(0, a1.length) forall { i => a1(i) == a2(i) }) - - @serializable - object WeekDay extends Enumeration { - type WeekDay = Value - val Monday, Tuesday, Wednesday, Thusday, Friday, Saturday, Sunday = Value - } - import WeekDay._, BigDecimal._, RoundingMode._ - - val x0 = List(1, 2, 3) - val x1 = Nil - val x2 = None - val x3 = Array(1, 2, 3) - val x4 = { x: Int => 2 * x } - val x5 = 'hello - val x6 = ("BannerLimit", 12345) - val x7 = BigDecimal.RoundingMode - val x8 = WeekDay - val x9 = UP // named element - val x10 = Monday // unamed element - - try { - val y0: List[Int] = read(write(x0)) - val y1: List[Nothing] = read(write(x1)) - val y2: Option[Nothing] = read(write(x2)) - val y3: Array[Int] = read(write(x3)) - val y4: Function[Int, Int] = read(write(x4)) - val y5: Symbol = read(write(x5)) - val y6: (String, Int) = read(write(x6)) - val y7: RoundingMode.type = read(write(x7)) - val y8: WeekDay.type = read(write(x8)) - val y9: RoundingMode = read(write(x9)) - val y10: WeekDay = read(write(x10)) - - println("x0 = " + x0) - println("y0 = " + y0) - println("x0 eq y0: " + (x0 eq y0) + ", y0 eq x0: " + (y0 eq x0)) - println("x0 equals y0: " + (x0 equals y0) + ", y0 equals x0: " + (y0 equals x0)) - println() - println("x1 = " + x1) - println("y1 = " + y1) - println("x1 eq y1: " + (x1 eq y1) + ", y1 eq x1: " + (y1 eq x1)) - println() - println("x2 = " + x2) - println("y2 = " + y2) - println("x2 eq y2: " + (x2 eq y2) + ", y2 eq x2: " + (y2 eq x2)) - println() - println("x3 = " + arrayToString(x3)) - println("y3 = " + arrayToString(y3)) - println("arrayEquals(x3, y3): " + arrayEquals(x3, y3)) - println() - println("x4 = <na>") - println("y4 = <na>") - println("x4(2): " + x4(2) + " - y4(2): " + y4(2)) - println() - println("x5 = " + x5) - println("y5 = " + y5) - println("x5 eq y5: " + (x5 eq y5) + ", y5 eq x5: " + (y5 eq x5)) - println("x5 equals y5: " + (x5 equals y5) + ", y5 equals x5: " + (y5 equals x5)) - println() - println("x6 = " + x6) - println("y6 = " + y6) - println("x6 eq y6: " + (x6 eq y6) + ", y6 eq x6: " + (y6 eq x6)) - println("x6 equals y6: " + (x6 equals y6) + ", y6 equals x6: " + (y6 equals x6)) - println() - println("x7 = " + x7) - println("y7 = " + y7) - println("x7 eq y7: " + (x7 eq y7) + ", y7 eq x7: " + (y7 eq x7)) - println("x7 equals y7: " + (x7 equals y7) + ", y7 equals x7: " + (y7 equals x7)) - println() - println("x8 = " + x8) - println("y8 = " + y8) - println("x8 eq y8: " + (x8 eq y8) + ", y8 eq x8: " + (y8 eq x8)) - println("x8 equals y8: " + (x8 equals y8) + ", y8 equals x8: " + (y8 equals x8)) - println() - println("x9 = " + x9) - println("y9 = " + y9) - println("x9 eq y9: " + (x9 eq y9) + ", y9 eq x9: " + (y9 eq x9)) - println("x9 equals y9: " + (x9 equals y9) + ", y9 equals x9: " + (y9 equals x9)) - println() - println("x10 = " + x10) - println("y10 = " + y10) - println("x10 eq y10: " + (x10 eq y10) + ", y10 eq x10: " + (y10 eq x10)) - println("x10 equals y10: " + (x10 equals y10) + ", y10 equals x10: " + (y10 equals x10)) - println() - println("x9 eq x10: " + (x9 eq x10) + ", x10 eq x9: " + (x10 eq x9)) - println("x9 equals x10: " + (x9 equals x10) + ", x10 equals x9: " + (x10 equals x9)) - println("x9 eq y10: " + (x9 eq y10) + ", y10 eq x9: " + (y10 eq x9)) - println("x9 equals y10: " + (x9 equals y10) + ", y10 equals x9: " + (y10 equals x9)) - println() - } - catch { - case e: Exception => - e.printStackTrace() - println("Error in Test1_scala: " + e) - } -} - -//############################################################################ -// Test classes in package "scala.collection.immutable" - -@serializable -object Test2_immutable { - import scala.collection.immutable.{ - BitSet, HashMap, ListMap, ListSet, Queue, Stack, TreeSet, TreeMap, Vector} - - val x1 = List( - ("buffers", 20), - ("layers", 2), - ("title", 3) - ) - - val m1 = new HashMap[Int, String] + (0 -> "A", 1 -> "B", 2 -> "C") - - val x2 = new ListMap[String, Int] + ("buffers" -> 20, "layers" -> 2, "title" -> 3) - - val x3 = { - val bs = new collection.mutable.BitSet() - bs += 2; bs += 3 - bs.toImmutable - } - - val x4 = new ListSet[Int]() + 3 + 5 - - val x5 = Queue("a", "b", "c") - - val x6 = Stack("a", "b", "c") - - val x7 = new TreeMap[Int, String] + (42 -> "FortyTwo") - - val x8 = new TreeSet[Int]() + 2 + 0 - - val x9 = Vector(1, 2, 3) - - try { - val y1: List[Pair[String, Int]] = read(write(x1)) - val n1: HashMap[Int, String] = read(write(m1)) - val y2: ListMap[String, Int] = read(write(x2)) - val y3: BitSet = read(write(x3)) - val y4: ListSet[Int] = read(write(x4)) - val y5: Queue[String] = read(write(x5)) - val y6: Stack[String] = read(write(x6)) - val y7: TreeMap[Int, String] = read(write(x7)) - val y8: TreeSet[Int] = read(write(x8)) - val y9: Vector[Int] = read(write(x9)) - - check(x1, y1) - check(m1, n1) - check(x2, y2) - check(x3, y3) - check(x4, y4) - check(x5, y5) - check(x6, y6) - check(x7, y7) - check(x8, y8) - check(x9, y9) - } - catch { - case e: Exception => - println("Error in Test2_immutable: " + e) - throw e - } -} - -//############################################################################ -// Test classes in package "scala.collection.mutable" - -object Test3_mutable { - import scala.collection.mutable.{ - ArrayBuffer, BitSet, HashMap, HashSet, History, LinkedList, ListBuffer, - Publisher, Queue, RevertableHistory, Stack} - - val x0 = new ArrayBuffer[String] - x0 ++= List("one", "two") - - val x2 = new BitSet() - x2 += 0 - x2 += 8 - x2 += 9 - - val x1 = new HashMap[String, Int] - x1 ++= Test2_immutable.x1 - - val x3 = new HashSet[String] - x3 ++= Test2_immutable.x1.map(p => p._1) - - val x4 = new LinkedList[Int](2, null) - x4.append(new LinkedList(3, null)) - - val x5 = new Queue[Int] - x5 ++= Test2_immutable.x1.map(p => p._2) - - val x6 = new Stack[Int] - x6 pushAll x5 - - val x7 = new ListBuffer[String] - x7 ++= List("white", "black") - - @serializable - class Feed extends Publisher[String, Feed] { - override def toString() = "Feed" - } - val feed = new Feed - - val x8 = new History[String, Feed] - x8.notify(feed, "hello") - - try { - val y0: ArrayBuffer[String] = read(write(x0)) - val y1: HashMap[String, Int] = read(write(x1)) - val y2: BitSet = read(write(x2)) - val y3: HashSet[String] = read(write(x3)) - val y4: LinkedList[Int] = read(write(x4)) - val y5: Queue[Int] = read(write(x5)) - val y6: Stack[Int] = read(write(x6)) - val y7: ListBuffer[String] = read(write(x7)) - val y8: History[String, Feed] = read(write(x8)) - - check(x0, y0) - check(x1, y1) - check(x2, y2) - check(x3, y3) - check(x4, y4) - check(x5, y5) - check(x6, y6) - check(x7, y7) - check(x8, y8) - } - catch { - case e: Exception => - println("Error in Test3_mutable: " + e) - } -} - -//############################################################################ -// Test classes in package "scala.xml" - -object Test4_xml { - import scala.xml.Elem - - val x1 = <html><title>title</title><body></body></html>; - - case class Person(name: String, age: Int) - - class AddressBook(a: Person*) { - private val people: List[Person] = a.toList - def toXHTML = - <table cellpadding="2" cellspacing="0"> - <tr> - <th>Last Name</th> - <th>First Name</th> - </tr> - { for (p <- people) yield - <tr> - <td> { p.name } </td> - <td> { p.age.toString() } </td> - </tr> } - </table>; - } - - val people = new AddressBook( - Person("Tom", 20), - Person("Bob", 22), - Person("James", 19)) - - val x2 = - <html> - <body> - { people.toXHTML } - </body> - </html>; - - try { - val y1: scala.xml.Elem = read(write(x1)) - val y2: scala.xml.Elem = read(write(x2)) - - check(x1, y1) - check(x2, y2) - } - catch { - case e: Exception => - println("Error in Test4_xml: " + e) - } -} - -//############################################################################ -// Test user-defined classes WITHOUT nesting - -@serializable -class Person(_name: String) { - private var name = _name - override def toString() = name - override def equals(that: Any): Boolean = - that.isInstanceOf[Person] && - (name == that.asInstanceOf[Person].name) -} - -@serializable -class Employee(_name: String) { - private var name = _name - override def toString() = name -} -@serializable -object bob extends Employee("Bob") - -object Test5 { - val x1 = new Person("Tim") - val x2 = bob - - try { - val y1: Person = read(write(x1)) - val y2: Employee = read(write(x2)) - - check(x1, y1) - check(x2, y2) - } - catch { - case e: Exception => - println("Error in Test5: " + e) - } -} - -//############################################################################ -// Test user-defined classes WITH nesting - -@serializable -object Test6 { - @serializable - object bill extends Employee("Bill") { - val x = paul - } - @serializable - object paul extends Person("Paul") { - val x = 4 // bill; => StackOverflowException !!! - } - val x1 = new Person("John") - val x2 = bill - val x3 = paul - - try { - val y1: Person = read(write(x1)) - val y2: Employee = read(write(x2)) - val y3: Person = read(write(x3)) - - check(x1, y1) - check(x2, y2) - check(x3, y3) - } - catch { - case e: Exception => - println("Error in Test6: " + e) - } -} - -//############################################################################ -// Test code - -object Test { - def main(args: Array[String]) { - Test1_scala - Test2_immutable - Test3_mutable - Test4_xml - Test5 - Test6 - } -} - -//############################################################################ - diff --git a/test/pending/jvm/t1801.check b/test/pending/jvm/t1801.check new file mode 100644 index 0000000000..bf78a99db9 --- /dev/null +++ b/test/pending/jvm/t1801.check @@ -0,0 +1,6 @@ +0 +100 +200 +300 +400 +done! diff --git a/test/pending/jvm/t1801.scala b/test/pending/jvm/t1801.scala new file mode 100644 index 0000000000..6ed7c56336 --- /dev/null +++ b/test/pending/jvm/t1801.scala @@ -0,0 +1,31 @@ +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 new file mode 100644 index 0000000000..8cb8bde11e --- /dev/null +++ b/test/pending/jvm/t2515.check @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000000..ee655967f3 --- /dev/null +++ b/test/pending/jvm/t2515.scala @@ -0,0 +1,43 @@ +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/t2705/GenericInterface.java b/test/pending/jvm/t2705/GenericInterface.java new file mode 100644 index 0000000000..ff4ecd403d --- /dev/null +++ b/test/pending/jvm/t2705/GenericInterface.java @@ -0,0 +1 @@ +public interface GenericInterface<T> { } diff --git a/test/pending/jvm/t2705/Methods.java b/test/pending/jvm/t2705/Methods.java new file mode 100644 index 0000000000..00eed6c595 --- /dev/null +++ b/test/pending/jvm/t2705/Methods.java @@ -0,0 +1,4 @@ +public class Methods { + public static <T> GenericInterface<T> getGenericInterface() { return null; } + public static <T> void acceptGenericInterface(GenericInterface<? super T> gi) { } +}
\ No newline at end of file diff --git a/test/pending/jvm/t2705/t2705.scala b/test/pending/jvm/t2705/t2705.scala new file mode 100644 index 0000000000..cc3cfd9faf --- /dev/null +++ b/test/pending/jvm/t2705/t2705.scala @@ -0,0 +1,5 @@ +class GenericsCompilerCrashTest { + def test() { + Methods.acceptGenericInterface(Methods.getGenericInterface()) + } +}
\ No newline at end of file diff --git a/test/pending/jvm/timeout.scala b/test/pending/jvm/timeout.scala index 3005beab2c..22b3647dce 100644 --- a/test/pending/jvm/timeout.scala +++ b/test/pending/jvm/timeout.scala @@ -16,7 +16,7 @@ object Test extends Application { case 'doTiming => val s = sender reactWithin(500) { - case TIMEOUT => + case TIMEOUT => s ! Timing(System.currentTimeMillis) } } diff --git a/test/pending/neg/bug112506A.scala b/test/pending/neg/bug112506A.scala deleted file mode 100644 index 5dffb5ebe6..0000000000 --- a/test/pending/neg/bug112506A.scala +++ /dev/null @@ -1,19 +0,0 @@ -package test; -import scala.collection.immutable.ListSet -import scala.collection.mutable._; -trait TypeManagerXXX { - trait TypedNode; - type Node; -} -trait ScalaTyperXXX extends TypeManagerXXX { - private var typed : Node = null; - private val dependMap = new HashMap[String,ListSet[TypedNode]]; - override def lookupEntry(name: String): String = { - val set = dependMap.get(name) match { - case Some(set) => set; - case None => new ListSet[Node] - } - dependMap.update(name, set + typed); - throw new Error; - } -} diff --git a/test/pending/neg/bug1210.scala b/test/pending/neg/bug1210.scala deleted file mode 100644 index fc2c954ff2..0000000000 --- a/test/pending/neg/bug1210.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test { - def id[T](f: T => T): T = error("bla") - - abstract class M { self => - type Settings - type selfType = M {type Settings = self.Settings} - - val v: selfType = id[M.this.selfType](_.v) - } -} diff --git a/test/pending/neg/bug1987.scala b/test/pending/neg/bug1987.scala deleted file mode 100644 index d45f1b0f0d..0000000000 --- a/test/pending/neg/bug1987.scala +++ /dev/null @@ -1,14 +0,0 @@ - - -// Copyright Shunsuke Sogame 2008-2009. -// Distributed under the terms of an MIT-style license. - - -package object overloading { - def bar(f: (Int) => Unit): Unit = () - def bar(f: (Int, Int) => Unit): Unit = () -} - -class PackageObjectOverloadingTest { - overloading.bar( (i: Int) => () ) // doesn't compile. -} diff --git a/test/pending/neg/dbldef.check b/test/pending/neg/dbldef.check new file mode 100644 index 0000000000..3ee63475e4 --- /dev/null +++ b/test/pending/neg/dbldef.check @@ -0,0 +1,14 @@ +dbldef.scala:1: error: x is already defined as value x +case class test0(x: Int, x: Float) + ^ +dbldef.scala:1: error: type mismatch; + found : Float + required: Int +case class test0(x: Int, x: Float) + ^ +dbldef.scala:1: error: type mismatch; + found : Float + required: Int +case class test0(x: Int, x: Float) + ^ +three errors found diff --git a/test/pending/neg/dbldef.scala b/test/pending/neg/dbldef.scala new file mode 100644 index 0000000000..c70fb97b2c --- /dev/null +++ b/test/pending/neg/dbldef.scala @@ -0,0 +1 @@ +case class test0(x: Int, x: Float) diff --git a/test/pending/neg/dot-classpath.flags b/test/pending/neg/dot-classpath.flags new file mode 100644 index 0000000000..5af7a81156 --- /dev/null +++ b/test/pending/neg/dot-classpath.flags @@ -0,0 +1 @@ +-Ylog-classpath
\ No newline at end of file diff --git a/test/pending/neg/dot-classpath/S_1.scala b/test/pending/neg/dot-classpath/S_1.scala new file mode 100644 index 0000000000..f8bd12404c --- /dev/null +++ b/test/pending/neg/dot-classpath/S_1.scala @@ -0,0 +1,3 @@ +package foo { + class Bippy +} diff --git a/test/pending/neg/dot-classpath/S_2.scala b/test/pending/neg/dot-classpath/S_2.scala new file mode 100644 index 0000000000..e44c1a5bb8 --- /dev/null +++ b/test/pending/neg/dot-classpath/S_2.scala @@ -0,0 +1,3 @@ +class A { + def f = new foo.Bippy +}
\ No newline at end of file diff --git a/test/pending/neg/plugin-after-terminal.check b/test/pending/neg/plugin-after-terminal.check new file mode 100644 index 0000000000..096efe09cd --- /dev/null +++ b/test/pending/neg/plugin-after-terminal.check @@ -0,0 +1,2 @@ +error: [phase assembly, after dependency on terminal phase not allowed: afterterminal => terminal] +one error found diff --git a/test/pending/neg/plugin-after-terminal.flags b/test/pending/neg/plugin-after-terminal.flags new file mode 100644 index 0000000000..6a44376213 --- /dev/null +++ b/test/pending/neg/plugin-after-terminal.flags @@ -0,0 +1,2 @@ +-Xplugin:files/neg/plugin-after-terminal/lib/plugins.jar + diff --git a/test/pending/neg/plugin-after-terminal/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-after-terminal/lib/plugins.jar.desired.sha1 new file mode 100644 index 0000000000..3e382f3a12 --- /dev/null +++ b/test/pending/neg/plugin-after-terminal/lib/plugins.jar.desired.sha1 @@ -0,0 +1 @@ +f174c50c4363c492362a05c72dd45b0da18fdcd8 ?plugins.jar diff --git a/test/pending/neg/plugin-after-terminal/misc/build.sh b/test/pending/neg/plugin-after-terminal/misc/build.sh new file mode 100755 index 0000000000..8899009d7f --- /dev/null +++ b/test/pending/neg/plugin-after-terminal/misc/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" + +BASE=`pwd` + +if [[ -d "${BASE}/src" ]] ; then + + mkdir -p build + ${SCALAC} -d build src/*.scala + jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . + rm -rf build +fi + diff --git a/test/pending/neg/plugin-after-terminal/misc/scalac-plugin.xml b/test/pending/neg/plugin-after-terminal/misc/scalac-plugin.xml new file mode 100644 index 0000000000..90ff27dc2a --- /dev/null +++ b/test/pending/neg/plugin-after-terminal/misc/scalac-plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <name>beforeparser</name> + <classname>scala.test.plugins.ThePlugin</classname> +</plugin> + diff --git a/test/pending/neg/plugin-after-terminal/src/ThePlugin.scala b/test/pending/neg/plugin-after-terminal/src/ThePlugin.scala new file mode 100644 index 0000000000..2a4607392f --- /dev/null +++ b/test/pending/neg/plugin-after-terminal/src/ThePlugin.scala @@ -0,0 +1,31 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "afterterminal" + val description = "Declares one plugin that wants to be after the terminal phase" + val components = List[PluginComponent](thePhase) + + private object thePhase extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]("terminal") + + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/pending/neg/plugin-after-terminal/testsource.scala b/test/pending/neg/plugin-after-terminal/testsource.scala new file mode 100644 index 0000000000..519d162fdf --- /dev/null +++ b/test/pending/neg/plugin-after-terminal/testsource.scala @@ -0,0 +1,4 @@ +object Test extends Application { + println("afterterminal") +} + diff --git a/test/pending/neg/plugin-before-parser.check b/test/pending/neg/plugin-before-parser.check new file mode 100644 index 0000000000..9a407923b1 --- /dev/null +++ b/test/pending/neg/plugin-before-parser.check @@ -0,0 +1,2 @@ +error: [phase assembly, before dependency on parser phase not allowed: parser => beforeparser] +one error found diff --git a/test/pending/neg/plugin-before-parser.flags b/test/pending/neg/plugin-before-parser.flags new file mode 100644 index 0000000000..632530922c --- /dev/null +++ b/test/pending/neg/plugin-before-parser.flags @@ -0,0 +1,2 @@ +-Xplugin:files/neg/plugin-before-parser/lib/plugins.jar + diff --git a/test/pending/neg/plugin-before-parser/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-before-parser/lib/plugins.jar.desired.sha1 new file mode 100644 index 0000000000..e82eed76ce --- /dev/null +++ b/test/pending/neg/plugin-before-parser/lib/plugins.jar.desired.sha1 @@ -0,0 +1 @@ +d7b100ad483484b598b7cd643424bd2e33898a0d ?plugins.jar diff --git a/test/pending/neg/plugin-before-parser/misc/build.sh b/test/pending/neg/plugin-before-parser/misc/build.sh new file mode 100755 index 0000000000..8899009d7f --- /dev/null +++ b/test/pending/neg/plugin-before-parser/misc/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" + +BASE=`pwd` + +if [[ -d "${BASE}/src" ]] ; then + + mkdir -p build + ${SCALAC} -d build src/*.scala + jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . + rm -rf build +fi + diff --git a/test/pending/neg/plugin-before-parser/misc/scalac-plugin.xml b/test/pending/neg/plugin-before-parser/misc/scalac-plugin.xml new file mode 100644 index 0000000000..90ff27dc2a --- /dev/null +++ b/test/pending/neg/plugin-before-parser/misc/scalac-plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <name>beforeparser</name> + <classname>scala.test.plugins.ThePlugin</classname> +</plugin> + diff --git a/test/pending/neg/plugin-before-parser/src/ThePlugin.scala b/test/pending/neg/plugin-before-parser/src/ThePlugin.scala new file mode 100644 index 0000000000..7ca896650d --- /dev/null +++ b/test/pending/neg/plugin-before-parser/src/ThePlugin.scala @@ -0,0 +1,32 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "beforeparser" + val description = "Declares one plugin that wants to be before the parser phase" + val components = List[PluginComponent](thePhase) + + private object thePhase extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]() + override val runsBefore = List[String]("parser") + + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/pending/neg/plugin-before-parser/testsource.scala b/test/pending/neg/plugin-before-parser/testsource.scala new file mode 100644 index 0000000000..9928aaa83c --- /dev/null +++ b/test/pending/neg/plugin-before-parser/testsource.scala @@ -0,0 +1,4 @@ +object Test extends Application { + println("beforeparser") +} + diff --git a/test/pending/neg/plugin-cyclic-dependency.check b/test/pending/neg/plugin-cyclic-dependency.check new file mode 100644 index 0000000000..a29bc3f5be --- /dev/null +++ b/test/pending/neg/plugin-cyclic-dependency.check @@ -0,0 +1,2 @@ +error: fatal error: Cycle in compiler phase dependencies detected, phase cyclicdependency1 reacted twice! +one error found diff --git a/test/pending/neg/plugin-cyclic-dependency.flags b/test/pending/neg/plugin-cyclic-dependency.flags new file mode 100644 index 0000000000..8716aaa65f --- /dev/null +++ b/test/pending/neg/plugin-cyclic-dependency.flags @@ -0,0 +1,2 @@ +-Xplugin:files/neg/plugin-cyclic-dependency/lib/plugins.jar + diff --git a/test/pending/neg/plugin-cyclic-dependency/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-cyclic-dependency/lib/plugins.jar.desired.sha1 new file mode 100644 index 0000000000..7e565e9e61 --- /dev/null +++ b/test/pending/neg/plugin-cyclic-dependency/lib/plugins.jar.desired.sha1 @@ -0,0 +1 @@ +7e6be9e33a87194e7061f94f6be115619f91ada2 ?plugins.jar diff --git a/test/pending/neg/plugin-cyclic-dependency/misc/build.sh b/test/pending/neg/plugin-cyclic-dependency/misc/build.sh new file mode 100755 index 0000000000..8899009d7f --- /dev/null +++ b/test/pending/neg/plugin-cyclic-dependency/misc/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" + +BASE=`pwd` + +if [[ -d "${BASE}/src" ]] ; then + + mkdir -p build + ${SCALAC} -d build src/*.scala + jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . + rm -rf build +fi + diff --git a/test/pending/neg/plugin-cyclic-dependency/misc/scalac-plugin.xml b/test/pending/neg/plugin-cyclic-dependency/misc/scalac-plugin.xml new file mode 100644 index 0000000000..90ff27dc2a --- /dev/null +++ b/test/pending/neg/plugin-cyclic-dependency/misc/scalac-plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <name>beforeparser</name> + <classname>scala.test.plugins.ThePlugin</classname> +</plugin> + diff --git a/test/pending/neg/plugin-cyclic-dependency/src/ThePlugin.scala b/test/pending/neg/plugin-cyclic-dependency/src/ThePlugin.scala new file mode 100644 index 0000000000..bd94ce60d7 --- /dev/null +++ b/test/pending/neg/plugin-cyclic-dependency/src/ThePlugin.scala @@ -0,0 +1,41 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "cyclicdependency" + val description = "Declares two phases that have a cyclic dependency" + val components = List[PluginComponent](thePhase1,thePhase2) + + private object thePhase1 extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]("tailcalls","cyclicdependency2") + + val phaseName = ThePlugin.this.name + "1" + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private object thePhase2 extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]("dce","cyclicdependency1") + + val phaseName = ThePlugin.this.name + "2" + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/pending/neg/plugin-cyclic-dependency/testsource.scala b/test/pending/neg/plugin-cyclic-dependency/testsource.scala new file mode 100644 index 0000000000..f1513ec9a0 --- /dev/null +++ b/test/pending/neg/plugin-cyclic-dependency/testsource.scala @@ -0,0 +1,4 @@ +object Test extends Application { + println("cyclicdependency") +} + diff --git a/test/pending/neg/plugin-multiple-rafter.check b/test/pending/neg/plugin-multiple-rafter.check new file mode 100644 index 0000000000..c54f884feb --- /dev/null +++ b/test/pending/neg/plugin-multiple-rafter.check @@ -0,0 +1,4 @@ +error: fatal error: Multiple phases want to run right after the phase explicitouter +Phases: erasure, multi-rafter, +Re-run with -Xgenerate-phase-graph <filename> to better see the problem. +one error found diff --git a/test/pending/neg/plugin-multiple-rafter.flags b/test/pending/neg/plugin-multiple-rafter.flags new file mode 100644 index 0000000000..dcae7f2f96 --- /dev/null +++ b/test/pending/neg/plugin-multiple-rafter.flags @@ -0,0 +1,2 @@ +-Xplugin:files/neg/plugin-multiple-rafter/lib/plugins.jar + diff --git a/test/pending/neg/plugin-multiple-rafter/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-multiple-rafter/lib/plugins.jar.desired.sha1 new file mode 100644 index 0000000000..f4905fcbd4 --- /dev/null +++ b/test/pending/neg/plugin-multiple-rafter/lib/plugins.jar.desired.sha1 @@ -0,0 +1 @@ +2bda582b574287429ad5ee2e1d9a3effc88b0a5f ?plugins.jar diff --git a/test/pending/neg/plugin-multiple-rafter/misc/build.sh b/test/pending/neg/plugin-multiple-rafter/misc/build.sh new file mode 100755 index 0000000000..8899009d7f --- /dev/null +++ b/test/pending/neg/plugin-multiple-rafter/misc/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" + +BASE=`pwd` + +if [[ -d "${BASE}/src" ]] ; then + + mkdir -p build + ${SCALAC} -d build src/*.scala + jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . + rm -rf build +fi + diff --git a/test/pending/neg/plugin-multiple-rafter/misc/scalac-plugin.xml b/test/pending/neg/plugin-multiple-rafter/misc/scalac-plugin.xml new file mode 100644 index 0000000000..90ff27dc2a --- /dev/null +++ b/test/pending/neg/plugin-multiple-rafter/misc/scalac-plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <name>beforeparser</name> + <classname>scala.test.plugins.ThePlugin</classname> +</plugin> + diff --git a/test/pending/neg/plugin-multiple-rafter/src/ThePlugin.scala b/test/pending/neg/plugin-multiple-rafter/src/ThePlugin.scala new file mode 100644 index 0000000000..819176fa88 --- /dev/null +++ b/test/pending/neg/plugin-multiple-rafter/src/ThePlugin.scala @@ -0,0 +1,31 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "multi-rafter" + val description = "" + val components = List[PluginComponent](thePhase) + + private object thePhase extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]() + override val runsRightAfter = Some("explicitouter") + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/pending/neg/plugin-multiple-rafter/testsource.scala b/test/pending/neg/plugin-multiple-rafter/testsource.scala new file mode 100644 index 0000000000..f73db1eb60 --- /dev/null +++ b/test/pending/neg/plugin-multiple-rafter/testsource.scala @@ -0,0 +1,4 @@ +object Test extends Application { + println("multi-rafter") +} + diff --git a/test/pending/neg/plugin-rafter-before-1.check b/test/pending/neg/plugin-rafter-before-1.check new file mode 100644 index 0000000000..19ed4d2fba --- /dev/null +++ b/test/pending/neg/plugin-rafter-before-1.check @@ -0,0 +1,2 @@ +error: fatal error: phase erasure want to run right after explicitouter, but some phase has declared to run before erasure. Re-run with -Xgenerate-phase-graph <filename> to better see the problem. +one error found diff --git a/test/pending/neg/plugin-rafter-before-1.flags b/test/pending/neg/plugin-rafter-before-1.flags new file mode 100644 index 0000000000..8bf03145b9 --- /dev/null +++ b/test/pending/neg/plugin-rafter-before-1.flags @@ -0,0 +1,2 @@ +-Xplugin:files/neg/plugin-rafter-before-1/lib/plugins.jar + diff --git a/test/pending/neg/plugin-rafter-before-1/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-rafter-before-1/lib/plugins.jar.desired.sha1 new file mode 100644 index 0000000000..8ad591b6ea --- /dev/null +++ b/test/pending/neg/plugin-rafter-before-1/lib/plugins.jar.desired.sha1 @@ -0,0 +1 @@ +af91fd67ccef349e7f8ea662615e17796a339485 ?plugins.jar diff --git a/test/pending/neg/plugin-rafter-before-1/misc/build.sh b/test/pending/neg/plugin-rafter-before-1/misc/build.sh new file mode 100755 index 0000000000..8899009d7f --- /dev/null +++ b/test/pending/neg/plugin-rafter-before-1/misc/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" + +BASE=`pwd` + +if [[ -d "${BASE}/src" ]] ; then + + mkdir -p build + ${SCALAC} -d build src/*.scala + jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . + rm -rf build +fi + diff --git a/test/pending/neg/plugin-rafter-before-1/misc/scalac-plugin.xml b/test/pending/neg/plugin-rafter-before-1/misc/scalac-plugin.xml new file mode 100644 index 0000000000..90ff27dc2a --- /dev/null +++ b/test/pending/neg/plugin-rafter-before-1/misc/scalac-plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <name>beforeparser</name> + <classname>scala.test.plugins.ThePlugin</classname> +</plugin> + diff --git a/test/pending/neg/plugin-rafter-before-1/src/ThePlugin.scala b/test/pending/neg/plugin-rafter-before-1/src/ThePlugin.scala new file mode 100644 index 0000000000..81ba85ae80 --- /dev/null +++ b/test/pending/neg/plugin-rafter-before-1/src/ThePlugin.scala @@ -0,0 +1,31 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "rafter-before-1" + val description = "" + val components = List[PluginComponent](thePhase1) + + private object thePhase1 extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]("refchecks") + override val runsBefore = List[String]("erasure") + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/pending/neg/plugin-rafter-before-1/testsource.scala b/test/pending/neg/plugin-rafter-before-1/testsource.scala new file mode 100644 index 0000000000..836459db22 --- /dev/null +++ b/test/pending/neg/plugin-rafter-before-1/testsource.scala @@ -0,0 +1,4 @@ +object Test extends Application { + println("rafter-before-1") +} + diff --git a/test/pending/neg/plugin-rightafter-terminal.check b/test/pending/neg/plugin-rightafter-terminal.check new file mode 100644 index 0000000000..6fe4f63c82 --- /dev/null +++ b/test/pending/neg/plugin-rightafter-terminal.check @@ -0,0 +1,2 @@ +error: [phase assembly, right after dependency on terminal phase not allowed: rightafterterminal => terminal] +one error found diff --git a/test/pending/neg/plugin-rightafter-terminal.flags b/test/pending/neg/plugin-rightafter-terminal.flags new file mode 100644 index 0000000000..948a318668 --- /dev/null +++ b/test/pending/neg/plugin-rightafter-terminal.flags @@ -0,0 +1,2 @@ +-Xplugin:files/neg/plugin-rightafter-terminal/lib/plugins.jar + diff --git a/test/pending/neg/plugin-rightafter-terminal/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-rightafter-terminal/lib/plugins.jar.desired.sha1 new file mode 100644 index 0000000000..c2e2b9cd43 --- /dev/null +++ b/test/pending/neg/plugin-rightafter-terminal/lib/plugins.jar.desired.sha1 @@ -0,0 +1 @@ +8cccde4914da2058dca893783c231cda23855603 ?plugins.jar diff --git a/test/pending/neg/plugin-rightafter-terminal/misc/build.sh b/test/pending/neg/plugin-rightafter-terminal/misc/build.sh new file mode 100755 index 0000000000..8899009d7f --- /dev/null +++ b/test/pending/neg/plugin-rightafter-terminal/misc/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" + +BASE=`pwd` + +if [[ -d "${BASE}/src" ]] ; then + + mkdir -p build + ${SCALAC} -d build src/*.scala + jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . + rm -rf build +fi + diff --git a/test/pending/neg/plugin-rightafter-terminal/misc/scalac-plugin.xml b/test/pending/neg/plugin-rightafter-terminal/misc/scalac-plugin.xml new file mode 100644 index 0000000000..90ff27dc2a --- /dev/null +++ b/test/pending/neg/plugin-rightafter-terminal/misc/scalac-plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <name>beforeparser</name> + <classname>scala.test.plugins.ThePlugin</classname> +</plugin> + diff --git a/test/pending/neg/plugin-rightafter-terminal/src/ThePlugin.scala b/test/pending/neg/plugin-rightafter-terminal/src/ThePlugin.scala new file mode 100644 index 0000000000..9d6d30b327 --- /dev/null +++ b/test/pending/neg/plugin-rightafter-terminal/src/ThePlugin.scala @@ -0,0 +1,32 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "rightafterterminal" + val description = "Declares one plugin that wants to be right after the terminal phase" + val components = List[PluginComponent](thePhase) + + private object thePhase extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]() + override val runsRightAfter = Some("terminal") + + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/pending/neg/plugin-rightafter-terminal/testsource.scala b/test/pending/neg/plugin-rightafter-terminal/testsource.scala new file mode 100644 index 0000000000..7af767b638 --- /dev/null +++ b/test/pending/neg/plugin-rightafter-terminal/testsource.scala @@ -0,0 +1,4 @@ +object Test extends Application { + println("rightafterterminal") +} + diff --git a/test/pending/neg/scopes.check b/test/pending/neg/scopes.check deleted file mode 100644 index bb8e15058b..0000000000 --- a/test/pending/neg/scopes.check +++ /dev/null @@ -1,30 +0,0 @@ -scopes.scala:1: error: x is already defined as value x -case class test0(x: int, x: float) - ^ -scopes.scala:5: error: t is already defined as type t - type t = float - ^ -scopes.scala:7: error: x is already defined as value x - val x: float = .0f; - ^ -scopes.scala:10: error: y is already defined as value y - val y: float = .0f - ^ -scopes.scala:13: error: x is already defined as value x - def f1(x: int, x: float) = x - ^ -scopes.scala:14: error: y is already defined as value y - def f2(x: int)(y: int, y: float) = x + y - ^ -scopes.scala:15: error: x is already defined as value x - val closure = (x: int, x: float) => x - ^ -scopes.scala:17: error: x is already defined as value x - case x::x => x - ^ -scopes.scala:1: error: type mismatch; - found : float - required: int -case class test0(x: int, x: float) - ^ -9 errors found diff --git a/test/pending/neg/scopes.scala b/test/pending/neg/scopes.scala deleted file mode 100644 index e38a0a3d2e..0000000000 --- a/test/pending/neg/scopes.scala +++ /dev/null @@ -1,20 +0,0 @@ -case class test0(x: int, x: float) - -object test1 { - type t = int - type t = float - val x: int = 0 - val x: float = .0f; - { - val y: int = 0 - val y: float = .0f - () - } - def f1(x: int, x: float) = x - def f2(x: int)(y: int, y: float) = x + y - val closure = (x: int, x: float) => x - List() match { - case x::x => x - case Nil => Nil - } -} diff --git a/test/pending/neg/t0513.scala b/test/pending/neg/t0513.scala deleted file mode 100644 index 0082b0e563..0000000000 --- a/test/pending/neg/t0513.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test { - case class Y[T1, T2 <: T1] - //val test = Y[Nothing, Int] // Compiler error - case class Test[T] - val test2 = Test[Y[Nothing, Int]] // No error -} diff --git a/test/pending/neg/t0625.check b/test/pending/neg/t0625.check deleted file mode 100644 index 45a35eb157..0000000000 --- a/test/pending/neg/t0625.check +++ /dev/null @@ -1,7 +0,0 @@ -<insert expected error message, current one is the following> - -t0625.scala:3: error: inferred the kinds of the type arguments (Option[B],Int) do not conform to the expected kinds of the type parameters (type C,type T). -Option[B]'s type parameters do not match type C's expected parameters: class Option has one type parameter, but type C has one - idMap(Some(0)) - ^ -one error found diff --git a/test/pending/neg/t0625.scala b/test/pending/neg/t0625.scala deleted file mode 100644 index a44a04fd97..0000000000 --- a/test/pending/neg/t0625.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test { - def idMap[C[_],T](m: { def map[U](f: T => U): C[U] }): C[T] = m.map(t => t) - idMap(Some(0)) -} diff --git a/test/pending/neg/t0653.check b/test/pending/neg/t0653.check deleted file mode 100644 index cb5ca65b8e..0000000000 --- a/test/pending/neg/t0653.check +++ /dev/null @@ -1,5 +0,0 @@ -t0653.scala:5: error: inferred the kinds of the type arguments (InL[Nothing,Nothing]) do not conform to the expected kinds of the type parameters (type Op) in class Fix. -InL[Nothing,Nothing]'s type parameters do not match type Op's expected parameters: class InL has two type parameters, but type Op has one - val zero = new Fix(new InL) - ^ -one error found diff --git a/test/pending/neg/t0653.scala b/test/pending/neg/t0653.scala index 156aa2d701..26204a8b40 100644 --- a/test/pending/neg/t0653.scala +++ b/test/pending/neg/t0653.scala @@ -1,6 +1,30 @@ -class InL[A, B] +// What is this test in place to test for? +// +class One[A] +class Two[A, B] class Fix[Op[A]](x : Op[Fix[Op]]) class FixTest { - val zero = new Fix(new InL) + // works + // val zero = new Fix[One](new One) + + // don't work: + val two = new Fix(new Two) // this was what I found here + val zero = new Fix(new One) // this seems like something which could plausibly work + + // neg/t0653.scala:12: error: no type parameters for constructor Fix: (x: Op[Fix[Op[A]]])Fix[Op[A]] exist so that it can be applied to arguments (Two[Nothing,Nothing]) + // --- because --- + // argument expression's type is not compatible with formal parameter type; + // found : Two[Nothing,Nothing] + // required: ?Op[ Fix[?Op[ A ]] ] + // val two = new Fix(new Two) // this was what I found here + // ^ + // neg/t0653.scala:13: error: no type parameters for constructor Fix: (x: Op[Fix[Op[A]]])Fix[Op[A]] exist so that it can be applied to arguments (One[Nothing]) + // --- because --- + // argument expression's type is not compatible with formal parameter type; + // found : One[Nothing] + // required: ?Op[ Fix[?Op[ A ]] ] + // val zero = new Fix(new One) // this seems like something which could plausibly work + // ^ + // two errors found } diff --git a/test/pending/neg/t1038.check b/test/pending/neg/t1038.check deleted file mode 100644 index 3bfd479f42..0000000000 --- a/test/pending/neg/t1038.check +++ /dev/null @@ -1,4 +0,0 @@ -t1038.scala:4: error: wrong number of arguments for constructor X: (Int)X - val a = new X - ^ -one error found diff --git a/test/pending/neg/t1038.scala b/test/pending/neg/t1038.scala deleted file mode 100644 index 7157aafa06..0000000000 --- a/test/pending/neg/t1038.scala +++ /dev/null @@ -1,7 +0,0 @@ -class X(x : Int) - -object Y { - val a = new X - import a._ - implicit val b : Int = 1 -} diff --git a/test/pending/neg/t1477.scala b/test/pending/neg/t1477.scala deleted file mode 100644 index 0cc0cd5f7a..0000000000 --- a/test/pending/neg/t1477.scala +++ /dev/null @@ -1,25 +0,0 @@ -object Test extends Application { - trait A - trait B extends A - - trait C { - type U - trait D { type T >: B <: A } - type V <: D - val y: V#T = new B { } - } - - trait Middle extends C { - type V <: (D with U) - } - - class D extends Middle { - trait E - trait F { type T = E } - type U = F - def frob(arg : E) : E = arg - frob(y) - } - - new D -} diff --git a/test/pending/neg/t1545.scala b/test/pending/neg/t1545.scala deleted file mode 100755 index d7c0245725..0000000000 --- a/test/pending/neg/t1545.scala +++ /dev/null @@ -1,16 +0,0 @@ -object Main extends Application { - - case class Foo (field : Option[String]) - - val x : PartialFunction[Foo,Int] = - { - c => c.field match { - case Some (s) => 42 - case None => 99 - } - } - - println (x (Foo (None))) // prints 99 - println (x (Foo (Some ("foo")))) // prints 42 - -} diff --git a/test/pending/neg/t1845.scala b/test/pending/neg/t1845.scala deleted file mode 100644 index cfb28aa03c..0000000000 --- a/test/pending/neg/t1845.scala +++ /dev/null @@ -1,12 +0,0 @@ -// Compiling the attached code makes scalac give a NPE. - -import scala.util.parsing.combinator.syntactical.TokenParsers -import scala.util.parsing.combinator.lexical.StdLexical -import scala.util.parsing.syntax.StdTokens - -class MyTokenParsers extends TokenParsers { - import lexical._ - type Tokens = StdTokens - type Elem = lexical.Token - val lexical = new StdLexical -} diff --git a/test/pending/neg/t2078.scala b/test/pending/neg/t2078.scala deleted file mode 100644 index a697afc646..0000000000 --- a/test/pending/neg/t2078.scala +++ /dev/null @@ -1,9 +0,0 @@ -class A[-S](y : S) { - val f = new { val x = y } -} - -object Test extends Application { - val a = new A(1) - val b = a : A[Nothing] - b.f.x -} diff --git a/test/pending/neg/t2080.scala b/test/pending/neg/t2080.scala index 0880a40faa..3f4306c091 100644 --- a/test/pending/neg/t2080.scala +++ b/test/pending/neg/t2080.scala @@ -14,4 +14,4 @@ object C extends B { } override def f(x : T) : T = { x.g; x } } -//It compiles without errors, but T in B and T in C are completely unrelated types. +//It compiles without errors, but T in B and T in C are completely unrelated types. diff --git a/test/pending/neg/t2180.scala b/test/pending/neg/t2180.scala deleted file mode 100644 index a8055bf77d..0000000000 --- a/test/pending/neg/t2180.scala +++ /dev/null @@ -1,31 +0,0 @@ - - -Given the following code (which is broken): - -class Mxml { - - private def processChildren( children:Seq[Any] ):List[Mxml] = { - - children.toList.flatMap ( e => { - - e match { - - case s:scala.collection.Traversable[_] => s case a => List(a) - - } - - }) - - } - -} - -I get the following error: - -Mxml.scala:5: error: could not find implicit value for parameter bf:scala.collection.generic.BuilderFactory[Any,List[Mxml],Sequence[Any]]. - - children.flatMap ( e => { - -I spent 4 hours failing before I figured out the problem. The return type was wrong. It should have been List[Any]. - -I have seen similar errors with map. My solution in the past has been to change it to a foldLeft because I have never been able to determine how to fix the problem until now. diff --git a/test/pending/neg/t3152.scala b/test/pending/neg/t3152.scala new file mode 100644 index 0000000000..3abc772076 --- /dev/null +++ b/test/pending/neg/t3152.scala @@ -0,0 +1,8 @@ +package test + +object NotEnclosing { + def main(args : Array[String]) : Unit = {} + def compare[T](x: Ordered[T], y: Ordered[T]) = error("") + def mkEx: Ordered[_] = error("") + compare(mkEx, mkEx) +} diff --git a/test/pending/neg/t3189.check b/test/pending/neg/t3189.check new file mode 100644 index 0000000000..43dd0f29a0 --- /dev/null +++ b/test/pending/neg/t3189.check @@ -0,0 +1,7 @@ +t3189.scala:2: error: illegal start of simple pattern + val Array(a,b*) = ("": Any) + ^ +t3189.scala:3: error: ')' expected but '}' found. +} +^ +two errors found diff --git a/test/pending/neg/t3189.scala b/test/pending/neg/t3189.scala new file mode 100644 index 0000000000..4ea4bb7581 --- /dev/null +++ b/test/pending/neg/t3189.scala @@ -0,0 +1,3 @@ +object A { + val Array(a,b*) = ("": Any) +}
\ No newline at end of file diff --git a/test/pending/neg/t3633/test/Test.scala b/test/pending/neg/t3633/test/Test.scala new file mode 100644 index 0000000000..395a6be6f4 --- /dev/null +++ b/test/pending/neg/t3633/test/Test.scala @@ -0,0 +1,23 @@ +package test + +final class Test extends PackageProtected { + def bar = foo +} + +package another { + object Main { + def t1(t: Test) { + // Can always be replicated. + println(t.foo) + } + def t2(t: Test) { + // Conditions to replicate: must use -optimise, class Test must be final + println(t.bar) + //@noinline is a usable workaround + } + def main(args: Array[String]) { + t1(new Test) + t2(new Test) + } + } +} diff --git a/test/pending/pos/t796.scala b/test/pending/neg/t796.scala index c013f49686..c013f49686 100644 --- a/test/pending/pos/t796.scala +++ b/test/pending/neg/t796.scala diff --git a/test/pending/neg/t2079.scala b/test/pending/neg/t963.scala index a86674c7e0..3be0be1b84 100644 --- a/test/pending/neg/t2079.scala +++ b/test/pending/neg/t963.scala @@ -1,11 +1,12 @@ +// Soundness bug, at #963 and dup at #2079. trait A { type T var v : T } object B { - def f(x : { val y : A }) { x.y.v = x.y.v } - + def f(x : { val y : A }) { x.y.v = x.y.v } + var a : A = _ var b : Boolean = false def y : A = { diff --git a/test/pending/neg/tcpoly_typealias_eta.scala b/test/pending/neg/tcpoly_typealias_eta.scala index 0fb2c2d33e..033c911f7c 100644 --- a/test/pending/neg/tcpoly_typealias_eta.scala +++ b/test/pending/neg/tcpoly_typealias_eta.scala @@ -12,7 +12,7 @@ trait A3 { trait FooCov[+x] trait FooCon[-x] -trait FooBound[+x <: String] +trait FooBound[+x <: String] trait BOk1 extends A { type m/*[+x]*/ = FooCov/*[x]*/ @@ -30,8 +30,8 @@ trait BOk4 extends A3 { type m/*[+x]*/ = FooCov/*[x]*/ // weaker variance } -// there are two aspects to check: - // does type alias signature (not considering RHS) correspond to abstract type member in super class +// there are two aspects to check: + // does type alias signature (not considering RHS) correspond to abstract type member in super class // does RHS correspond to the type alias sig trait BInv extends A{ type m/*[x]*/ = FooCov/*[x]*/ // error: invariant x in alias def diff --git a/test/pending/neg/tcpoly_variance_enforce_getter_setter.scala b/test/pending/neg/tcpoly_variance_enforce_getter_setter.scala index 321d392cc4..deafba8d8a 100644 --- a/test/pending/neg/tcpoly_variance_enforce_getter_setter.scala +++ b/test/pending/neg/tcpoly_variance_enforce_getter_setter.scala @@ -1,12 +1,12 @@ trait coll[+m[+x]] -class FooInvar[x] +class FooInvar[x] class FooContra[-x] class FooCov[+x] object test { var ok: coll[FooCov] = _ - + var x: coll[FooInvar] = _ // TODO: error should be reported only once instead of separately for getter and setter var y: coll[FooContra] = _ } diff --git a/test/pending/neg/type-diagnostics.scala b/test/pending/neg/type-diagnostics.scala new file mode 100644 index 0000000000..a3a9172bb2 --- /dev/null +++ b/test/pending/neg/type-diagnostics.scala @@ -0,0 +1,11 @@ +object TooManyParens { + def f = Map(1 -> 2).keySet() + // + // Confusion reigns! + // + // work/a.scala:27: error: not enough arguments for method apply: (elem: Int)Boolean in trait SetLike. + // Unspecified value parameter elem. + // def f = Map(1 -> 2).keySet() + // ^ + +} diff --git a/test/pending/pos/bug0305.scala b/test/pending/pos/bug0305.scala deleted file mode 100644 index 433f0e72c3..0000000000 --- a/test/pending/pos/bug0305.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test extends Application { - - def foo(is:int*) = 1; - def foo(i:int) = 2; - - Console.println( foo( List(3):_* ) ) - -} diff --git a/test/pending/pos/bug0418.scala b/test/pending/pos/bug0418.scala deleted file mode 100644 index 67007010d4..0000000000 --- a/test/pending/pos/bug0418.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - null match { case Foo12340771.Bar(x) => x } -} diff --git a/test/pending/pos/bug112606B.scala b/test/pending/pos/bug112606B.scala deleted file mode 100644 index 6dfaf4bf01..0000000000 --- a/test/pending/pos/bug112606B.scala +++ /dev/null @@ -1,11 +0,0 @@ -package test; -trait Test2 { - case class Token(text : String); - class KeywordToken(text : String) extends Token(text); - def decode(tok : KeywordToken) = tok match { - // constructor cannot be instantiated to expected type; - // found : Test2.this.Token - // required: Test2.this.KeywordToken - case Token("final") => true; - } -} diff --git a/test/pending/pos/bug2018.scala b/test/pending/pos/bug2018.scala deleted file mode 100644 index f1753f4d7a..0000000000 --- a/test/pending/pos/bug2018.scala +++ /dev/null @@ -1,15 +0,0 @@ -class A { - val b = new B - - def getChildren = List(new A).elements - - class B { - private def check = true - - private def getAncestor(p: A): A = { - val c = (p.getChildren.find(_.b.check)) match {case Some(d) => d case None => p} - - if (c == p) p else c.b.getAncestor(c) - } - } -} diff --git a/test/pending/pos/bug563.scala b/test/pending/pos/bug563.scala deleted file mode 100644 index d559226bdb..0000000000 --- a/test/pending/pos/bug563.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test { - def map[A,R](a : List[A], f : A => R) : List[R] = a.map(f); - - def split(sn : Iterable[List[Cell[int]]]) : unit = - for (val n <- sn) - map(n,ptr => new Cell(ptr.elem)); -} diff --git a/test/pending/pos/bug572.scala b/test/pending/pos/bug572.scala deleted file mode 100644 index 3a69cde4a6..0000000000 --- a/test/pending/pos/bug572.scala +++ /dev/null @@ -1,33 +0,0 @@ -package lampion.collections; - -object DirX { - abstract class Dir { - def reverse : Dir; - } - object BEFORE extends Dir { - def reverse = AFTER; - } - object AFTER extends Dir { - def reverse = BEFORE; - } -} -import DirX._; -abstract class Linked { - type Node <: Node0; - - abstract class Node0 { - var next : Node = _; - var prev : Node = _; - - def get(dir : Dir) = if (dir == BEFORE) prev; else next; - private def set(dir : Dir, node : Node) = - if (dir == BEFORE) prev = node; else next = node; - - def link(dir : Dir, node : Node) = { - assert(get(dir) == null); - assert(node.get(dir.reverse) == null); - set(dir, node); - node.set(dir.reverse(), node); - } - } -} diff --git a/test/pending/pos/bug573.scala b/test/pending/pos/bug573.scala deleted file mode 100644 index b1b4f75098..0000000000 --- a/test/pending/pos/bug573.scala +++ /dev/null @@ -1,43 +0,0 @@ -package lampion.collections; - -object DirX { - abstract class Dir { - def reverse : Dir; - } - object BEFORE extends Dir { - def reverse = AFTER; - } - object AFTER extends Dir { - def reverse = BEFORE; - } -} - -import DirX._; - -abstract class Linked { - type Node <: Node0; - - abstract class Node0 { - var next : Node = _; - var prev : Node = _; - - def self : Node; - - def get(dir : Dir) = if (dir == BEFORE) prev; else next; - private def set(dir : Dir, node : Node) = - if (dir == BEFORE) prev = node; else next = node; - - def link(dir : Dir, node : Node) = { - assert(get(dir) == null); - assert(node.get(dir.reverse) == null); - set(dir, node); - node.set(dir.reverse, self); - } - - - def end(dir : Dir) : Node = { - if (get(dir) == null) this; - else get(dir).end(dir); - } - } -} diff --git a/test/pending/pos/bug578.scala b/test/pending/pos/bug578.scala deleted file mode 100644 index 4899fa7f5f..0000000000 --- a/test/pending/pos/bug578.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test { - val x = Nil - val x2: Nil = x - val y = None - val y2:None = y - Console.println("Okay") -} diff --git a/test/pending/pos/bug579.scala b/test/pending/pos/bug579.scala deleted file mode 100644 index a0806919e0..0000000000 --- a/test/pending/pos/bug579.scala +++ /dev/null @@ -1,21 +0,0 @@ -package my.webapp.bean.stuff; - -import scala.reflect.BeanProperty - -class MyBean { - [BeanProperty] - var frombulizer: String = _; -} - -object Test extends Application { - - val x = new MyBean; - x.frombulizer = "hello" - - x.setFrombulizer ("hola") // synthetic methods comes too late for typechecking this code - - val z:String = x.frombulizer - - val zz:String = x.getFrombulizer // synthetic methods comes too late for typechecking this code - -} diff --git a/test/pending/pos/bug586.scala b/test/pending/pos/bug586.scala deleted file mode 100644 index b736e6ab43..0000000000 --- a/test/pending/pos/bug586.scala +++ /dev/null @@ -1,78 +0,0 @@ -import scala.collection.immutable.{Map, TreeMap, ListMap, ListSet, Set} -import scala.collection.{immutable=>imm, mutable=>mut} - -case class HashTreeSet[A](map: imm.Map[A, Unit]) -extends Object -with imm.Set[A] -{ - def this() = this(null) - - def size = map.size - def +(elem: A) = new HashTreeSet(map + elem -> ()) - def -(elem: A) = new HashTreeSet(map - elem) - def contains(elem: A) = map.isDefinedAt(elem) - def iterator = map.iterator.map(._1) - def empty:imm.Set[A] = new HashTreeSet[A]() -} - - -abstract class Goal2 { - type Question - val question: Question - - type Answer - def initialAnswer: Answer -} - - - -abstract class AbstractRespondersGoal -extends Goal2 // TYPEFIX -- comment out the extends Goal2 -{ -} - -class RespondersGoal( - val question: String, - rcvr: String, - signature: String, - codebase: String) -extends AbstractRespondersGoal -{ - type Question = String - type Answer = imm.Set[String] - - val initialAnswer = new HashTreeSet[String]()// TYPEFIX .asInstanceOf[Answer] -} - - -class SingleResponderGoal(val question: String, responder: String) -extends AbstractRespondersGoal -{ - type Question = String - type Answer = Set[String] - val initialAnswer = (new ListSet[String])//TYPEFIX .asInstanceOf[Answer] -} - -class RespondersGoalSet -//extends OneKindGoalSet -{ - type Question = String - type Answer = imm.Set[String] - type MyGoal = AbstractRespondersGoal - - var selector: Boolean = _ - def newGoal(question: String) //TYPEFIX :MyGoal - = { - - selector match { -// case StaticMethodSelector(method: MethodRef) => - case true => - new SingleResponderGoal(null, null) - -// case DynamicMethodSelector(signature: MethodSignature) => { -case false => { - new RespondersGoal(null, null,null,null) - } - } - } -} diff --git a/test/pending/pos/existentials-harmful.scala b/test/pending/pos/existentials-harmful.scala new file mode 100644 index 0000000000..8722852e8a --- /dev/null +++ b/test/pending/pos/existentials-harmful.scala @@ -0,0 +1,54 @@ +// a.scala +// Mon Jul 11 14:18:26 PDT 2011 + +object ExistentialsConsideredHarmful { + class Animal(val name: String) + object Dog extends Animal("Dog") + object Sheep extends Animal("Sheep") + + trait Tools[A] { + def shave(a: A): A + } + def tools[A](a: A): Tools[A] = null // dummy + + case class TransportBox[A <: Animal](animal: A, tools: Tools[A]) { + def label: String = animal.name + } + + // 1. + def carry[A <: Animal](box: TransportBox[A]): Unit = { + println(box.animal.name+" got carried away") + } + + val aBox = + if (math.random < 0.5) + TransportBox(Dog, tools(Dog)) + else + TransportBox(Sheep, tools(Sheep)) + + // 2. + //aBox.tools.shave(aBox.animal) + + // Use pattern match to avoid opening the existential twice + aBox match { + case TransportBox(animal, tools) => tools.shave(animal) + } + + abstract class BoxCarrier[R <: Animal](box: TransportBox[R]) { + def speed: Int + + def talkToAnimal: Unit = println("The carrier says hello to"+box.animal.name) + } + + // 3. + //val bc = new BoxCarrier(aBox) { + + // Use pattern match to avoid opening the existential twice + // Type annotation on bc is required ... possible compiler bug? + // val bc : BoxCarrier[_ <: Animal] = aBox match { + val bc = aBox match { + case tb : TransportBox[a] => new BoxCarrier(tb) { + def speed: Int = 12 + } + } +} diff --git a/test/pending/pos/foo.scala b/test/pending/pos/foo.scala deleted file mode 100644 index 8b45addbd5..0000000000 --- a/test/pending/pos/foo.scala +++ /dev/null @@ -1,3 +0,0 @@ -object foo { - var x: String -} diff --git a/test/pending/pos/misc/B.scala b/test/pending/pos/misc/B.scala index 3a080e4712..afc30944f5 100644 --- a/test/pending/pos/misc/B.scala +++ b/test/pending/pos/misc/B.scala @@ -1,7 +1,7 @@ package test class B { - + def myA = new A() } diff --git a/test/pending/pos/moors.scala b/test/pending/pos/moors.scala deleted file mode 100644 index 4f7346f57f..0000000000 --- a/test/pending/pos/moors.scala +++ /dev/null @@ -1,12 +0,0 @@ -object Test { - - implicit def foo2bar(foo :Foo) :Bar = foo.bar - - class Foo(val bar :Bar) { - def testCoercion ={ val a: this.type = this; a.baz /* here, foo2bar is inferred by the compiler, as expected */} - def testCoercionThis = baz // --> error: not found: value baz - def testCoercionThis = (this: Foo).baz // --> error: value baz is not a member of Foo - } - - class Bar { def baz = System.out.println("baz")} -} diff --git a/test/pending/pos/no-widen-locals.scala b/test/pending/pos/no-widen-locals.scala new file mode 100644 index 0000000000..013e63f0a2 --- /dev/null +++ b/test/pending/pos/no-widen-locals.scala @@ -0,0 +1,19 @@ +// Worked from r23262 until that was reverted somewhere +// around r25016. +import annotation.switch + +object Test { + def f(x: Int) = { + val X1 = 5 + val X2 = 10 + val X3 = 15 + val X4 = 20 + + (x: @switch) match { + case X1 => 1 + case X2 => 2 + case X3 => 3 + case X4 => 4 + } + } +} diff --git a/test/pending/pos/package-case.scala b/test/pending/pos/package-case.scala new file mode 100644 index 0000000000..906f1eb3f2 --- /dev/null +++ b/test/pending/pos/package-case.scala @@ -0,0 +1,4 @@ +// a.scala +// Sat Jul 16 00:34:36 EDT 2011 + +package object io { case class TextReader() } diff --git a/test/pending/pos/sig/sigs.scala b/test/pending/pos/sig/sigs.scala index 72a293d0e6..bdb72a09bb 100644 --- a/test/pending/pos/sig/sigs.scala +++ b/test/pending/pos/sig/sigs.scala @@ -1,5 +1,5 @@ package test -class T { +class T { def foo[T <: String](x: T): T = x def bar[T](x: T): T = x class Inner { diff --git a/test/pending/pos/t0576.scala b/test/pending/pos/t0576.scala deleted file mode 100644 index 669806826d..0000000000 --- a/test/pending/pos/t0576.scala +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - new Object { self => - def f(other: Any): Boolean = - other match { - case that: self.type => true - case _ => false - } - } -} diff --git a/test/pending/pos/t0621.scala b/test/pending/pos/t0621.scala index d178bed0fb..1d2531c4bd 100644 --- a/test/pending/pos/t0621.scala +++ b/test/pending/pos/t0621.scala @@ -1,7 +1,7 @@ object Test { val x1 : List[T] forSome { type T } = List(42) val w1 = x1 match { case y : List[u] => ((z : u) => z)(y.head) } - + val x2 : T forSome { type T } = 42 val w2 = x2 match { case y : u => ((z : u) => z)(y) } } diff --git a/test/pending/pos/t0644.scala b/test/pending/pos/t0644.scala deleted file mode 100644 index 5ad12c3632..0000000000 --- a/test/pending/pos/t0644.scala +++ /dev/null @@ -1,11 +0,0 @@ -class A { - def appply(): Int = 0 - def update(n: Int) {} -} - -class B extends A { - this() - this()=1 - super() - super()=1 -} diff --git a/test/pending/pos/t0716.scala b/test/pending/pos/t0716.scala deleted file mode 100644 index 98ba9bb2aa..0000000000 --- a/test/pending/pos/t0716.scala +++ /dev/null @@ -1,24 +0,0 @@ -trait Functor[F[_]] { - def fmap[A,B](fun: A=>B, arg:F[A]): F[B] -} -object Functor{ - implicit val ListFunctor = new Functor[List] { - def fmap[A, B](f: A => B, arg: List[A]):List[B] = arg map f - } - - final class OOFunctor[F[_],A](arg:F[A])(implicit ftr: Functor[F]) { - def fmap[B](fun: A=>B):F[B] = ftr.fmap(fun,arg) - } - - //breaks if uncommented - implicit def lifttoOO[F[_],A](arg:F[A])(implicit ftr: Functor[F]) = new OOFunctor[F,A](arg)(ftr) - - //works if uncommented - //implicit def liftListtoOO[A](arg:List[A]):OOFunctor[List,A] = new OOFunctor[List,A](arg) -} - -object GeneralLiftingDemo extends Application { - import Functor._ - val l = List(1,2,3) - println("OO : " + l.fmap( 1+) ) -} diff --git a/test/pending/pos/t0756.scala b/test/pending/pos/t0756.scala deleted file mode 100644 index a778bd63d0..0000000000 --- a/test/pending/pos/t0756.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - for { - n <- Some(42) - - _ - m <- Some(24) - } yield n -} diff --git a/test/pending/pos/t0805.scala b/test/pending/pos/t0805.scala deleted file mode 100644 index 565a2a6527..0000000000 --- a/test/pending/pos/t0805.scala +++ /dev/null @@ -1,9 +0,0 @@ -package fr.up5.mi.noel.scala -object Test { - def make(t: Test) : Test = TestList(t.args.toList) -} -case class TestList[T](elements: List[T])(implicit f: T => Test) - -class Test { - val args: Array[Test] -} diff --git a/test/pending/pos/t0816.scala b/test/pending/pos/t0816.scala deleted file mode 100644 index 44282ea872..0000000000 --- a/test/pending/pos/t0816.scala +++ /dev/null @@ -1,12 +0,0 @@ -abstract class Atest(val data: String) - -case class Btest(override val data: String, val b: boolean) extends Atest(data) - -case class Ctest(override val data: String) extends Btest(data, true) - -class testCaseClass { - def test(x: Atest) = x match { - case Ctest(data) => Console.println("C") - case Btest(data, b) => Console.println("B") - } -} diff --git a/test/pending/pos/t1003.scala b/test/pending/pos/t1003.scala deleted file mode 100644 index 27becdb10f..0000000000 --- a/test/pending/pos/t1003.scala +++ /dev/null @@ -1,3 +0,0 @@ -object A { - classOf[String].getMethod("equals", "") -} diff --git a/test/pending/pos/t1004.scala b/test/pending/pos/t1004.scala deleted file mode 100644 index e86631acea..0000000000 --- a/test/pending/pos/t1004.scala +++ /dev/null @@ -1,6 +0,0 @@ -object A { - def main(args: Array[String]) = { - val x = new { def copy(a : this.type) = a }; - x.copy(x) - } -} diff --git a/test/pending/pos/t1024.scala b/test/pending/pos/t1024.scala deleted file mode 100644 index 0bd5b026a5..0000000000 --- a/test/pending/pos/t1024.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test { - trait T { trait U { val x = 3 } } - val x = new AnyRef with T#U { } -} diff --git a/test/pending/pos/t1035.scala b/test/pending/pos/t1035.scala deleted file mode 100644 index 2485c10018..0000000000 --- a/test/pending/pos/t1035.scala +++ /dev/null @@ -1,32 +0,0 @@ -//A fatal error or Scala compiler -// Scala compiler version 2.7.1-final -- (c) 2002-2009 LAMP/EPFL -// Carlos Loria cloria@artinsoft.com -// 7/10/2008 - -class A { - var name:String = _ - def getName() = name - def this(name:String, age:Int){this();this.name=name} - -} - -class B(name:String) extends A(name,0){ -} - -class D { - - object A { - def unapply(p:A) = Some(p.getName) - } - - object B { - def unapply(p:B) = Some(p.getName) - } - def foo(p:Any) = p match { - case B(n) => println("B") - case A(n) => println("A") - - - } - -} diff --git a/test/pending/pos/t1053.scala b/test/pending/pos/t1053.scala deleted file mode 100644 index 1d4dfb637e..0000000000 --- a/test/pending/pos/t1053.scala +++ /dev/null @@ -1,6 +0,0 @@ -trait T[A] { trait U { type W = A; val x = 3 } } - -object Test { - val x : ({ type V = T[this.type] })#V = null - val y = new x.U { } -} diff --git a/test/pending/pos/t1357.scala b/test/pending/pos/t1357.scala new file mode 100644 index 0000000000..7bc6d45034 --- /dev/null +++ b/test/pending/pos/t1357.scala @@ -0,0 +1,21 @@ +object NonEmptyCons { + def unapply[H, T](c: (H, T)): Option[(H, T)] = Some(c) +} + + +object Main { + + type BT[+H, +T <: Tuple2[Tuple2[H, T], Tuple2[H, T]]] = Tuple2[H, T] + + // type T = Tuple2[String,String] + type BinaryTree[+E] = BT[E, T forSome { type T <: Tuple2[BT[E, T], BT[E, T]] }] + + def foo[E](tree: BinaryTree[E]): Unit = tree match { + case NonEmptyCons(_, tail) => { + tail match { + case NonEmptyCons(_, _) => { + } + } + } + } +}
\ No newline at end of file diff --git a/test/pending/pos/t1380/gnujaxp.jar.desired.sha1 b/test/pending/pos/t1380/gnujaxp.jar.desired.sha1 new file mode 100644 index 0000000000..c155c2aaa2 --- /dev/null +++ b/test/pending/pos/t1380/gnujaxp.jar.desired.sha1 @@ -0,0 +1 @@ +ee000286d00c5209d5644462c1cfea87fc8b1342 ?gnujaxp.jar diff --git a/test/pending/pos/t1380/hallo.scala b/test/pending/pos/t1380/hallo.scala new file mode 100644 index 0000000000..bb8fff2333 --- /dev/null +++ b/test/pending/pos/t1380/hallo.scala @@ -0,0 +1,3 @@ +object hallo { + def main(args:Array[String]) = println("hallo") +} diff --git a/test/pending/pos/t1659.scala b/test/pending/pos/t1659.scala deleted file mode 100644 index 10470d66f8..0000000000 --- a/test/pending/pos/t1659.scala +++ /dev/null @@ -1,4 +0,0 @@ -trait Y { type X } -trait W { def u[A](v : Y { type X = A }) : Unit } -class Z extends W { def u[A](v : Y { type X = A }) = null } - diff --git a/test/pending/pos/t1786.scala b/test/pending/pos/t1786.scala index d0cf8c7bac..dca2edaab4 100644 --- a/test/pending/pos/t1786.scala +++ b/test/pending/pos/t1786.scala @@ -1,10 +1,10 @@ /** This a consequence of the current type checking algorithm, where bounds * are checked only after variables are instantiated. I believe this will change once we go to contraint-based type inference. Assigning low priority until then. - * + * * */ class SomeClass(val intValue:Int) -class MyClass[T <: SomeClass](val myValue:T) +class MyClass[T <: SomeClass](val myValue:T) object Test extends Application { def myMethod(i:MyClass[_]) { diff --git a/test/pending/pos/t1836/J.java b/test/pending/pos/t1836/J.java deleted file mode 100644 index a009a59e21..0000000000 --- a/test/pending/pos/t1836/J.java +++ /dev/null @@ -1 +0,0 @@ -public abstract class J<T> { protected J(T id) { } } diff --git a/test/pending/pos/t1836/S.scala b/test/pending/pos/t1836/S.scala deleted file mode 100644 index 88ce1063e9..0000000000 --- a/test/pending/pos/t1836/S.scala +++ /dev/null @@ -1 +0,0 @@ -class S extends J("") diff --git a/test/pending/pos/bug1957.scala b/test/pending/pos/t1957.scala index f80cf730ed..f80cf730ed 100644 --- a/test/pending/pos/bug1957.scala +++ b/test/pending/pos/t1957.scala diff --git a/test/pending/pos/t1987/a.scala b/test/pending/pos/t1987/a.scala new file mode 100644 index 0000000000..ff27044b69 --- /dev/null +++ b/test/pending/pos/t1987/a.scala @@ -0,0 +1,7 @@ +package bug + +// goes with t1987b.scala +package object packageb { + def func(a: Int) = () + def func(a: String) = () +} diff --git a/test/pending/pos/t1987/b.scala b/test/pending/pos/t1987/b.scala new file mode 100644 index 0000000000..a469ca6ea8 --- /dev/null +++ b/test/pending/pos/t1987/b.scala @@ -0,0 +1,10 @@ +// compile with t1987a.scala + +package bug.packageb +// Note that the overloading works if instead of being in the package we import it: +// replace the above line with import bug.packageb._ + +class Client { + val x = func(1) // doesn't compile: type mismatch; found: Int(1) required: String + val y = func("1") // compiles +} diff --git a/test/pending/pos/t1996.scala b/test/pending/pos/t1996.scala deleted file mode 100644 index 2730128196..0000000000 --- a/test/pending/pos/t1996.scala +++ /dev/null @@ -1,19 +0,0 @@ -object forbug { - val l1 = List(List(ValDef(new A)), List(ValDef(new A))) - for ((e1s, e2s) <- l1.zip(l1); - (e1, e2) <- e1s.zip(e2s)) { - e1.a.doSome(20) -// () - } -} - - -class A { - def doSome(a: Int): this.type = { - println(a) - this - } -} - -case class ValDef(a: A) - diff --git a/test/pending/pos/t2060.scala b/test/pending/pos/t2060.scala deleted file mode 100644 index 3f47259849..0000000000 --- a/test/pending/pos/t2060.scala +++ /dev/null @@ -1,28 +0,0 @@ -object Test { - class Op[I]; - class IntOp extends Op[Int]; - - class Rich(x : Double) { - def + (op : IntOp) = op; - def + [I](op : Op[I]) = op; - def plus [I](op : Op[I]) = op; - } - - implicit def iToRich(x : Double) = - new Rich(x); - - // fails to compile - val failure = 1.0 + new Op[Int]; - - // works as expected -- - // problem isn't in adding new "+" - val a = 1.0 + new IntOp; - - // works as expected -- - // problem isn't in binding type variable I - val b = 1.0 plus new Op[Int]; - - // works as expected -- - // problem isn't in using Rich.+[I](op : Op[I]) - val c = iToRich(1.0) + new Op[Int]; -} diff --git a/test/pending/pos/t2099.scala b/test/pending/pos/t2099.scala deleted file mode 100644 index 934b6691a7..0000000000 --- a/test/pending/pos/t2099.scala +++ /dev/null @@ -1,27 +0,0 @@ -// nice to have, not terribly urgent, maybe? - -I have a trait: - -trait Vis[+T] - -and an object/class pair: - -object VisImpl? { def apply() = new VisImpl? } class VisImpl? extends Vis[Missing] - -Where Missing is some class of mine. In a separate project (where Vis and VisImpl? are on the classpath but Missing is not), if I do: - -object Test extends Application { - - val v = VisImpl?() println(v) - -} - -This causes a Scala compiler error (using 2.7.5 compiler). The error is: - -"Caused by java.lang.RuntimeException?: malformed Scala signature of VisImpl? at 3634; reference value data of package mypack refers to nonexisting symbol" - -Where mypack is the root package of the Missing class. This is not a helpful error as all my classes share the same root package and the problem is not in the VisImpl? declaration in any case. - -I would expect to see an error of the form: - -" Type parameter not found 'Missing': VisImpl? extends Vis[Missing] at Test: #4: val v = VisImpl?() " diff --git a/test/pending/pos/t2162.scala b/test/pending/pos/t2162.scala deleted file mode 100644 index b21404726b..0000000000 --- a/test/pending/pos/t2162.scala +++ /dev/null @@ -1,20 +0,0 @@ -// crash verified; no solution yet -class Foo(x: Int) -class Bar extends Foo(1) - -trait A { - def foo[T <: Foo] -} -class B extends A { - def foo[Bar] { println("B.foo[Bar]") } -} -object test { - val x = new B - val y = new A { - def foo[Bar] { println("A.foo[Bar]") } - } - def main(args: Array[String]) { - x.foo // ok - y.foo // java.lang.AssertionError: assertion failed (Erasure.scala:441 in r18338)) - } -} diff --git a/test/pending/pos/t2173.scala b/test/pending/pos/t2173.scala index 9a9a2edce4..cf1913d88b 100644 --- a/test/pending/pos/t2173.scala +++ b/test/pending/pos/t2173.scala @@ -1,17 +1,12 @@ - - -This (somewhat convoluted) code fails to compile - -class A[+U>:Null] { - - type R[+X>:Null] = X type O[+X] = A[R[X]] - +class A[+U >: Null] { + type R[+X >: Null] = X + type O[+X] = A[R[X]] } -with the following error: - -type arguments [A.this.R[X]] do not conform to class A's type parameter bounds [+U >: Null] - -However, because type R[+X>:Null] is identical to X, it should carry X bounds and R[X] lower bound should be known to be X's lower bound, i.e. Null. - -The same problem occurs with upper bounds. +// with the following error: +// +// type arguments [A.this.R[X]] do not conform to class A's type parameter bounds [+U >: Null] +// +// However, because type R[+X>:Null] is identical to X, it should carry X bounds and R[X] lower bound should be known to be X's lower bound, i.e. Null. +// +// The same problem occurs with upper bounds. diff --git a/test/pending/pos/t2179.scala b/test/pending/pos/t2179.scala deleted file mode 100644 index fd37d8f760..0000000000 --- a/test/pending/pos/t2179.scala +++ /dev/null @@ -1,6 +0,0 @@ -on trunk r18368, this delightful little poison pill: - -(Nil:List[List[Double]]).reduceLeft((_: Any, _: Any) => Nil.indices.map(_ => 0d)) - -sends the compiler into an apparently infinite loop. a sample thread dump shows: - diff --git a/test/pending/pos/t425.scala b/test/pending/pos/t425.scala deleted file mode 100644 index e50c50ac35..0000000000 --- a/test/pending/pos/t425.scala +++ /dev/null @@ -1,11 +0,0 @@ -object Temp{ - case class A(x: Int) - case class B(override val x: Int, y: Double) extends A(x) - - val b: A = B(5, 3.3) - b match { - case B(x, y) => Console.println(y) - case A(x) => Console.println(x) - } -} - diff --git a/test/pending/pos/t425variant.scala b/test/pending/pos/t425variant.scala deleted file mode 100644 index 458f3b9da8..0000000000 --- a/test/pending/pos/t425variant.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Temp{ - case class A(x: Int) - case class B(override val x: Int, y: Double) extends A(x) - - B(5, 3.3) match { - case B(x, y) => Console.println(y) - case A(x) => Console.println(x) - } -} - diff --git a/test/pending/pos/t4606.scala b/test/pending/pos/t4606.scala new file mode 100644 index 0000000000..f4e5058483 --- /dev/null +++ b/test/pending/pos/t4606.scala @@ -0,0 +1,29 @@ +object t4606 { + class A(var x: Int) + class B(x: Int) extends A(x) + trait C { self: B => + def foo = x + def bar = self.x + def baz = { + val b: B = self + b.x + } + } + + object Toto extends App { + val x = new B(10) with C + println(x.foo) // 10 + println(x.bar) // 10 + println(x.baz) // 10 + println(x.x) // 10 + } +} + +object t3194 { + class A(var x: Int) + class B(x: Int) extends A(x) { + self: A => + + def update(z: Int) = this.x = z + } +}
\ No newline at end of file diff --git a/test/pending/pos/t4859.scala b/test/pending/pos/t4859.scala new file mode 100644 index 0000000000..ec5abd966d --- /dev/null +++ b/test/pending/pos/t4859.scala @@ -0,0 +1,15 @@ +object O { + C().CC() + D().DD() +} + +case class C() { + case class CC() +} + +case class D() { + class DD() + object DD { + def apply() = new DD() + } +} diff --git a/test/pending/pos/those-kinds-are-high.scala b/test/pending/pos/those-kinds-are-high.scala new file mode 100644 index 0000000000..3012e72d7e --- /dev/null +++ b/test/pending/pos/those-kinds-are-high.scala @@ -0,0 +1,37 @@ +class A { + trait Container[+T] + trait Template[+CC[X] <: Container[X]] + + class C1[T] extends Template[C1] with Container[T] + class C2[T] extends Template[C2] with Container[T] + + /** Target expression: + * List(new C1[String], new C2[String]) + */ + + // Here's what would ideally be inferred. + // + // scala> :type List[Template[Container] with Container[String]](new C1[String], new C2[String]) + // List[Template[Container] with Container[java.lang.String]] + // + // Here's what it does infer. + // + // scala> :type List(new C1[String], new C2[String]) + // <console>:8: error: type mismatch; + // found : C1[String] + // required: Container[String] with Template[Container[Any] with Template[Container[Any] with Template[Any] with ScalaObject] with ScalaObject] with ScalaObject + // List(new C1[String], new C2[String]) + // ^ + // + // Simplified, the inferred type is: + // + // List[Container[String] with Template[Container[Any] with Template[Container[Any] with Template[Any]]] + // + + /** Working version explicitly typed. + */ + def fExplicit = List[Template[Container] with Container[String]](new C1[String], new C2[String]) + + // nope + // def fFail = List(new C1[String], new C2[String]) +} diff --git a/test/pending/pos/ticket2251.scala b/test/pending/pos/ticket2251.scala deleted file mode 100644 index 7b6efb0ea0..0000000000 --- a/test/pending/pos/ticket2251.scala +++ /dev/null @@ -1,25 +0,0 @@ - -// Martin: I am not sure this is a solvable problem right now. I'll leave it in pending. -// derived from pos/bug1001 -class A -trait B[T <: B[T]] extends A -class C extends B[C] -class D extends B[D] - -class Data { - // force computing lub of C and D (printLubs enabled:) - -/* -lub of List(D, C) at depth 2 - lub of List(D, C) at depth 1 - lub of List(D, C) at depth 0 - lub of List(D, C) is A - lub of List(D, C) is B[_1] forSome { type _1 >: D with C <: A } -lub of List(D, C) is B[_2] forSome { type _2 >: D with C{} <: B[_1] forSome { type _1 >: D with C{} <: A } } -*/ -// --> result = WRONG - - // should be: B[X] forSome {type X <: B[X]} -- can this be done automatically? for now, just detect f-bounded polymorphism and fall back to more coarse approximation - - val data: List[A] = List(new C, new D) -} diff --git a/test/pending/pos/unappgadteval.scala b/test/pending/pos/unappgadteval.scala index 0c22c71dee..89f6cabc43 100644 --- a/test/pending/pos/unappgadteval.scala +++ b/test/pending/pos/unappgadteval.scala @@ -1,35 +1,77 @@ -//Class hierarchy +/** Cleaned up in october 2010 by paulp. + * Hey, we should get this working. + */ + +// Class hierarchy trait Term[a] + object Var{ def unapply[a](x:Var[a]) = Some(x.name) } class Var[a] (val name : String) extends Term[a] + object Num{ def unapply(x:Num) = Some(x.value) } -class Num (val value : int) extends Term[int] -object Lam{ def unapply[b,c](l:Lam[b,c]) = Some{l.x,l.e}} -class Lam[b, c] (val x : Var[b], val e : Term[c]) extends Term[b => c] -object App{ def unapply[b,c](a:App[b,c]) = Some{a.f,a.e}} +class Num (val value : Int) extends Term[Int] + +object Lam{ def unapply[b,c](l: Lam[b,c]) = Some(l.x, l.e) } +class Lam[b, c](val x : Var[b], val e : Term[c]) extends Term[b => c] + +object App{ def unapply[b,c](a: App[b,c]) = Some(a.f, a.e) } class App[b, c] (val f : Term[b => c], val e : Term[b]) extends Term[c] -object Suc{ def unapply(a:Suc) = true } -class Suc () extends Term[int => int] + +object Suc { def unapply(a: Suc) = true } +class Suc() extends Term[Int => Int] + // Environments : -abstract class Env { - def apply[a](v : Var[a]): a - def extend[a](v : Var[a], x : a) = new Env { - def apply[b](w: Var[b]): b = w match { +abstract class Env { + def apply[a](v: Var[a]): a + def extend[a](v: Var[a], x : a) = new Env { + def apply[b](w: Var[b]): b = w match { case _ : v.type => x // v eq w, hence a = b case _ => Env.this.apply(w) }} } -object empty extends Env { - def apply[a](x : Var[a]): a = throw new Error("not found : "+x.name) +object empty extends Env { + def apply[a](x: Var[a]): a = throw new Error("not found : "+x.name) } + object Test { -// Evaluation : -def eval[a](t : Term[a], env : Env): a = t match { - case v : Var[b] => env(v) // a = b - case n @ Num(value) => value // a = int - case i @ Suc() => { y: int => y + 1 } // a = int=>int - case f @ Lam[b,c](x,e) => { y: b => eval(e, env.extend(x, y))} // a = b=>c - case a @ App(f,e) => eval(f, env)(eval(e, env)) // a = c -} + val v1 = new Var[util.Random]("random") + val v2 = new Var[Int]("Int") + val v3 = new Var[List[String]]("list") + + val anEnv = (empty + .extend(v1, new util.Random) + .extend(v2, 58) + .extend(v3, Nil) + ) + + def eval[a](t: Term[a], env : Env): a = t match { + // First three work + case v : Var[b] => env(v) // a = b + case n @ Num(value) => value // a = Int + case a @ App(f,e) => eval(f, env)(eval(e, env)) // a = c + + // Next one fails like: + // + // found : (Int) => Int + // required: a + case i @ Suc() => { (y: Int) => y + 1 } // a = Int => Int + + // Next one fails like: + // + // error: '=>' expected but '[' found. + // case f @ Lam[b,c](x, e) => { (y: b) => eval(e, env.extend(x, y)) } // a = b=>c + // ^ + case f @ Lam[b,c](x, e) => { (y: b) => eval(e, env.extend(x, y)) } // a = b=>c + } + + val f1 = () => eval(v1, anEnv) + val f2 = () => eval(v2, anEnv) + val f3 = () => eval(v3, anEnv) + + def main(args: Array[String]): Unit = { + println(f1()) + println(f2()) + println(f3()) + } } diff --git a/test/pending/pos/unapplyGeneric.scala b/test/pending/pos/unapplyGeneric.scala new file mode 100644 index 0000000000..bf88816885 --- /dev/null +++ b/test/pending/pos/unapplyGeneric.scala @@ -0,0 +1,11 @@ +object Bar { + def unapply[A,B](bar:Bar[A,B]) = Some(bar) +} + +class Bar[A,B](val _1:A, val _2:B) extends Product2[A,B] + +object Test { + new Bar(2, 'a') match { + case Bar(x,y) => + } +} diff --git a/test/pending/pos/virt.scala b/test/pending/pos/virt.scala index 6fe21246b0..99dcd747b2 100644 --- a/test/pending/pos/virt.scala +++ b/test/pending/pos/virt.scala @@ -1,9 +1,9 @@ object Virt extends Application { - class Foo { + class Foo { trait Inner <: { val x : Int = 3 } } - class Bar extends Foo { + class Bar extends Foo { trait Inner <: { val y : Int = x } } } diff --git a/test/pending/res/bug1092.res b/test/pending/res/bug1092.res deleted file mode 100644 index 6deef8afd0..0000000000 --- a/test/pending/res/bug1092.res +++ /dev/null @@ -1 +0,0 @@ -bug1092/A.scala bug1092/B.scala bug1092/C.scala diff --git a/test/pending/res/bug1092/A.scala b/test/pending/res/bug1092/A.scala deleted file mode 100644 index 192e7afe11..0000000000 --- a/test/pending/res/bug1092/A.scala +++ /dev/null @@ -1,4 +0,0 @@ -object HolderA { - class A(a: Int) -} - diff --git a/test/pending/res/bug1092/B.scala b/test/pending/res/bug1092/B.scala deleted file mode 100644 index 5c80e8e84d..0000000000 --- a/test/pending/res/bug1092/B.scala +++ /dev/null @@ -1,4 +0,0 @@ -object HolderB { - import HolderA.A - trait B extends A -} diff --git a/test/pending/res/bug1092/C.scala b/test/pending/res/bug1092/C.scala deleted file mode 100644 index f961a93b5b..0000000000 --- a/test/pending/res/bug1092/C.scala +++ /dev/null @@ -1,6 +0,0 @@ -object C extends Application { - import HolderA.A - import HolderB.B - - println(new A(4) with B) -} diff --git a/test/pending/res/bug830/Bad.scala b/test/pending/res/bug830/Bad.scala deleted file mode 100644 index 17632290ff..0000000000 --- a/test/pending/res/bug830/Bad.scala +++ /dev/null @@ -1,11 +0,0 @@ -package test; -trait HasNodeXXX { - type Node <: NodeImpl; - trait NodeImpl; -} -trait ScalaFlowScannerZZZ extends HasNodeXXX { - type Node <: NodeImpl; - trait NodeImplA extends super.NodeImpl; - trait NodeImplB extends NodeImpl; - trait NodeImpl extends NodeImplA with NodeImplB; -} diff --git a/test/pending/res/bug830/Good.scala b/test/pending/res/bug830/Good.scala deleted file mode 100644 index 84789bfc47..0000000000 --- a/test/pending/res/bug830/Good.scala +++ /dev/null @@ -1,11 +0,0 @@ -package test; -trait HasNodeXXX { - type Node <: NodeImpl; - trait NodeImpl; -} -trait ScalaFlowScannerZZZ extends HasNodeXXX { - type Node <: NodeImpl; - trait NodeImplA extends super.NodeImpl; - trait NodeImplB extends super.NodeImpl; - trait NodeImpl extends NodeImplA with NodeImplB; -} diff --git a/test/pending/res/bug830A.res b/test/pending/res/bug830A.res deleted file mode 100644 index 421e1a2fee..0000000000 --- a/test/pending/res/bug830A.res +++ /dev/null @@ -1,13 +0,0 @@ -bug830/Good.scala -bug830/Bad.scala -bug830/Good.scala -bug830/Bad.scala -bug830/Good.scala -bug830/Bad.scala -bug830/Good.scala -bug830/Bad.scala -bug830/Good.scala -bug830/Bad.scala -bug830/Good.scala -bug830/Bad.scala -bug830/Good.scala diff --git a/test/pending/res/bug830B.res b/test/pending/res/bug830B.res deleted file mode 100644 index 54c13801b6..0000000000 --- a/test/pending/res/bug830B.res +++ /dev/null @@ -1,13 +0,0 @@ -bug830/Good.scala -bug830/Good.scala -bug830/Good.scala -bug830/Bad.scala -bug830/Bad.scala -bug830/Bad.scala -bug830/Good.scala -bug830/Good.scala -bug830/Good.scala -bug830/Bad.scala -bug830/Bad.scala -bug830/Bad.scala -bug830/Good.scala diff --git a/test/pending/res/bug837.res b/test/pending/res/bug837.res deleted file mode 100644 index a0f5100843..0000000000 --- a/test/pending/res/bug837.res +++ /dev/null @@ -1,3 +0,0 @@ -DataFlowAnalysis.scala DeadCode.scala -DeadCode.scala - diff --git a/test/pending/res/bug837/DataFlowAnalysis.scala b/test/pending/res/bug837/DataFlowAnalysis.scala deleted file mode 100644 index 25c2fbc635..0000000000 --- a/test/pending/res/bug837/DataFlowAnalysis.scala +++ /dev/null @@ -1,17 +0,0 @@ -package test; -import scala.collection.mutable._; -trait CompleteLattice { - trait Elem; -} -trait DataFlowAnalysis[L <: CompleteLattice] { - type P; - val lattice : L; - val out: Map[P, lattice.Elem] = new HashMap; -} -abstract class Liveness { - object livenessLattice extends CompleteLattice; - final class LivenessAnalysis extends DataFlowAnalysis[livenessLattice.type] { - type P = String; - val lattice = livenessLattice; - } -} diff --git a/test/pending/res/bug837/DeadCode.scala b/test/pending/res/bug837/DeadCode.scala deleted file mode 100644 index 2978e24d42..0000000000 --- a/test/pending/res/bug837/DeadCode.scala +++ /dev/null @@ -1,6 +0,0 @@ -package test; -trait DeadcodeAnalysis { - object liveness extends Liveness; - val a = new liveness.LivenessAnalysis(); - var live = a.out("hello"); -} diff --git a/test/pending/run/TestFlatMap.scala b/test/pending/run/TestFlatMap.scala new file mode 100644 index 0000000000..dd5a0a0c2f --- /dev/null +++ b/test/pending/run/TestFlatMap.scala @@ -0,0 +1,29 @@ +import scala.collection.parallel.{ ParMap => PMap } +import scala.collection.parallel.mutable.{ ParHashSet => PMHashSet, ParHashMap => PMHashMap, ParArray } +import scala.util.Random +import scala.collection.parallel.CompositeThrowable + +object Test { + + def main(args: Array[String]) { + val N = 1500 + val M = 1500 + var unmatchedLeft = new PMHashSet[Int] + var unmatchedRight = new PMHashSet[Int] + Range(0, N).foreach{ x => unmatchedLeft += x} + Range(0, M).foreach{ x => unmatchedRight += x} + + try { + val matches = unmatchedLeft.flatMap{ lind: Int => + val dists = unmatchedRight.seq.map{ rind: Int => + val dist = Random.nextInt + (rind, dist) + } + dists + } + } catch { + case c: CompositeThrowable => for (t <- c.throwables) println("\n%s\n%s".format(t, t.getStackTrace.mkString("\n"))) + } + } + +} diff --git a/test/pending/run/array_casts.check b/test/pending/run/array_casts.check deleted file mode 100644 index f7d3e5036c..0000000000 --- a/test/pending/run/array_casts.check +++ /dev/null @@ -1,16 +0,0 @@ -is object - true -is seq - true -is collection - true -is random-access-seq - true -is random-access-seq-mutable - true -not string - true -not list - true -class [I -Array(10) -Array(10) -Array(10) -Array(10) -Good, arrays are not lists -Good, arrays are not rich strings -is-seq array true -class [I diff --git a/test/pending/run/array_casts.scala b/test/pending/run/array_casts.scala deleted file mode 100644 index 9d298bbc2b..0000000000 --- a/test/pending/run/array_casts.scala +++ /dev/null @@ -1,42 +0,0 @@ -object Test { - val a = Array(10) - def main(args : Array[String]) : Unit = { - val a = this.a : AnyRef - Console.println("is object - " + a.isInstanceOf[Object]) - Console.println("is seq - " + a.isInstanceOf[Seq[_]]) - Console.println("is collection - " + a.isInstanceOf[Collection[_]]) - Console.println("is random-access-seq - " + a.isInstanceOf[RandomAccessSeq[_]]) - Console.println("is random-access-seq-mutable - " + a.isInstanceOf[RandomAccessSeq.Mutable[_]]) - Console.println("not string - " + !a.isInstanceOf[String]) - Console.println("not list - " + !a.isInstanceOf[List[_]]) - try { - Console.println(a.asInstanceOf[Object].getClass) - } catch { case ex : ClassCastException => Console.println("Bad, arrays should be objects") } - try { - Console.println(a.asInstanceOf[Seq[_]]) - } catch { case ex : ClassCastException => Console.println("Bad, arrays should be seqs") } - try { - Console.println(a.asInstanceOf[Collection[_]]) - } catch { case ex : ClassCastException => Console.println("Bad, arrays should be collections") } - try { - Console.println(a.asInstanceOf[RandomAccessSeq[_]]) - } catch { case ex : ClassCastException => Console.println("Bad, arrays should be random access seqs") } - try { - Console.println(a.asInstanceOf[RandomAccessSeq.Mutable[_]]) - } catch { case ex : ClassCastException => Console.println("Bad, arrays should be mutable random access seqs") } - try { - Console.println("not expected: " + a.asInstanceOf[List[_]]) - } catch { case ex : ClassCastException => Console.println("Good, arrays are not lists") } - try { - Console.println("not expected: " + a.asInstanceOf[runtime.RichString]) - throw new Error("not expected") - } catch { case ex : ClassCastException => Console.println("Good, arrays are not rich strings") } - // check that arrays as seqs are still dynamically typed as arrays - val s = this.a : Seq[Int] - Console.println("is-seq array " + s.isInstanceOf[Array[Char]]) - try { - Console.println(s.asInstanceOf[Array[Int]].getClass) - } catch { case ex : ClassCastException => Console.println("Bad, arrays as seqs should still be arrays of int") } - () - } -} diff --git a/test/pending/run/arrays-2.check b/test/pending/run/arrays-2.check deleted file mode 100644 index ce28533c20..0000000000 --- a/test/pending/run/arrays-2.check +++ /dev/null @@ -1,7 +0,0 @@ -a1=Array(3, 2, 1) -a1=[3,2,1] -a2=Array(0, 4, 2, 6) -a2=[0,4,2,6] -a2=[0,7,4,2,1,3,6,5] -a2=[0,1,2,3,4,5,6,7] -true diff --git a/test/pending/run/arrays-2.scala b/test/pending/run/arrays-2.scala deleted file mode 100644 index bee22db577..0000000000 --- a/test/pending/run/arrays-2.scala +++ /dev/null @@ -1,25 +0,0 @@ -//############################################################################ -// Arrays 2 -//############################################################################ - -//############################################################################ - -object Test extends Application { - val a1 = Array(1, 2, 3) - val a2 = Array(0, 7, 4, 2, 1, 3, 6, 5) - val a3 = new Array(1, 2, 3) // ticket #193 (VerifyError) - - def _toString[A](a: Array[A]) = a.mkString("[", ",", "]") - - // slice: see file slices.scala - println("a1=" + a1.reverse) - println("a1=" + _toString(a1.reverse)) - println("a2=" + a2.filter(_ % 2 == 0)) - println("a2=" + _toString(a2.filter(_ % 2 == 0))) - - println("a2=" + _toString(a2)) - util.Sorting.stableSort(a2) - println("a2=" + _toString(a2)) - - println(a1 deepEquals a3) -} diff --git a/test/pending/run/bug0412.scala b/test/pending/run/bug0412.scala deleted file mode 100644 index 4610235427..0000000000 --- a/test/pending/run/bug0412.scala +++ /dev/null @@ -1,33 +0,0 @@ -object Magic { - - abstract class A[T1,T2]() { - trait C { type T; } - trait C1 extends C { type T = T1; } - trait C2 extends C { type T <: T2; } - - type CX; - - var cv: CX with C2 = _; - val c: CX with C2 = cv; - - def castA(x: c.T): T2 = x; - } - - class B[T1,T2] extends A[T1,T2]() { - type CX = C1; - - def castB(x: T1): T2 = castA(x); - } - - def cast[T1,T2](v: T1): T2 = - new B[T1,T2]().castB(v) - -} - -object Test { - - def main(args: Array[String]): Unit = { - Magic.cast[String,Exception]("xyz").printStackTrace(); - } - -} diff --git a/test/pending/run/bug0551.scala b/test/pending/run/bug0551.scala deleted file mode 100644 index ffa36d7cb0..0000000000 --- a/test/pending/run/bug0551.scala +++ /dev/null @@ -1,5 +0,0 @@ -case class A(x: int) -class B(x: int) extends A(x) -object Test extends Application { - Console.println(A(1) == new B(1)) -} diff --git a/test/pending/run/bug1006.check b/test/pending/run/bug1006.check deleted file mode 100644 index 409940768f..0000000000 --- a/test/pending/run/bug1006.check +++ /dev/null @@ -1 +0,0 @@ -23 diff --git a/test/pending/run/bug1006.scala b/test/pending/run/bug1006.scala deleted file mode 100644 index 0a82373fb6..0000000000 --- a/test/pending/run/bug1006.scala +++ /dev/null @@ -1,13 +0,0 @@ -object foo { - def main(args: Array[String]) { - abstract class A[T] { - def myVal: T - } - - class B[T](value: T) extends A[T] { - def myVal = value - } - - Console.println(new B[int](23).myVal) - } -} diff --git a/test/pending/run/bug1031.scala b/test/pending/run/bug1031.scala deleted file mode 100644 index 4db5674489..0000000000 --- a/test/pending/run/bug1031.scala +++ /dev/null @@ -1,11 +0,0 @@ -abstract class Tree -case class Foo(xs: List[Int]) extends Tree - -object test extends Application { - Foo(Nil) match { - case Foo(xs: List[_]) => - Console.println(xs) - case _ => - ; - } -} diff --git a/test/pending/run/bug1042.scala b/test/pending/run/bug1042.scala deleted file mode 100644 index 26b06a6f0c..0000000000 --- a/test/pending/run/bug1042.scala +++ /dev/null @@ -1,14 +0,0 @@ -abstract class A { - override def toString(): String // crucial - - def toString(sb: StringBuilder): StringBuilder // crucial -} - -case class B extends A { - // overloaded version is implemented, causing toString not to be implemented? - def toString(sb: StringBuilder): StringBuilder = error("") -} - -object Test extends Application { - Console.println(B) -} diff --git a/test/pending/run/bug2087.scala b/test/pending/run/bug2087.scala deleted file mode 100644 index b3f96fa415..0000000000 --- a/test/pending/run/bug2087.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - val s: Short = 0xFA99.toShort - val c: Char = 0xFA99.toChar - - assert((s == c) == (c == s)) - } -}
\ No newline at end of file diff --git a/test/pending/run/bug424.scala b/test/pending/run/bug424.scala deleted file mode 100644 index bc7a55732d..0000000000 --- a/test/pending/run/bug424.scala +++ /dev/null @@ -1,3 +0,0 @@ -object M { - def f = 3; -} diff --git a/test/pending/run/bug874.scala b/test/pending/run/bug874.scala deleted file mode 100644 index 29dfabe0e9..0000000000 --- a/test/pending/run/bug874.scala +++ /dev/null @@ -1,17 +0,0 @@ -object Test { - abstract class Base { - val U: { - def apply[A](x1: A)(x2: int): Any - } - U("xyz")(2) - } - class Mix extends Base { - case class U[A](x1: A)(x2: int) { - Console.println("U created with "+x1+" and "+x2) - } - } - def main(args : Array[String]) : Unit = { - val obvious: Base = new Mix; - obvious.U("abc")(1) - } -} diff --git a/test/pending/run/bugs425-and-816.scala b/test/pending/run/bugs425-and-816.scala deleted file mode 100644 index d9267d06af..0000000000 --- a/test/pending/run/bugs425-and-816.scala +++ /dev/null @@ -1,27 +0,0 @@ -object Test { - object bug425 { - case class A(x: Int) - case class B(override val x: Int, y: Double) extends A(x) - - val b: A = B(5, 3.3) - b match { - case B(x, y) => Console.println(y) - case A(x) => Console.println(x) - } - } - - object bug816 { - abstract class Atest(val data: String) - - case class Btest(override val data: String, val b: boolean) extends Atest(data) - - case class Ctest(override val data: String) extends Btest(data, true) - - class testCaseClass { - def test(x: Atest) = x match { - case Ctest(data) => Console.println("C") - case Btest(data, b) => Console.println("B") - } - } - } -} diff --git a/test/pending/run/castsingleton.check b/test/pending/run/castsingleton.check deleted file mode 100644 index 49742281f0..0000000000 --- a/test/pending/run/castsingleton.check +++ /dev/null @@ -1,2 +0,0 @@ -L() -L() diff --git a/test/pending/run/castsingleton.scala b/test/pending/run/castsingleton.scala deleted file mode 100644 index 171b380dc9..0000000000 --- a/test/pending/run/castsingleton.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test extends Application { - case class L(); - object N extends L(); - - def empty(xs : L) : Unit = xs match { - case x@N => println(x); println(x); - } - - empty(L()) -} diff --git a/test/pending/run/collections.check b/test/pending/run/collections.check deleted file mode 100644 index 33a8551bf3..0000000000 --- a/test/pending/run/collections.check +++ /dev/null @@ -1,36 +0,0 @@ -***** immutable.ListSet: -test1: 14005 -test2: 25005003 -test3: 25005003 -***** immutable.TreeSet: -test1: 14005 -test2: 25005003 -test3: 25005003 -***** mutable.HashSet: -test1: 14005 -test2: 25005003 -test3: 25005003 -***** immutable.ListMap: -test1: 14005 -test2: 1013003 -test3: 1013003 -***** immutable.TreeMap: -test1: 14005 -test2: 1013003 -test3: 1013003 -***** immutable.UnBalancedTreeMap: -test1: 14005 -test2: 1013003 -test3: 1013003 -***** immutable.HashTreeSet: -test1: 14005 -test2: 25005003 -test3: 25005003 -***** immutable.HashTreeMap: -test1: 14005 -test2: 1013003 -test3: 1013003 -***** mutable.HashMap: -test1: 14005 -test2: 25005003 -test3: 25005003 diff --git a/test/pending/run/collections.scala b/test/pending/run/collections.scala deleted file mode 100644 index 6717b524bb..0000000000 --- a/test/pending/run/collections.scala +++ /dev/null @@ -1,102 +0,0 @@ -import collection._ - -object Test extends Application { - - val printTime = false - - def sum[A](xs: Iterable[int]) = (0 /: xs)((x, y) => x + y) - - def time(op: => unit): unit = { - val start = System.currentTimeMillis; - op - if (printTime) Console.println(" time = "+(System.currentTimeMillis - start)+"ms") - } - - def test(msg: String, s0: collection.immutable.Set[int]) = { - Console.println("***** "+msg+":") - var s = s0 - s = s + 2 - s = s + (3, 4000, 10000) - Console.println("test1: "+sum(s)) - time { - s = s ++ (List.range(0, 5000) map (2*)) - Console.println("test2: "+sum(s)) - } - time { - var x = 0 - for (val i <- (0 to 10000)) - if (s contains i) x = x + i - Console.println("test3: "+x) - } - } - - def test(msg: String, s0: collection.mutable.Set[int]) = { - Console.println("***** "+msg+":") - var s = s0 - s = s + 2 - s = s + (3, 4000, 10000) - Console.println("test1: "+sum(s)) - time { - s = s ++ (List.range(0, 5000) map (2*)) - Console.println("test2: "+sum(s)) - } - time { - var x = 0 - for (val i <- (0 to 10000)) - if (s contains i) x = x + i - Console.println("test3: "+x) - } - } - - def test(msg: String, s0: collection.immutable.Map[int, int]) = { - Console.println("***** "+msg+":") - var s = s0 - s = s + (2 -> 2) - s = s + (3 -> 3, 4000 -> 4000, 10000 -> 10000) - Console.println("test1: "+sum(s map (._2))) - time { - s = s ++ (List.range(0, 1000) map (x => x * 2 -> x * 2)) - Console.println("test2: "+sum(s map (._2))) - } - time { - var x = 0 - for (val i <- (0 to 10000)) - s get i match { - case Some(i) => x = x + i - case None => - } - Console.println("test3: "+x) - } - } - - def test(msg: String, s0: collection.mutable.Map[int, int]) = { - Console.println("***** "+msg+":") - var s = s0 - s = s + (2 -> 2) - s = s + (3 -> 3, 4000 -> 4000, 10000 -> 10000) - Console.println("test1: "+sum(s map (._2))) - time { - s = s ++ (List.range(0, 5000) map (x => x * 2 -> x * 2)) - Console.println("test2: "+sum(s map (._2))) - } - time { - var x = 0 - for (val i <- (0 to 10000)) - s get i match { - case Some(i) => x = x + i - case None => - } - Console.println("test3: "+x) - } - } - - test("immutable.ListSet", new immutable.ListSet[int]) - test("immutable.TreeSet", new immutable.TreeSet[int]) - test("mutable.HashSet", new mutable.HashSet[int]) - test("immutable.ListMap", new immutable.ListMap[int, int]) - test("immutable.TreeMap", new immutable.TreeMap[int, int]) - test("immutable.UnBalancedTreeMap", new immutable.UnbalancedTreeMap[int, int]) - test("immutable.HashTreeSet", new immutable.HashTreeSet[int]) - test("immutable.HashTreeMap", new immutable.HashTreeMap[int, int]) - test("mutable.HashMap", new mutable.HashMap[int, int]) -} diff --git a/test/pending/run/deprecated.scala b/test/pending/run/deprecated.scala deleted file mode 100644 index 122e339d2f..0000000000 --- a/test/pending/run/deprecated.scala +++ /dev/null @@ -1,35 +0,0 @@ -object Test { - abstract class AbstractStuff { - def dostuff: Unit - } - - [postabstract] - class BlueStuff extends AbstractStuff { - [deprecated] def dostuff = Console.println("blue") - def five = "five" - } - - class LightBlueStuff extends BlueStuff { - [deprecated] override def dostuff = {Console.println("light blue")} - - // warning: deprecated method overrides a concrete method - [deprecated] override def five = "light five" - } - - // warning: not marked as postabstract - class RedStuff extends AbstractStuff { - [deprecated] def dostuff = Console.println("red") - } - - - def main(args: Array[String]) { - // warning: BlueStuff will be abstract after deprecated methods are removed - val blue = new BlueStuff - - // warning: RedStuff will be abstract after deprecated methods are removed - val red = new RedStuff - - // warning: dostuff is deprecated - blue.dostuff - } -} diff --git a/test/pending/run/exc.scala b/test/pending/run/exc.scala deleted file mode 100644 index 26f80412c0..0000000000 --- a/test/pending/run/exc.scala +++ /dev/null @@ -1,10 +0,0 @@ -object exc1 extends Application { - def foo() = { - while (true) { - try { - } catch { - case ex: Exception => - } - } - } -} diff --git a/test/pending/run/exc1.scala b/test/pending/run/exc1.scala deleted file mode 100644 index 48fc084dda..0000000000 --- a/test/pending/run/exc1.scala +++ /dev/null @@ -1,10 +0,0 @@ -object exc1 extends Application { - def foo(): unit = { - while (true) { - try { - } catch { - case ex: Exception => - } - } - } -} diff --git a/test/pending/run/exc2.scala b/test/pending/run/exc2.scala deleted file mode 100644 index 8adf9b4a37..0000000000 --- a/test/pending/run/exc2.scala +++ /dev/null @@ -1,12 +0,0 @@ -object exc2 extends Application { - def foo() = { - while (true) { - try { - Console.println("foo") - } catch { - case ex: Exception => - Console.println("bar") - } - } - } -} diff --git a/test/pending/run/hk-lub-fail.scala b/test/pending/run/hk-lub-fail.scala new file mode 100644 index 0000000000..b58a86ee75 --- /dev/null +++ b/test/pending/run/hk-lub-fail.scala @@ -0,0 +1,37 @@ +// Tue Jul 12 16:38:23 PDT 2011 + +class Bip[T1] +class Foo[T2] extends Bip[T2] +class Bar[T3] extends Bip[T3] + +abstract class Factory[CC[X] <: Bip[X]] { } + +object Quux1 extends Factory[Foo] +object Quux2 extends Factory[Bar] + +object Test { + // FAIL + val xs = List(Quux1, Quux2) + // error: type mismatch; + // found : Quux1.type (with underlying type object Quux1) + // required: Factory[_ >: Bar with Foo <: Bip] + // ^^ ^^ ^^ ^^ <-- QUIZ: what is missing from these types? + + // The type it should figure out, come on scalac + type F = Factory[CC] forSome { type X ; type CC[X] >: Bar[X] with Foo[X] <: Bip[X] } + + // No problem + val ys = List[F](Quux1, Quux2) + + // A repl session to get you started. +/* + val quux1 = EmptyPackageClass.tpe.member(newTermName("Quux1")) + val quux2 = EmptyPackageClass.tpe.member(newTermName("Quux2")) + val tps = List(quux1, quux2) map (_.tpe) + val test = EmptyPackageClass.tpe.member(newTermName("Test")) + val f = test.tpe.member(newTypeName("F")).tpe + + val fn = f.normalize.asInstanceOf[ExistentialType] + val fn2 = fn.underlying.asInstanceOf[TypeRef] +*/ +} diff --git a/test/pending/run/instanceOfAndTypeMatching.scala b/test/pending/run/instanceOfAndTypeMatching.scala new file mode 100644 index 0000000000..e04ae13585 --- /dev/null +++ b/test/pending/run/instanceOfAndTypeMatching.scala @@ -0,0 +1,192 @@ +// Summary of incorrect or questionable behavior. +// Full code and successful parts follow. + +object Summary { + class Outer { + class Inner { } + def f() = { class MethodInner ; new MethodInner } + } + + // 1 static issue: + // + // Given method in MethodInner: def g(other: MethodInner) = () + // method1.g(method1) fails to compile with type error. + // + // Note that this cannot be worked around by widening the return type + // of f() because MethodInner is declared inside of f. So there is no way + // I see for a class declared inside a method to receive members of its + // own declared type -- not only the narrow type of those from this + // instance, but ANY members, because there is no Foo#Bar syntax which will + // traverse a method. + // + // 4 runtime issues: + // + // From the outside: inner1.isInstanceOf[outer2.Inner] is true, should (maybe) be false + // From inside inner1: inner2.isInstanceOf[Outer.this.Inner] is true, should (maybe) be false + // From the outside: inner1 match { case _: outer2.Inner => true ... } is true, should definitely be false + // From inside method1: method2 match { case _: MethodInner => true ... } is true, should definitely be false + // + // Note that the fact that every test returns true on instances of MethodInner means + // that it is impossible to draw any type distinction between instances. As far as one + // can tell, they are all of the same type regardless not only of whether they were + // created on the same method invocation but whether they are contained in the same + // instance of Outer. + // + // WRT "same method invocation", see Iterator.duplicate for an example of this. +} + +// Tests + +class Outer { + class Inner { + def passOuter(other: Outer) = () // pass any Outer + def passThisType(other: Outer.this.type) = () // pass only this Outer instance + def passInner(other: Inner) = () // pass only Inners from this Outer instance + def passInner2(other: Outer.this.Inner) = () // same as above + def passInnerSharp(other: Outer#Inner) = () // pass any Inner + + def compareSimpleWithTypeMatch(other: Any) = other match { + case _: Inner => true + case _ => false + } + def compareSimpleWithInstanceOf(other: Any) = other.isInstanceOf[Inner] + + def compareSharpWithTypeMatch(other: Any) = { + other match { + case _: Outer#Inner => true + case _ => false + } + } + def compareSharpWithInstanceOf(other: Any) = other.isInstanceOf[Outer#Inner] + + def comparePathWithTypeMatch(other: Any) = other match { + case _: Outer.this.Inner => true + case _ => false + } + def comparePathWithInstanceOf(other: Any) = other.isInstanceOf[Outer.this.Inner] + } + + def f() = { + class MethodInner { + def passOuter(other: Outer) = () // pass any Outer + def passThisType(other: Outer.this.type) = () // pass only this Outer instance + def passInner(other: Inner) = () // pass only Inners from this Outer instance + def passInner2(other: Outer.this.Inner) = () // same as above + def passInnerSharp(other: Outer#Inner) = () // pass any Inner + def passMethodInner(other: MethodInner) = () // pass only MethodInners from this Outer instance + // is there any way to refer to Outer#MethodInner? Not that there should be. + + def compareWithInstanceOf(other: Any) = other.isInstanceOf[MethodInner] + def compareWithTypeMatch(other: Any) = other match { + case _: MethodInner => true + case _ => false + } + } + + new MethodInner + } +} + +object Test { + val outer1 = new Outer + val outer2 = new Outer + val inner1 = new outer1.Inner + val inner2 = new outer2.Inner + val method1 = outer1.f() + val method2 = outer2.f() + + def testInnerStatic = { + // these should all work + inner1.passOuter(outer1) + inner1.passOuter(outer2) + inner1.passThisType(outer1) + inner1.passInner(inner1) + inner1.passInner2(inner1) + inner1.passInnerSharp(inner1) + inner1.passInnerSharp(inner2) + + // these should all fail to compile, and do + // + // inner1.passThisType(outer2) + // inner1.passInner(inner2) + // inner1.passInner2(inner2) + } + def testInnerRuntime = { + println("testInnerRuntime\n") + + List("These should be true under any scenario: ", + inner1.isInstanceOf[outer1.Inner] , + inner1.isInstanceOf[Outer#Inner] , + (inner1: Any) match { case _: Outer#Inner => true ; case _ => false } , + (inner1: Any) match { case _: outer1.Inner => true ; case _ => false } , + inner1.compareSharpWithTypeMatch(inner2) , + inner1.compareSharpWithInstanceOf(inner2) + ) foreach println + + List("These should be true under current proposal: ", + inner1.compareSimpleWithInstanceOf(inner2) + ) foreach println + + List("These should be false under current proposal: ", + inner1.compareSimpleWithTypeMatch(inner2) , + inner1.comparePathWithTypeMatch(inner2) + ) foreach println + + List("These return true but I think should return false: ", + inner1.isInstanceOf[outer2.Inner] , // true + inner1.comparePathWithInstanceOf(inner2) // true + ) foreach println + + List("These are doing the wrong thing under current proposal", + (inner1: Any) match { case _: outer2.Inner => true ; case _ => false } // should be false + ) foreach println + } + + def testMethodInnerStatic = { + // these should all work + method1.passOuter(outer1) + method1.passOuter(outer2) + method1.passThisType(outer1) + method1.passInner(inner1) + method1.passInner2(inner1) + method1.passInnerSharp(inner1) + method1.passInnerSharp(inner2) + // This fails with: + // + // a.scala:114: error: type mismatch; + // found : Test.method1.type (with underlying type MethodInner forSome { type MethodInner <: java.lang.Object with ScalaObject{def passOuter(other: Outer): Unit; def passThisType(other: Test.outer1.type): Unit; def passInner(other: Test.outer1.Inner): Unit; def passInner2(other: Test.outer1.Inner): Unit; def passInnerSharp(other: Outer#Inner): Unit; def passMethodInner(other: MethodInner): Unit} }) + // required: MethodInner where type MethodInner <: java.lang.Object with ScalaObject{def passOuter(other: Outer): Unit; def passThisType(other: Test.outer1.type): Unit; def passInner(other: Test.outer1.Inner): Unit; def passInner2(other: Test.outer1.Inner): Unit; def passInnerSharp(other: Outer#Inner): Unit; def passMethodInner(other: MethodInner): Unit} + // method1.passMethodInner(method1) + // ^ + method1.passMethodInner(method1) + + // these should all fail to compile, and do + // + // method1.passThisType(outer2) + // method1.passInner(inner2) + // method1.passInner2(inner2) + // method1.passMethodInner(method2) + } + + def testMethodInnerRuntime = { + println("\ntestMethodInnerRuntime\n") + + List("These should be true under any scenario: ", + method1.compareWithInstanceOf(method1) , + method1.compareWithTypeMatch(method1) + ) foreach println + + List("These should be true under current proposal: ", + method1.compareWithInstanceOf(method2) + ) foreach println + + List("These are doing the wrong thing under current proposal", + method1.compareWithTypeMatch(method2) // should be false + ) foreach println + } + + def main(args: Array[String]): Unit = { + testInnerRuntime + testMethodInnerRuntime + } +} diff --git a/test/pending/run/jar-version.scala b/test/pending/run/jar-version.scala new file mode 100644 index 0000000000..b79dfe733d --- /dev/null +++ b/test/pending/run/jar-version.scala @@ -0,0 +1,11 @@ +import scala.util.Properties._ +import scala.tools.nsc.util.ClassPath._ + +object Test { + def main(args: Array[String]): Unit = { + infoFor(this).jarManifestMainAttrs get ScalaCompilerVersion match { + case Some(v) => println("I was built by scala compiler version " + v) + case _ => println("I was not apprised of which scala compiler version built me.") + } + } +} diff --git a/test/pending/run/mixins.scala b/test/pending/run/mixins.scala deleted file mode 100644 index c7926c9c53..0000000000 --- a/test/pending/run/mixins.scala +++ /dev/null @@ -1,6 +0,0 @@ -trait A { val x: Int } -trait B extends A { override val x = 1 } // with A -trait C extends A { override val x = 2 } // with A -object Test extends B with C with Application { - println(x) -} diff --git a/test/pending/run/preinits.scala b/test/pending/run/preinits.scala deleted file mode 100644 index 8de43b62ea..0000000000 --- a/test/pending/run/preinits.scala +++ /dev/null @@ -1,6 +0,0 @@ -trait A { val x: Int; println("A") } -trait B extends { override val x = 1 } with A { println("B") } -trait C extends { override val x = 2 } with A -object Test extends B with C with Application { - println(x) -} diff --git a/test/pending/run/records.scala b/test/pending/run/records.scala deleted file mode 100644 index 87b15265f2..0000000000 --- a/test/pending/run/records.scala +++ /dev/null @@ -1,25 +0,0 @@ -trait C { - def f: int -} - -object Test { - type T = C { - def f: int - def g: String - } - - val x: T = new C { - def f = 1 - def g = "hello" - } - - val y = new C { - def f = 2 - def g = " world" - } - - val z: T = y - - Console.println(x.f+z.f+", expected = 3") - Console.println(x.g+z.g+", expected = hello world") -} diff --git a/test/pending/run/reify_addressbook.check b/test/pending/run/reify_addressbook.check new file mode 100644 index 0000000000..4e12f87bdc --- /dev/null +++ b/test/pending/run/reify_addressbook.check @@ -0,0 +1,30 @@ +<html> + <head> + <title> + My Address Book + </title> + <style type="text/css"> table { border-right: 1px solid #cccccc; } + th { background-color: #cccccc; } + td { border-left: 1px solid #acacac; } + td { border-bottom: 1px solid #acacac; + </style> + </head> + <body> + <table cellspacing="0" cellpadding="2"> + <tr> + <th>Name</th> + <th>Age</th> + </tr> + <tr> + <td> Tom </td> + <td> 20 </td> + </tr><tr> + <td> Bob </td> + <td> 22 </td> + </tr><tr> + <td> James </td> + <td> 19 </td> + </tr> + </table> + </body> + </html> diff --git a/test/pending/run/reify_addressbook.scala b/test/pending/run/reify_addressbook.scala new file mode 100644 index 0000000000..225f26b75e --- /dev/null +++ b/test/pending/run/reify_addressbook.scala @@ -0,0 +1,71 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + case class Person(name: String, age: Int) + + /** An AddressBook takes a variable number of arguments + * which are accessed as a Sequence + */ + class AddressBook(a: Person*) { + private val people: List[Person] = a.toList + + /** Serialize to XHTML. Scala supports XML literals + * which may contain Scala expressions between braces, + * which are replaced by their evaluation + */ + def toXHTML = + <table cellpadding="2" cellspacing="0"> + <tr> + <th>Name</th> + <th>Age</th> + </tr> + { for (p <- people) yield + <tr> + <td> { p.name } </td> + <td> { p.age.toString() } </td> + </tr> + } + </table>; + } + + /** We introduce CSS using raw strings (between triple + * quotes). Raw strings may contain newlines and special + * characters (like \) are not interpreted. + */ + val header = + <head> + <title> + { "My Address Book" } + </title> + <style type="text/css"> { + """table { border-right: 1px solid #cccccc; } + th { background-color: #cccccc; } + td { border-left: 1px solid #acacac; } + td { border-bottom: 1px solid #acacac;"""} + </style> + </head>; + + val people = new AddressBook( + Person("Tom", 20), + Person("Bob", 22), + Person("James", 19)); + + val page = + <html> + { header } + <body> + { people.toXHTML } + </body> + </html>; + + println(page) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/reify_brainf_ck.check b/test/pending/run/reify_brainf_ck.check new file mode 100644 index 0000000000..702bb18394 --- /dev/null +++ b/test/pending/run/reify_brainf_ck.check @@ -0,0 +1,4 @@ +---running--- +Hello World! + +---done--- diff --git a/test/pending/run/reify_brainf_ck.scala b/test/pending/run/reify_brainf_ck.scala new file mode 100644 index 0000000000..3bfb76c9ea --- /dev/null +++ b/test/pending/run/reify_brainf_ck.scala @@ -0,0 +1,85 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + import scala.annotation._ + + trait Func[T] { + val zero: T + def inc(t: T): T + def dec(t: T): T + def in: T + def out(t: T): Unit + } + + object ByteFunc extends Func[Byte] { + override val zero: Byte = 0 + override def inc(t: Byte) = ((t + 1) & 0xFF).toByte + override def dec(t: Byte) = ((t - 1) & 0xFF).toByte + override def in: Byte = readByte + override def out(t: Byte) { print(t.toChar) } + } + + case class Tape[T](left: List[T], cell: T, right: List[T])(implicit func: Func[T]) { + private def headOf(list:List[T]) = if (list.isEmpty) func.zero else list.head + private def tailOf(list:List[T]) = if (list.isEmpty) Nil else list.tail + def isZero = cell == func.zero + def execute(ch: Char) = (ch: @switch) match { + case '+' => copy(cell = func.inc(cell)) + case '-' => copy(cell = func.dec(cell)) + case '<' => Tape(tailOf(left), headOf(left), cell :: right) + case '>' => Tape(cell :: left, headOf(right), tailOf(right)) + case '.' => func.out(cell); this + case ',' => copy(cell = func.in) + case '[' | ']' => this + case _ => error("Unexpected token: " + ch) + } + } + + object Tape { + def empty[T](func: Func[T]) = Tape(Nil, func.zero, Nil)(func) + } + + class Brainfuck[T](func:Func[T]) { + + def execute(p: String) { + val prog = p.replaceAll("[^\\+\\-\\[\\]\\.\\,\\>\\<]", "") + + @tailrec def braceMatcher(pos: Int, stack: List[Int], o2c: Map[Int, Int]): Map[Int,Int] = + if(pos == prog.length) o2c else (prog(pos): @switch) match { + case '[' => braceMatcher(pos + 1, pos :: stack, o2c) + case ']' => braceMatcher(pos + 1, stack.tail, o2c + (stack.head -> pos)) + case _ => braceMatcher(pos + 1, stack, o2c) + } + + val open2close = braceMatcher(0, Nil, Map()) + val close2open = open2close.map(_.swap) + + @tailrec def ex(pos:Int, tape:Tape[T]): Unit = + if(pos < prog.length) ex((prog(pos): @switch) match { + case '[' if tape.isZero => open2close(pos) + case ']' if ! tape.isZero => close2open(pos) + case _ => pos + 1 + }, tape.execute(prog(pos))) + + println("---running---") + ex(0, Tape.empty(func)) + println("\n---done---") + } + } + + val bf = new Brainfuck(ByteFunc) + bf.execute(""">+++++++++[<++++++++>-]<.>+++++++[<++ + ++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] + <.#>+++++++++++[<+++++>-]<.>++++++++[<++ + +>-]<.+++.------.--------.[-]>++++++++[<++++> + -]<+.[-]++++++++++.""") + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/reify_callccinterpreter.check b/test/pending/run/reify_callccinterpreter.check new file mode 100644 index 0000000000..ef8fc121df --- /dev/null +++ b/test/pending/run/reify_callccinterpreter.check @@ -0,0 +1,3 @@ +42 +wrong +5 diff --git a/test/pending/run/reify_callccinterpreter.scala b/test/pending/run/reify_callccinterpreter.scala new file mode 100644 index 0000000000..c10f4f0b4e --- /dev/null +++ b/test/pending/run/reify_callccinterpreter.scala @@ -0,0 +1,94 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + type Answer = Value; + + /** + * A continuation monad. + */ + case class M[A](in: (A => Answer) => Answer) { + def bind[B](k: A => M[B]) = M[B](c => in (a => k(a) in c)) + def map[B](f: A => B): M[B] = bind(x => unitM(f(x))) + def flatMap[B](f: A => M[B]): M[B] = bind(f) + } + + def unitM[A](a: A) = M[A](c => c(a)) + + def id[A] = (x: A) => x + def showM(m: M[Value]): String = (m in id).toString() + + def callCC[A](h: (A => M[A]) => M[A]) = + M[A](c => h(a => M[A](d => c(a))) in c) + + type Name = String + + trait Term + case class Var(x: Name) extends Term + case class Con(n: Int) extends Term + case class Add(l: Term, r: Term) extends Term + case class Lam(x: Name, body: Term) extends Term + case class App(fun: Term, arg: Term) extends Term + case class Ccc(x: Name, t: Term) extends Term + + trait Value + case object Wrong extends Value { + override def toString() = "wrong" + } + case class Num(n: Int) extends Value { + override def toString() = n.toString() + } + case class Fun(f: Value => M[Value]) extends Value { + override def toString() = "<function>" + } + + type Environment = List[Pair[Name, Value]]; + + def lookup(x: Name, e: Environment): M[Value] = e match { + case List() => unitM(Wrong) + case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1) + } + + def add(a: Value, b: Value): M[Value] = Pair(a, b) match { + case Pair(Num(m), Num(n)) => unitM(Num(m + n)) + case _ => unitM(Wrong) + } + + def apply(a: Value, b: Value): M[Value] = a match { + case Fun(k) => k(b) + case _ => unitM(Wrong) + } + + def interp(t: Term, e: Environment): M[Value] = t match { + case Var(x) => lookup(x, e) + case Con(n) => unitM(Num(n)) + case Add(l, r) => for (a <- interp(l, e); + b <- interp(r, e); + c <- add(a, b)) + yield c + case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e))) + case App(f, t) => for (a <- interp(f, e); + b <- interp(t, e); + c <- apply(a, b)) + yield c + case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e)) + } + + def test(t: Term): String = showM(interp(t, List())) + + val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11))) + val term1 = App(Con(1), Con(2)) + val term2 = Add(Con(1), Ccc("k", Add(Con(2), App(Var("k"), Con(4))))) + + println(test(term0)) + println(test(term1)) + println(test(term2)) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/reify_closure2b.check b/test/pending/run/reify_closure2b.check new file mode 100644 index 0000000000..c1f3abd7e6 --- /dev/null +++ b/test/pending/run/reify_closure2b.check @@ -0,0 +1,2 @@ +11 +12 diff --git a/test/pending/run/reify_closure2b.scala b/test/pending/run/reify_closure2b.scala new file mode 100644 index 0000000000..e9fb40bede --- /dev/null +++ b/test/pending/run/reify_closure2b.scala @@ -0,0 +1,22 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + def foo(y: Int): Int => Int = { + class Foo(y: Int) { + val fun: reflect.Code[Int => Int] = x => { + x + y + } + } + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(new Foo(y).fun.tree) + val dyn = toolbox.runExpr(ttree) + dyn.asInstanceOf[Int => Int] + } + + println(foo(1)(10)) + println(foo(2)(10)) +} diff --git a/test/pending/run/reify_closure3b.check b/test/pending/run/reify_closure3b.check new file mode 100644 index 0000000000..c1f3abd7e6 --- /dev/null +++ b/test/pending/run/reify_closure3b.check @@ -0,0 +1,2 @@ +11 +12 diff --git a/test/pending/run/reify_closure3b.scala b/test/pending/run/reify_closure3b.scala new file mode 100644 index 0000000000..5c4f3c81b9 --- /dev/null +++ b/test/pending/run/reify_closure3b.scala @@ -0,0 +1,24 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + def foo(y: Int): Int => Int = { + class Foo(y: Int) { + def y1 = y + + val fun: reflect.Code[Int => Int] = x => { + x + y1 + } + } + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(new Foo(y).fun.tree) + val dyn = toolbox.runExpr(ttree) + dyn.asInstanceOf[Int => Int] + } + + println(foo(1)(10)) + println(foo(2)(10)) +} diff --git a/test/pending/run/reify_closure4b.check b/test/pending/run/reify_closure4b.check new file mode 100644 index 0000000000..c1f3abd7e6 --- /dev/null +++ b/test/pending/run/reify_closure4b.check @@ -0,0 +1,2 @@ +11 +12 diff --git a/test/pending/run/reify_closure4b.scala b/test/pending/run/reify_closure4b.scala new file mode 100644 index 0000000000..24dfa9fe17 --- /dev/null +++ b/test/pending/run/reify_closure4b.scala @@ -0,0 +1,24 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + def foo(y: Int): Int => Int = { + class Foo(y: Int) { + val y1 = y + + val fun: reflect.Code[Int => Int] = x => { + x + y1 + } + } + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(new Foo(y).fun.tree) + val dyn = toolbox.runExpr(ttree) + dyn.asInstanceOf[Int => Int] + } + + println(foo(1)(10)) + println(foo(2)(10)) +} diff --git a/test/pending/run/reify_closure5b.check b/test/pending/run/reify_closure5b.check new file mode 100644 index 0000000000..df9e19c591 --- /dev/null +++ b/test/pending/run/reify_closure5b.check @@ -0,0 +1,2 @@ +13 +14 diff --git a/test/pending/run/reify_closure5b.scala b/test/pending/run/reify_closure5b.scala new file mode 100644 index 0000000000..02eb771f0c --- /dev/null +++ b/test/pending/run/reify_closure5b.scala @@ -0,0 +1,22 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + def foo[T](ys: List[T]): Int => Int = { + class Foo[T](ys: List[T]) { + val fun: reflect.Code[Int => Int] = x => { + x + ys.length + } + } + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(new Foo(ys).fun.tree) + val dyn = toolbox.runExpr(ttree) + dyn.asInstanceOf[Int => Int] + } + + println(foo(List(1, 2, 3))(10)) + println(foo(List(1, 2, 3, 4))(10)) +} diff --git a/test/pending/run/reify_closure8b.check b/test/pending/run/reify_closure8b.check new file mode 100644 index 0000000000..9a037142aa --- /dev/null +++ b/test/pending/run/reify_closure8b.check @@ -0,0 +1 @@ +10
\ No newline at end of file diff --git a/test/pending/run/reify_closure8b.scala b/test/pending/run/reify_closure8b.scala new file mode 100644 index 0000000000..9e37e4e09a --- /dev/null +++ b/test/pending/run/reify_closure8b.scala @@ -0,0 +1,17 @@ +import scala.reflect.Code._ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + class Foo(y: Int) { + def fun = lift{y} + } + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(new Foo(10).fun.tree) + val dyn = toolbox.runExpr(ttree) + val foo = dyn.asInstanceOf[Int] + println(foo) +} diff --git a/test/pending/run/reify_closure9a.check b/test/pending/run/reify_closure9a.check new file mode 100644 index 0000000000..9a037142aa --- /dev/null +++ b/test/pending/run/reify_closure9a.check @@ -0,0 +1 @@ +10
\ No newline at end of file diff --git a/test/pending/run/reify_closure9a.scala b/test/pending/run/reify_closure9a.scala new file mode 100644 index 0000000000..f3ee153d3c --- /dev/null +++ b/test/pending/run/reify_closure9a.scala @@ -0,0 +1,20 @@ +import scala.reflect.Code._ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + def foo(y: Int) = { + class Foo(val y: Int) { + def fun = lift{y} + } + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(new Foo(y).fun.tree) + val dyn = toolbox.runExpr(ttree) + dyn.asInstanceOf[Int] + } + + println(foo(10)) +} diff --git a/test/pending/run/reify_closure9b.check b/test/pending/run/reify_closure9b.check new file mode 100644 index 0000000000..9a037142aa --- /dev/null +++ b/test/pending/run/reify_closure9b.check @@ -0,0 +1 @@ +10
\ No newline at end of file diff --git a/test/pending/run/reify_closure9b.scala b/test/pending/run/reify_closure9b.scala new file mode 100644 index 0000000000..8d349e8701 --- /dev/null +++ b/test/pending/run/reify_closure9b.scala @@ -0,0 +1,20 @@ +import scala.reflect.Code._ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + def foo(y: Int) = { + class Foo(y: Int) { + def fun = lift{y} + } + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(new Foo(y).fun.tree) + val dyn = toolbox.runExpr(ttree) + dyn.asInstanceOf[Int] + } + + println(foo(10)) +} diff --git a/test/pending/run/reify_closures11.check b/test/pending/run/reify_closures11.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/pending/run/reify_closures11.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/pending/run/reify_closures11.scala b/test/pending/run/reify_closures11.scala new file mode 100644 index 0000000000..42053bd029 --- /dev/null +++ b/test/pending/run/reify_closures11.scala @@ -0,0 +1,18 @@ +import scala.reflect.Code._ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + def fun() = { + def z() = 2 + lift{z} + } + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(fun().tree) + val dyn = toolbox.runExpr(ttree) + val foo = dyn.asInstanceOf[Int] + println(foo) +} diff --git a/test/pending/run/reify_csv.check b/test/pending/run/reify_csv.check new file mode 100644 index 0000000000..b56f4bb50b --- /dev/null +++ b/test/pending/run/reify_csv.check @@ -0,0 +1,10 @@ +List(phase name, id, description) +record(parser,1,parse source into ASTs, perform simple desugaring) +record(namer,2,resolve names, attach symbols to named trees) +record(packageobjects,3,load package objects) +record(typer,4,the meat and potatoes: type the trees) +record(superaccessors,5,add super accessors in traits and nested classes) +record(pickler,6,serialize symbol tables) +record(refchecks,7,reference/override checking, translate nested objects) +record(selectiveanf,8,) +record(liftcode,9,reify trees) diff --git a/test/pending/run/reify_csv.scala b/test/pending/run/reify_csv.scala new file mode 100644 index 0000000000..a05a3b55d4 --- /dev/null +++ b/test/pending/run/reify_csv.scala @@ -0,0 +1,42 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val csv = """ + | phase name; id; description + | parser; 1; parse source into ASTs, perform simple desugaring + | namer; 2; resolve names, attach symbols to named trees + |packageobjects; 3; load package objects + | typer; 4; the meat and potatoes: type the trees + |superaccessors; 5; add super accessors in traits and nested classes + | pickler; 6; serialize symbol tables + | refchecks; 7; reference/override checking, translate nested objects + | selectiveanf; 8; + | liftcode; 9; reify trees""".stripMargin.split("\n").map{_.trim()}.drop(1).toList + + val fields = csv.head.split(";").map{_.trim()}.toList + println(fields) + + val code = scala.reflect.Code.lift({ + object Csv { + case class record(`phase name`: String, id: String, description: String) + + object record { + def parse(lines: List[String]) = { + lines drop(1) map { line => line.split(";", -1).toList match { + case phase$whitespace$name :: id :: description :: _ => record(phase$whitespace$name.trim(), id.trim(), description.trim()) + case _ => throw new Exception("format error") + }} + } + } + } + + Csv.record.parse(csv) foreach println + }) + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/reify_fors.check b/test/pending/run/reify_fors.check new file mode 100644 index 0000000000..eefddedc20 --- /dev/null +++ b/test/pending/run/reify_fors.check @@ -0,0 +1,5 @@ +Persons over 20: John Richard +divisors(34) = List(1, 2, 17, 34) +findNums(15) = (4,1) (5,2) (6,1) (7,4) (8,3) (8,5) (9,2) (9,4) (10,1) (10,3) (10,7) (11,2) (11,6) (11,8) (12,1) (12,5) (12,7) (13,4) (13,6) (13,10) (14,3) (14,5) (14,9) +average(List(3.5, 5.0, 4.5)) = 4.333333333333333 +scalProd(List(3.5, 5.0, 4.5), List(2.0, 1.0, 3.0)) = 25.5 diff --git a/test/pending/run/reify_fors.scala b/test/pending/run/reify_fors.scala new file mode 100644 index 0000000000..f3556514a9 --- /dev/null +++ b/test/pending/run/reify_fors.scala @@ -0,0 +1,107 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + object Persons { + /** A list of persons. To create a list, we use Predef.List + * which takes a variable number of arguments and constructs + * a list out of them. + */ + val persons = List( + new Person("Bob", 17), + new Person("John", 40), + new Person("Richard", 68) + ) + + /** A Person class. 'val' constructor parameters become + * public members of the class. + */ + class Person(val name: String, val age: Int) + + /** Return an iterator over persons that are older than 20. + */ + def olderThan20(xs: Seq[Person]): Iterator[String] = + olderThan20(xs.elements) + + /** Return an iterator over persons older than 20, given + * an iterator over persons. + */ + def olderThan20(xs: Iterator[Person]): Iterator[String] = { + + // The first expression is called a 'generator' and makes + // 'p' take values from 'xs'. The second expression is + // called a 'filter' and it is a boolean expression which + // selects only persons older than 20. There can be more than + // one generator and filter. The 'yield' expression is evaluated + // for each 'p' which satisfies the filters and used to assemble + // the resulting iterator + for (p <- xs if p.age > 20) yield p.name + } + } + + /** Some functions over lists of numbers which demonstrate + * the use of for comprehensions. + */ + object Numeric { + + /** Return the divisors of n. */ + def divisors(n: Int): List[Int] = + for (i <- List.range(1, n+1) if n % i == 0) yield i + + /** Is 'n' a prime number? */ + def isPrime(n: Int) = divisors(n).length == 2 + + /** Return pairs of numbers whose sum is prime. */ + def findNums(n: Int): Iterable[(Int, Int)] = { + + // a for comprehension using two generators + for (i <- 1 until n; + j <- 1 until (i-1); + if isPrime(i + j)) yield (i, j) + } + + /** Return the sum of the elements of 'xs'. */ + def sum(xs: List[Double]): Double = + xs.foldLeft(0.0) { (x, y) => x + y } + + /** Return the sum of pairwise product of the two lists. */ + def scalProd(xs: List[Double], ys: List[Double]) = + sum(for((x, y) <- xs zip ys) yield x * y); + + /** Remove duplicate elements in 'xs'. */ + def removeDuplicates[A](xs: List[A]): List[A] = + if (xs.isEmpty) + xs + else + xs.head :: removeDuplicates(for (x <- xs.tail if x != xs.head) yield x) + } + + // import all members of object 'persons' in the current scope + import Persons._ + + print("Persons over 20:") + olderThan20(persons) foreach { x => print(" " + x) } + println + + import Numeric._ + + println("divisors(34) = " + divisors(34)) + + print("findNums(15) =") + findNums(15) foreach { x => print(" " + x) } + println + + val xs = List(3.5, 5.0, 4.5) + println("average(" + xs + ") = " + sum(xs) / xs.length) + + val ys = List(2.0, 1.0, 3.0) + println("scalProd(" + xs + ", " + ys +") = " + scalProd(xs, ys)) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/reify_gadts.check b/test/pending/run/reify_gadts.check new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/test/pending/run/reify_gadts.check @@ -0,0 +1 @@ +42 diff --git a/test/pending/run/reify_gadts.scala b/test/pending/run/reify_gadts.scala new file mode 100644 index 0000000000..7077de735c --- /dev/null +++ b/test/pending/run/reify_gadts.scala @@ -0,0 +1,45 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + /* The syntax tree of a toy language */ + abstract class Term[T] + + /* An integer literal */ + case class Lit(x: Int) extends Term[Int] + + /* Successor of a number */ + case class Succ(t: Term[Int]) extends Term[Int] + + /* Is 't' equal to zero? */ + case class IsZero(t: Term[Int]) extends Term[Boolean] + + /* An 'if' expression. */ + case class If[T](c: Term[Boolean], + t1: Term[T], + t2: Term[T]) extends Term[T] + + /** A type-safe eval function. The right-hand sides can + * make use of the fact that 'T' is a more precise type, + * constraint by the pattern type. + */ + def eval[T](t: Term[T]): T = t match { + case Lit(n) => n + + // the right hand side makes use of the fact + // that T = Int and so it can use '+' + case Succ(u) => eval(u) + 1 + case IsZero(u) => eval(u) == 0 + case If(c, u1, u2) => eval(if (eval(c)) u1 else u2) + } + println( + eval(If(IsZero(Lit(1)), Lit(41), Succ(Lit(41))))) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/reify_lazyevaluation.check b/test/pending/run/reify_lazyevaluation.check new file mode 100644 index 0000000000..1c7f96cd96 --- /dev/null +++ b/test/pending/run/reify_lazyevaluation.check @@ -0,0 +1,8 @@ +s = Susp(?) +evaluating... +s() = 3 +s = Susp(3) +2 + s = 5 +sl2 = Susp(?) +sl2() = Some(3) +sl2 = Susp(Some(3)) diff --git a/test/pending/run/reify_lazyevaluation.scala b/test/pending/run/reify_lazyevaluation.scala new file mode 100644 index 0000000000..f38af76751 --- /dev/null +++ b/test/pending/run/reify_lazyevaluation.scala @@ -0,0 +1,65 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + object lazyLib { + + /** Delay the evaluation of an expression until it is needed. */ + def delay[A](value: => A): Susp[A] = new SuspImpl[A](value) + + /** Get the value of a delayed expression. */ + implicit def force[A](s: Susp[A]): A = s() + + /** + * Data type of suspended computations. (The name froms from ML.) + */ + abstract class Susp[+A] extends Function0[A] + + /** + * Implementation of suspended computations, separated from the + * abstract class so that the type parameter can be invariant. + */ + class SuspImpl[A](lazyValue: => A) extends Susp[A] { + private var maybeValue: Option[A] = None + + override def apply() = maybeValue match { + case None => + val value = lazyValue + maybeValue = Some(value) + value + case Some(value) => + value + } + + override def toString() = maybeValue match { + case None => "Susp(?)" + case Some(value) => "Susp(" + value + ")" + } + } + } + + import lazyLib._ + + val s: Susp[Int] = delay { println("evaluating..."); 3 } + + println("s = " + s) // show that s is unevaluated + println("s() = " + s()) // evaluate s + println("s = " + s) // show that the value is saved + println("2 + s = " + (2 + s)) // implicit call to force() + + val sl = delay { Some(3) } + val sl1: Susp[Some[Int]] = sl + val sl2: Susp[Option[Int]] = sl1 // the type is covariant + + println("sl2 = " + sl2) + println("sl2() = " + sl2()) + println("sl2 = " + sl2) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/reify_maps.check b/test/pending/run/reify_maps.check new file mode 100644 index 0000000000..08cbbb1359 --- /dev/null +++ b/test/pending/run/reify_maps.check @@ -0,0 +1,4 @@ +red has code: 16711680 +Unknown color: green +Unknown color: blue +turquoise has code: 65535 diff --git a/test/pending/run/reify_maps.scala b/test/pending/run/reify_maps.scala new file mode 100644 index 0000000000..589b28d049 --- /dev/null +++ b/test/pending/run/reify_maps.scala @@ -0,0 +1,26 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + val colors = Map("red" -> 0xFF0000, + "turquoise" -> 0x00FFFF, + "black" -> 0x000000, + "orange" -> 0xFF8040, + "brown" -> 0x804000) + for (name <- List("red", "green", "blue", "turquoise")) println( + colors.get(name) match { + case Some(code) => + name + " has code: " + code + case None => + "Unknown color: " + name + } + ) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/reify_properties.check b/test/pending/run/reify_properties.check new file mode 100644 index 0000000000..d769bea4b0 --- /dev/null +++ b/test/pending/run/reify_properties.check @@ -0,0 +1,2 @@ +user1: MR. ROBERT <noname> +user2: MR. BOB KUZ diff --git a/test/pending/run/reify_properties.scala b/test/pending/run/reify_properties.scala new file mode 100644 index 0000000000..2115a96715 --- /dev/null +++ b/test/pending/run/reify_properties.scala @@ -0,0 +1,63 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + /** A mutable property whose getter and setter may be customized. */ + case class Property[T](init: T) { + private var value: T = init + + /** The getter function, defaults to identity. */ + private var setter: T => T = identity[T] + + /** The setter function, defaults to identity. */ + private var getter: T => T = identity[T] + + /** Retrive the value held in this property. */ + def apply(): T = getter(value) + + /** Update the value held in this property, through the setter. */ + def update(newValue: T) = value = setter(newValue) + + /** Change the getter. */ + def get(newGetter: T => T) = { getter = newGetter; this } + + /** Change the setter */ + def set(newSetter: T => T) = { setter = newSetter; this } + } + + class User { + // Create a property with custom getter and setter + val firstname = Property("") + .get { v => v.toUpperCase() } + .set { v => "Mr. " + v } + val lastname = Property("<noname>") + + /** Scala provides syntactic sugar for calling 'apply'. Simply + * adding a list of arguments between parenthesis (in this case, + * an empty list) is translated to a call to 'apply' with those + * arguments. + */ + override def toString() = firstname() + " " + lastname() + } + + val user1 = new User + + // Syntactic sugar for 'update': an assignment is translated to a + // call to method 'update' + user1.firstname() = "Robert" + + val user2 = new User + user2.firstname() = "bob" + user2.lastname() = "KUZ" + + println("user1: " + user1) + println("user2: " + user2) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/reify_simpleinterpreter.check b/test/pending/run/reify_simpleinterpreter.check new file mode 100644 index 0000000000..4344dc9009 --- /dev/null +++ b/test/pending/run/reify_simpleinterpreter.check @@ -0,0 +1,2 @@ +42 +wrong diff --git a/test/pending/run/reify_simpleinterpreter.scala b/test/pending/run/reify_simpleinterpreter.scala new file mode 100644 index 0000000000..b39f5583bb --- /dev/null +++ b/test/pending/run/reify_simpleinterpreter.scala @@ -0,0 +1,82 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + case class M[A](value: A) { + def bind[B](k: A => M[B]): M[B] = k(value) + def map[B](f: A => B): M[B] = bind(x => unitM(f(x))) + def flatMap[B](f: A => M[B]): M[B] = bind(f) + } + + def unitM[A](a: A): M[A] = M(a) + + def showM(m: M[Value]): String = m.value.toString(); + + type Name = String + + trait Term; + case class Var(x: Name) extends Term + case class Con(n: Int) extends Term + case class Add(l: Term, r: Term) extends Term + case class Lam(x: Name, body: Term) extends Term + case class App(fun: Term, arg: Term) extends Term + + trait Value + case object Wrong extends Value { + override def toString() = "wrong" + } + case class Num(n: Int) extends Value { + override def toString() = n.toString() + } + case class Fun(f: Value => M[Value]) extends Value { + override def toString() = "<function>" + } + + type Environment = List[Pair[Name, Value]] + + def lookup(x: Name, e: Environment): M[Value] = e match { + case List() => unitM(Wrong) + case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1) + } + + def add(a: Value, b: Value): M[Value] = Pair(a, b) match { + case Pair(Num(m), Num(n)) => unitM(Num(m + n)) + case _ => unitM(Wrong) + } + + def apply(a: Value, b: Value): M[Value] = a match { + case Fun(k) => k(b) + case _ => unitM(Wrong) + } + + def interp(t: Term, e: Environment): M[Value] = t match { + case Var(x) => lookup(x, e) + case Con(n) => unitM(Num(n)) + case Add(l, r) => for (a <- interp(l, e); + b <- interp(r, e); + c <- add(a, b)) + yield c + case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e))) + case App(f, t) => for (a <- interp(f, e); + b <- interp(t, e); + c <- apply(a, b)) + yield c + } + + def test(t: Term): String = + showM(interp(t, List())) + + val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11))) + val term1 = App(Con(1), Con(2)) + + println(test(term0)) + println(test(term1)) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/reify_timeofday.check b/test/pending/run/reify_timeofday.check new file mode 100644 index 0000000000..3fd3b76a62 --- /dev/null +++ b/test/pending/run/reify_timeofday.check @@ -0,0 +1 @@ +DateError diff --git a/test/pending/run/reify_timeofday.scala b/test/pending/run/reify_timeofday.scala new file mode 100644 index 0000000000..6bd11b0d30 --- /dev/null +++ b/test/pending/run/reify_timeofday.scala @@ -0,0 +1,48 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + class DateError extends Exception + + /** Simulating properties in Scala + * (example 4.2.1 in ScalaReference.pdf) + */ + class TimeOfDayVar { + private var h, m, s: Int = 0 + + def hours = h + + /** A method 'ident_=' is a setter for 'ident'. 'code.ident = ...' will + * be translated to a call to 'ident_=' + */ + def hours_= (h: Int) = + if (0 <= h && h < 24) this.h = h + else throw new DateError() + + def minutes = m + def minutes_= (m: Int) = + if (0 <= m && m < 60) this.m = m + else throw new DateError() + + def seconds = s + def seconds_= (s: Int) = + if (0 <= s && s < 60) this.s = s + else throw new DateError() + } + + val d = new TimeOfDayVar + d.hours = 8; d.minutes = 30; d.seconds = 0 + try { d.hours = 25 // throws a DateError exception + } catch { + case de: DateError => println("DateError") + case e: Exception => println("Exception") + } + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/signals.scala b/test/pending/run/signals.scala new file mode 100644 index 0000000000..608b3c7fd5 --- /dev/null +++ b/test/pending/run/signals.scala @@ -0,0 +1,22 @@ +// not exactly "pending", here as an example usage. +// +val manager = scala.tools.util.SignalManager + +manager.requireInterval(3, manager.INT) { + case true => Console.println("\nPress ctrl-C again to exit.") + case false => System.exit(1) +} + +manager("HUP") = println("HUP 1!") +manager("HUP").raise() + +manager("HUP") += println("HUP 2!") +manager("HUP").raise() + +manager("HUP") += println("HUP 3!") +manager("HUP").raise() + +manager("HUP") = println("Back to HUP 1!") +manager("HUP").raise() + +manager.dump() diff --git a/test/pending/run/sigtp.check b/test/pending/run/sigtp.check new file mode 100644 index 0000000000..a4d0f55ece --- /dev/null +++ b/test/pending/run/sigtp.check @@ -0,0 +1,11 @@ +BugBase + (m) public abstract A BugBase.key() + (m) public abstract E BugBase.next() + (m) public abstract void BugBase.next_$eq(E) +Bug + (m) public Bug<A, B> Bug.foo() + (m) public A Bug.key() + (m) public Bug<A, B> Bug.next() (bridge) + (m) public void Bug.next_$eq(Bug<A, B>) (bridge) + (f) private final A Bug.key + (f) private java.lang.Object Bug.next diff --git a/test/pending/run/sigtp.scala b/test/pending/run/sigtp.scala new file mode 100644 index 0000000000..f8e050dbdc --- /dev/null +++ b/test/pending/run/sigtp.scala @@ -0,0 +1,17 @@ +import scala.tools.partest._ + +trait BugBase [A, E] { + val key: A + var next: E = _ +} + +final class Bug[A, B](val key: A) extends BugBase[A, Bug[A, B]] { + def foo = next +} + +object Test extends SigTest { + def main(args: Array[String]): Unit = { + show[BugBase[_, _]]() + show[Bug[_, _]]() + } +} diff --git a/test/pending/run/string-reverse.scala b/test/pending/run/string-reverse.scala new file mode 100644 index 0000000000..976a970dec --- /dev/null +++ b/test/pending/run/string-reverse.scala @@ -0,0 +1,22 @@ +/** In case we ever feel like taking on unicode string reversal. + * See ticket #2565. + */ +object Test { + val xs = "Les Mise\u0301rables" // this is the tricky one to reverse + val ys = "Les Misérables" + val xs2 = new StringBuilder(xs) + val ys2 = new StringBuilder(ys) + + def main(args: Array[String]): Unit = { + val out = new java.io.PrintStream(System.out, true, "UTF-8") + + out.println("Strings") + List(xs, xs.reverse, ys, ys.reverse) foreach (out println _) + + out.println("StringBuilder") + out.println(xs2.toString) + out.println(xs2.reverseContents().toString) + out.println(ys2.toString) + out.println(ys2.reverseContents().toString) + } +}
\ No newline at end of file diff --git a/test/pending/run/structural-types-vs-anon-classes.scala b/test/pending/run/structural-types-vs-anon-classes.scala new file mode 100644 index 0000000000..23410e3955 --- /dev/null +++ b/test/pending/run/structural-types-vs-anon-classes.scala @@ -0,0 +1,17 @@ +object Test { + class Arm + class Leg + class Tail + class Monkey(arms: List[Arm], legs :List[Leg], tail: Tail) + + def makeAwesomeMonkey(arms: List[Arm], legs: List[Leg], tail: Tail) = { + object m extends Monkey(arms, legs, tail) { + def beAwesome () = "I can fly! I can fly!" + } + m + } + + def main(args: Array[String]): Unit = { + println(makeAwesomeMonkey(Nil, Nil, new Tail) beAwesome) + } +} diff --git a/test/pending/run/t0048.check b/test/pending/run/t0048.check deleted file mode 100644 index 1e8b314962..0000000000 --- a/test/pending/run/t0048.check +++ /dev/null @@ -1 +0,0 @@ -6 diff --git a/test/pending/run/t0048.scala b/test/pending/run/t0048.scala deleted file mode 100644 index 71f37d26e4..0000000000 --- a/test/pending/run/t0048.scala +++ /dev/null @@ -1,13 +0,0 @@ -object A1 { - object A2 { - class X { def unapply(v : Int) = Some(v + 1) } - } -} - -object C { - def main(args: Array[String]) { - val q = new A1.A2.X - val res = 5 match { case q(x) => x } - println(res) - } -} diff --git a/test/pending/run/t0446.scala b/test/pending/run/t0446.scala deleted file mode 100644 index 0f74b32ba0..0000000000 --- a/test/pending/run/t0446.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test extends Application { - val a = Array(1,3).takeWhile(_ < 2) - val b = Array(1,3).dropWhile(_ < 2) - println(a.toString) - println(b.toString) -} diff --git a/test/pending/run/t0508x.scala b/test/pending/run/t0508x.scala index 0c1ffde3ed..12d3d09711 100644 --- a/test/pending/run/t0508x.scala +++ b/test/pending/run/t0508x.scala @@ -4,12 +4,12 @@ }; def foo[A >: Nothing <: Any, B >: Nothing <: Any, C >: Nothing <: Any] - (unapply1: (A) => Option[(B, C)], v: A): Unit = + (unapply1: (A) => Option[(B, C)], v: A): Unit = unapply1.apply(v) match { - case Some((fst @ _, snd @ _)) => + case Some((fst @ _, snd @ _)) => scala.Predef.println(scala.Tuple2.apply[java.lang.String, java.lang.String]("first: ".+(fst), " second: ".+(snd))) case _ => scala.Predef.println(":(") - } + } Test.this.foo[Test.Foo, String, Int]({ ((eta$0$1: Test.Foo) => Test.this.Foo.unapply(eta$0$1)) }, Test.this.Foo.apply("this might be fun", 10)); diff --git a/test/pending/run/t0565.scala b/test/pending/run/t0565.scala deleted file mode 100644 index eb6e32e644..0000000000 --- a/test/pending/run/t0565.scala +++ /dev/null @@ -1,22 +0,0 @@ -object Test extends Application { - - class MacGuffin - - object A { - var x : { type T >: Null <: AnyRef; - val y : T; - def z (w : T) : T } = - new { type T = String; - val y = "foo"; - def z (w : String) = w + "bar" } - lazy val u = { println("u evaluated"); x } - def foo (v : => u.type#T) : u.type#T = { - x = new { type T = MacGuffin; - val y = new MacGuffin; - def z (w : MacGuffin) = w } - u.z(v) - } - } - - A.foo(A.u.y) -} diff --git a/test/pending/run/t0727.check b/test/pending/run/t0727.check deleted file mode 100644 index bb101b641b..0000000000 --- a/test/pending/run/t0727.check +++ /dev/null @@ -1,2 +0,0 @@ -true -true diff --git a/test/pending/run/t0727.scala b/test/pending/run/t0727.scala deleted file mode 100644 index 9f5be7c108..0000000000 --- a/test/pending/run/t0727.scala +++ /dev/null @@ -1,5 +0,0 @@ -object t0727 extends Application { - val arr = Array("foo") - println(arr.isInstanceOf[Array[String]]) - println(Array("foo").isInstanceOf[Array[String]]) -} diff --git a/test/pending/run/t0732.check b/test/pending/run/t0732.check deleted file mode 100644 index e4ec30754a..0000000000 --- a/test/pending/run/t0732.check +++ /dev/null @@ -1,3 +0,0 @@ -c - -c diff --git a/test/pending/run/t0732.scala b/test/pending/run/t0732.scala deleted file mode 100644 index 24fdba0017..0000000000 --- a/test/pending/run/t0732.scala +++ /dev/null @@ -1,8 +0,0 @@ -object t0732 extends Application { - val x1 = <a b="c" /> - println(x1 \ "@b") - val x2 = <a x:b="c" xmlns:x="uri" /> - println(x2 \ "@b") - val x3 = <a x:b="c" xmlns:x="uri" /> - println(x3 \ "@x:b") -} diff --git a/test/pending/run/t0807.scala b/test/pending/run/t0807.scala deleted file mode 100644 index e69aa1c71c..0000000000 --- a/test/pending/run/t0807.scala +++ /dev/null @@ -1,5 +0,0 @@ -trait A -trait B extends A { val x = println("early") } -object Test extends Application { - new B {} -} diff --git a/test/pending/run/t0818.scala b/test/pending/run/t0818.scala deleted file mode 100644 index 677b85d920..0000000000 --- a/test/pending/run/t0818.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Seth extends Application { - println( - new java.util.ArrayList[String]().toArray(Array[String]())) -} diff --git a/test/pending/run/t0947.check b/test/pending/run/t0947.check deleted file mode 100644 index e1431236cc..0000000000 --- a/test/pending/run/t0947.check +++ /dev/null @@ -1 +0,0 @@ -foo: test.Foo = Foo diff --git a/test/pending/run/t0947.scala b/test/pending/run/t0947.scala deleted file mode 100644 index f5daca3d30..0000000000 --- a/test/pending/run/t0947.scala +++ /dev/null @@ -1,8 +0,0 @@ -import scala.tools.nsc._ - -object Test extends Application { - class Foo { override def toString = "Foo" }; - - val int = new Interpreter(new Settings()); - int.bind("foo", "Test.Foo", new Test.Foo()); -} diff --git a/test/pending/run/t1044.scala b/test/pending/run/t1044.scala deleted file mode 100644 index c521e5837b..0000000000 --- a/test/pending/run/t1044.scala +++ /dev/null @@ -1,5 +0,0 @@ -// looks OK -object Main extends Application{ - val ducks = Array[AnyRef]("Huey", "Dewey", "Louie") - ducks.iterator/*.asInstanceOf[Iterator[String]]*/ -} diff --git a/test/pending/run/t1697.scala b/test/pending/run/t1697.scala new file mode 100644 index 0000000000..01590dd405 --- /dev/null +++ b/test/pending/run/t1697.scala @@ -0,0 +1,19 @@ +class Term +case class Num(n: Int) extends Term +case class Add(x: Term, y: Term) extends Term + +object Value { + def unapply(term: Any): Boolean = true +} + +object Test { + def main(args: Array[String]) { + val term = Add(Num(1), Add(Num(2), Num(3))) + val res = term match { + case Add(Num(x), Num(y)) => "Add(Num, Num)" + case Add(Value(), y) => "Add(Value, ?)" + case _ => "?" + } + assert(res == "Add(Value, ?)") + } +} diff --git a/test/pending/run/t1939.scala b/test/pending/run/t1939.scala deleted file mode 100644 index 44ab1769d2..0000000000 --- a/test/pending/run/t1939.scala +++ /dev/null @@ -1,41 +0,0 @@ -// works in trunk -class Module {} - -abstract class T { - type moduleType <: Module - def module: moduleType -} - -final class T1(val module: Module) extends T { - type moduleType = Module -} - -final class T2(_module: Module) extends T { - type moduleType = Module - - def module = _module -} - -object Main extends Application { - - type mType = Module - - type tType = T { type moduleType <: mType } - // type tType = T { type moduleType <: Module } // runs successfully - // type tType = T // runs successfully - - def f(ts: List[tType]): Unit = { - - for (t <- ts; m = t.module) {} - ts.map(_.module).foreach { _ => () } - // ts.map(t => (t : T).module).foreach { _ => () } // runs successfully - } - - f(new T1(new Module) :: new T2(new Module) :: Nil) -} - -/* - * java.lang.AbstractMethodError - at scala.List.foreach(List.scala:849) - at Main$.f -*/ diff --git a/test/pending/run/t1980.scala b/test/pending/run/t1980.scala index 67cb3ada9e..71c178d634 100644 --- a/test/pending/run/t1980.scala +++ b/test/pending/run/t1980.scala @@ -1,9 +1,9 @@ -by-name argument incorrectly evaluated on :-ending operator -Reported by: extempore Owned by: odersky -Priority: normal Component: Compiler -Keywords: Cc: paulp@… -Fixed in version: -Description +// by-name argument incorrectly evaluated on :-ending operator +// Reported by: extempore Owned by: odersky +// Priority: normal Component: Compiler +// Keywords: Cc: paulp@… +// Fixed in version: +// Description scala> def foo() = { println("foo") ; 5 } foo: ()Int @@ -19,9 +19,9 @@ scala> c m1 foo() scala> foo() m2_: c foo -But it is not evaluated if invoked directly: +// But it is not evaluated if invoked directly: scala> c.m2_:(foo()) -scala> +// scala> diff --git a/test/pending/run/t2318.check b/test/pending/run/t2318.check new file mode 100644 index 0000000000..a486f1ac47 --- /dev/null +++ b/test/pending/run/t2318.check @@ -0,0 +1,2 @@ +bar +bar diff --git a/test/pending/run/t2318.scala b/test/pending/run/t2318.scala new file mode 100644 index 0000000000..e42cbb9680 --- /dev/null +++ b/test/pending/run/t2318.scala @@ -0,0 +1,38 @@ +import java.security._ + +object Test { + trait Bar { def bar: Unit } + + object Mgr extends SecurityManager { + override def checkPermission(perm: Permission) = perm match { + case _: java.lang.RuntimePermission => () + case _: java.io.FilePermission => () + case x: java.security.AccessControlException if x.getName contains ".networkaddress." => () // generality ftw + case _ => super.checkPermission(perm) + } + } + + def t1() = { + val p = Runtime.getRuntime().exec("ls"); + type Destroyable = { def destroy() : Unit } + def doDestroy( obj : Destroyable ) : Unit = obj.destroy(); + doDestroy( p ); + } + def t2() = { + System.setSecurityManager(Mgr) + + val b = new Bar { def bar = println("bar") } + b.bar + + val structural = b.asInstanceOf[{ def bar: Unit }] + structural.bar + } + + def main(args: Array[String]) { + // figuring this will otherwise break on windows + try t1() + catch { case _: java.io.IOException => () } + + t2() + } +} diff --git a/test/pending/run/t2364.check b/test/pending/run/t2364.check new file mode 100644 index 0000000000..219305e43a --- /dev/null +++ b/test/pending/run/t2364.check @@ -0,0 +1 @@ +<test></test> diff --git a/test/pending/run/t2364.scala b/test/pending/run/t2364.scala new file mode 100644 index 0000000000..d5805a13b8 --- /dev/null +++ b/test/pending/run/t2364.scala @@ -0,0 +1,60 @@ +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import com.sun.xml.internal.fastinfoset._ +import com.sun.xml.internal.fastinfoset.sax._ +import scala.xml.parsing.NoBindingFactoryAdapter +import scala.xml._ + +// Note - this is in pending because com.sun.xml.etc is not standard, +// and I don't have time to extract a smaller test. + +object Test { + def main(args: Array[String]) { + val node = <test/> + val bytes = new ByteArrayOutputStream + val serializer = new SAXDocumentSerializer() + + serializer.setOutputStream(bytes) + serializer.startDocument() + serialize(node, serializer) + serializer.endDocument() + println(parse(new ByteArrayInputStream(bytes.toByteArray))) + } + def serialize(node: Node, serializer: SAXDocumentSerializer) { + node match { + case _ : ProcInstr | _ : Comment | _ : EntityRef => + case x : Atom[_] => + val chars = x.text.toCharArray + serializer.characters(chars, 0, chars.length) + case _ : Elem => + serializer.startElement("", node.label.toLowerCase, node.label.toLowerCase, attributes(node.attributes)) + for (m <- node.child) serialize(m, serializer) + serializer.endElement("", node.label.toLowerCase, node.label.toLowerCase) + } + } + def parse(str: ByteArrayInputStream) = { + val parser = new SAXDocumentParser + val fac = new NoBindingFactoryAdapter + + parser.setContentHandler(fac) + try { + parser.parse(str) + } catch { + case x: Exception => + x.printStackTrace + } + fac.rootElem + } + def attributes(d: MetaData) = { + val attrs = new AttributesHolder + + if (d != null) { + for (attr <- d) { + val sb = new StringBuilder() + Utility.sequenceToXML(attr.value, TopScope, sb, true) + attrs.addAttribute(new QualifiedName("", "", attr.key.toLowerCase), sb.toString) + } + } + attrs + } +} diff --git a/test/pending/run/t2897.scala b/test/pending/run/t2897.scala new file mode 100644 index 0000000000..40fd3c2b08 --- /dev/null +++ b/test/pending/run/t2897.scala @@ -0,0 +1,22 @@ +class A { + def f1(t: String) = { + trait T { + def xs = Nil map (_ => t) + } + } + def f2(t: String) = { + def xs = Nil map (_ => t) + } + def f3(t: String) = { + var t1 = 5 + trait T { + def xs = { t1 = 10 ; t } + } + } + def f4() = { + var u = 5 + trait T { + def xs = Nil map (_ => u = 10) + } + } +} diff --git a/test/pending/run/t3609.scala b/test/pending/run/t3609.scala new file mode 100755 index 0000000000..eb25afd667 --- /dev/null +++ b/test/pending/run/t3609.scala @@ -0,0 +1,28 @@ +object Test extends Application { + class A + class B extends A + def foo(x: A, y: B) = print(1) + val foo = new { + // def apply(x: B, y: A) = print(3) + def apply = (x: B, z: B) => print(4) + } + + foo(new B, new B) +} + +// This code prints 1. If we remove comment, then it will print 4. +// Moreover following code prints 3 (which is most strange thing): + +object Test2 extends Application { + class A + class B extends A + def foo(x: A, y: B) = print(1) + val foo = new { + def apply(x: B, y: A) = print(3) + def apply = new { + def apply = (x: B, z: B) => print(4) + } + } + + foo(new B, new B) +}
\ No newline at end of file diff --git a/test/pending/run/t3669.scala b/test/pending/run/t3669.scala new file mode 100644 index 0000000000..c60ba98538 --- /dev/null +++ b/test/pending/run/t3669.scala @@ -0,0 +1,22 @@ +trait MyTrait[T <: { var id: U }, U] { + def test(t: T): T = { + val v: U = t.id + t.id = v + t + } +} + +class C (var id: String){ + // uncommenting this fixes it + // def id_=(x: AnyRef) { id = x.asInstanceOf[String] } +} + +class Test extends MyTrait[C, String] + +object Test { + def main(args: Array[String]): Unit = { + val t = new Test() + val c1 = new C("a") + val c2 = t.test(c1) + } +} diff --git a/test/pending/run/t3857.check b/test/pending/run/t3857.check new file mode 100644 index 0000000000..520b350ff5 --- /dev/null +++ b/test/pending/run/t3857.check @@ -0,0 +1,11 @@ +ScalaGeneric + (m) public java.util.Set<java.lang.String> ScalaGeneric.s() + (m) public void ScalaGeneric.s_$eq(java.util.Set<java.lang.String>) + (f) private java.util.Set<java.lang.String> ScalaGeneric.s +ScalaGeneric2Trait + (m) public abstract java.util.Set<java.lang.String> ScalaGeneric2Trait.s() + (m) public abstract void ScalaGeneric2Trait.s_$eq(java.util.Set<java.lang.String>) +ScalaGeneric2 + (m) public java.util.Set<java.lang.String> ScalaGeneric2.s() (bridge) + (m) public void ScalaGeneric2.s_$eq(java.util.Set<java.lang.String>) (bridge) + (f) private java.util.Set<java.lang.String> ScalaGeneric2.s diff --git a/test/pending/run/t3857.scala b/test/pending/run/t3857.scala new file mode 100644 index 0000000000..62bdc39da9 --- /dev/null +++ b/test/pending/run/t3857.scala @@ -0,0 +1,13 @@ +import scala.tools.partest._ + +class ScalaGeneric { var s: java.util.Set[String] = _ } +trait ScalaGeneric2Trait { var s: java.util.Set[String] = _ } +class ScalaGeneric2 extends ScalaGeneric2Trait { } + +object Test extends SigTest { + def main(args: Array[String]): Unit = { + show[ScalaGeneric]() + show[ScalaGeneric2Trait]() + show[ScalaGeneric2]() + } +} diff --git a/test/pending/run/t4283/AbstractFoo.java b/test/pending/run/t4283/AbstractFoo.java new file mode 100644 index 0000000000..0403271b74 --- /dev/null +++ b/test/pending/run/t4283/AbstractFoo.java @@ -0,0 +1,6 @@ +package test; + +/* package private */ class AbstractFoo { + public int t = 1; + public int f() { return 2; } +}
\ No newline at end of file diff --git a/test/pending/run/t4283/IllegalAccess.scala b/test/pending/run/t4283/IllegalAccess.scala new file mode 100644 index 0000000000..33039c9350 --- /dev/null +++ b/test/pending/run/t4283/IllegalAccess.scala @@ -0,0 +1,17 @@ +package other + +object IllegalAccess { + def main(args: Array[String]) { + val x = (new test.ScalaBipp).make.get.asInstanceOf[test.ScalaBipp].f() + println(x) + val y = (new test.ScalaBipp).make.get.f() + println(y) + val u = (new test.ScalaBipp).make.get.asInstanceOf[test.ScalaBipp].t + println(u) + val v = (new test.ScalaBipp).make.get.t + println(v) + val sb: test.ScalaBipp = (new test.ScalaBipp).make.get + val z = sb.t + println(z) + } +} diff --git a/test/pending/run/t4283/ScalaBipp.scala b/test/pending/run/t4283/ScalaBipp.scala new file mode 100644 index 0000000000..36dea9f4de --- /dev/null +++ b/test/pending/run/t4283/ScalaBipp.scala @@ -0,0 +1,5 @@ +package test + +class ScalaBipp extends AbstractFoo { + def make: Option[ScalaBipp] = Option(this) +} diff --git a/test/pending/run/t4291.check b/test/pending/run/t4291.check new file mode 100644 index 0000000000..30bacfac28 --- /dev/null +++ b/test/pending/run/t4291.check @@ -0,0 +1,87 @@ +scala.collection.immutable.List + (m) public java.lang.Object scala.collection.immutable.List.apply(java.lang.Object) (bridge) + (m) public A scala.collection.immutable.List.apply(int) (bridge) +scala.Option + (m) public abstract A scala.Option.get() +scala.Function1 + (m) public abstract R scala.Function1.apply(T1) +scala.collection.Traversable + (m) public abstract <B,That> That scala.collection.TraversableLike.map(scala.Function1<A, B>,scala.collection.generic.CanBuildFrom<Repr, B, That>) +scala.collection.Iterable + (m) public abstract <B,That> That scala.collection.TraversableLike.map(scala.Function1<A, B>,scala.collection.generic.CanBuildFrom<Repr, B, That>) +scala.collection.Seq + (m) public abstract <B,That> That scala.collection.TraversableLike.map(scala.Function1<A, B>,scala.collection.generic.CanBuildFrom<Repr, B, That>) +scala.collection.immutable.Set + (m) public abstract <B,That> That scala.collection.TraversableLike.map(scala.Function1<A, B>,scala.collection.generic.CanBuildFrom<Repr, B, That>) + (m) public abstract <B,That> That scala.collection.SetLike.map(scala.Function1<A, B>,scala.collection.generic.CanBuildFrom<This, B, That>) +scala.collection.immutable.Map + (m) public abstract <B,That> That scala.collection.TraversableLike.map(scala.Function1<A, B>,scala.collection.generic.CanBuildFrom<Repr, B, That>) +scala.collection.immutable.Vector + (m) public <B,That> That scala.collection.immutable.Vector.map(scala.Function1<A, B>,scala.collection.generic.CanBuildFrom<scala.collection.immutable.Vector<A>, B, That>) (bridge) +scala.collection.immutable.Range + (m) public <B,That> That scala.collection.immutable.Range.map(scala.Function1<java.lang.Object, B>,scala.collection.generic.CanBuildFrom<scala.collection.immutable.IndexedSeq<java.lang.Object>, B, That>) (bridge) +scala.collection.Traversable + (m) public abstract <B,That> That scala.collection.TraversableLike.flatMap(scala.Function1<A, scala.collection.TraversableOnce<B>>,scala.collection.generic.CanBuildFrom<Repr, B, That>) +scala.collection.Iterable + (m) public abstract <B,That> That scala.collection.TraversableLike.flatMap(scala.Function1<A, scala.collection.TraversableOnce<B>>,scala.collection.generic.CanBuildFrom<Repr, B, That>) +scala.collection.Seq + (m) public abstract <B,That> That scala.collection.TraversableLike.flatMap(scala.Function1<A, scala.collection.TraversableOnce<B>>,scala.collection.generic.CanBuildFrom<Repr, B, That>) +scala.collection.immutable.Set + (m) public abstract <B,That> That scala.collection.TraversableLike.flatMap(scala.Function1<A, scala.collection.TraversableOnce<B>>,scala.collection.generic.CanBuildFrom<Repr, B, That>) +scala.collection.immutable.Map + (m) public abstract <B,That> That scala.collection.TraversableLike.flatMap(scala.Function1<A, scala.collection.TraversableOnce<B>>,scala.collection.generic.CanBuildFrom<Repr, B, That>) +scala.collection.immutable.Vector + (m) public <B,That> That scala.collection.immutable.Vector.flatMap(scala.Function1<A, scala.collection.TraversableOnce<B>>,scala.collection.generic.CanBuildFrom<scala.collection.immutable.Vector<A>, B, That>) (bridge) +scala.collection.immutable.Range + (m) public <B,That> That scala.collection.immutable.Range.flatMap(scala.Function1<java.lang.Object, scala.collection.TraversableOnce<B>>,scala.collection.generic.CanBuildFrom<scala.collection.immutable.IndexedSeq<java.lang.Object>, B, That>) (bridge) +scala.collection.Traversable + (m) public abstract Repr scala.collection.TraversableLike.filter(scala.Function1<A, java.lang.Object>) +scala.collection.Iterable + (m) public abstract Repr scala.collection.TraversableLike.filter(scala.Function1<A, java.lang.Object>) +scala.collection.Seq + (m) public abstract Repr scala.collection.TraversableLike.filter(scala.Function1<A, java.lang.Object>) +scala.collection.immutable.Set + (m) public abstract Repr scala.collection.TraversableLike.filter(scala.Function1<A, java.lang.Object>) +scala.collection.immutable.Map + (m) public abstract Repr scala.collection.TraversableLike.filter(scala.Function1<A, java.lang.Object>) +scala.collection.immutable.Vector + (m) public scala.collection.immutable.Vector<A> scala.collection.immutable.Vector.filter(scala.Function1<A, java.lang.Object>) (bridge) +scala.collection.immutable.Range + (m) public scala.collection.immutable.IndexedSeq<java.lang.Object> scala.collection.immutable.Range.filter(scala.Function1<java.lang.Object, java.lang.Object>) (bridge) +scala.collection.Traversable + (m) public abstract A scala.collection.TraversableLike.head() + (m) public abstract A scala.collection.generic.GenericTraversableTemplate.head() +scala.collection.Iterable + (m) public abstract A scala.collection.TraversableLike.head() + (m) public abstract A scala.collection.generic.GenericTraversableTemplate.head() + (m) public abstract A scala.collection.IterableLike.head() +scala.collection.Seq + (m) public abstract A scala.collection.TraversableLike.head() + (m) public abstract A scala.collection.generic.GenericTraversableTemplate.head() + (m) public abstract A scala.collection.IterableLike.head() +scala.collection.immutable.Set + (m) public abstract A scala.collection.TraversableLike.head() + (m) public abstract A scala.collection.generic.GenericTraversableTemplate.head() + (m) public abstract A scala.collection.IterableLike.head() +scala.collection.immutable.Map + (m) public abstract A scala.collection.TraversableLike.head() + (m) public abstract A scala.collection.generic.GenericTraversableTemplate.head() + (m) public abstract A scala.collection.IterableLike.head() +scala.collection.immutable.Vector + (m) public A scala.collection.immutable.Vector.head() +scala.collection.immutable.Range + (m) public java.lang.Object scala.collection.immutable.Range.head() (bridge) +scala.collection.Traversable + (m) public abstract <K> scala.collection.immutable.Map<K, Repr> scala.collection.TraversableLike.groupBy(scala.Function1<A, K>) +scala.collection.Iterable + (m) public abstract <K> scala.collection.immutable.Map<K, Repr> scala.collection.TraversableLike.groupBy(scala.Function1<A, K>) +scala.collection.Seq + (m) public abstract <K> scala.collection.immutable.Map<K, Repr> scala.collection.TraversableLike.groupBy(scala.Function1<A, K>) +scala.collection.immutable.Set + (m) public abstract <K> scala.collection.immutable.Map<K, Repr> scala.collection.TraversableLike.groupBy(scala.Function1<A, K>) +scala.collection.immutable.Map + (m) public abstract <K> scala.collection.immutable.Map<K, Repr> scala.collection.TraversableLike.groupBy(scala.Function1<A, K>) +scala.collection.immutable.Vector + (m) public <K> scala.collection.immutable.Map<K, scala.collection.immutable.Vector<A>> scala.collection.immutable.Vector.groupBy(scala.Function1<A, K>) (bridge) +scala.collection.immutable.Range + (m) public <K> scala.collection.immutable.Map<K, scala.collection.immutable.IndexedSeq<java.lang.Object>> scala.collection.immutable.Range.groupBy(scala.Function1<java.lang.Object, K>) (bridge) diff --git a/test/pending/run/t4291.scala b/test/pending/run/t4291.scala new file mode 100644 index 0000000000..0213bb2c20 --- /dev/null +++ b/test/pending/run/t4291.scala @@ -0,0 +1,19 @@ +import scala.tools.partest._ + +object Test extends SigTest { + def main(args: Array[String]): Unit = { + show[List[_]]("apply") + show[Option[_]]("get") + show[Function1[_, _]]("apply") + + for (name <- List("map", "flatMap", "filter", "head", "groupBy")) { + show[Traversable[_]](name) + show[Iterable[_]](name) + show[Seq[_]](name) + show[Set[_]](name) + show[Map[_,_]](name) + show[Vector[_]](name) + show[Range](name) + } + } +} diff --git a/test/pending/run/t4713/JavaAnnots.java b/test/pending/run/t4713/JavaAnnots.java new file mode 100644 index 0000000000..29541b1ee0 --- /dev/null +++ b/test/pending/run/t4713/JavaAnnots.java @@ -0,0 +1,14 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.List; + +public abstract class JavaAnnots { + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.FIELD) + public @interface Book { + } + + public static final List<String> Book = null; +}
\ No newline at end of file diff --git a/test/pending/run/t4713/Problem.scala b/test/pending/run/t4713/Problem.scala new file mode 100644 index 0000000000..e87f657d2e --- /dev/null +++ b/test/pending/run/t4713/Problem.scala @@ -0,0 +1,5 @@ +object Problem { + def d() { + val v: java.util.List[String] = JavaAnnots.Book + } +} diff --git a/test/pending/run/t5224.check b/test/pending/run/t5224.check new file mode 100644 index 0000000000..2b920773c0 --- /dev/null +++ b/test/pending/run/t5224.check @@ -0,0 +1,9 @@ +{ + @serializable class C extends Object with ScalaObject { + def <init>() = { + super.<init>(); + () + } + }; + () +}
\ No newline at end of file diff --git a/test/pending/run/t5224.scala b/test/pending/run/t5224.scala new file mode 100644 index 0000000000..865ce4bfe9 --- /dev/null +++ b/test/pending/run/t5224.scala @@ -0,0 +1,8 @@ +import scala.reflect._ +import scala.reflect.api._ + +object Test extends App { + println(scala.reflect.Code.lift{ + @serializable class C + }.tree.toString) +}
\ No newline at end of file diff --git a/test/pending/run/t5225_1.check b/test/pending/run/t5225_1.check new file mode 100644 index 0000000000..b29cd9c365 --- /dev/null +++ b/test/pending/run/t5225_1.check @@ -0,0 +1,4 @@ +{ + @transient @volatile var x: Int = 2; + () +}
\ No newline at end of file diff --git a/test/pending/run/t5225_1.scala b/test/pending/run/t5225_1.scala new file mode 100644 index 0000000000..454502e810 --- /dev/null +++ b/test/pending/run/t5225_1.scala @@ -0,0 +1,8 @@ +import scala.reflect._ +import scala.reflect.api._ + +object Test extends App { + println(scala.reflect.Code.lift{ + @transient @volatile var x = 2 + }.tree.toString) +}
\ No newline at end of file diff --git a/test/pending/run/t5225_2.check b/test/pending/run/t5225_2.check new file mode 100644 index 0000000000..88972fd27f --- /dev/null +++ b/test/pending/run/t5225_2.check @@ -0,0 +1,4 @@ +{ + def foo(@cloneable x: Int): String = ""; + () +} diff --git a/test/pending/run/t5225_2.scala b/test/pending/run/t5225_2.scala new file mode 100644 index 0000000000..82bad0f353 --- /dev/null +++ b/test/pending/run/t5225_2.scala @@ -0,0 +1,8 @@ +import scala.reflect._ +import scala.reflect.api._ + +object Test extends App { + println(scala.reflect.Code.lift{ + def foo(@cloneable x: Int) = "" + }.tree.toString) +}
\ No newline at end of file diff --git a/test/pending/run/t5229_1.check b/test/pending/run/t5229_1.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/pending/run/t5229_1.check diff --git a/test/pending/run/t5229_1.scala b/test/pending/run/t5229_1.scala new file mode 100644 index 0000000000..1d7bf0590b --- /dev/null +++ b/test/pending/run/t5229_1.scala @@ -0,0 +1,14 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + object C + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/t5229_1_nolift.scala b/test/pending/run/t5229_1_nolift.scala new file mode 100644 index 0000000000..33855d2e4f --- /dev/null +++ b/test/pending/run/t5229_1_nolift.scala @@ -0,0 +1 @@ +object C diff --git a/test/pending/run/t5229_2.check b/test/pending/run/t5229_2.check new file mode 100644 index 0000000000..5db6ec9b38 --- /dev/null +++ b/test/pending/run/t5229_2.check @@ -0,0 +1,2 @@ +2 +evaluated = null diff --git a/test/pending/run/t5229_2.scala b/test/pending/run/t5229_2.scala new file mode 100644 index 0000000000..67be7328a6 --- /dev/null +++ b/test/pending/run/t5229_2.scala @@ -0,0 +1,19 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + object C { + val x = 2 + } + + println(C.x) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + val evaluated = toolbox.runExpr(ttree) + println("evaluated = " + evaluated) +} diff --git a/test/pending/run/t5256c.check b/test/pending/run/t5256c.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/pending/run/t5256c.check diff --git a/test/pending/run/t5256c.scala b/test/pending/run/t5256c.scala new file mode 100644 index 0000000000..8ebb51a009 --- /dev/null +++ b/test/pending/run/t5256c.scala @@ -0,0 +1,10 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + class A + val c = classToType(classOf[A]) + println(c) + println(c.typeSymbol == classToSymbol(classOf[A])) + } +} diff --git a/test/pending/run/t5256g.check b/test/pending/run/t5256g.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/pending/run/t5256g.check diff --git a/test/pending/run/t5256g.scala b/test/pending/run/t5256g.scala new file mode 100644 index 0000000000..6158a9281d --- /dev/null +++ b/test/pending/run/t5256g.scala @@ -0,0 +1,11 @@ +import scala.reflect.mirror._ + +class A +trait B + +object Test extends App { + val mutant = new A with B + val c = classToType(mutant.getClass) + println(c) + println(c.typeSymbol == classToSymbol(mutant.getClass)) +} diff --git a/test/pending/run/t5256h.check b/test/pending/run/t5256h.check new file mode 100644 index 0000000000..4f9b8faf71 --- /dev/null +++ b/test/pending/run/t5256h.check @@ -0,0 +1,8 @@ +import scala.reflect.mirror._ + +object Test extends App { + val mutant = new { val x = 2 } + val c = classToType(mutant.getClass) + println(c) + println(c.typeSymbol == classToSymbol(mutant.getClass)) +} diff --git a/test/pending/run/t5256h.scala b/test/pending/run/t5256h.scala new file mode 100644 index 0000000000..4f9b8faf71 --- /dev/null +++ b/test/pending/run/t5256h.scala @@ -0,0 +1,8 @@ +import scala.reflect.mirror._ + +object Test extends App { + val mutant = new { val x = 2 } + val c = classToType(mutant.getClass) + println(c) + println(c.typeSymbol == classToSymbol(mutant.getClass)) +} diff --git a/test/pending/run/t5258b.check b/test/pending/run/t5258b.check new file mode 100644 index 0000000000..283b4225fb --- /dev/null +++ b/test/pending/run/t5258b.check @@ -0,0 +1 @@ +TBI
\ No newline at end of file diff --git a/test/pending/run/t5258b.scala b/test/pending/run/t5258b.scala new file mode 100644 index 0000000000..70cb4a7f4e --- /dev/null +++ b/test/pending/run/t5258b.scala @@ -0,0 +1,15 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + class C + println(classOf[C]) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +}
\ No newline at end of file diff --git a/test/pending/run/t5258c.check b/test/pending/run/t5258c.check new file mode 100644 index 0000000000..283b4225fb --- /dev/null +++ b/test/pending/run/t5258c.check @@ -0,0 +1 @@ +TBI
\ No newline at end of file diff --git a/test/pending/run/t5258c.scala b/test/pending/run/t5258c.scala new file mode 100644 index 0000000000..a93170d0d6 --- /dev/null +++ b/test/pending/run/t5258c.scala @@ -0,0 +1,15 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + object E extends Enumeration { val foo, bar = Value } + println(E.foo) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +}
\ No newline at end of file diff --git a/test/pending/run/t5270.check b/test/pending/run/t5270.check new file mode 100644 index 0000000000..08839f6bb2 --- /dev/null +++ b/test/pending/run/t5270.check @@ -0,0 +1 @@ +200 diff --git a/test/pending/run/t5270.scala b/test/pending/run/t5270.scala new file mode 100644 index 0000000000..10f79790b0 --- /dev/null +++ b/test/pending/run/t5270.scala @@ -0,0 +1,26 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + class Y { + def y = 100 + } + + trait Z { this: Y => + val z = 2 * y + } + + class X extends Y with Z { + def println() = Predef.println(z) + } + + new X().println() + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/t5271_1.check b/test/pending/run/t5271_1.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/pending/run/t5271_1.check diff --git a/test/pending/run/t5271_1.scala b/test/pending/run/t5271_1.scala new file mode 100644 index 0000000000..5f10e64528 --- /dev/null +++ b/test/pending/run/t5271_1.scala @@ -0,0 +1,14 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + case class C(foo: Int, bar: Int) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/t5271_2.check b/test/pending/run/t5271_2.check new file mode 100644 index 0000000000..b8626c4cff --- /dev/null +++ b/test/pending/run/t5271_2.check @@ -0,0 +1 @@ +4 diff --git a/test/pending/run/t5271_2.scala b/test/pending/run/t5271_2.scala new file mode 100644 index 0000000000..71967c04ed --- /dev/null +++ b/test/pending/run/t5271_2.scala @@ -0,0 +1,16 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + case class C(foo: Int, bar: Int) + val c = C(2, 2) + println(c.foo * c.bar) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/t5272.check b/test/pending/run/t5272.check new file mode 100644 index 0000000000..dcf02b2fb6 --- /dev/null +++ b/test/pending/run/t5272.check @@ -0,0 +1 @@ +okay diff --git a/test/pending/run/t5272.scala b/test/pending/run/t5272.scala new file mode 100644 index 0000000000..3f44d05fb3 --- /dev/null +++ b/test/pending/run/t5272.scala @@ -0,0 +1,17 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + 2 match { + case 2 => println("okay") + case _ => println("not okay") + } + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/t5273_1.check b/test/pending/run/t5273_1.check new file mode 100644 index 0000000000..c551774ca5 --- /dev/null +++ b/test/pending/run/t5273_1.check @@ -0,0 +1 @@ +name = American Dollar, shortname = USD, value = 2,8567 diff --git a/test/pending/run/t5273_1.scala b/test/pending/run/t5273_1.scala new file mode 100644 index 0000000000..8b75084463 --- /dev/null +++ b/test/pending/run/t5273_1.scala @@ -0,0 +1,16 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + val RegexParser = """(.*) \d+([A-Z]+) \| (.*) \|.*""".r + val RegexParser(name, shortname, value) = "American Dollar 1USD | 2,8567 | sometext" + println("name = %s, shortname = %s, value = %s".format(name, shortname, value)) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/t5273_2.check b/test/pending/run/t5273_2.check new file mode 100644 index 0000000000..0cfbf08886 --- /dev/null +++ b/test/pending/run/t5273_2.check @@ -0,0 +1 @@ +2 diff --git a/test/pending/run/t5273_2.scala b/test/pending/run/t5273_2.scala new file mode 100644 index 0000000000..1175881c9f --- /dev/null +++ b/test/pending/run/t5273_2.scala @@ -0,0 +1,17 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + List(1, 2, 3) match { + case foo :: bar :: _ => println(foo * bar) + case _ => println("this is getting out of hand!") + } + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/t5276.check b/test/pending/run/t5276.check new file mode 100644 index 0000000000..0cfbf08886 --- /dev/null +++ b/test/pending/run/t5276.check @@ -0,0 +1 @@ +2 diff --git a/test/pending/run/t5276.scala b/test/pending/run/t5276.scala new file mode 100644 index 0000000000..432fdb91e4 --- /dev/null +++ b/test/pending/run/t5276.scala @@ -0,0 +1,15 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + lazy x = 2 + println(x) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/t5334_1.scala b/test/pending/run/t5334_1.scala new file mode 100644 index 0000000000..c1eba89c2b --- /dev/null +++ b/test/pending/run/t5334_1.scala @@ -0,0 +1,15 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + class C + new C + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/t5334_2.scala b/test/pending/run/t5334_2.scala new file mode 100644 index 0000000000..361b8c85f2 --- /dev/null +++ b/test/pending/run/t5334_2.scala @@ -0,0 +1,15 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + class C + List((new C, new C)) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} diff --git a/test/pending/run/t5418.check b/test/pending/run/t5418.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/pending/run/t5418.check diff --git a/test/pending/run/t5418.scala b/test/pending/run/t5418.scala new file mode 100644 index 0000000000..065710f15e --- /dev/null +++ b/test/pending/run/t5418.scala @@ -0,0 +1,14 @@ +import scala.tools.nsc.reporters._ +import scala.tools.nsc.Settings +import reflect.runtime.Mirror.ToolBox + +object Test extends App { + val code = scala.reflect.Code.lift{ + new Object().getClass + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +}
\ No newline at end of file diff --git a/test/pending/run/t5427a.check b/test/pending/run/t5427a.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/pending/run/t5427a.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/pending/run/t5427a.scala b/test/pending/run/t5427a.scala new file mode 100644 index 0000000000..27b28da0ac --- /dev/null +++ b/test/pending/run/t5427a.scala @@ -0,0 +1,10 @@ +import scala.reflect.mirror._ + +object Foo { val bar = 2 } + +object Test extends App { + val tpe = getType(Foo) + val bar = tpe.nonPrivateMember(newTermName("bar")) + val value = getValue(Foo, bar) + println(value) +}
\ No newline at end of file diff --git a/test/pending/run/t5427b.check b/test/pending/run/t5427b.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/pending/run/t5427b.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/pending/run/t5427b.scala b/test/pending/run/t5427b.scala new file mode 100644 index 0000000000..7a92b6ebbe --- /dev/null +++ b/test/pending/run/t5427b.scala @@ -0,0 +1,11 @@ +import scala.reflect.mirror._ + +class Foo { val bar = 2 } + +object Test extends App { + val foo = new Foo + val tpe = getType(foo) + val bar = tpe.nonPrivateMember(newTermName("bar")) + val value = getValue(foo, bar) + println(value) +}
\ No newline at end of file diff --git a/test/pending/run/t5427c.check b/test/pending/run/t5427c.check new file mode 100644 index 0000000000..32c91abbd6 --- /dev/null +++ b/test/pending/run/t5427c.check @@ -0,0 +1 @@ +no public member
\ No newline at end of file diff --git a/test/pending/run/t5427c.scala b/test/pending/run/t5427c.scala new file mode 100644 index 0000000000..ab41d8b8cd --- /dev/null +++ b/test/pending/run/t5427c.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +class Foo(bar: Int) + +object Test extends App { + val foo = new Foo(2) + val tpe = getType(foo) + val bar = tpe.nonPrivateMember(newTermName("bar")) + bar match { + case NoSymbol => println("no public member") + case _ => println("i'm screwed") + } +}
\ No newline at end of file diff --git a/test/pending/run/t5427d.check b/test/pending/run/t5427d.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/pending/run/t5427d.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/pending/run/t5427d.scala b/test/pending/run/t5427d.scala new file mode 100644 index 0000000000..fd4c62e876 --- /dev/null +++ b/test/pending/run/t5427d.scala @@ -0,0 +1,11 @@ +import scala.reflect.mirror._ + +class Foo(val bar: Int) + +object Test extends App { + val foo = new Foo(2) + val tpe = getType(foo) + val bar = tpe.nonPrivateMember(newTermName("bar")) + val value = getValue(foo, bar) + println(value) +}
\ No newline at end of file diff --git a/test/pending/run/treesetmap.check b/test/pending/run/treesetmap.check deleted file mode 100644 index c55dc061db..0000000000 --- a/test/pending/run/treesetmap.check +++ /dev/null @@ -1 +0,0 @@ -class scala.collection.immutable.TreeMap diff --git a/test/pending/run/treesetmap.scala b/test/pending/run/treesetmap.scala deleted file mode 100644 index 60902d2b90..0000000000 --- a/test/pending/run/treesetmap.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test{ - def main(args : Array[String]){ - println(scala.collection.immutable.TreeSet(1, 2, 3).map(x => x).getClass); - } -} diff --git a/test/pending/scalacheck/CheckEither.scala b/test/pending/scalacheck/CheckEither.scala deleted file mode 100644 index a6c728451b..0000000000 --- a/test/pending/scalacheck/CheckEither.scala +++ /dev/null @@ -1,253 +0,0 @@ - -// To run these tests: -// 1) wget http://scalacheck.googlecode.com/files/ScalaCheck-1.2.jar -// 2) scalac -classpath ScalaCheck-1.2.jar Either.scala -// 3) scala -classpath .:ScalaCheck-1.2.jar scala.CheckEither -// 4) observe passing tests - -import org.scalacheck.Arbitrary -import org.scalacheck.Arbitrary.{arbitrary, arbThrowable} -import org.scalacheck.Gen.oneOf -import org.scalacheck.{Prop, StdRand} -import org.scalacheck.Prop._ -import org.scalacheck.ConsoleReporter.{testReport, propReport} -import org.scalacheck.Test.{Params, check} -import org.scalacheck.ConsoleReporter.testStatsEx -import Function.tupled - -object CheckEither { - implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = - Arbitrary[Either[X, Y]](oneOf(arbitrary[X].map(Left(_)), arbitrary[Y].map(Right(_)))) - - val prop_either1 = property((n: Int) => Left(n).either(x => x, b => error("fail")) == n) - - val prop_either2 = property((n: Int) => Right(n).either(a => error("fail"), x => x) == n) - - val prop_swap = property((e: Either[Int, Int]) => e match { - case Left(a) => e.swap.right.value == a - case Right(b) => e.swap.left.value == b - }) - - val prop_isLeftRight = property((e: Either[Int, Int]) => e.isLeft != e.isRight) - - object CheckLeftProjection { - val prop_valueE = property((n: Int, s: String) => Left(n).left.valueE(s) == n) - - val prop_value = property((n: Int) => Left(n).left.value == n) - - val prop_on = property((e: Either[Int, Int]) => e.left.on((_: Int) + 1) == (e match { - case Left(a) => a - case Right(b) => b + 1 - })) - - val prop_getOrElse = property((e: Either[Int, Int], or: Int) => e.left.getOrElse(or) == (e match { - case Left(a) => a - case Right(_) => or - })) - - val prop_forall = property((e: Either[Int, Int]) => - e.left.forall(_ % 2 == 0) == (e.isRight || e.left.value % 2 == 0)) - - val prop_exists = property((e: Either[Int, Int]) => - e.left.exists(_ % 2 == 0) == (e.isLeft && e.left.value % 2 == 0)) - - val prop_flatMapLeftIdentity = property((e: Either[Int, Int], n: Int, s: String) => { - def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s) - Left(n).left.flatMap(f(_)) == f(n)}) - - val prop_flatMapRightIdentity = property((e: Either[Int, Int]) => e.left.flatMap(Left(_)) == e) - - val prop_flatMapComposition = property((e: Either[Int, Int]) => { - def f(x: Int) = if(x % 2 == 0) Left(x) else Right(x) - def g(x: Int) = if(x % 7 == 0) Right(x) else Left(x) - e.left.flatMap(f(_)).left.flatMap(g(_)) == e.left.flatMap(f(_).left.flatMap(g(_)))}) - - val prop_mapIdentity = property((e: Either[Int, Int]) => e.left.map(x => x) == e) - - val prop_mapComposition = property((e: Either[String, Int]) => { - def f(s: String) = s.toLowerCase - def g(s: String) = s.reverse - e.left.map(x => f(g(x))) == e.left.map(x => g(x)).left.map(f(_))}) - - val prop_filter = property((e: Either[Int, Int], x: Int) => e.left.filter(_ % 2 == 0) == - (if(e.isRight || e.left.value % 2 != 0) None else Some(e))) - - val prop_ap = property((e1: Either[Int, Int], e2: Either[Int, Int]) => { - val ee2 = e2.left map (n => (x: Int) => x + n) - e1.left.ap(ee2) == (ee2 match { - case Left(f) => e1 match { - case Left(a) => Left(f(a)) - case Right(b) => Right(b) - } - case Right(b) => Right(b) - }) - }) - - val prop_seq = property((e: Either[Int, Int]) => e.left.seq == (e match { - case Left(a) => Seq.singleton(a) - case Right(_) => Seq.empty - })) - - val prop_option = property((e: Either[Int, Int]) => e.left.option == (e match { - case Left(a) => Some(a) - case Right(_) => None - })) - } - - object CheckRightProjection { - val prop_valueE = property((n: Int, s: String) => Right(n).right.valueE(s) == n) - - val prop_value = property((n: Int) => Right(n).right.value == n) - - val prop_on = property((e: Either[Int, Int]) => e.right.on((_: Int) + 1) == (e match { - case Left(a) => a + 1 - case Right(b) => b - })) - - val prop_getOrElse = property((e: Either[Int, Int], or: Int) => e.right.getOrElse(or) == (e match { - case Left(_) => or - case Right(b) => b - })) - - val prop_forall = property((e: Either[Int, Int]) => - e.right.forall(_ % 2 == 0) == (e.isLeft || e.right.value % 2 == 0)) - - val prop_exists = property((e: Either[Int, Int]) => - e.right.exists(_ % 2 == 0) == (e.isRight && e.right.value % 2 == 0)) - - val prop_flatMapLeftIdentity = property((e: Either[Int, Int], n: Int, s: String) => { - def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s) - Right(n).right.flatMap(f(_)) == f(n)}) - - val prop_flatMapRightIdentity = property((e: Either[Int, Int]) => e.right.flatMap(Right(_)) == e) - - val prop_flatMapComposition = property((e: Either[Int, Int]) => { - def f(x: Int) = if(x % 2 == 0) Left(x) else Right(x) - def g(x: Int) = if(x % 7 == 0) Right(x) else Left(x) - e.right.flatMap(f(_)).right.flatMap(g(_)) == e.right.flatMap(f(_).right.flatMap(g(_)))}) - - val prop_mapIdentity = property((e: Either[Int, Int]) => e.right.map(x => x) == e) - - val prop_mapComposition = property((e: Either[Int, String]) => { - def f(s: String) = s.toLowerCase - def g(s: String) = s.reverse - e.right.map(x => f(g(x))) == e.right.map(x => g(x)).right.map(f(_))}) - - val prop_filter = property((e: Either[Int, Int], x: Int) => e.right.filter(_ % 2 == 0) == - (if(e.isLeft || e.right.value % 2 != 0) None else Some(e))) - - val prop_ap = property((e1: Either[Int, Int], e2: Either[Int, Int]) => { - val ee2 = e2.right map (n => (x: Int) => x + n) - e1.right.ap(ee2) == (ee2 match { - case Left(a) => Left(a) - case Right(f) => e1 match { - case Left(a) => Left(a) - case Right(b) => Right(f(b)) - } - }) - }) - - val prop_seq = property((e: Either[Int, Int]) => e.right.seq == (e match { - case Left(_) => Seq.empty - case Right(b) => Seq.singleton(b) - })) - - val prop_option = property((e: Either[Int, Int]) => e.right.option == (e match { - case Left(_) => None - case Right(b) => Some(b) - })) - } - - val prop_Either_left = property((n: Int) => Either.left(n).left.value == n) - - val prop_Either_right = property((n: Int) => Either.right(n).right.value == n) - - val prop_Either_joinLeft = property((e: Either[Either[Int, Int], Int]) => e match { - case Left(ee) => Either.joinLeft(e) == ee - case Right(n) => Either.joinLeft(e) == Right(n) - }) - - val prop_Either_joinRight = property((e: Either[Int, Either[Int, Int]]) => e match { - case Left(n) => Either.joinRight(e) == Left(n) - case Right(ee) => Either.joinRight(e) == ee - }) - - val prop_Either_lefts = property((es: List[Either[Int, Int]]) => - Either.lefts(es) == es.filter(_.isLeft).map(_.left.value)) - - val prop_Either_rights = property((es: List[Either[Int, Int]]) => - Either.rights(es) == es.filter(_.isRight).map(_.right.value)) - - val prop_Either_leftRights = property((es: List[Either[Int, Int]]) => - Either.rights(es) == es.filter(_.isRight).map(_.right.value)) - - val prop_Either_throws = property((n: Int) => - Either.throws(n) == Right(n) && Either.throws(error("error")).isLeft) - - val prop_Either_throwIt = property((e: Either[Throwable, Int]) => - try { - Either.throwIt(e) == e.right.value - } catch { - case (t) => e.isLeft && e.left.value == t - }) - - val prop_Either_reduce = property((e: Either[Int, Int]) => - Either.reduce(e) == (e match { - case Left(a) => a - case Right(a) => a - })) - - val prop_Either_iif = property((c: Boolean, a: Int, b: Int) => - Either.iif(c, a, b) == (if(c) Right(b) else Left(a))) - - val tests = List( - ("prop_either1", prop_either1), - ("prop_either2", prop_either2), - ("prop_swap", prop_swap), - ("prop_isLeftRight", prop_isLeftRight), - ("Left.prop_valueE", CheckLeftProjection.prop_valueE), - ("Left.prop_value", CheckLeftProjection.prop_value), - ("Left.prop_getOrElse", CheckLeftProjection.prop_getOrElse), - ("Left.prop_forall", CheckLeftProjection.prop_forall), - ("Left.prop_exists", CheckLeftProjection.prop_exists), - ("Left.prop_flatMapLeftIdentity", CheckLeftProjection.prop_flatMapLeftIdentity), - ("Left.prop_flatMapRightIdentity", CheckLeftProjection.prop_flatMapRightIdentity), - ("Left.prop_flatMapComposition", CheckLeftProjection.prop_flatMapComposition), - ("Left.prop_mapIdentity", CheckLeftProjection.prop_mapIdentity), - ("Left.prop_mapComposition", CheckLeftProjection.prop_mapComposition), - ("Left.prop_filter", CheckLeftProjection.prop_filter), - ("Left.prop_ap", CheckLeftProjection.prop_ap), - ("Left.prop_seq", CheckLeftProjection.prop_seq), - ("Left.prop_option", CheckLeftProjection.prop_option), - ("Right.prop_valueE", CheckRightProjection.prop_valueE), - ("Right.prop_value", CheckRightProjection.prop_value), - ("Right.prop_getOrElse", CheckRightProjection.prop_getOrElse), - ("Right.prop_forall", CheckRightProjection.prop_forall), - ("Right.prop_exists", CheckRightProjection.prop_exists), - ("Right.prop_flatMapLeftIdentity", CheckRightProjection.prop_flatMapLeftIdentity), - ("Right.prop_flatMapRightIdentity", CheckRightProjection.prop_flatMapRightIdentity), - ("Right.prop_flatMapComposition", CheckRightProjection.prop_flatMapComposition), - ("Right.prop_mapIdentity", CheckRightProjection.prop_mapIdentity), - ("Right.prop_mapComposition", CheckRightProjection.prop_mapComposition), - ("Right.prop_filter", CheckRightProjection.prop_filter), - ("Right.prop_ap", CheckRightProjection.prop_ap), - ("Right.prop_seq", CheckRightProjection.prop_seq), - ("Right.prop_option", CheckRightProjection.prop_option), - ("prop_Either_left", prop_Either_left), - ("prop_Either_right", prop_Either_right), - ("prop_Either_joinLeft", prop_Either_joinLeft), - ("prop_Either_joinRight", prop_Either_joinRight), - ("prop_Either_lefts", prop_Either_lefts), - ("prop_Either_rights", prop_Either_rights), - ("prop_Either_leftRights", prop_Either_leftRights), - ("prop_Either_throws", prop_Either_throws), - ("prop_Either_throwIt", prop_Either_throwIt), - ("prop_Either_reduce", prop_Either_reduce), - ("prop_Either_iif", prop_Either_iif) - ) - - def main(args: Array[String]) = - tests foreach (tupled((name, prop) => - testStatsEx(name, testReport(check(Params(500, 0, 0, 500, StdRand), prop, propReport))))) -} - diff --git a/test/pending/scalacheck/process.scala b/test/pending/scalacheck/process.scala new file mode 100644 index 0000000000..f3aa872361 --- /dev/null +++ b/test/pending/scalacheck/process.scala @@ -0,0 +1,160 @@ +/** process tests. + */ + +import java.io.{ File, FileNotFoundException, IOException, InputStream, OutputStream, FileInputStream } +import java.net.{ URI, URISyntaxException, URL } +import org.scalacheck._ +import Prop._ +import sys.process._ +import scala.tools.nsc.io.{ File => SFile } + +/** This has scrounged bits of sbt to flesh it out enough to run. + */ +package processtest { + + object exit + { + def fn(code: Int) = System.exit(code) + def main(args: Array[String]) = exit.fn(java.lang.Integer.parseInt(args(0))) + } + object cat + { + def main(args: Array[String]) + { + try { + if (args.length == 0) + IO.transfer(System.in, System.out) + else + catFiles(args.toList) + exit.fn(0) + } catch { + case e => + e.printStackTrace() + System.err.println("Error: " + e.toString) + exit.fn(1) + } + } + private def catFiles(filenames: List[String]): Option[String] = filenames match { + case head :: tail => + val file = new File(head) + if (file.isDirectory) + throw new IOException("Is directory: " + file) + else if (file.exists) { + IO.transfer(file, System.out) + catFiles(tail) + } + else + throw new FileNotFoundException("No such file or directory: " + file) + case Nil => None + } + } + object echo + { + def main(args: Array[String]) + { + System.out.println(args.mkString(" ")) + } + } +} + +object IO { + def transfer(in: InputStream, out: OutputStream): Unit = BasicIO.transferFully(in, out) + def transfer(in: File, out: OutputStream): Unit = BasicIO.transferFully(new FileInputStream(in), out) + + def classLocation(cl: Class[_]): URL = { + val codeSource = cl.getProtectionDomain.getCodeSource + if(codeSource == null) sys.error("No class location for " + cl) + else codeSource.getLocation + } + def classLocationFile(cl: Class[_]): File = toFile(classLocation(cl)) + def classLocation[T](implicit mf: Manifest[T]): URL = classLocation(mf.erasure) + def classLocationFile[T](implicit mf: Manifest[T]): File = classLocationFile(mf.erasure) + + def toFile(url: URL) = + try { new File(url.toURI) } + catch { case _: URISyntaxException => new File(url.getPath) } +} + +class ProcessSpecification extends Properties("Process I/O") { + implicit val exitCodeArb: Arbitrary[Array[Byte]] = Arbitrary(Gen.choose(0, 10) flatMap { size => + Gen.resize(size, Arbitrary.arbArray[Byte].arbitrary) + }) + + /*property("Correct exit code") = forAll( (exitCode: Byte) => checkExit(exitCode)) + property("#&& correct") = forAll( (exitCodes: Array[Byte]) => checkBinary(exitCodes)(_ #&& _)(_ && _)) + property("#|| correct") = forAll( (exitCodes: Array[Byte]) => checkBinary(exitCodes)(_ #|| _)(_ || _)) + property("### correct") = forAll( (exitCodes: Array[Byte]) => checkBinary(exitCodes)(_ ### _)( (x,latest) => latest))*/ + property("Pipe to output file") = forAll( (data: Array[Byte]) => checkFileOut(data)) + property("Pipe to input file") = forAll( (data: Array[Byte]) => checkFileIn(data)) + property("Pipe to process") = forAll( (data: Array[Byte]) => checkPipe(data)) + + private def checkBinary(codes: Array[Byte])(reduceProcesses: (ProcessBuilder, ProcessBuilder) => ProcessBuilder)(reduceExit: (Boolean, Boolean) => Boolean) = + { + (codes.length > 1) ==> + { + val unsignedCodes = codes.map(unsigned) + val exitCode = unsignedCodes.map(code => Process(process("processtest.exit " + code))).reduceLeft(reduceProcesses) ! + val expectedExitCode = unsignedCodes.map(toBoolean).reduceLeft(reduceExit) + toBoolean(exitCode) == expectedExitCode + } + } + private def toBoolean(exitCode: Int) = exitCode == 0 + private def checkExit(code: Byte) = + { + val exitCode = unsigned(code) + (process("processtest.exit " + exitCode) !) == exitCode + } + private def checkFileOut(data: Array[Byte]) = + { + withData(data) { (temporaryFile, temporaryFile2) => + val catCommand = process("processtest.cat " + temporaryFile.getAbsolutePath) + catCommand #> temporaryFile2 + } + } + private def checkFileIn(data: Array[Byte]) = + { + withData(data) { (temporaryFile, temporaryFile2) => + val catCommand = process("processtest.cat") + temporaryFile #> catCommand #> temporaryFile2 + } + } + private def checkPipe(data: Array[Byte]) = + { + withData(data) { (temporaryFile, temporaryFile2) => + val catCommand = process("processtest.cat") + temporaryFile #> catCommand #| catCommand #> temporaryFile2 + } + } + private def temp() = SFile(File.createTempFile("processtest", "")) + private def withData(data: Array[Byte])(f: (File, File) => ProcessBuilder) = + { + val temporaryFile1 = temp() + val temporaryFile2 = temp() + try { + temporaryFile1 writeBytes data + val process = f(temporaryFile1.jfile, temporaryFile2.jfile) + ( process ! ) == 0 && + { + val b1 = temporaryFile1.slurp() + val b2 = temporaryFile2.slurp() + b1 == b2 + } + } + finally + { + temporaryFile1.delete() + temporaryFile2.delete() + } + } + private def unsigned(b: Byte): Int = ((b: Int) +256) % 256 + private def process(command: String) = { + val thisClasspath = List(getSource[ScalaObject], getSource[IO.type], getSource[SourceTag]).mkString(File.pathSeparator) + "java -cp " + thisClasspath + " " + command + } + private def getSource[T : Manifest]: String = + IO.classLocationFile[T].getAbsolutePath +} +private trait SourceTag + + +object Test extends ProcessSpecification { } diff --git a/test/pending/script/errors.check b/test/pending/script/error-messages.check index 1aee1fb44a..1aee1fb44a 100644 --- a/test/pending/script/errors.check +++ b/test/pending/script/error-messages.check diff --git a/test/pending/script/errors.scala b/test/pending/script/error-messages.scala index 2e2025b203..2e2025b203 100644 --- a/test/pending/script/errors.scala +++ b/test/pending/script/error-messages.scala diff --git a/test/pending/script/t2365.javaopts b/test/pending/script/t2365.javaopts new file mode 100644 index 0000000000..357e033c1c --- /dev/null +++ b/test/pending/script/t2365.javaopts @@ -0,0 +1 @@ +-XX:MaxPermSize=25M diff --git a/test/pending/script/t2365.sh b/test/pending/script/t2365.sh new file mode 100755 index 0000000000..f3c44ad086 --- /dev/null +++ b/test/pending/script/t2365.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# +# This script should fail with any build of scala where #2365 +# is not fixed, and otherwise succeed. Failure means running out +# of PermGen space. + +CP=.:/local/lib/java/ivy.jar +# SCALAC=/scala/inst/28/bin/scalac +SCALAC=scalac +RUN_OPTS="-XX:MaxPermSize=25M -verbose:gc" + +$SCALAC -cp $CP *.scala +JAVA_OPTS="${RUN_OPTS}" scala -cp $CP Test diff --git a/test/pending/script/t2365/Test.scala b/test/pending/script/t2365/Test.scala new file mode 100644 index 0000000000..110dea2ab6 --- /dev/null +++ b/test/pending/script/t2365/Test.scala @@ -0,0 +1,35 @@ +import scala.tools.nsc.io._ +import java.net.URL + +object A { def apply(d: { def apply(): Int}) = d.apply() } +object A2 { def apply(d: { def apply(): Int}) = d.apply() } +object A3 { def apply(d: { def apply(): Int}) = d.apply() } +object A4 { def apply(d: { def apply(): Int}) = d.apply() } + +class B extends Function0[Int] { + def apply() = 3 +} + +object Test +{ + type StructF0 = { def apply(): Int } + def main(args: Array[String]) { + for(i <- 0 until 150) + println(i + " " + test(A.apply) + " " + test(A2.apply) + " " + test(A3.apply) + " " + test(A3.apply)) + } + + def test(withF0: StructF0 => Int): Int = { + // Some large jar + val jar = File("../../../../lib/scalacheck.jar").toURL + // load a class in a separate loader that will be passed to A + val loader = new java.net.URLClassLoader(Array(File(".").toURL, jar)) + // load a real class to fill perm gen space + Class.forName("org.scalacheck.Properties", true, loader).newInstance + // create a class from another class loader with an apply: Int method + val b = Class.forName("B", true, loader).newInstance + + // pass instance to a, which will call apply using structural type reflection. + // This should hold on to the class for B, which means bLoader will not get collected + withF0(b.asInstanceOf[StructF0]) + } +} diff --git a/test/pending/script/t2365/runner.scala b/test/pending/script/t2365/runner.scala new file mode 100755 index 0000000000..b5e05325cf --- /dev/null +++ b/test/pending/script/t2365/runner.scala @@ -0,0 +1,9 @@ +#!/bin/sh +# +# This script should fail with any build of scala where #2365 +# is not fixed, and otherwise succeed. Failure means running out +# of PermGen space. +# + +scalac -cp .:/local/lib/java/ivy.jar Test.scala +JAVA_OPTS="-XX:MaxPermSize=25M -verbose:gc" scalac -cp $CP Test diff --git a/test/pending/shootout/fasta.check b/test/pending/shootout/fasta.check new file mode 100644 index 0000000000..f1caba0d62 --- /dev/null +++ b/test/pending/shootout/fasta.check @@ -0,0 +1,171 @@ +>ONE Homo sapiens alu +GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA +TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT +AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG +GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG +CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT +GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA +GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA +TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG +AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA +GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT +AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC +AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG +GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC +CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG +AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT +TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA +TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT +GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG +TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT +CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG +CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG +TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA +CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG +AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG +GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC +TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA +TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA +GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT +GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC +ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT +TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC +CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG +CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG +GGCGACAGAGCGAGACTCCG +>TWO IUB ambiguity codes +cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg +tactDtDagcctatttSVHtHttKtgtHMaSattgWaHKHttttagacatWatgtRgaaa +NtactMcSMtYtcMgRtacttctWBacgaaatatagScDtttgaagacacatagtVgYgt +cattHWtMMWcStgttaggKtSgaYaaccWStcgBttgcgaMttBYatcWtgacaYcaga +gtaBDtRacttttcWatMttDBcatWtatcttactaBgaYtcttgttttttttYaaScYa +HgtgttNtSatcMtcVaaaStccRcctDaataataStcYtRDSaMtDttgttSagtRRca +tttHatSttMtWgtcgtatSSagactYaaattcaMtWatttaSgYttaRgKaRtccactt +tattRggaMcDaWaWagttttgacatgttctacaaaRaatataataaMttcgDacgaSSt +acaStYRctVaNMtMgtaggcKatcttttattaaaaagVWaHKYagtttttatttaacct +tacgtVtcVaattVMBcttaMtttaStgacttagattWWacVtgWYagWVRctDattBYt +gtttaagaagattattgacVatMaacattVctgtBSgaVtgWWggaKHaatKWcBScSWa +accRVacacaaactaccScattRatatKVtactatatttHttaagtttSKtRtacaaagt +RDttcaaaaWgcacatWaDgtDKacgaacaattacaRNWaatHtttStgttattaaMtgt +tgDcgtMgcatBtgcttcgcgaDWgagctgcgaggggVtaaScNatttacttaatgacag +cccccacatYScaMgtaggtYaNgttctgaMaacNaMRaacaaacaKctacatagYWctg +ttWaaataaaataRattagHacacaagcgKatacBttRttaagtatttccgatctHSaat +actcNttMaagtattMtgRtgaMgcataatHcMtaBSaRattagttgatHtMttaaKagg +YtaaBataSaVatactWtataVWgKgttaaaacagtgcgRatatacatVtHRtVYataSa +KtWaStVcNKHKttactatccctcatgWHatWaRcttactaggatctataDtDHBttata +aaaHgtacVtagaYttYaKcctattcttcttaataNDaaggaaaDYgcggctaaWSctBa +aNtgctggMBaKctaMVKagBaactaWaDaMaccYVtNtaHtVWtKgRtcaaNtYaNacg +gtttNattgVtttctgtBaWgtaattcaagtcaVWtactNggattctttaYtaaagccgc +tcttagHVggaYtgtNcDaVagctctctKgacgtatagYcctRYHDtgBattDaaDgccK +tcHaaStttMcctagtattgcRgWBaVatHaaaataYtgtttagMDMRtaataaggatMt +ttctWgtNtgtgaaaaMaatatRtttMtDgHHtgtcattttcWattRSHcVagaagtacg +ggtaKVattKYagactNaatgtttgKMMgYNtcccgSKttctaStatatNVataYHgtNa +BKRgNacaactgatttcctttaNcgatttctctataScaHtataRagtcRVttacDSDtt +aRtSatacHgtSKacYagttMHtWataggatgactNtatSaNctataVtttRNKtgRacc +tttYtatgttactttttcctttaaacatacaHactMacacggtWataMtBVacRaSaatc +cgtaBVttccagccBcttaRKtgtgcctttttRtgtcagcRttKtaaacKtaaatctcac +aattgcaNtSBaaccgggttattaaBcKatDagttactcttcattVtttHaaggctKKga +tacatcBggScagtVcacattttgaHaDSgHatRMaHWggtatatRgccDttcgtatcga +aacaHtaagttaRatgaVacttagattVKtaaYttaaatcaNatccRttRRaMScNaaaD +gttVHWgtcHaaHgacVaWtgttScactaagSgttatcttagggDtaccagWattWtRtg +ttHWHacgattBtgVcaYatcggttgagKcWtKKcaVtgaYgWctgYggVctgtHgaNcV +taBtWaaYatcDRaaRtSctgaHaYRttagatMatgcatttNattaDttaattgttctaa +ccctcccctagaWBtttHtBccttagaVaatMcBHagaVcWcagBVttcBtaYMccagat +gaaaaHctctaacgttagNWRtcggattNatcRaNHttcagtKttttgWatWttcSaNgg +gaWtactKKMaacatKatacNattgctWtatctaVgagctatgtRaHtYcWcttagccaa +tYttWttaWSSttaHcaaaaagVacVgtaVaRMgattaVcDactttcHHggHRtgNcctt +tYatcatKgctcctctatVcaaaaKaaaagtatatctgMtWtaaaacaStttMtcgactt +taSatcgDataaactaaacaagtaaVctaggaSccaatMVtaaSKNVattttgHccatca +cBVctgcaVatVttRtactgtVcaattHgtaaattaaattttYtatattaaRSgYtgBag +aHSBDgtagcacRHtYcBgtcacttacactaYcgctWtattgSHtSatcataaatataHt +cgtYaaMNgBaatttaRgaMaatatttBtttaaaHHKaatctgatWatYaacttMctctt +ttVctagctDaaagtaVaKaKRtaacBgtatccaaccactHHaagaagaaggaNaaatBW +attccgStaMSaMatBttgcatgRSacgttVVtaaDMtcSgVatWcaSatcttttVatag +ttactttacgatcaccNtaDVgSRcgVcgtgaacgaNtaNatatagtHtMgtHcMtagaa +attBgtataRaaaacaYKgtRccYtatgaagtaataKgtaaMttgaaRVatgcagaKStc +tHNaaatctBBtcttaYaBWHgtVtgacagcaRcataWctcaBcYacYgatDgtDHccta +>THREE Homo sapiens frequency +aacacttcaccaggtatcgtgaaggctcaagattacccagagaacctttgcaatataaga +atatgtatgcagcattaccctaagtaattatattctttttctgactcaaagtgacaagcc +ctagtgtatattaaatcggtatatttgggaaattcctcaaactatcctaatcaggtagcc +atgaaagtgatcaaaaaagttcgtacttataccatacatgaattctggccaagtaaaaaa +tagattgcgcaaaattcgtaccttaagtctctcgccaagatattaggatcctattactca +tatcgtgtttttctttattgccgccatccccggagtatctcacccatccttctcttaaag +gcctaatattacctatgcaaataaacatatattgttgaaaattgagaacctgatcgtgat +tcttatgtgtaccatatgtatagtaatcacgcgactatatagtgctttagtatcgcccgt +gggtgagtgaatattctgggctagcgtgagatagtttcttgtcctaatatttttcagatc +gaatagcttctatttttgtgtttattgacatatgtcgaaactccttactcagtgaaagtc +atgaccagatccacgaacaatcttcggaatcagtctcgttttacggcggaatcttgagtc +taacttatatcccgtcgcttactttctaacaccccttatgtatttttaaaattacgttta +ttcgaacgtacttggcggaagcgttattttttgaagtaagttacattgggcagactcttg +acattttcgatacgactttctttcatccatcacaggactcgttcgtattgatatcagaag +ctcgtgatgattagttgtcttctttaccaatactttgaggcctattctgcgaaatttttg +ttgccctgcgaacttcacataccaaggaacacctcgcaacatgccttcatatccatcgtt +cattgtaattcttacacaatgaatcctaagtaattacatccctgcgtaaaagatggtagg +ggcactgaggatatattaccaagcatttagttatgagtaatcagcaatgtttcttgtatt +aagttctctaaaatagttacatcgtaatgttatctcgggttccgcgaataaacgagatag +attcattatatatggccctaagcaaaaacctcctcgtattctgttggtaattagaatcac +acaatacgggttgagatattaattatttgtagtacgaagagatataaaaagatgaacaat +tactcaagtcaagatgtatacgggatttataataaaaatcgggtagagatctgctttgca +attcagacgtgccactaaatcgtaatatgtcgcgttacatcagaaagggtaactattatt +aattaataaagggcttaatcactacatattagatcttatccgatagtcttatctattcgt +tgtatttttaagcggttctaattcagtcattatatcagtgctccgagttctttattattg +ttttaaggatgacaaaatgcctcttgttataacgctgggagaagcagactaagagtcgga +gcagttggtagaatgaggctgcaaaagacggtctcgacgaatggacagactttactaaac +caatgaaagacagaagtagagcaaagtctgaagtggtatcagcttaattatgacaaccct +taatacttccctttcgccgaatactggcgtggaaaggttttaaaagtcgaagtagttaga +ggcatctctcgctcataaataggtagactactcgcaatccaatgtgactatgtaatactg +ggaacatcagtccgcgatgcagcgtgtttatcaaccgtccccactcgcctggggagacat +gagaccacccccgtggggattattagtccgcagtaatcgactcttgacaatccttttcga +ttatgtcatagcaatttacgacagttcagcgaagtgactactcggcgaaatggtattact +aaagcattcgaacccacatgaatgtgattcttggcaatttctaatccactaaagcttttc +cgttgaatctggttgtagatatttatataagttcactaattaagatcacggtagtatatt +gatagtgatgtctttgcaagaggttggccgaggaatttacggattctctattgatacaat +ttgtctggcttataactcttaaggctgaaccaggcgtttttagacgacttgatcagctgt +tagaatggtttggactccctctttcatgtcagtaacatttcagccgttattgttacgata +tgcttgaacaatattgatctaccacacacccatagtatattttataggtcatgctgttac +ctacgagcatggtattccacttcccattcaatgagtattcaacatcactagcctcagaga +tgatgacccacctctaataacgtcacgttgcggccatgtgaaacctgaacttgagtagac +gatatcaagcgctttaaattgcatataacatttgagggtaaagctaagcggatgctttat +ataatcaatactcaataataagatttgattgcattttagagttatgacacgacatagttc +actaacgagttactattcccagatctagactgaagtactgatcgagacgatccttacgtc +gatgatcgttagttatcgacttaggtcgggtctctagcggtattggtacttaaccggaca +ctatactaataacccatgatcaaagcataacagaatacagacgataatttcgccaacata +tatgtacagaccccaagcatgagaagctcattgaaagctatcattgaagtcccgctcaca +atgtgtcttttccagacggtttaactggttcccgggagtcctggagtttcgacttacata +aatggaaacaatgtattttgctaatttatctatagcgtcatttggaccaatacagaatat +tatgttgcctagtaatccactataacccgcaagtgctgatagaaaatttttagacgattt +ataaatgccccaagtatccctcccgtgaatcctccgttatactaattagtattcgttcat +acgtataccgcgcatatatgaacatttggcgataaggcgcgtgaattgttacgtgacaga +gatagcagtttcttgtgatatggttaacagacgtacatgaagggaaactttatatctata +gtgatgcttccgtagaaataccgccactggtctgccaatgatgaagtatgtagctttagg +tttgtactatgaggctttcgtttgtttgcagagtataacagttgcgagtgaaaaaccgac +gaatttatactaatacgctttcactattggctacaaaatagggaagagtttcaatcatga +gagggagtatatggatgctttgtagctaaaggtagaacgtatgtatatgctgccgttcat +tcttgaaagatacataagcgataagttacgacaattataagcaacatccctaccttcgta +acgatttcactgttactgcgcttgaaatacactatggggctattggcggagagaagcaga +tcgcgccgagcatatacgagacctataatgttgatgatagagaaggcgtctgaattgata +catcgaagtacactttctttcgtagtatctctcgtcctctttctatctccggacacaaga +attaagttatatatatagagtcttaccaatcatgttgaatcctgattctcagagttcttt +ggcgggccttgtgatgactgagaaacaatgcaatattgctccaaatttcctaagcaaatt +ctcggttatgttatgttatcagcaaagcgttacgttatgttatttaaatctggaatgacg +gagcgaagttcttatgtcggtgtgggaataattcttttgaagacagcactccttaaataa +tatcgctccgtgtttgtatttatcgaatgggtctgtaaccttgcacaagcaaatcggtgg +tgtatatatcggataacaattaatacgatgttcatagtgacagtatactgatcgagtcct +ctaaagtcaattacctcacttaacaatctcattgatgttgtgtcattcccggtatcgccc +gtagtatgtgctctgattgaccgagtgtgaaccaaggaacatctactaatgcctttgtta +ggtaagatctctctgaattccttcgtgccaacttaaaacattatcaaaatttcttctact +tggattaactacttttacgagcatggcaaattcccctgtggaagacggttcattattatc +ggaaaccttatagaaattgcgtgttgactgaaattagatttttattgtaagagttgcatc +tttgcgattcctctggtctagcttccaatgaacagtcctcccttctattcgacatcgggt +ccttcgtacatgtctttgcgatgtaataattaggttcggagtgtggccttaatgggtgca +actaggaatacaacgcaaatttgctgacatgatagcaaatcggtatgccggcaccaaaac +gtgctccttgcttagcttgtgaatgagactcagtagttaaataaatccatatctgcaatc +gattccacaggtattgtccactatctttgaactactctaagagatacaagcttagctgag +accgaggtgtatatgactacgctgatatctgtaaggtaccaatgcaggcaaagtatgcga +gaagctaataccggctgtttccagctttataagattaaaatttggctgtcctggcggcct +cagaattgttctatcgtaatcagttggttcattaattagctaagtacgaggtacaactta +tctgtcccagaacagctccacaagtttttttacagccgaaacccctgtgtgaatcttaat +atccaagcgcgttatctgattagagtttacaactcagtattttatcagtacgttttgttt +ccaacattacccggtatgacaaaatgacgccacgtgtcgaataatggtctgaccaatgta +ggaagtgaaaagataaatat diff --git a/test/pending/shootout/fasta.scala b/test/pending/shootout/fasta.scala new file mode 100644 index 0000000000..8b711083a5 --- /dev/null +++ b/test/pending/shootout/fasta.scala @@ -0,0 +1,162 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy +*/ + +import java.io._ + +object fasta { + def main(args: Array[String]) = { + + val ALU = + "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" + + "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" + + "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" + + "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" + + "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" + + "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" + + "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA" + + val _IUB = Array( + Pair('a', 0.27), + Pair('c', 0.12), + Pair('g', 0.12), + Pair('t', 0.27), + + Pair('B', 0.02), + Pair('D', 0.02), + Pair('H', 0.02), + Pair('K', 0.02), + Pair('M', 0.02), + Pair('N', 0.02), + Pair('R', 0.02), + Pair('S', 0.02), + Pair('V', 0.02), + Pair('W', 0.02), + Pair('Y', 0.02) + ) + + val IUB = makeCumulative(_IUB) + + val _HomoSapiens = Array( + Pair('a', 0.3029549426680), + Pair('c', 0.1979883004921), + Pair('g', 0.1975473066391), + Pair('t', 0.3015094502008) + ) + + val HomoSapiens = makeCumulative(_HomoSapiens) + + + val n = Integer parseInt(args(0)) + val s = new FastaOutputStream(System.out) + + s.writeDescription("ONE Homo sapiens alu") + s.writeRepeatingSequence(ALU,n*2) + + s.writeDescription("TWO IUB ambiguity codes") + s.writeRandomSequence(IUB,n*3) + + s.writeDescription("THREE Homo sapiens frequency") + s.writeRandomSequence(HomoSapiens,n*5) + + s.close + } + + def makeCumulative(a: Array[Pair[Char,Double]]) = { + var cp = 0.0 + a map (frequency => + frequency match { + case Pair(code,percent) => + cp = cp + percent; new Frequency(code.toByte,cp) + } + ) + } + +} + + +// We could use instances of Pair or Tuple2 but specific labels +// make the code more readable than index numbers + +class Frequency(_code: Byte, _percent: Double){ + var code = _code; var percent = _percent; +} + + +// extend the Java BufferedOutputStream class + +class FastaOutputStream(out: OutputStream) extends BufferedOutputStream(out) { + + private val LineLength = 60 + private val nl = '\n'.toByte + + def writeDescription(desc: String) = { write( (">" + desc + "\n").getBytes ) } + + def writeRepeatingSequence(_alu: String, length: Int) = { + val alu = _alu.getBytes + var n = length; var k = 0; val kn = alu.length; + + while (n > 0) { + val m = if (n < LineLength) n else LineLength + + var i = 0 + while (i < m){ + if (k == kn) k = 0 + val b = alu(k) + if (count < buf.length){ buf(count) = b; count = count + 1 } + else { write(b) } // flush buffer + k = k+1 + i = i+1 + } + + write(nl) + n = n - LineLength + } + + } + + def writeRandomSequence(distribution: Array[Frequency], length: Int) = { + var n = length + while (n > 0) { + val m = if (n < LineLength) n else LineLength + + var i = 0 + while (i < m){ + val b = selectRandom(distribution) + if (count < buf.length){ buf(count) = b; count = count + 1 } + else { write(b) } // flush buffer + i = i+1 + } + + if (count < buf.length){ buf(count) = nl; count = count + 1 } + else { write(nl) } // flush buffer + n = n - LineLength + } + } + + private def selectRandom(distribution: Array[Frequency]): Byte = { + val n = distribution.length + val r = RandomNumber scaledTo(1.0) + + var i = 0 + while (i < n) { + if (r < distribution(i).percent) return distribution(i).code + i = i+1 + } + return distribution(n-1).code + } +} + + +object RandomNumber { + private val IM = 139968 + private val IA = 3877 + private val IC = 29573 + private var seed = 42 + + def scaledTo(max: Double) = { + seed = (seed * IA + IC) % IM + max * seed / IM + } +} diff --git a/test/pending/shootout/fasta.scala.runner b/test/pending/shootout/fasta.scala.runner new file mode 100644 index 0000000000..e95a749cf2 --- /dev/null +++ b/test/pending/shootout/fasta.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(25000,250000,2500000)) fasta.main(Array(n.toString)) +} diff --git a/test/pending/shootout/harmonic.scala-2.scala b/test/pending/shootout/harmonic.scala-2.scala new file mode 100644 index 0000000000..a55e164e50 --- /dev/null +++ b/test/pending/shootout/harmonic.scala-2.scala @@ -0,0 +1,14 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy (Scala novice) +*/ + +object harmonic { + def main(args: Array[String]) = { + val n = Integer.parseInt(args(0)); + var partialSum = 0.0; + + for (i <- Iterator.range(1,n+1)) partialSum = partialSum + 1.0/i; + Console.printf("{0,number,#.000000000}\n")(partialSum); + } +} diff --git a/test/pending/shootout/harmonic.scala-2.scala.runner b/test/pending/shootout/harmonic.scala-2.scala.runner new file mode 100644 index 0000000000..d0ea85742a --- /dev/null +++ b/test/pending/shootout/harmonic.scala-2.scala.runner @@ -0,0 +1,16 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy (Scala novice) +*/ +object Test extends Application { + for(n <- List(6000000,8000000,10000000)) harmonic.main(Array(n.toString)) +} +object harmonic { + def main(args: Array[String]) = { + val n = Integer.parseInt(args(0)); + var partialSum = 0.0; + + for (i <- Iterator.range(1,n+1)) partialSum = partialSum + 1.0/i; + Console.printf("{0,number,#.000000000}\n")(partialSum); + } +} diff --git a/test/pending/shootout/harmonic.scala-3.scala b/test/pending/shootout/harmonic.scala-3.scala new file mode 100644 index 0000000000..dc631fcf12 --- /dev/null +++ b/test/pending/shootout/harmonic.scala-3.scala @@ -0,0 +1,15 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy (Scala novice) +*/ + +object harmonic { + def main(args: Array[String]) = { + val n = Integer.parseInt(args(0)); + var partialSum = 0.0; + var i = 1; + + while (i < n){ partialSum = partialSum + 1.0/i; i = i + 1; } + Console.printf("{0,number,#.000000000}\n", partialSum); + } +} diff --git a/test/pending/shootout/harmonic.scala-3.scala.runner b/test/pending/shootout/harmonic.scala-3.scala.runner new file mode 100644 index 0000000000..b5eda3f034 --- /dev/null +++ b/test/pending/shootout/harmonic.scala-3.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(6000000,8000000,10000000)) harmonic.main(Array(n.toString)) +} diff --git a/test/pending/shootout/heapsort.scala b/test/pending/shootout/heapsort.scala new file mode 100644 index 0000000000..59b1fe27cb --- /dev/null +++ b/test/pending/shootout/heapsort.scala @@ -0,0 +1,72 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy (Scala novice) +*/ + +object heapsort { + def main(args: Array[String]) = { + val n = toPositiveInt(args); + + val numbers = new Array[Double](n+1); + for (i <- Iterator.range(1,n+1)) + numbers(i) = generate(100.0); + + heapsort(n, numbers); + + Console.printf("{0,number,#.000000000}\n", numbers(n)); + } + + + def heapsort(n: Int, ra: Array[Double]): Unit = { + var l = 0; var j = 0; var ir = 0; var i = 0; + var rra = 0.0d; + + if (n < 2) return; + l = (n >> 1) + 1; + ir = n; + while (true) { + if (l > 1) { l = l-1; rra = ra(l); } + else { + rra = ra(ir); + ra(ir) = ra(1); + ir = ir-1; + if (ir == 1) { + ra(1) = rra; + return; + } + } + i = l; + j = l << 1; + while (j <= ir) { + if (j < ir && ra(j) < ra(j+1)) { j = j+1; } + if (rra < ra(j)) { + ra(i) = ra(j); + i = j; + j = j + i; + } + else j = ir + 1; + } + ra(i) = rra; + } + } + + + private val IM = 139968; + private val IA = 3877; + private val IC = 29573; + private var seed = 42; + + private def generate(max: Double) = { + seed = (seed * IA + IC) % IM; + max * seed / IM; + } + + + private def toPositiveInt(s: Array[String]) = { + val i = + try { Integer.parseInt(s(0)); } + catch { case _ => 1 } + if (i>0) i; else 1; + } + +} diff --git a/test/pending/shootout/heapsort.scala.runner b/test/pending/shootout/heapsort.scala.runner new file mode 100644 index 0000000000..07e4ec7fbd --- /dev/null +++ b/test/pending/shootout/heapsort.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(20000,40000,60000,80000,100000)) heapsort.main(Array(n.toString)) +} diff --git a/test/pending/shootout/mandelbrot.scala-2.check b/test/pending/shootout/mandelbrot.scala-2.check Binary files differnew file mode 100644 index 0000000000..2f7bbbc6b0 --- /dev/null +++ b/test/pending/shootout/mandelbrot.scala-2.check diff --git a/test/pending/shootout/mandelbrot.scala-2.scala b/test/pending/shootout/mandelbrot.scala-2.scala new file mode 100644 index 0000000000..dffdc354a0 --- /dev/null +++ b/test/pending/shootout/mandelbrot.scala-2.scala @@ -0,0 +1,79 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy +*/ + +// This test is in pending because it fails on windows only, +// but partest's output and the fact that this test outputs in +// binary makes it a challenge to debug remotely. However, +// it's easy to guess that it has to do with the BufferedOutputStream +// and some kind of windows-specific damage that requires an extra +// flush, or different line-ending characters, or any of the various +// write-once-know-quirks-everywhere aspects of java i/o. +// +// [partest] testing: [...]\files\shootout\mandelbrot.scala-2.scala [FAILED] +// [partest] P4 +// [partest] 200 200 +// [partest] +// ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^B^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ +// ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ +// [etc] + +import java.io.BufferedOutputStream + +object mandelbrot { + def main(args: Array[String]) = { + val side = Integer.parseInt(args(0)) + val limitSquared = 4.0 + val max = 50 + var bits = 0 + var bitnum = 0 + val w = new BufferedOutputStream(System.out) + + Console.println("P4\n" + side + " " + side) + + var y = 0 + while (y < side){ + + var x = 0 + while (x < side){ + + val cr = 2.0 * x / side - 1.5 + val ci = 2.0 * y / side - 1.0 + + var zr = 0.0; var zi = 0.0 + var tr = 0.0; var ti = 0.0 + + var j = max + do { + zi = 2.0 * zr * zi + ci + zr = tr - ti + cr + ti = zi*zi + tr = zr*zr + + j = j - 1 + } while (!(tr + ti > limitSquared) && j > 0) + + + bits = bits << 1 + if (!(tr + ti > limitSquared)) bits = bits + 1 + bitnum = bitnum + 1 + + if (x == side - 1){ + bits = bits << (8 - bitnum) + bitnum = 8 + } + + if (bitnum == 8){ + w.write(bits.toByte) + bits = 0 + bitnum = 0 + } + + x = x + 1 + } + y = y + 1 + } + w.close + } +} diff --git a/test/pending/shootout/mandelbrot.scala-2.scala.runner b/test/pending/shootout/mandelbrot.scala-2.scala.runner new file mode 100644 index 0000000000..27f69f6aec --- /dev/null +++ b/test/pending/shootout/mandelbrot.scala-2.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(200,400,600)) mandelbrot.main(Array(n.toString)) +} diff --git a/test/pending/shootout/message.check b/test/pending/shootout/message.check new file mode 100644 index 0000000000..354b2529b2 --- /dev/null +++ b/test/pending/shootout/message.check @@ -0,0 +1 @@ +500000 diff --git a/test/pending/shootout/message.javaopts b/test/pending/shootout/message.javaopts new file mode 100644 index 0000000000..1879c77427 --- /dev/null +++ b/test/pending/shootout/message.javaopts @@ -0,0 +1 @@ +-Xss128k diff --git a/test/pending/shootout/message.scala b/test/pending/shootout/message.scala new file mode 100644 index 0000000000..a7a1dacc9d --- /dev/null +++ b/test/pending/shootout/message.scala @@ -0,0 +1,47 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy +*/ + + +import scala.concurrent._ + +object message { + def main(args: Array[String]) = { + val n = Integer.parseInt(args(0)) + val nActors = 500 + val finalSum = n * nActors + + case class Message(value: Int) + + class Incrementor(next: Pid) extends Actor { + var sum = 0 + + override def run() = { + while (true) { + receive { + case Message(value) => + val j = value + 1 + if (null != next){ + next ! Message(j) + } else { + sum = sum + j + if (sum >= finalSum){ + Console.println(sum); + System.exit(0) // exit without cleaning up + } + } + } + } + } + + def pid() = { this.start; this.self } + } + + def actorChain(i: Int, a: Pid): Pid = + if (i > 0) actorChain(i-1, new Incrementor(a).pid ) else a + + val firstActor = actorChain(nActors, null) + var i = n; while (i > 0){ firstActor ! Message(0); i = i-1 } + } +} diff --git a/test/pending/shootout/message.scala.runner b/test/pending/shootout/message.scala.runner new file mode 100644 index 0000000000..ffbee1640b --- /dev/null +++ b/test/pending/shootout/message.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(1000,2000,3000)) message.main(Array(n.toString)) +} diff --git a/test/pending/shootout/meteor.scala b/test/pending/shootout/meteor.scala new file mode 100644 index 0000000000..2fd702753a --- /dev/null +++ b/test/pending/shootout/meteor.scala @@ -0,0 +1,496 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy +*/ + +// This is an un-optimised example implementation + + +import scala.collection.mutable._ + +object meteor { + def main(args: Array[String]) = { + val solver = new Solver( Integer.parseInt(args(0)) ) + solver.findSolutions + solver.printSolutions + } +} + + + + +// Solver.scala +// import scala.collection.mutable._ + +final class Solver (n: Int) { + private var countdown = n + private var first: String = _ + private var last: String = _ + + private val board = new Board() + + val pieces = Array( + new Piece(0), new Piece(1), new Piece(2), new Piece(3), new Piece(4), + new Piece(5), new Piece(6), new Piece(7), new Piece(8), new Piece(9) ) + + val unplaced = new BitSet(pieces.length) + + { unplaced ++= (0 until pieces.length) } + + + def findSolutions(): Unit = { + if (countdown == 0) return + + if (unplaced.size > 0){ + val emptyCellIndex = board.firstEmptyCellIndex + + for (k <- Iterator.range(0,pieces.length)){ + if (unplaced.contains(k)){ + unplaced -= k + + for (i <- Iterator.range(0,Piece.orientations)){ + val piece = pieces(k).nextOrientation + + for (j <- Iterator.range(0,Piece.size)){ + if (board.add(j,emptyCellIndex,piece)) { + + if (!shouldPrune) findSolutions + + board.remove(piece) + } + } + } + unplaced += k + } + } + } + else { + puzzleSolved + } + } + + private def puzzleSolved() = { + val b = board.asString + if (first == null){ + first = b; last = b + } else { + if (b < first){ first = b } else { if (b > last){ last = b } } + } + countdown = countdown - 1 + } + + private def shouldPrune() = { + board.unmark + !board.cells.forall(c => c.contiguousEmptyCells % Piece.size == 0) + } + + + def printSolutions() = { + + def printBoard(s: String) = { + var indent = false + var i = 0 + while (i < s.length){ + if (indent) Console.print(' ') + for (j <- Iterator.range(0,Board.cols)){ + Console.print(s.charAt(i)); Console.print(' ') + i = i + 1 + } + Console.print('\n') + indent = !indent + } + Console.print('\n') + } + + Console.print(n + " solutions found\n\n") + printBoard(first) + printBoard(last) + } + +/* + def printPieces() = + for (i <- Iterator.range(0,Board.pieces)) pieces(i).print +*/ + +} + + + + +// Board.scala +// import scala.collection.mutable._ + +object Board { + val cols = 5 + val rows = 10 + val size = rows * cols +} + +final class Board { + val cells = boardCells() + + val cellsPieceWillFill = new Array[BoardCell](Piece.size) + var cellCount = 0 + + def unmark() = for (c <- cells) c.unmark + + def asString() = + new String( cells map( + c => if (c.piece == null) '-'.toByte + else (c.piece.number + 48).toByte )) + + def firstEmptyCellIndex() = cells.findIndexOf(c => c.isEmpty) + + def add(pieceIndex: Int, boardIndex: Int, p: Piece) = { + cellCount = 0 + p.unmark + + find( p.cells(pieceIndex), cells(boardIndex)) + + val boardHasSpace = cellCount == Piece.size && + cellsPieceWillFill.forall(c => c.isEmpty) + + if (boardHasSpace) cellsPieceWillFill.foreach(c => c.piece = p) + + boardHasSpace + } + + def remove(piece: Piece) = for (c <- cells; if c.piece == piece) c.empty + + + private def find(p: PieceCell, b: BoardCell): Unit = { + if (p != null && !p.marked && b != null){ + cellsPieceWillFill(cellCount) = b + cellCount = cellCount + 1 + p.mark + for (i <- Iterator.range(0,Cell.sides)) find(p.next(i), b.next(i)) + } + } + + + private def boardCells() = { + val a = for (i <- Array.range(0,Board.size)) yield new BoardCell(i) + val m = (Board.size / Board.cols) - 1 + + for (i <- Iterator.range(0,a.length)){ + val row = i / Board.cols + val isFirst = i % Board.cols == 0 + val isLast = (i+1) % Board.cols == 0 + val c = a(i) + + if (row % 2 == 1) { + if (!isLast) c.next(Cell.NE) = a(i-(Board.cols-1)) + c.next(Cell.NW) = a(i-Board.cols) + if (row != m) { + if (!isLast) c.next(Cell.SE) = a(i+(Board.cols+1)) + c.next(Cell.SW) = a(i+Board.cols) + } + } else { + if (row != 0) { + if (!isFirst) c.next(Cell.NW) = a(i-(Board.cols+1)) + c.next(Cell.NE) = a(i-Board.cols) + } + if (row != m) { + if (!isFirst) c.next(Cell.SW) = a(i+(Board.cols-1)) + c.next(Cell.SE) = a(i+Board.cols) + } + } + if (!isFirst) c.next(Cell.W) = a(i-1) + if (!isLast) c.next(Cell.E) = a(i+1) + } + a + } + + +/* +// Printing all the board cells and their neighbours +// helps check that they are connected properly + + def printBoardCellsAndNeighbours() = { + Console.println("cell\tNW NE W E SW SE") + for (i <- Iterator.range(0,Board.size)){ + Console.print(i + "\t") + for (j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + Console.printf("{0,number,00} ")(c.number) + } + Console.println("") + } + Console.println("") + } +*/ + +} + + + + +// Piece.scala + +object Piece { + val size = 5 + val rotations = Cell.sides + val flips = 2 + val orientations = rotations * flips +} + +final class Piece(_number: Int) { + val number = _number + val cells = for (i <- Array.range(0,Piece.size)) yield new PieceCell() + + { + number match { + case 0 => make0 + case 1 => make1 + case 2 => make2 + case 3 => make3 + case 4 => make4 + case 5 => make5 + case 6 => make6 + case 7 => make7 + case 8 => make8 + case 9 => make9 + } + } + + def flip() = for (c <- cells) c.flip + def rotate() = for (c <- cells) c.rotate + def unmark() = for (c <- cells) c.unmark + + + private var orientation = 0 + + def nextOrientation() = { + if (orientation == Piece.orientations) orientation = 0 + if (orientation % Piece.rotations == 0) flip else rotate + orientation = orientation + 1 + this + } + + + private def make0() = { + cells(0).next(Cell.E) = cells(1) + cells(1).next(Cell.W) = cells(0) + cells(1).next(Cell.E) = cells(2) + cells(2).next(Cell.W) = cells(1) + cells(2).next(Cell.E) = cells(3) + cells(3).next(Cell.W) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make1() = { + cells(0).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(0) + cells(1).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(1) + cells(2).next(Cell.W) = cells(3) + cells(3).next(Cell.E) = cells(2) + cells(3).next(Cell.SW) = cells(4) + cells(4).next(Cell.NE) = cells(3) + } + + private def make2() = { + cells(0).next(Cell.W) = cells(1) + cells(1).next(Cell.E) = cells(0) + cells(1).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(1) + cells(2).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make3() = { + cells(0).next(Cell.SW) = cells(1) + cells(1).next(Cell.NE) = cells(0) + cells(1).next(Cell.W) = cells(2) + cells(2).next(Cell.E) = cells(1) + cells(1).next(Cell.SW) = cells(3) + cells(3).next(Cell.NE) = cells(1) + cells(2).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make4() = { + cells(0).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(0) + cells(1).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(1) + cells(1).next(Cell.E) = cells(3) + cells(3).next(Cell.W) = cells(1) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make5() = { + cells(0).next(Cell.SW) = cells(1) + cells(1).next(Cell.NE) = cells(0) + cells(0).next(Cell.SE) = cells(2) + cells(2).next(Cell.NW) = cells(0) + cells(1).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(1) + cells(2).next(Cell.SW) = cells(3) + cells(3).next(Cell.NE) = cells(2) + cells(3).next(Cell.SW) = cells(4) + cells(4).next(Cell.NE) = cells(3) + } + + private def make6() = { + cells(0).next(Cell.SW) = cells(1) + cells(1).next(Cell.NE) = cells(0) + cells(2).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(2) + cells(1).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(1) + cells(3).next(Cell.SW) = cells(4) + cells(4).next(Cell.NE) = cells(3) + } + + private def make7() = { + cells(0).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(0) + cells(0).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(0) + cells(2).next(Cell.SW) = cells(3) + cells(3).next(Cell.NE) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make8() = { + cells(0).next(Cell.E) = cells(1) + cells(1).next(Cell.W) = cells(0) + cells(1).next(Cell.E) = cells(2) + cells(2).next(Cell.W) = cells(1) + cells(2).next(Cell.NE) = cells(3) + cells(3).next(Cell.SW) = cells(2) + cells(3).next(Cell.E) = cells(4) + cells(4).next(Cell.W) = cells(3) + } + + private def make9() = { + cells(0).next(Cell.E) = cells(1) + cells(1).next(Cell.W) = cells(0) + cells(1).next(Cell.E) = cells(2) + cells(2).next(Cell.W) = cells(1) + cells(2).next(Cell.NE) = cells(3) + cells(3).next(Cell.SW) = cells(2) + cells(2).next(Cell.E) = cells(4) + cells(4).next(Cell.W) = cells(2) + cells(4).next(Cell.NW) = cells(3) + cells(3).next(Cell.SE) = cells(4) + } + +/* + def print() = { + Console.println("Piece # " + number) + Console.println("cell\tNW NE W E SW SE") + for (i <- Iterator.range(0,Piece.size)){ + Console.print(i + "\t") + for (j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + for (k <- Iterator.range(0,Piece.size)){ + if (cells(k) == c) Console.printf(" {0,number,0} ")(k) + } + } + Console.println("") + } + Console.println("") + } +*/ + +} + + + + +// Cell.scala + +object Cell { + val NW = 0; val NE = 1 + val W = 2; val E = 3 + val SW = 4; val SE = 5 + + val sides = 6 +} + +abstract class Cell { + implicit def m: Manifest[T] + type T + val next = new Array[T](Cell.sides) + var marked = false + + def mark() = marked = true + def unmark() = marked = false +} + +// BoardCell.scala + +final class BoardCell(_number: Int) extends { + type T = BoardCell + implicit val m = manifest[BoardCell] +} with Cell { + val number = _number + var piece: Piece = _ + + def isEmpty() = piece == null + def empty() = piece = null + + def contiguousEmptyCells(): Int = { + if (!marked && isEmpty){ + mark + var count = 1 + + for (neighbour <- next) + if (neighbour != null && neighbour.isEmpty) + count = count + neighbour.contiguousEmptyCells + + count } else { 0 } + } +} + + + + +// PieceCell.scala + +final class PieceCell extends Cell { + type T = PieceCell + + def flip = { + var swap = next(Cell.NE) + next(Cell.NE) = next(Cell.NW) + next(Cell.NW) = swap + + swap = next(Cell.E) + next(Cell.E) = next(Cell.W) + next(Cell.W) = swap + + swap = next(Cell.SE) + next(Cell.SE) = next(Cell.SW) + next(Cell.SW) = swap + } + + def rotate = { + var swap = next(Cell.E) + next(Cell.E) = next(Cell.NE) + next(Cell.NE) = next(Cell.NW) + next(Cell.NW) = next(Cell.W) + next(Cell.W) = next(Cell.SW) + next(Cell.SW) = next(Cell.SE) + next(Cell.SE) = swap + } +} + + + + diff --git a/test/pending/shootout/meteor.scala-2.scala b/test/pending/shootout/meteor.scala-2.scala new file mode 100644 index 0000000000..2b42c19260 --- /dev/null +++ b/test/pending/shootout/meteor.scala-2.scala @@ -0,0 +1,496 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy +*/ + +// This is an un-optimised example implementation +// classes BoardCell and PieceCell have Array + + +import scala.collection.mutable._ + +object meteor { + def main(args: Array[String]) = { + val solver = new Solver( Integer.parseInt(args(0)) ) + solver.findSolutions + solver.printSolutions + } +} + + + + +// Solver.scala +// import scala.collection.mutable._ + +final class Solver (n: Int) { + private var countdown = n + private var first: String = _ + private var last: String = _ + + private val board = new Board() + + val pieces = Array( + new Piece(0), new Piece(1), new Piece(2), new Piece(3), new Piece(4), + new Piece(5), new Piece(6), new Piece(7), new Piece(8), new Piece(9) ) + + val unplaced = new BitSet(pieces.length) + + { unplaced ++= (0 until pieces.length) } + + + def findSolutions(): Unit = { + if (countdown == 0) return + + if (unplaced.size > 0){ + val emptyCellIndex = board.firstEmptyCellIndex + + for (k <- Iterator.range(0,pieces.length)){ + if (unplaced.contains(k)){ + unplaced -= k + + for (i <- Iterator.range(0,Piece.orientations)){ + val piece = pieces(k).nextOrientation + + for (j <- Iterator.range(0,Piece.size)){ + if (board.add(j,emptyCellIndex,piece)) { + + if (!shouldPrune) findSolutions + + board.remove(piece) + } + } + } + unplaced += k + } + } + } + else { + puzzleSolved + } + } + + private def puzzleSolved() = { + val b = board.asString + if (first == null){ + first = b; last = b + } else { + if (b < first){ first = b } else { if (b > last){ last = b } } + } + countdown = countdown - 1 + } + + private def shouldPrune() = { + board.unmark + !board.cells.forall(c => c.contiguousEmptyCells % Piece.size == 0) + } + + + def printSolutions() = { + + def printBoard(s: String) = { + var indent = false + var i = 0 + while (i < s.length){ + if (indent) Console.print(' ') + for (j <- Iterator.range(0,Board.cols)){ + Console.print(s.charAt(i)); Console.print(' ') + i = i + 1 + } + Console.print('\n') + indent = !indent + } + Console.print('\n') + } + + Console.print(n + " solutions found\n\n") + printBoard(first) + printBoard(last) + } + +/* + def printPieces() = + for (i <- Iterator.range(0,Board.pieces)) pieces(i).print +*/ + +} + + + + +// Board.scala +// import scala.collection.mutable._ + +object Board { + val cols = 5 + val rows = 10 + val size = rows * cols +} + +final class Board { + val cells = boardCells() + + val cellsPieceWillFill = new Array[BoardCell](Piece.size) + var cellCount = 0 + + def unmark() = for (c <- cells) c.unmark + + def asString() = + new String( cells map( + c => if (c.piece == null) '-'.toByte + else (c.piece.number + 48).toByte )) + + def firstEmptyCellIndex() = cells.findIndexOf(c => c.isEmpty) + + + def add(pieceIndex: Int, boardIndex: Int, p: Piece) = { + cellCount = 0 + p.unmark + + find( p.cells(pieceIndex), cells(boardIndex)) + + val boardHasSpace = cellCount == Piece.size && + cellsPieceWillFill.forall(c => c.isEmpty) + + if (boardHasSpace) cellsPieceWillFill.foreach(c => c.piece = p) + + boardHasSpace + } + + def remove(piece: Piece) = for (c <- cells; if c.piece == piece) c.empty + + + private def find(p: PieceCell, b: BoardCell): Unit = { + if (p != null && !p.marked && b != null){ + cellsPieceWillFill(cellCount) = b + cellCount = cellCount + 1 + p.mark + for (i <- Iterator.range(0,Cell.sides)) find(p.next(i), b.next(i)) + } + } + + + private def boardCells() = { + val a = for (i <- Array.range(0,Board.size)) yield new BoardCell(i) + val m = (Board.size / Board.cols) - 1 + + for (i <- Iterator.range(0,a.length)){ + val row = i / Board.cols + val isFirst = i % Board.cols == 0 + val isLast = (i+1) % Board.cols == 0 + val c = a(i) + + if (row % 2 == 1) { + if (!isLast) c.next(Cell.NE) = a(i-(Board.cols-1)) + c.next(Cell.NW) = a(i-Board.cols) + if (row != m) { + if (!isLast) c.next(Cell.SE) = a(i+(Board.cols+1)) + c.next(Cell.SW) = a(i+Board.cols) + } + } else { + if (row != 0) { + if (!isFirst) c.next(Cell.NW) = a(i-(Board.cols+1)) + c.next(Cell.NE) = a(i-Board.cols) + } + if (row != m) { + if (!isFirst) c.next(Cell.SW) = a(i+(Board.cols-1)) + c.next(Cell.SE) = a(i+Board.cols) + } + } + if (!isFirst) c.next(Cell.W) = a(i-1) + if (!isLast) c.next(Cell.E) = a(i+1) + } + a + } + + +/* +// Printing all the board cells and their neighbours +// helps check that they are connected properly + + def printBoardCellsAndNeighbours() = { + Console.println("cell\tNW NE W E SW SE") + for (i <- Iterator.range(0,Board.size)){ + Console.print(i + "\t") + for (j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + Console.printf("{0,number,00} ")(c.number) + } + Console.println("") + } + Console.println("") + } +*/ + +} + + + + +// Piece.scala + +object Piece { + val size = 5 + val rotations = Cell.sides + val flips = 2 + val orientations = rotations * flips +} + +final class Piece(_number: Int) { + val number = _number + val cells = for (i <- Array.range(0,Piece.size)) yield new PieceCell() + + { + number match { + case 0 => make0 + case 1 => make1 + case 2 => make2 + case 3 => make3 + case 4 => make4 + case 5 => make5 + case 6 => make6 + case 7 => make7 + case 8 => make8 + case 9 => make9 + } + } + + def flip() = for (c <- cells) c.flip + def rotate() = for (c <- cells) c.rotate + def unmark() = for (c <- cells) c.unmark + + + private var orientation = 0 + + def nextOrientation() = { + if (orientation == Piece.orientations) orientation = 0 + if (orientation % Piece.rotations == 0) flip else rotate + orientation = orientation + 1 + this + } + + + private def make0() = { + cells(0).next(Cell.E) = cells(1) + cells(1).next(Cell.W) = cells(0) + cells(1).next(Cell.E) = cells(2) + cells(2).next(Cell.W) = cells(1) + cells(2).next(Cell.E) = cells(3) + cells(3).next(Cell.W) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make1() = { + cells(0).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(0) + cells(1).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(1) + cells(2).next(Cell.W) = cells(3) + cells(3).next(Cell.E) = cells(2) + cells(3).next(Cell.SW) = cells(4) + cells(4).next(Cell.NE) = cells(3) + } + + private def make2() = { + cells(0).next(Cell.W) = cells(1) + cells(1).next(Cell.E) = cells(0) + cells(1).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(1) + cells(2).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make3() = { + cells(0).next(Cell.SW) = cells(1) + cells(1).next(Cell.NE) = cells(0) + cells(1).next(Cell.W) = cells(2) + cells(2).next(Cell.E) = cells(1) + cells(1).next(Cell.SW) = cells(3) + cells(3).next(Cell.NE) = cells(1) + cells(2).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make4() = { + cells(0).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(0) + cells(1).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(1) + cells(1).next(Cell.E) = cells(3) + cells(3).next(Cell.W) = cells(1) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make5() = { + cells(0).next(Cell.SW) = cells(1) + cells(1).next(Cell.NE) = cells(0) + cells(0).next(Cell.SE) = cells(2) + cells(2).next(Cell.NW) = cells(0) + cells(1).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(1) + cells(2).next(Cell.SW) = cells(3) + cells(3).next(Cell.NE) = cells(2) + cells(3).next(Cell.SW) = cells(4) + cells(4).next(Cell.NE) = cells(3) + } + + private def make6() = { + cells(0).next(Cell.SW) = cells(1) + cells(1).next(Cell.NE) = cells(0) + cells(2).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(2) + cells(1).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(1) + cells(3).next(Cell.SW) = cells(4) + cells(4).next(Cell.NE) = cells(3) + } + + private def make7() = { + cells(0).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(0) + cells(0).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(0) + cells(2).next(Cell.SW) = cells(3) + cells(3).next(Cell.NE) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make8() = { + cells(0).next(Cell.E) = cells(1) + cells(1).next(Cell.W) = cells(0) + cells(1).next(Cell.E) = cells(2) + cells(2).next(Cell.W) = cells(1) + cells(2).next(Cell.NE) = cells(3) + cells(3).next(Cell.SW) = cells(2) + cells(3).next(Cell.E) = cells(4) + cells(4).next(Cell.W) = cells(3) + } + + private def make9() = { + cells(0).next(Cell.E) = cells(1) + cells(1).next(Cell.W) = cells(0) + cells(1).next(Cell.E) = cells(2) + cells(2).next(Cell.W) = cells(1) + cells(2).next(Cell.NE) = cells(3) + cells(3).next(Cell.SW) = cells(2) + cells(2).next(Cell.E) = cells(4) + cells(4).next(Cell.W) = cells(2) + cells(4).next(Cell.NW) = cells(3) + cells(3).next(Cell.SE) = cells(4) + } + +/* + def print() = { + Console.println("Piece # " + number) + Console.println("cell\tNW NE W E SW SE") + for (i <- Iterator.range(0,Piece.size)){ + Console.print(i + "\t") + for (j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + for (k <- Iterator.range(0,Piece.size)){ + if (cells(k) == c) Console.printf(" {0,number,0} ")(k) + } + } + Console.println("") + } + Console.println("") + } +*/ + +} + + + + +// Cell.scala + +object Cell { + val NW = 0; val NE = 1 + val W = 2; val E = 3 + val SW = 4; val SE = 5 + + val sides = 6 +} + +abstract class Cell { + var marked = false + + def mark() = marked = true + def unmark() = marked = false +} + + + + +// BoardCell.scala + +final class BoardCell(_number: Int) extends Cell { + val next = new Array[BoardCell](Cell.sides) + val number = _number + var piece: Piece = _ + + def isEmpty() = piece == null + def empty() = piece = null + + def contiguousEmptyCells(): Int = { + if (!marked && isEmpty){ + mark + var count = 1 + + for (neighbour <- next) + if (neighbour != null && neighbour.isEmpty) + count = count + neighbour.contiguousEmptyCells + + count } else { 0 } + } +} + + + + +// PieceCell.scala + +final class PieceCell extends Cell { + val next = new Array[PieceCell](Cell.sides) + + def flip = { + var swap = next(Cell.NE) + next(Cell.NE) = next(Cell.NW) + next(Cell.NW) = swap + + swap = next(Cell.E) + next(Cell.E) = next(Cell.W) + next(Cell.W) = swap + + swap = next(Cell.SE) + next(Cell.SE) = next(Cell.SW) + next(Cell.SW) = swap + } + + def rotate = { + var swap = next(Cell.E) + next(Cell.E) = next(Cell.NE) + next(Cell.NE) = next(Cell.NW) + next(Cell.NW) = next(Cell.W) + next(Cell.W) = next(Cell.SW) + next(Cell.SW) = next(Cell.SE) + next(Cell.SE) = swap + } +} + + + + diff --git a/test/pending/shootout/meteor.scala-2.scala.runner b/test/pending/shootout/meteor.scala-2.scala.runner new file mode 100644 index 0000000000..dae384311f --- /dev/null +++ b/test/pending/shootout/meteor.scala-2.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(0)) meteor.main(Array(n.toString)) +} diff --git a/test/pending/shootout/meteor.scala-3.scala b/test/pending/shootout/meteor.scala-3.scala new file mode 100644 index 0000000000..01dacf90c6 --- /dev/null +++ b/test/pending/shootout/meteor.scala-3.scala @@ -0,0 +1,557 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy +*/ + +// Most for-comprehension replaced by while loops + + + +import scala.collection.mutable._ + +object meteor { + def main(args: Array[String]) = { + val solver = new Solver( Integer.parseInt(args(0)) ) + solver.findSolutions + solver.printSolutions + } +} + + + + +// Solver.scala +// import scala.collection.mutable._ + +final class Solver (n: Int) { + private var countdown = n + private var first: String = _ + private var last: String = _ + + private val board = new Board() + + val pieces = Array( + new Piece(0), new Piece(1), new Piece(2), new Piece(3), new Piece(4), + new Piece(5), new Piece(6), new Piece(7), new Piece(8), new Piece(9) ) + + val unplaced = new BitSet(pieces.length) + + { unplaced ++= (0 until pieces.length) } + + + def findSolutions(): Unit = { + if (countdown == 0) return + + if (unplaced.size > 0){ + val emptyCellIndex = board.firstEmptyCellIndex + + var k = 0 + while (k < pieces.length){ + if (unplaced.contains(k)){ + unplaced -= k + + var i = 0 + while (i < Piece.orientations){ + val piece = pieces(k).nextOrientation + + var j = 0 + while (j < Piece.size){ + if (board.add(j,emptyCellIndex,piece)) { + + if (!shouldPrune) findSolutions + + board.remove(piece) + } + j = j + 1 + } + i = i + 1 + } + unplaced += k + } + k = k + 1 + } + } + else { + puzzleSolved + } + } + + private def puzzleSolved() = { + val b = board.asString + if (first == null){ + first = b; last = b + } else { + if (b < first){ first = b } else { if (b > last){ last = b } } + } + countdown = countdown - 1 + } + + private def shouldPrune(): Boolean = { + board.unmark + var i = 0 + while (i < board.cells.length){ + if (board.cells(i).contiguousEmptyCells % Piece.size != 0) return true + i = i + 1 + } + false + } + + + def printSolutions() = { + + def printBoard(s: String) = { + var indent = false + var i = 0 + while (i < s.length){ + if (indent) Console.print(' ') + var j = 0 + while (j < Board.cols){ + Console.print(s.charAt(i)); Console.print(' ') + j = j + 1 + i = i + 1 + } + Console.print('\n') + indent = !indent + } + Console.print('\n') + } + + Console.print(n + " solutions found\n\n") + printBoard(first) + printBoard(last) + } + +/* + def printPieces() = + for (i <- Iterator.range(0,Board.pieces)) pieces(i).print +*/ + +} + + + + + +// Board.scala +// import scala.collection.mutable._ + +object Board { + val cols = 5 + val rows = 10 + val size = rows * cols +} + +final class Board { + val cells = boardCells() + + val cellsPieceWillFill = new Array[BoardCell](Piece.size) + var cellCount = 0 + + def unmark() = { + var i = 0 + while (i < cells.length){ + cells(i).unmark + i = i + 1 + } + } + + def asString() = + new String( cells map( + c => if (c.piece == null) '-'.toByte + else (c.piece.number + 48).toByte )) + + def firstEmptyCellIndex() = cells.findIndexOf(c => c.isEmpty) + + + def add(pieceIndex: Int, boardIndex: Int, p: Piece): Boolean = { + cellCount = 0 + p.unmark + + find(p.cells(pieceIndex), cells(boardIndex)) + + if (cellCount != Piece.size) return false + + var i = 0 + while (i < cellCount){ + if (!cellsPieceWillFill(i).isEmpty) return false + i = i + 1 + } + + i = 0 + while (i < cellCount){ + cellsPieceWillFill(i).piece = p + i = i + 1 + } + + true + } + + def remove(piece: Piece) = { + var i = 0 + while (i < cells.length){ + if (cells(i).piece == piece) cells(i).empty + i = i + 1 + } + } + + private def find(p: PieceCell, b: BoardCell): Unit = { + if (p != null && !p.marked && b != null){ + cellsPieceWillFill(cellCount) = b + cellCount = cellCount + 1 + p.mark + + var i = 0 + while (i < Cell.sides){ + find(p.next(i), b.next(i)) + i = i + 1 + } + } + } + + + private def boardCells() = { + val a = for (i <- Array.range(0,Board.size)) yield new BoardCell(i) + val m = (Board.size / Board.cols) - 1 + + for (i <- Iterator.range(0,a.length)){ + val row = i / Board.cols + val isFirst = i % Board.cols == 0 + val isLast = (i+1) % Board.cols == 0 + val c = a(i) + + if (row % 2 == 1) { + if (!isLast) c.next(Cell.NE) = a(i-(Board.cols-1)) + c.next(Cell.NW) = a(i-Board.cols) + if (row != m) { + if (!isLast) c.next(Cell.SE) = a(i+(Board.cols+1)) + c.next(Cell.SW) = a(i+Board.cols) + } + } else { + if (row != 0) { + if (!isFirst) c.next(Cell.NW) = a(i-(Board.cols+1)) + c.next(Cell.NE) = a(i-Board.cols) + } + if (row != m) { + if (!isFirst) c.next(Cell.SW) = a(i+(Board.cols-1)) + c.next(Cell.SE) = a(i+Board.cols) + } + } + if (!isFirst) c.next(Cell.W) = a(i-1) + if (!isLast) c.next(Cell.E) = a(i+1) + } + a + } + +/* +// Printing all the board cells and their neighbours +// helps check that they are connected properly + + def printBoardCellsAndNeighbours() = { + Console.println("cell\tNW NE W E SW SE") + for (i <- Iterator.range(0,Board.size)){ + Console.print(i + "\t") + for (j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + Console.printf("{0,number,00} ")(c.number) + } + Console.println("") + } + Console.println("") + } +*/ + +} + + + + +// Piece.scala + +object Piece { + val size = 5 + val rotations = Cell.sides + val flips = 2 + val orientations = rotations * flips +} + +final class Piece(_number: Int) { + val number = _number + val cells = for (i <- Array.range(0,Piece.size)) yield new PieceCell() + + { + number match { + case 0 => make0 + case 1 => make1 + case 2 => make2 + case 3 => make3 + case 4 => make4 + case 5 => make5 + case 6 => make6 + case 7 => make7 + case 8 => make8 + case 9 => make9 + } + } + + def flip() = { + var i = 0 + while (i < cells.length){ + cells(i).flip + i = i + 1 + } + } + + def rotate() = { + var i = 0 + while (i < cells.length){ + cells(i).rotate + i = i + 1 + } + } + + def unmark() = { + var i = 0 + while (i < cells.length){ + cells(i).unmark + i = i + 1 + } + } + + + private var orientation = 0 + + def nextOrientation() = { + if (orientation == Piece.orientations) orientation = 0 + if (orientation % Piece.rotations == 0) flip else rotate + orientation = orientation + 1 + this + } + + + private def make0() = { + cells(0).next(Cell.E) = cells(1) + cells(1).next(Cell.W) = cells(0) + cells(1).next(Cell.E) = cells(2) + cells(2).next(Cell.W) = cells(1) + cells(2).next(Cell.E) = cells(3) + cells(3).next(Cell.W) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make1() = { + cells(0).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(0) + cells(1).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(1) + cells(2).next(Cell.W) = cells(3) + cells(3).next(Cell.E) = cells(2) + cells(3).next(Cell.SW) = cells(4) + cells(4).next(Cell.NE) = cells(3) + } + + private def make2() = { + cells(0).next(Cell.W) = cells(1) + cells(1).next(Cell.E) = cells(0) + cells(1).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(1) + cells(2).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make3() = { + cells(0).next(Cell.SW) = cells(1) + cells(1).next(Cell.NE) = cells(0) + cells(1).next(Cell.W) = cells(2) + cells(2).next(Cell.E) = cells(1) + cells(1).next(Cell.SW) = cells(3) + cells(3).next(Cell.NE) = cells(1) + cells(2).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make4() = { + cells(0).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(0) + cells(1).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(1) + cells(1).next(Cell.E) = cells(3) + cells(3).next(Cell.W) = cells(1) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make5() = { + cells(0).next(Cell.SW) = cells(1) + cells(1).next(Cell.NE) = cells(0) + cells(0).next(Cell.SE) = cells(2) + cells(2).next(Cell.NW) = cells(0) + cells(1).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(1) + cells(2).next(Cell.SW) = cells(3) + cells(3).next(Cell.NE) = cells(2) + cells(3).next(Cell.SW) = cells(4) + cells(4).next(Cell.NE) = cells(3) + } + + private def make6() = { + cells(0).next(Cell.SW) = cells(1) + cells(1).next(Cell.NE) = cells(0) + cells(2).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(2) + cells(1).next(Cell.SE) = cells(3) + cells(3).next(Cell.NW) = cells(1) + cells(3).next(Cell.SW) = cells(4) + cells(4).next(Cell.NE) = cells(3) + } + + private def make7() = { + cells(0).next(Cell.SE) = cells(1) + cells(1).next(Cell.NW) = cells(0) + cells(0).next(Cell.SW) = cells(2) + cells(2).next(Cell.NE) = cells(0) + cells(2).next(Cell.SW) = cells(3) + cells(3).next(Cell.NE) = cells(2) + cells(3).next(Cell.SE) = cells(4) + cells(4).next(Cell.NW) = cells(3) + } + + private def make8() = { + cells(0).next(Cell.E) = cells(1) + cells(1).next(Cell.W) = cells(0) + cells(1).next(Cell.E) = cells(2) + cells(2).next(Cell.W) = cells(1) + cells(2).next(Cell.NE) = cells(3) + cells(3).next(Cell.SW) = cells(2) + cells(3).next(Cell.E) = cells(4) + cells(4).next(Cell.W) = cells(3) + } + + private def make9() = { + cells(0).next(Cell.E) = cells(1) + cells(1).next(Cell.W) = cells(0) + cells(1).next(Cell.E) = cells(2) + cells(2).next(Cell.W) = cells(1) + cells(2).next(Cell.NE) = cells(3) + cells(3).next(Cell.SW) = cells(2) + cells(2).next(Cell.E) = cells(4) + cells(4).next(Cell.W) = cells(2) + cells(4).next(Cell.NW) = cells(3) + cells(3).next(Cell.SE) = cells(4) + } + +/* + def print() = { + Console.println("Piece # " + number) + Console.println("cell\tNW NE W E SW SE") + for (i <- Iterator.range(0,Piece.size)){ + Console.print(i + "\t") + for (j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + for (k <- Iterator.range(0,Piece.size)){ + if (cells(k) == c) Console.printf(" {0,number,0} ")(k) + } + } + Console.println("") + } + Console.println("") + } +*/ + +} + + + + +// Cell.scala + +object Cell { + val NW = 0; val NE = 1 + val W = 2; val E = 3 + val SW = 4; val SE = 5 + + val sides = 6 +} + +abstract class Cell { + var marked = false + + def mark() = marked = true + def unmark() = marked = false +} + + + + +// BoardCell.scala + +final class BoardCell(_number: Int) extends Cell { + val next = new Array[BoardCell](Cell.sides) + val number = _number + var piece: Piece = _ + + def isEmpty() = piece == null + def empty() = piece = null + + def contiguousEmptyCells(): Int = { + if (!marked && isEmpty){ + mark + var count = 1 + + var i = 0 + while (i < next.length){ + if (next(i) != null && next(i).isEmpty) + count = count + next(i).contiguousEmptyCells + i = i + 1 + } + + count } else { 0 } + } +} + + + + +// PieceCell.scala + +final class PieceCell extends Cell { + val next = new Array[PieceCell](Cell.sides) + + def flip = { + var swap = next(Cell.NE) + next(Cell.NE) = next(Cell.NW) + next(Cell.NW) = swap + + swap = next(Cell.E) + next(Cell.E) = next(Cell.W) + next(Cell.W) = swap + + swap = next(Cell.SE) + next(Cell.SE) = next(Cell.SW) + next(Cell.SW) = swap + } + + def rotate = { + var swap = next(Cell.E) + next(Cell.E) = next(Cell.NE) + next(Cell.NE) = next(Cell.NW) + next(Cell.NW) = next(Cell.W) + next(Cell.W) = next(Cell.SW) + next(Cell.SW) = next(Cell.SE) + next(Cell.SE) = swap + } +} + + + + diff --git a/test/pending/shootout/meteor.scala-3.scala.runner b/test/pending/shootout/meteor.scala-3.scala.runner new file mode 100644 index 0000000000..dae384311f --- /dev/null +++ b/test/pending/shootout/meteor.scala-3.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(0)) meteor.main(Array(n.toString)) +} diff --git a/test/pending/shootout/meteor.scala-4.scala b/test/pending/shootout/meteor.scala-4.scala new file mode 100644 index 0000000000..ee036f7fab --- /dev/null +++ b/test/pending/shootout/meteor.scala-4.scala @@ -0,0 +1,587 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy +*/ + +// Most for-comprehension replaced by while loops +// BoardCells occupied by each Piece orientation are cached +// Piece orientations are cached + +import scala.collection.mutable._ + +object meteor { + def main(args: Array[String]) = { + val solver = new Solver( Integer.parseInt(args(0)) ) + solver.findSolutions + solver.printSolutions + } +} + + + + +// Solver.scala +// import scala.collection.mutable._ + +final class Solver (n: Int) { + private var countdown = n + private var first: String = _ + private var last: String = _ + + private val board = new Board() + + val pieces = Array( + new Piece(0), new Piece(1), new Piece(2), new Piece(3), new Piece(4), + new Piece(5), new Piece(6), new Piece(7), new Piece(8), new Piece(9) ) + + val unplaced = new BitSet(pieces.length) + + { unplaced ++= (0 until pieces.length) } + + + def findSolutions(): Unit = { + if (countdown == 0) return + + if (unplaced.size > 0){ + val emptyCellIndex = board.firstEmptyCellIndex + + var k = 0 + while (k < pieces.length){ + if (unplaced.contains(k)){ + unplaced -= k + + var i = 0 + while (i < Piece.orientations){ + val piece = pieces(k).nextOrientation + + var j = 0 + while (j < Piece.size){ + if (board.add(j,emptyCellIndex,piece)) { + + if (!shouldPrune) findSolutions + + board.remove(piece) + } + j = j + 1 + } + i = i + 1 + } + unplaced += k + } + k = k + 1 + } + } + else { + puzzleSolved + } + } + + private def puzzleSolved() = { + val b = board.asString + if (first == null){ + first = b; last = b + } else { + if (b < first){ first = b } else { if (b > last){ last = b } } + } + countdown = countdown - 1 + } + + private def shouldPrune(): Boolean = { + board.unmark + var i = 0 + while (i < board.cells.length){ + if (board.cells(i).contiguousEmptyCells % Piece.size != 0) return true + i = i + 1 + } + false + } + + + def printSolutions() = { + + def printBoard(s: String) = { + var indent = false + var i = 0 + while (i < s.length){ + if (indent) Console.print(' ') + var j = 0 + while (j < Board.cols){ + Console.print(s.charAt(i)); Console.print(' ') + j = j + 1 + i = i + 1 + } + Console.print('\n') + indent = !indent + } + Console.print('\n') + } + + Console.print(n + " solutions found\n\n") + printBoard(first) + printBoard(last) + } + +/* + def printPieces() = + for (i <- Iterator.range(0,Board.pieces)) pieces(i).print +*/ + +} + + + +// Board.scala +// import scala.collection.mutable._ + +object Board { + val cols = 5 + val rows = 10 + val size = rows * cols + val pieces = 10 + val noFit = new Array[BoardCell](0) +} + +final class Board { + val cells = boardCells() + + val cellsPieceWillFill = new Array[BoardCell](Piece.size) + var cellCount = 0 + + def unmark() = { + var i = 0 + while (i < cells.length){ + cells(i).unmark + i = i + 1 + } + } + + def asString() = + new String( cells map( + c => if (c.piece == null) '-'.toByte + else (c.piece.number + 48).toByte )) + + def firstEmptyCellIndex() = cells.findIndexOf(c => c.isEmpty) + + + private val cache: Array[Array[Array[Array[ Array[BoardCell] ]]]] = + for (i <- Array.range(0,Board.pieces)) + yield + for (j <- Array.range(0,Piece.orientations)) + yield + for (k <- Array.range(0,Piece.size)) // piece cell index + yield + for (m <- Array.range(0,Board.size)) // board cell index + yield (null: BoardCell) + + + def add(pieceIndex: Int, boardIndex: Int, p: Piece): Boolean = { + var a = cache(p.number)(p.orientation)(pieceIndex)(boardIndex) + + cellCount = 0 + p.unmark + + if (a == null){ + find(p.cells(pieceIndex), cells(boardIndex)) + + if (cellCount != Piece.size){ + cache(p.number)(p.orientation)(pieceIndex)(boardIndex) = Board.noFit + return false + } + + a = cellsPieceWillFill .filter(c => true) + cache(p.number)(p.orientation)(pieceIndex)(boardIndex) = a + } + else { + if (a == Board.noFit) return false + } + + var i = 0 + while (i < a.length){ + if (!a(i).isEmpty) return false + i = i + 1 + } + + i = 0 + while (i < a.length){ + a(i).piece = p + i = i + 1 + } + + true + } + + + def remove(piece: Piece) = { + var i = 0 + while (i < cells.length){ + if (cells(i).piece == piece) cells(i).empty + i = i + 1 + } + } + + + private def find(p: PieceCell, b: BoardCell): Unit = { + if (p != null && !p.marked && b != null){ + cellsPieceWillFill(cellCount) = b + cellCount = cellCount + 1 + p.mark + + var i = 0 + while (i < Cell.sides){ + find(p.next(i), b.next(i)) + i = i + 1 + } + } + } + + + private def boardCells() = { + val a = for (i <- Array.range(0,Board.size)) yield new BoardCell(i) + val m = (Board.size / Board.cols) - 1 + + for (i <- Iterator.range(0,a.length)){ + val row = i / Board.cols + val isFirst = i % Board.cols == 0 + val isLast = (i+1) % Board.cols == 0 + val c = a(i) + + if (row % 2 == 1) { + if (!isLast) c.next(Cell.NE) = a(i-(Board.cols-1)) + c.next(Cell.NW) = a(i-Board.cols) + if (row != m) { + if (!isLast) c.next(Cell.SE) = a(i+(Board.cols+1)) + c.next(Cell.SW) = a(i+Board.cols) + } + } else { + if (row != 0) { + if (!isFirst) c.next(Cell.NW) = a(i-(Board.cols+1)) + c.next(Cell.NE) = a(i-Board.cols) + } + if (row != m) { + if (!isFirst) c.next(Cell.SW) = a(i+(Board.cols-1)) + c.next(Cell.SE) = a(i+Board.cols) + } + } + if (!isFirst) c.next(Cell.W) = a(i-1) + if (!isLast) c.next(Cell.E) = a(i+1) + } + a + } + + +/* +// Printing all the board cells and their neighbours +// helps check that they are connected properly + + def printBoardCellsAndNeighbours() = { + Console.println("cell\tNW NE W E SW SE") + for (i <- Iterator.range(0,Board.size)){ + Console.print(i + "\t") + for (j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + Console.printf("{0,number,00} ")(c.number) + } + Console.println("") + } + Console.println("") + } +*/ + +} + + + + +// Piece.scala + +object Piece { + val size = 5 + val rotations = Cell.sides + val flips = 2 + val orientations = rotations * flips +} + +final class Piece(_number: Int) { + val number = _number + + def unmark() = { + val c = cache(orientation) + var i = 0 + while (i < c.length){ + c(i).unmark + i = i + 1 + } + } + + def cells = cache(orientation) + + private val cache = + for (i <- Array.range(0,Piece.orientations)) + yield pieceOrientation(i) + + var orientation = 0 + + def nextOrientation() = { + orientation = (orientation + 1) % Piece.orientations + this + } + + + private def pieceOrientation(k: Int) = { + val cells = for (i <- Array.range(0,Piece.size)) yield new PieceCell() + makePiece(number,cells) + + var i = 0 + while (i < k){ + if (i % Piece.rotations == 0) + for (c <- cells) c.flip + else + for (c <- cells) c.rotate + + i = i + 1 + } + cells + } + + private def makePiece(number: Int, cells: Array[PieceCell]) = { + number match { + case 0 => make0(cells) + case 1 => make1(cells) + case 2 => make2(cells) + case 3 => make3(cells) + case 4 => make4(cells) + case 5 => make5(cells) + case 6 => make6(cells) + case 7 => make7(cells) + case 8 => make8(cells) + case 9 => make9(cells) + } + } + + private def make0(a: Array[PieceCell]) = { + a(0).next(Cell.E) = a(1) + a(1).next(Cell.W) = a(0) + a(1).next(Cell.E) = a(2) + a(2).next(Cell.W) = a(1) + a(2).next(Cell.E) = a(3) + a(3).next(Cell.W) = a(2) + a(3).next(Cell.SE) = a(4) + a(4).next(Cell.NW) = a(3) + } + + private def make1(a: Array[PieceCell]) = { + a(0).next(Cell.SE) = a(1) + a(1).next(Cell.NW) = a(0) + a(1).next(Cell.SW) = a(2) + a(2).next(Cell.NE) = a(1) + a(2).next(Cell.W) = a(3) + a(3).next(Cell.E) = a(2) + a(3).next(Cell.SW) = a(4) + a(4).next(Cell.NE) = a(3) + } + + private def make2(a: Array[PieceCell]) = { + a(0).next(Cell.W) = a(1) + a(1).next(Cell.E) = a(0) + a(1).next(Cell.SW) = a(2) + a(2).next(Cell.NE) = a(1) + a(2).next(Cell.SE) = a(3) + a(3).next(Cell.NW) = a(2) + a(3).next(Cell.SE) = a(4) + a(4).next(Cell.NW) = a(3) + } + + private def make3(a: Array[PieceCell]) = { + a(0).next(Cell.SW) = a(1) + a(1).next(Cell.NE) = a(0) + a(1).next(Cell.W) = a(2) + a(2).next(Cell.E) = a(1) + a(1).next(Cell.SW) = a(3) + a(3).next(Cell.NE) = a(1) + a(2).next(Cell.SE) = a(3) + a(3).next(Cell.NW) = a(2) + a(3).next(Cell.SE) = a(4) + a(4).next(Cell.NW) = a(3) + } + + private def make4(a: Array[PieceCell]) = { + a(0).next(Cell.SE) = a(1) + a(1).next(Cell.NW) = a(0) + a(1).next(Cell.SW) = a(2) + a(2).next(Cell.NE) = a(1) + a(1).next(Cell.E) = a(3) + a(3).next(Cell.W) = a(1) + a(3).next(Cell.SE) = a(4) + a(4).next(Cell.NW) = a(3) + } + + private def make5(a: Array[PieceCell]) = { + a(0).next(Cell.SW) = a(1) + a(1).next(Cell.NE) = a(0) + a(0).next(Cell.SE) = a(2) + a(2).next(Cell.NW) = a(0) + a(1).next(Cell.SE) = a(3) + a(3).next(Cell.NW) = a(1) + a(2).next(Cell.SW) = a(3) + a(3).next(Cell.NE) = a(2) + a(3).next(Cell.SW) = a(4) + a(4).next(Cell.NE) = a(3) + } + + private def make6(a: Array[PieceCell]) = { + a(0).next(Cell.SW) = a(1) + a(1).next(Cell.NE) = a(0) + a(2).next(Cell.SE) = a(1) + a(1).next(Cell.NW) = a(2) + a(1).next(Cell.SE) = a(3) + a(3).next(Cell.NW) = a(1) + a(3).next(Cell.SW) = a(4) + a(4).next(Cell.NE) = a(3) + } + + private def make7(a: Array[PieceCell]) = { + a(0).next(Cell.SE) = a(1) + a(1).next(Cell.NW) = a(0) + a(0).next(Cell.SW) = a(2) + a(2).next(Cell.NE) = a(0) + a(2).next(Cell.SW) = a(3) + a(3).next(Cell.NE) = a(2) + a(3).next(Cell.SE) = a(4) + a(4).next(Cell.NW) = a(3) + } + + private def make8(a: Array[PieceCell]) = { + a(0).next(Cell.E) = a(1) + a(1).next(Cell.W) = a(0) + a(1).next(Cell.E) = a(2) + a(2).next(Cell.W) = a(1) + a(2).next(Cell.NE) = a(3) + a(3).next(Cell.SW) = a(2) + a(3).next(Cell.E) = a(4) + a(4).next(Cell.W) = a(3) + } + + private def make9(a: Array[PieceCell]) = { + a(0).next(Cell.E) = a(1) + a(1).next(Cell.W) = a(0) + a(1).next(Cell.E) = a(2) + a(2).next(Cell.W) = a(1) + a(2).next(Cell.NE) = a(3) + a(3).next(Cell.SW) = a(2) + a(2).next(Cell.E) = a(4) + a(4).next(Cell.W) = a(2) + a(4).next(Cell.NW) = a(3) + a(3).next(Cell.SE) = a(4) + } + +/* + def print() = { + Console.println("Piece # " + number) + Console.println("cell\tNW NE W E SW SE") + for (i <- Iterator.range(0,Piece.size)){ + Console.print(i + "\t") + for (j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + for (k <- Iterator.range(0,Piece.size)){ + if (cells(k) == c) Console.printf(" {0,number,0} ")(k) + } + } + Console.println("") + } + Console.println("") + } +*/ +} + + + + + +// Cell.scala + +object Cell { + val NW = 0; val NE = 1 + val W = 2; val E = 3 + val SW = 4; val SE = 5 + + val sides = 6 +} + +abstract class Cell { + var marked = false + + def mark() = marked = true + def unmark() = marked = false +} + + + + +// BoardCell.scala + +final class BoardCell(_number: Int) extends Cell { + val next = new Array[BoardCell](Cell.sides) + val number = _number + var piece: Piece = _ + + def isEmpty() = piece == null + def empty() = piece = null + + def contiguousEmptyCells(): Int = { + if (!marked && isEmpty){ + mark + var count = 1 + + var i = 0 + while (i < next.length){ + if (next(i) != null && next(i).isEmpty) + count = count + next(i).contiguousEmptyCells + i = i + 1 + } + + count } else { 0 } + } +} + + + + +// PieceCell.scala + +final class PieceCell extends Cell { + val next = new Array[PieceCell](Cell.sides) + + def flip = { + var swap = next(Cell.NE) + next(Cell.NE) = next(Cell.NW) + next(Cell.NW) = swap + + swap = next(Cell.E) + next(Cell.E) = next(Cell.W) + next(Cell.W) = swap + + swap = next(Cell.SE) + next(Cell.SE) = next(Cell.SW) + next(Cell.SW) = swap + } + + def rotate = { + var swap = next(Cell.E) + next(Cell.E) = next(Cell.NE) + next(Cell.NE) = next(Cell.NW) + next(Cell.NW) = next(Cell.W) + next(Cell.W) = next(Cell.SW) + next(Cell.SW) = next(Cell.SE) + next(Cell.SE) = swap + } +} + + + + diff --git a/test/pending/shootout/meteor.scala-4.scala.runner b/test/pending/shootout/meteor.scala-4.scala.runner new file mode 100644 index 0000000000..dae384311f --- /dev/null +++ b/test/pending/shootout/meteor.scala-4.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(0)) meteor.main(Array(n.toString)) +} diff --git a/test/pending/shootout/meteor.scala.runner b/test/pending/shootout/meteor.scala.runner new file mode 100644 index 0000000000..dae384311f --- /dev/null +++ b/test/pending/shootout/meteor.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(0)) meteor.main(Array(n.toString)) +} diff --git a/test/pending/shootout/methcall.scala b/test/pending/shootout/methcall.scala new file mode 100644 index 0000000000..9f7234c72d --- /dev/null +++ b/test/pending/shootout/methcall.scala @@ -0,0 +1,58 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy (Scala novice) +*/ + +object methcall { + def main(args: Array[String]) = { + var n = toPositiveInt(args); + var v: Boolean = false + + val toggle = new Toggle(true); + for (i <- Iterator.range(1,n)) v = toggle.activate.value; + + Console println( toggle.activate.value ); + + val ntoggle = new NToggle(true,3); + for (i <- Iterator.range(1,n)) v = ntoggle.activate.value; + + Console println( ntoggle.activate.value ); + } + + + private def toPositiveInt(s: Array[String]) = { + val i = + try { Integer.parseInt(s(0)); } + catch { case _ => 1 } + if (i>0) i; else 1; + } +} + + +private class Toggle(b: Boolean) { + var state = b; + + def value = state; + + def activate = { + state = !state; + this + } +} + + +private class NToggle(b: Boolean, trigger: Int) +extends Toggle(b) { + + val toggleTrigger = trigger; + var count = 0; + + override def activate = { + count = count + 1; + if (count >= toggleTrigger) { + state = !state; + count = 0; + } + this + } +} diff --git a/test/pending/shootout/methcall.scala.runner b/test/pending/shootout/methcall.scala.runner new file mode 100644 index 0000000000..555413cc6c --- /dev/null +++ b/test/pending/shootout/methcall.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(100000,400000,700000,1000000)) methcall.main(Array(n.toString)) +} diff --git a/test/pending/shootout/nsieve.scala-4.check b/test/pending/shootout/nsieve.scala-4.check new file mode 100644 index 0000000000..5ae0440a5a --- /dev/null +++ b/test/pending/shootout/nsieve.scala-4.check @@ -0,0 +1,9 @@ +Primes up to 1280000 98610 +Primes up to 640000 52074 +Primes up to 320000 27608 +Primes up to 2560000 187134 +Primes up to 1280000 98610 +Primes up to 640000 52074 +Primes up to 5120000 356244 +Primes up to 2560000 187134 +Primes up to 1280000 98610 diff --git a/test/pending/shootout/nsieve.scala-4.scala b/test/pending/shootout/nsieve.scala-4.scala new file mode 100644 index 0000000000..741eb80398 --- /dev/null +++ b/test/pending/shootout/nsieve.scala-4.scala @@ -0,0 +1,45 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy +*/ + + +object nsieve { + + def nsieve(m: Int, isPrime: Array[Boolean]) = { + for (i <- List.range(2, m)) isPrime(i) = true + var count = 0 + + for (i <- List.range(2, m)){ + if (isPrime(i)){ + var k = i+i + while (k < m){ isPrime(k) = false; k = k+i } + count = count + 1 + } + } + count + } + + + def main(args: Array[String]) = { + val n = Integer.parseInt(args(0)) + val m = (1<<n)*10000 + val flags = new Array[Boolean](m+1) + + def printPrimes(m: Int) = { + + def pad(i: Int, width: Int) = { + val s = i.toString + List.range(0, width - s.length) + .map((i) => " ") .foldLeft("")((a,b) => a+b) + s + } + + Console.println("Primes up to " + pad(m,8) + pad(nsieve(m,flags),9)) + } + + + printPrimes(m) + printPrimes( (1<<n-1)*10000 ) + printPrimes( (1<<n-2)*10000 ) + } +} diff --git a/test/pending/shootout/nsieve.scala-4.scala.runner b/test/pending/shootout/nsieve.scala-4.scala.runner new file mode 100644 index 0000000000..67be6d5844 --- /dev/null +++ b/test/pending/shootout/nsieve.scala-4.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(7,8,9)) nsieve.main(Array(n.toString)) +} diff --git a/test/pending/shootout/pidigits.check b/test/pending/shootout/pidigits.check new file mode 100644 index 0000000000..ad4dc9962b --- /dev/null +++ b/test/pending/shootout/pidigits.check @@ -0,0 +1,100 @@ +3141592653 :10 +5897932384 :20 +6264338327 :30 +9502884197 :40 +1693993751 :50 +0582097494 :60 +4592307816 :70 +4062862089 :80 +9862803482 :90 +5342117067 :100 +9821480865 :110 +1328230664 :120 +7093844609 :130 +5505822317 :140 +2535940812 :150 +8481117450 :160 +2841027019 :170 +3852110555 :180 +9644622948 :190 +9549303819 :200 +6442881097 :210 +5665933446 :220 +1284756482 :230 +3378678316 :240 +5271201909 :250 +1456485669 :260 +2346034861 :270 +0454326648 :280 +2133936072 :290 +6024914127 :300 +3724587006 :310 +6063155881 :320 +7488152092 :330 +0962829254 :340 +0917153643 :350 +6789259036 :360 +0011330530 :370 +5488204665 :380 +2138414695 :390 +1941511609 :400 +4330572703 :410 +6575959195 :420 +3092186117 :430 +3819326117 :440 +9310511854 :450 +8074462379 :460 +9627495673 :470 +5188575272 :480 +4891227938 :490 +1830119491 :500 +2983367336 :510 +2440656643 :520 +0860213949 :530 +4639522473 :540 +7190702179 :550 +8609437027 :560 +7053921717 :570 +6293176752 :580 +3846748184 :590 +6766940513 :600 +2000568127 :610 +1452635608 :620 +2778577134 :630 +2757789609 :640 +1736371787 :650 +2146844090 :660 +1224953430 :670 +1465495853 :680 +7105079227 :690 +9689258923 :700 +5420199561 :710 +1212902196 :720 +0864034418 :730 +1598136297 :740 +7477130996 :750 +0518707211 :760 +3499999983 :770 +7297804995 :780 +1059731732 :790 +8160963185 :800 +9502445945 :810 +5346908302 :820 +6425223082 :830 +5334468503 :840 +5261931188 :850 +1710100031 :860 +3783875288 :870 +6587533208 :880 +3814206171 :890 +7766914730 :900 +3598253490 :910 +4287554687 :920 +3115956286 :930 +3882353787 :940 +5937519577 :950 +8185778053 :960 +2171226806 :970 +6130019278 :980 +7661119590 :990 +9216420198 :1000 diff --git a/test/pending/shootout/pidigits.scala b/test/pending/shootout/pidigits.scala new file mode 100644 index 0000000000..b0becafda8 --- /dev/null +++ b/test/pending/shootout/pidigits.scala @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------------ */ +/* The Computer Language Shootout */ +/* http://shootout.alioth.debian.org/ */ +/* */ +/* Contributed by Anthony Borla */ +/* ------------------------------------------------------------------ */ + +object pidigits +{ + def main(args: Array[String]): Unit = + { + val N: Int = Integer.parseInt(args(0)); var i: Int = 10 + + while (i <= N) + { + System.out.println(pi_digits(10) + "\t:" + i) + i = i + 10 + } + + i = i - 10 + + if (i < N) + { + System.out.println(pi_digits(N - i) + "\t:" + N) + } + } + + def compose(a: Array[BigInt], b: Array[BigInt]): Array[BigInt] = + { + return Array(a(0) * b(0), + a(0) * b(1) + a(1) * b(3), + a(2) * b(0) + a(3) * b(2), + a(2) * b(1) + a(3) * b(3)) + } + + def extract(a: Array[BigInt], j: Int): BigInt = + { + return (a(0) * j + a(1)) / (a(2) * j + a(3)) + } + + def pi_digits(c: Int): String = + { + val r: StringBuffer = new StringBuffer(); var i: Int = 0 + + while (i < c) + { + var y: BigInt = extract(Z, 3) + + while (y != extract(Z, 4)) + { + K = K + 1; Z = compose(Z, Array(K, 4 * K + 2, 0, 2 * K + 1)) + y = extract(Z, 3) + } + +// Z = compose(Array(10, (-y) * 10, 0, 1), Z) + + Z = compose(Array(10, y * (-10), 0, 1), Z) + + r.append(y); i = i + 1; + } + + return r.toString() + } + + var K: Int = 0 + + var Z: Array[BigInt] = Array(1, 0, 0, 1) +} + diff --git a/test/pending/shootout/pidigits.scala.runner b/test/pending/shootout/pidigits.scala.runner new file mode 100644 index 0000000000..4bf5a8bde9 --- /dev/null +++ b/test/pending/shootout/pidigits.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(600,800,1000)) pidigits.main(Array(n.toString)) +} diff --git a/test/pending/shootout/prodcons.scala b/test/pending/shootout/prodcons.scala new file mode 100644 index 0000000000..d48d3e94d8 --- /dev/null +++ b/test/pending/shootout/prodcons.scala @@ -0,0 +1,64 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy (Scala novice) +*/ + +import concurrent.SyncVar; +import concurrent.ops._; + +object prodcons { + def main(args: Array[String]) = { + val n = toPositiveInt(args); + val buffer = new SharedBuffer(); + var p = 0; + var c = 0; + val cDone = new SyncVar[Boolean]; + + spawn { + while(p<n) { p=p+1; buffer put(p); } + } + + spawn { + var v: Int = _; + while(c<n) { c=c+1; v = buffer.get; } + cDone set true; + } + + cDone.get; + Console println(p + " " + c); + } + + + private def toPositiveInt(s: Array[String]) = { + val i = + try { Integer.parseInt(s(0)); } + catch { case _ => 1 } + if (i>0) i; else 1; + } +} + + +private class SharedBuffer() { + var contents: Int = _; + var available = false; + + def get = synchronized { + while (available == false) wait(); + available = false; + // Console println("\t" + "get " + contents); + notifyAll(); + contents + } + + def put(value: Int) = synchronized { + while (available == true) wait(); + contents = value; + available = true; + // Console println("put " + value); + notifyAll(); + } +} + + + + diff --git a/test/pending/shootout/prodcons.scala.runner b/test/pending/shootout/prodcons.scala.runner new file mode 100644 index 0000000000..75faf8ca6e --- /dev/null +++ b/test/pending/shootout/prodcons.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(30000,70000,100000,150000)) prodcons.main(Array(n.toString)) +} diff --git a/test/pending/shootout/random.scala b/test/pending/shootout/random.scala new file mode 100644 index 0000000000..0a86a35637 --- /dev/null +++ b/test/pending/shootout/random.scala @@ -0,0 +1,32 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy (Scala novice) +*/ + +object random { + def main(args: Array[String]) = { + var n = toPositiveInt(args); + var result: Double = 0 + + while (n>0) { result=generate(100.0); n=n-1; } + + Console.printf("{0,number,#.000000000}\n", result) + } + + private val IM = 139968; + private val IA = 3877; + private val IC = 29573; + private var seed = 42; + + def generate(max: Double) = { + seed = (seed * IA + IC) % IM; + max * seed / IM; + } + + private def toPositiveInt(s: Array[String]) = { + val i = + try { Integer.parseInt(s(0)); } + catch { case _ => 1 } + if (i>0) i; else 1; + } +} diff --git a/test/pending/shootout/random.scala.runner b/test/pending/shootout/random.scala.runner new file mode 100644 index 0000000000..11cbeef0f6 --- /dev/null +++ b/test/pending/shootout/random.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(9000,300000,600000,900000)) random.main(Array(n.toString)) +} diff --git a/test/pending/shootout/revcomp.scala-2.check b/test/pending/shootout/revcomp.scala-2.check new file mode 100644 index 0000000000..14d792ade8 --- /dev/null +++ b/test/pending/shootout/revcomp.scala-2.check @@ -0,0 +1,171 @@ +>ONE Homo sapiens alu +CGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAAC +CTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACA +GGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCAT +GTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAA +AGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTC +TGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGG +GTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACC +ACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTG +GTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTA +CAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCT +GGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTC +TCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCCCGGCTAAT +TTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTCGAACTCCT +GACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCA +CCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGC +GCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCC +TCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTA +GTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGAT +CCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCT +TTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTC +ACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTG +GGATTACAGGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGT +TTCACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGG +CCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAG +TCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCG +CCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGC +GCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGG +CCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGC +TGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCG +CCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCA +AGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCC +CGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTC +GAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGC +GTGAGCCACCGCGCCCGGCC +>TWO IUB ambiguity codes +TAGGDHACHATCRGTRGVTGAGWTATGYTGCTGTCABACDWVTRTAAGAVVAGATTTNDA +GASMTCTGCATBYTTCAAKTTACMTATTACTTCATARGGYACMRTGTTTTYTATACVAAT +TTCTAKGDACKADACTATATNTANTCGTTCACGBCGYSCBHTANGGTGATCGTAAAGTAA +CTATBAAAAGATSTGWATBCSGAKHTTABBAACGTSYCATGCAAVATKTSKTASCGGAAT +WVATTTNTCCTTCTTCTTDDAGTGGTTGGATACVGTTAYMTMTBTACTTTHAGCTAGBAA +AAGAGKAAGTTRATWATCAGATTMDDTTTAAAVAAATATTKTCYTAAATTVCNKTTRACG +ADTATATTTATGATSADSCAATAWAGCGRTAGTGTAAGTGACVGRADYGTGCTACHVSDT +CTVCARCSYTTAATATARAAAATTTAATTTACDAATTGBACAGTAYAABATBTGCAGBVG +TGATGGDCAAAATBNMSTTABKATTGGSTCCTAGBTTACTTGTTTAGTTTATHCGATSTA +AAGTCGAKAAASTGTTTTAWAKCAGATATACTTTTMTTTTGBATAGAGGAGCMATGATRA +AAGGNCAYDCCDDGAAAGTHGBTAATCKYTBTACBGTBCTTTTTGDTAASSWTAAWAARA +TTGGCTAAGWGRADTYACATAGCTCBTAGATAWAGCAATNGTATMATGTTKMMAGTAWTC +CCNTSGAAWATWCAAAAMACTGAADNTYGATNAATCCGAYWNCTAACGTTAGAGDTTTTC +ATCTGGKRTAVGAABVCTGWGBTCTDVGKATTBTCTAAGGVADAAAVWTCTAGGGGAGGG +TTAGAACAATTAAHTAATNAAATGCATKATCTAAYRTDTCAGSAYTTYHGATRTTWAVTA +BGNTCDACAGBCCRCAGWCRTCABTGMMAWGMCTCAACCGATRTGBCAVAATCGTDWDAA +CAYAWAATWCTGGTAHCCCTAAGATAACSCTTAGTGSAACAWTBGTCDTTDGACWDBAAC +HTTTNGSKTYYAAYGGATNTGATTTAARTTAMBAATCTAAGTBTCATYTAACTTADTGTT +TCGATACGAAHGGCYATATACCWDTKYATDCSHTDTCAAAATGTGBACTGSCCVGATGTA +TCMMAGCCTTDAAABAATGAAGAGTAACTHATMGVTTAATAACCCGGTTVSANTGCAATT +GTGAGATTTAMGTTTAMAAYGCTGACAYAAAAAGGCACAMYTAAGVGGCTGGAABVTACG +GATTSTYGTBVAKTATWACCGTGTKAGTDTGTATGTTTAAAGGAAAAAGTAACATARAAA +GGTYCAMNYAAABTATAGNTSATANAGTCATCCTATWADKAACTRGTMSACDGTATSAYT +AAHSHGTAABYGACTYTATADTGSTATAGAGAAATCGNTAAAGGAAATCAGTTGTNCYMV +TNACDRTATBNATATASTAGAAMSCGGGANRCKKMCAAACATTNAGTCTRMAATBMTACC +CGTACTTCTBGDSYAATWGAAAATGACADDCHAKAAAYATATTKTTTTCACANACWAGAA +AKATCCTTATTAYKHKCTAAACARTATTTTDATBTVWCYGCAATACTAGGKAAASTTDGA +MGGCHTTHAATVCAHDRYAGGRCTATACGTCMAGAGAGCTBTHGNACARTCCBDCTAAGA +GCGGCTTTARTAAAGAATCCNAGTAWBTGACTTGAATTACWTVACAGAAABCAATNAAAC +CGTNTRANTTGAYCMAWBADTANABRGGTKTHTWTAGTTVCTMBKTAGMTVKCCAGCANT +TVAGSWTTAGCCGCRHTTTCCTTHNTATTAAGAAGAATAGGMTRAARTCTABGTACDTTT +TATAAVDHAHTATAGATCCTAGTAAGYTWATDWCATGAGGGATAGTAAMDMNGBASTWAM +TSTATRBAYDABATGTATATYCGCACTGTTTTAACMCWBTATAWAGTATBTSTATVTTAR +CCTMTTAAKADATCAACTAATYTSVTAKGDATTATGCKTCAYCAKAATACTTKAANGAGT +ATTSDAGATCGGAAATACTTAAYAAVGTATMCGCTTGTGTDCTAATYTATTTTATTTWAA +CAGWRCTATGTAGMTGTTTGTTYKTNGTTKTCAGAACNTRACCTACKTGSRATGTGGGGG +CTGTCATTAAGTAAATNGSTTABCCCCTCGCAGCTCWHTCGCGAAGCAVATGCKACGHCA +ACAKTTAATAACASAAADATTWNYTGTAATTGTTCGTMHACHTWATGTGCWTTTTGAAHY +ACTTTGTAYAMSAAACTTAADAAATATAGTABMATATYAATGSGGTAGTTTGTGTBYGGT +TWSGSVGWMATTDMTCCWWCABTCSVACAGBAATGTTKATBGTCAATAATCTTCTTAAAC +ARVAATHAGYBWCTRWCABGTWWAATCTAAGTCASTAAAKTAAGVKBAATTBGABACGTA +AGGTTAAATAAAAACTRMDTWBCTTTTTAATAAAAGATMGCCTACKAKNTBAGYRASTGT +ASSTCGTHCGAAKTTATTATATTYTTTGTAGAACATGTCAAAACTWTWTHGKTCCYAATA +AAGTGGAYTMCYTAARCSTAAATWAKTGAATTTRAGTCTSSATACGACWAKAASATDAAA +TGYYACTSAACAAHAKTSHYARGASTATTATTHAGGYGGASTTTBGAKGATSANAACACD +TRGSTTRAAAAAAAACAAGARTCVTAGTAAGATAWATGVHAAKATWGAAAAGTYAHVTAC +TCTGRTGTCAWGATRVAAKTCGCAAVCGASWGGTTRTCSAMCCTAACASGWKKAWDAATG +ACRCBACTATGTGTCTTCAAAHGSCTATATTTCGTVWAGAAGTAYCKGARAKSGKAGTAN +TTTCYACATWATGTCTAAAADMDTWCAATSTKDACAMAADADBSAAATAGGCTHAHAGTA +CGACVGAATTATAAAGAHCCVAYHGHTTTACATSTTTATGNCCMTAGCATATGATAVAAG +>THREE Homo sapiens frequency +ATATTTATCTTTTCACTTCCTACATTGGTCAGACCATTATTCGACACGTGGCGTCATTTT +GTCATACCGGGTAATGTTGGAAACAAAACGTACTGATAAAATACTGAGTTGTAAACTCTA +ATCAGATAACGCGCTTGGATATTAAGATTCACACAGGGGTTTCGGCTGTAAAAAAACTTG +TGGAGCTGTTCTGGGACAGATAAGTTGTACCTCGTACTTAGCTAATTAATGAACCAACTG +ATTACGATAGAACAATTCTGAGGCCGCCAGGACAGCCAAATTTTAATCTTATAAAGCTGG +AAACAGCCGGTATTAGCTTCTCGCATACTTTGCCTGCATTGGTACCTTACAGATATCAGC +GTAGTCATATACACCTCGGTCTCAGCTAAGCTTGTATCTCTTAGAGTAGTTCAAAGATAG +TGGACAATACCTGTGGAATCGATTGCAGATATGGATTTATTTAACTACTGAGTCTCATTC +ACAAGCTAAGCAAGGAGCACGTTTTGGTGCCGGCATACCGATTTGCTATCATGTCAGCAA +ATTTGCGTTGTATTCCTAGTTGCACCCATTAAGGCCACACTCCGAACCTAATTATTACAT +CGCAAAGACATGTACGAAGGACCCGATGTCGAATAGAAGGGAGGACTGTTCATTGGAAGC +TAGACCAGAGGAATCGCAAAGATGCAACTCTTACAATAAAAATCTAATTTCAGTCAACAC +GCAATTTCTATAAGGTTTCCGATAATAATGAACCGTCTTCCACAGGGGAATTTGCCATGC +TCGTAAAAGTAGTTAATCCAAGTAGAAGAAATTTTGATAATGTTTTAAGTTGGCACGAAG +GAATTCAGAGAGATCTTACCTAACAAAGGCATTAGTAGATGTTCCTTGGTTCACACTCGG +TCAATCAGAGCACATACTACGGGCGATACCGGGAATGACACAACATCAATGAGATTGTTA +AGTGAGGTAATTGACTTTAGAGGACTCGATCAGTATACTGTCACTATGAACATCGTATTA +ATTGTTATCCGATATATACACCACCGATTTGCTTGTGCAAGGTTACAGACCCATTCGATA +AATACAAACACGGAGCGATATTATTTAAGGAGTGCTGTCTTCAAAAGAATTATTCCCACA +CCGACATAAGAACTTCGCTCCGTCATTCCAGATTTAAATAACATAACGTAACGCTTTGCT +GATAACATAACATAACCGAGAATTTGCTTAGGAAATTTGGAGCAATATTGCATTGTTTCT +CAGTCATCACAAGGCCCGCCAAAGAACTCTGAGAATCAGGATTCAACATGATTGGTAAGA +CTCTATATATATAACTTAATTCTTGTGTCCGGAGATAGAAAGAGGACGAGAGATACTACG +AAAGAAAGTGTACTTCGATGTATCAATTCAGACGCCTTCTCTATCATCAACATTATAGGT +CTCGTATATGCTCGGCGCGATCTGCTTCTCTCCGCCAATAGCCCCATAGTGTATTTCAAG +CGCAGTAACAGTGAAATCGTTACGAAGGTAGGGATGTTGCTTATAATTGTCGTAACTTAT +CGCTTATGTATCTTTCAAGAATGAACGGCAGCATATACATACGTTCTACCTTTAGCTACA +AAGCATCCATATACTCCCTCTCATGATTGAAACTCTTCCCTATTTTGTAGCCAATAGTGA +AAGCGTATTAGTATAAATTCGTCGGTTTTTCACTCGCAACTGTTATACTCTGCAAACAAA +CGAAAGCCTCATAGTACAAACCTAAAGCTACATACTTCATCATTGGCAGACCAGTGGCGG +TATTTCTACGGAAGCATCACTATAGATATAAAGTTTCCCTTCATGTACGTCTGTTAACCA +TATCACAAGAAACTGCTATCTCTGTCACGTAACAATTCACGCGCCTTATCGCCAAATGTT +CATATATGCGCGGTATACGTATGAACGAATACTAATTAGTATAACGGAGGATTCACGGGA +GGGATACTTGGGGCATTTATAAATCGTCTAAAAATTTTCTATCAGCACTTGCGGGTTATA +GTGGATTACTAGGCAACATAATATTCTGTATTGGTCCAAATGACGCTATAGATAAATTAG +CAAAATACATTGTTTCCATTTATGTAAGTCGAAACTCCAGGACTCCCGGGAACCAGTTAA +ACCGTCTGGAAAAGACACATTGTGAGCGGGACTTCAATGATAGCTTTCAATGAGCTTCTC +ATGCTTGGGGTCTGTACATATATGTTGGCGAAATTATCGTCTGTATTCTGTTATGCTTTG +ATCATGGGTTATTAGTATAGTGTCCGGTTAAGTACCAATACCGCTAGAGACCCGACCTAA +GTCGATAACTAACGATCATCGACGTAAGGATCGTCTCGATCAGTACTTCAGTCTAGATCT +GGGAATAGTAACTCGTTAGTGAACTATGTCGTGTCATAACTCTAAAATGCAATCAAATCT +TATTATTGAGTATTGATTATATAAAGCATCCGCTTAGCTTTACCCTCAAATGTTATATGC +AATTTAAAGCGCTTGATATCGTCTACTCAAGTTCAGGTTTCACATGGCCGCAACGTGACG +TTATTAGAGGTGGGTCATCATCTCTGAGGCTAGTGATGTTGAATACTCATTGAATGGGAA +GTGGAATACCATGCTCGTAGGTAACAGCATGACCTATAAAATATACTATGGGTGTGTGGT +AGATCAATATTGTTCAAGCATATCGTAACAATAACGGCTGAAATGTTACTGACATGAAAG +AGGGAGTCCAAACCATTCTAACAGCTGATCAAGTCGTCTAAAAACGCCTGGTTCAGCCTT +AAGAGTTATAAGCCAGACAAATTGTATCAATAGAGAATCCGTAAATTCCTCGGCCAACCT +CTTGCAAAGACATCACTATCAATATACTACCGTGATCTTAATTAGTGAACTTATATAAAT +ATCTACAACCAGATTCAACGGAAAAGCTTTAGTGGATTAGAAATTGCCAAGAATCACATT +CATGTGGGTTCGAATGCTTTAGTAATACCATTTCGCCGAGTAGTCACTTCGCTGAACTGT +CGTAAATTGCTATGACATAATCGAAAAGGATTGTCAAGAGTCGATTACTGCGGACTAATA +ATCCCCACGGGGGTGGTCTCATGTCTCCCCAGGCGAGTGGGGACGGTTGATAAACACGCT +GCATCGCGGACTGATGTTCCCAGTATTACATAGTCACATTGGATTGCGAGTAGTCTACCT +ATTTATGAGCGAGAGATGCCTCTAACTACTTCGACTTTTAAAACCTTTCCACGCCAGTAT +TCGGCGAAAGGGAAGTATTAAGGGTTGTCATAATTAAGCTGATACCACTTCAGACTTTGC +TCTACTTCTGTCTTTCATTGGTTTAGTAAAGTCTGTCCATTCGTCGAGACCGTCTTTTGC +AGCCTCATTCTACCAACTGCTCCGACTCTTAGTCTGCTTCTCCCAGCGTTATAACAAGAG +GCATTTTGTCATCCTTAAAACAATAATAAAGAACTCGGAGCACTGATATAATGACTGAAT +TAGAACCGCTTAAAAATACAACGAATAGATAAGACTATCGGATAAGATCTAATATGTAGT +GATTAAGCCCTTTATTAATTAATAATAGTTACCCTTTCTGATGTAACGCGACATATTACG +ATTTAGTGGCACGTCTGAATTGCAAAGCAGATCTCTACCCGATTTTTATTATAAATCCCG +TATACATCTTGACTTGAGTAATTGTTCATCTTTTTATATCTCTTCGTACTACAAATAATT +AATATCTCAACCCGTATTGTGTGATTCTAATTACCAACAGAATACGAGGAGGTTTTTGCT +TAGGGCCATATATAATGAATCTATCTCGTTTATTCGCGGAACCCGAGATAACATTACGAT +GTAACTATTTTAGAGAACTTAATACAAGAAACATTGCTGATTACTCATAACTAAATGCTT +GGTAATATATCCTCAGTGCCCCTACCATCTTTTACGCAGGGATGTAATTACTTAGGATTC +ATTGTGTAAGAATTACAATGAACGATGGATATGAAGGCATGTTGCGAGGTGTTCCTTGGT +ATGTGAAGTTCGCAGGGCAACAAAAATTTCGCAGAATAGGCCTCAAAGTATTGGTAAAGA +AGACAACTAATCATCACGAGCTTCTGATATCAATACGAACGAGTCCTGTGATGGATGAAA +GAAAGTCGTATCGAAAATGTCAAGAGTCTGCCCAATGTAACTTACTTCAAAAAATAACGC +TTCCGCCAAGTACGTTCGAATAAACGTAATTTTAAAAATACATAAGGGGTGTTAGAAAGT +AAGCGACGGGATATAAGTTAGACTCAAGATTCCGCCGTAAAACGAGACTGATTCCGAAGA +TTGTTCGTGGATCTGGTCATGACTTTCACTGAGTAAGGAGTTTCGACATATGTCAATAAA +CACAAAAATAGAAGCTATTCGATCTGAAAAATATTAGGACAAGAAACTATCTCACGCTAG +CCCAGAATATTCACTCACCCACGGGCGATACTAAAGCACTATATAGTCGCGTGATTACTA +TACATATGGTACACATAAGAATCACGATCAGGTTCTCAATTTTCAACAATATATGTTTAT +TTGCATAGGTAATATTAGGCCTTTAAGAGAAGGATGGGTGAGATACTCCGGGGATGGCGG +CAATAAAGAAAAACACGATATGAGTAATAGGATCCTAATATCTTGGCGAGAGACTTAAGG +TACGAATTTTGCGCAATCTATTTTTTACTTGGCCAGAATTCATGTATGGTATAAGTACGA +ACTTTTTTGATCACTTTCATGGCTACCTGATTAGGATAGTTTGAGGAATTTCCCAAATAT +ACCGATTTAATATACACTAGGGCTTGTCACTTTGAGTCAGAAAAAGAATATAATTACTTA +GGGTAATGCTGCATACATATTCTTATATTGCAAAGGTTCTCTGGGTAATCTTGAGCCTTC +ACGATACCTGGTGAAGTGTT diff --git a/test/pending/shootout/revcomp.scala-2.scala b/test/pending/shootout/revcomp.scala-2.scala new file mode 100644 index 0000000000..92260ad021 --- /dev/null +++ b/test/pending/shootout/revcomp.scala-2.scala @@ -0,0 +1,92 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy +*/ + +import java.io._ +import scala.collection.mutable.Stack + +object revcomp { + + val IUB = IUBCodeComplements + + def IUBCodeComplements() = { + val code = "ABCDGHKMNRSTVWYabcdghkmnrstvwy".getBytes + val comp = "TVGHCDMKNYSABWRTVGHCDMKNYSABWR".getBytes + val a: Array[Byte] = new Array( 'z'.toByte ) + + for (indexValue <- code zip comp) + indexValue match { case Pair(i,v) => a(i) = v } + + a + } + + + type LineStack = Stack[Array[Byte]] + + def main(args: Array[String]) = { + val r = new BufferedReader(new InputStreamReader(System.in)) + val w = new BufferedOutputStream(System.out) + + var lines: LineStack = new Stack + var desc = "" + + var line = r.readLine + while (line != null) { + val c = line.charAt(0) + if (c == '>'){ + if (desc.length > 0){ + complementReverseWrite(desc, lines, w) + lines = new Stack + } + desc = line + } else { + if (c != ';') lines += line.getBytes + } + line = r.readLine + } + r.close + + if (desc.length > 0) complementReverseWrite(desc, lines, w) + w.close + } + + + def complementReverseWrite(desc: String, lines: LineStack, + w: BufferedOutputStream) = { + + def inplaceComplementReverse(b: Array[Byte]) = { + var i = 0 + var j = b.length - 1 + while (i < j){ + val swap = b(i) + b(i) = IUB( b(j) ) + b(j) = IUB( swap ) + i = i + 1 + j = j - 1 + } + if (i == j) b(i) = IUB( b(i) ) + } + + val nl = '\n'.toByte + w.write(desc.getBytes); w.write(nl) + + val n = 60 + val k = if (lines.isEmpty) 0 else lines.top.length + val isSplitLine = k < n + var isFirstLine = true + + while (!lines.isEmpty) { + val line = lines.pop + inplaceComplementReverse(line) + + if (isSplitLine){ + if (isFirstLine){ w.write(line); isFirstLine = false } + else { w.write(line,0,n-k); w.write(nl); w.write(line,n-k,k) } + } + else { w.write(line); w.write(nl) } + } + if (isSplitLine && !isFirstLine) w.write(nl) + } + +} diff --git a/test/pending/shootout/revcomp.scala-2.scala.runner b/test/pending/shootout/revcomp.scala-2.scala.runner new file mode 100644 index 0000000000..f51d6170c8 --- /dev/null +++ b/test/pending/shootout/revcomp.scala-2.scala.runner @@ -0,0 +1,6 @@ +object Test extends Application { + for(n <- List(25000,250000,2500000)) { + System.setIn(new java.io.FileInputStream(System.getProperty("partest.cwd")+"/revcomp-input"+n+".txt")) + revcomp.main(Array(n.toString)) + } +} diff --git a/test/pending/shootout/revcomp.scala-3.check b/test/pending/shootout/revcomp.scala-3.check new file mode 100644 index 0000000000..14d792ade8 --- /dev/null +++ b/test/pending/shootout/revcomp.scala-3.check @@ -0,0 +1,171 @@ +>ONE Homo sapiens alu +CGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAAC +CTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACA +GGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCAT +GTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAA +AGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTC +TGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGG +GTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACC +ACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTG +GTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTA +CAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCT +GGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTC +TCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCCCGGCTAAT +TTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTCGAACTCCT +GACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCA +CCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGC +GCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCC +TCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTA +GTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGAT +CCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCT +TTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTC +ACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTG +GGATTACAGGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGT +TTCACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGG +CCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAG +TCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCG +CCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGC +GCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGG +CCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGC +TGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCG +CCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCA +AGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCC +CGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTC +GAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGC +GTGAGCCACCGCGCCCGGCC +>TWO IUB ambiguity codes +TAGGDHACHATCRGTRGVTGAGWTATGYTGCTGTCABACDWVTRTAAGAVVAGATTTNDA +GASMTCTGCATBYTTCAAKTTACMTATTACTTCATARGGYACMRTGTTTTYTATACVAAT +TTCTAKGDACKADACTATATNTANTCGTTCACGBCGYSCBHTANGGTGATCGTAAAGTAA +CTATBAAAAGATSTGWATBCSGAKHTTABBAACGTSYCATGCAAVATKTSKTASCGGAAT +WVATTTNTCCTTCTTCTTDDAGTGGTTGGATACVGTTAYMTMTBTACTTTHAGCTAGBAA +AAGAGKAAGTTRATWATCAGATTMDDTTTAAAVAAATATTKTCYTAAATTVCNKTTRACG +ADTATATTTATGATSADSCAATAWAGCGRTAGTGTAAGTGACVGRADYGTGCTACHVSDT +CTVCARCSYTTAATATARAAAATTTAATTTACDAATTGBACAGTAYAABATBTGCAGBVG +TGATGGDCAAAATBNMSTTABKATTGGSTCCTAGBTTACTTGTTTAGTTTATHCGATSTA +AAGTCGAKAAASTGTTTTAWAKCAGATATACTTTTMTTTTGBATAGAGGAGCMATGATRA +AAGGNCAYDCCDDGAAAGTHGBTAATCKYTBTACBGTBCTTTTTGDTAASSWTAAWAARA +TTGGCTAAGWGRADTYACATAGCTCBTAGATAWAGCAATNGTATMATGTTKMMAGTAWTC +CCNTSGAAWATWCAAAAMACTGAADNTYGATNAATCCGAYWNCTAACGTTAGAGDTTTTC +ATCTGGKRTAVGAABVCTGWGBTCTDVGKATTBTCTAAGGVADAAAVWTCTAGGGGAGGG +TTAGAACAATTAAHTAATNAAATGCATKATCTAAYRTDTCAGSAYTTYHGATRTTWAVTA +BGNTCDACAGBCCRCAGWCRTCABTGMMAWGMCTCAACCGATRTGBCAVAATCGTDWDAA +CAYAWAATWCTGGTAHCCCTAAGATAACSCTTAGTGSAACAWTBGTCDTTDGACWDBAAC +HTTTNGSKTYYAAYGGATNTGATTTAARTTAMBAATCTAAGTBTCATYTAACTTADTGTT +TCGATACGAAHGGCYATATACCWDTKYATDCSHTDTCAAAATGTGBACTGSCCVGATGTA +TCMMAGCCTTDAAABAATGAAGAGTAACTHATMGVTTAATAACCCGGTTVSANTGCAATT +GTGAGATTTAMGTTTAMAAYGCTGACAYAAAAAGGCACAMYTAAGVGGCTGGAABVTACG +GATTSTYGTBVAKTATWACCGTGTKAGTDTGTATGTTTAAAGGAAAAAGTAACATARAAA +GGTYCAMNYAAABTATAGNTSATANAGTCATCCTATWADKAACTRGTMSACDGTATSAYT +AAHSHGTAABYGACTYTATADTGSTATAGAGAAATCGNTAAAGGAAATCAGTTGTNCYMV +TNACDRTATBNATATASTAGAAMSCGGGANRCKKMCAAACATTNAGTCTRMAATBMTACC +CGTACTTCTBGDSYAATWGAAAATGACADDCHAKAAAYATATTKTTTTCACANACWAGAA +AKATCCTTATTAYKHKCTAAACARTATTTTDATBTVWCYGCAATACTAGGKAAASTTDGA +MGGCHTTHAATVCAHDRYAGGRCTATACGTCMAGAGAGCTBTHGNACARTCCBDCTAAGA +GCGGCTTTARTAAAGAATCCNAGTAWBTGACTTGAATTACWTVACAGAAABCAATNAAAC +CGTNTRANTTGAYCMAWBADTANABRGGTKTHTWTAGTTVCTMBKTAGMTVKCCAGCANT +TVAGSWTTAGCCGCRHTTTCCTTHNTATTAAGAAGAATAGGMTRAARTCTABGTACDTTT +TATAAVDHAHTATAGATCCTAGTAAGYTWATDWCATGAGGGATAGTAAMDMNGBASTWAM +TSTATRBAYDABATGTATATYCGCACTGTTTTAACMCWBTATAWAGTATBTSTATVTTAR +CCTMTTAAKADATCAACTAATYTSVTAKGDATTATGCKTCAYCAKAATACTTKAANGAGT +ATTSDAGATCGGAAATACTTAAYAAVGTATMCGCTTGTGTDCTAATYTATTTTATTTWAA +CAGWRCTATGTAGMTGTTTGTTYKTNGTTKTCAGAACNTRACCTACKTGSRATGTGGGGG +CTGTCATTAAGTAAATNGSTTABCCCCTCGCAGCTCWHTCGCGAAGCAVATGCKACGHCA +ACAKTTAATAACASAAADATTWNYTGTAATTGTTCGTMHACHTWATGTGCWTTTTGAAHY +ACTTTGTAYAMSAAACTTAADAAATATAGTABMATATYAATGSGGTAGTTTGTGTBYGGT +TWSGSVGWMATTDMTCCWWCABTCSVACAGBAATGTTKATBGTCAATAATCTTCTTAAAC +ARVAATHAGYBWCTRWCABGTWWAATCTAAGTCASTAAAKTAAGVKBAATTBGABACGTA +AGGTTAAATAAAAACTRMDTWBCTTTTTAATAAAAGATMGCCTACKAKNTBAGYRASTGT +ASSTCGTHCGAAKTTATTATATTYTTTGTAGAACATGTCAAAACTWTWTHGKTCCYAATA +AAGTGGAYTMCYTAARCSTAAATWAKTGAATTTRAGTCTSSATACGACWAKAASATDAAA +TGYYACTSAACAAHAKTSHYARGASTATTATTHAGGYGGASTTTBGAKGATSANAACACD +TRGSTTRAAAAAAAACAAGARTCVTAGTAAGATAWATGVHAAKATWGAAAAGTYAHVTAC +TCTGRTGTCAWGATRVAAKTCGCAAVCGASWGGTTRTCSAMCCTAACASGWKKAWDAATG +ACRCBACTATGTGTCTTCAAAHGSCTATATTTCGTVWAGAAGTAYCKGARAKSGKAGTAN +TTTCYACATWATGTCTAAAADMDTWCAATSTKDACAMAADADBSAAATAGGCTHAHAGTA +CGACVGAATTATAAAGAHCCVAYHGHTTTACATSTTTATGNCCMTAGCATATGATAVAAG +>THREE Homo sapiens frequency +ATATTTATCTTTTCACTTCCTACATTGGTCAGACCATTATTCGACACGTGGCGTCATTTT +GTCATACCGGGTAATGTTGGAAACAAAACGTACTGATAAAATACTGAGTTGTAAACTCTA +ATCAGATAACGCGCTTGGATATTAAGATTCACACAGGGGTTTCGGCTGTAAAAAAACTTG +TGGAGCTGTTCTGGGACAGATAAGTTGTACCTCGTACTTAGCTAATTAATGAACCAACTG +ATTACGATAGAACAATTCTGAGGCCGCCAGGACAGCCAAATTTTAATCTTATAAAGCTGG +AAACAGCCGGTATTAGCTTCTCGCATACTTTGCCTGCATTGGTACCTTACAGATATCAGC +GTAGTCATATACACCTCGGTCTCAGCTAAGCTTGTATCTCTTAGAGTAGTTCAAAGATAG +TGGACAATACCTGTGGAATCGATTGCAGATATGGATTTATTTAACTACTGAGTCTCATTC +ACAAGCTAAGCAAGGAGCACGTTTTGGTGCCGGCATACCGATTTGCTATCATGTCAGCAA +ATTTGCGTTGTATTCCTAGTTGCACCCATTAAGGCCACACTCCGAACCTAATTATTACAT +CGCAAAGACATGTACGAAGGACCCGATGTCGAATAGAAGGGAGGACTGTTCATTGGAAGC +TAGACCAGAGGAATCGCAAAGATGCAACTCTTACAATAAAAATCTAATTTCAGTCAACAC +GCAATTTCTATAAGGTTTCCGATAATAATGAACCGTCTTCCACAGGGGAATTTGCCATGC +TCGTAAAAGTAGTTAATCCAAGTAGAAGAAATTTTGATAATGTTTTAAGTTGGCACGAAG +GAATTCAGAGAGATCTTACCTAACAAAGGCATTAGTAGATGTTCCTTGGTTCACACTCGG +TCAATCAGAGCACATACTACGGGCGATACCGGGAATGACACAACATCAATGAGATTGTTA +AGTGAGGTAATTGACTTTAGAGGACTCGATCAGTATACTGTCACTATGAACATCGTATTA +ATTGTTATCCGATATATACACCACCGATTTGCTTGTGCAAGGTTACAGACCCATTCGATA +AATACAAACACGGAGCGATATTATTTAAGGAGTGCTGTCTTCAAAAGAATTATTCCCACA +CCGACATAAGAACTTCGCTCCGTCATTCCAGATTTAAATAACATAACGTAACGCTTTGCT +GATAACATAACATAACCGAGAATTTGCTTAGGAAATTTGGAGCAATATTGCATTGTTTCT +CAGTCATCACAAGGCCCGCCAAAGAACTCTGAGAATCAGGATTCAACATGATTGGTAAGA +CTCTATATATATAACTTAATTCTTGTGTCCGGAGATAGAAAGAGGACGAGAGATACTACG +AAAGAAAGTGTACTTCGATGTATCAATTCAGACGCCTTCTCTATCATCAACATTATAGGT +CTCGTATATGCTCGGCGCGATCTGCTTCTCTCCGCCAATAGCCCCATAGTGTATTTCAAG +CGCAGTAACAGTGAAATCGTTACGAAGGTAGGGATGTTGCTTATAATTGTCGTAACTTAT +CGCTTATGTATCTTTCAAGAATGAACGGCAGCATATACATACGTTCTACCTTTAGCTACA +AAGCATCCATATACTCCCTCTCATGATTGAAACTCTTCCCTATTTTGTAGCCAATAGTGA +AAGCGTATTAGTATAAATTCGTCGGTTTTTCACTCGCAACTGTTATACTCTGCAAACAAA +CGAAAGCCTCATAGTACAAACCTAAAGCTACATACTTCATCATTGGCAGACCAGTGGCGG +TATTTCTACGGAAGCATCACTATAGATATAAAGTTTCCCTTCATGTACGTCTGTTAACCA +TATCACAAGAAACTGCTATCTCTGTCACGTAACAATTCACGCGCCTTATCGCCAAATGTT +CATATATGCGCGGTATACGTATGAACGAATACTAATTAGTATAACGGAGGATTCACGGGA +GGGATACTTGGGGCATTTATAAATCGTCTAAAAATTTTCTATCAGCACTTGCGGGTTATA +GTGGATTACTAGGCAACATAATATTCTGTATTGGTCCAAATGACGCTATAGATAAATTAG +CAAAATACATTGTTTCCATTTATGTAAGTCGAAACTCCAGGACTCCCGGGAACCAGTTAA +ACCGTCTGGAAAAGACACATTGTGAGCGGGACTTCAATGATAGCTTTCAATGAGCTTCTC +ATGCTTGGGGTCTGTACATATATGTTGGCGAAATTATCGTCTGTATTCTGTTATGCTTTG +ATCATGGGTTATTAGTATAGTGTCCGGTTAAGTACCAATACCGCTAGAGACCCGACCTAA +GTCGATAACTAACGATCATCGACGTAAGGATCGTCTCGATCAGTACTTCAGTCTAGATCT +GGGAATAGTAACTCGTTAGTGAACTATGTCGTGTCATAACTCTAAAATGCAATCAAATCT +TATTATTGAGTATTGATTATATAAAGCATCCGCTTAGCTTTACCCTCAAATGTTATATGC +AATTTAAAGCGCTTGATATCGTCTACTCAAGTTCAGGTTTCACATGGCCGCAACGTGACG +TTATTAGAGGTGGGTCATCATCTCTGAGGCTAGTGATGTTGAATACTCATTGAATGGGAA +GTGGAATACCATGCTCGTAGGTAACAGCATGACCTATAAAATATACTATGGGTGTGTGGT +AGATCAATATTGTTCAAGCATATCGTAACAATAACGGCTGAAATGTTACTGACATGAAAG +AGGGAGTCCAAACCATTCTAACAGCTGATCAAGTCGTCTAAAAACGCCTGGTTCAGCCTT +AAGAGTTATAAGCCAGACAAATTGTATCAATAGAGAATCCGTAAATTCCTCGGCCAACCT +CTTGCAAAGACATCACTATCAATATACTACCGTGATCTTAATTAGTGAACTTATATAAAT +ATCTACAACCAGATTCAACGGAAAAGCTTTAGTGGATTAGAAATTGCCAAGAATCACATT +CATGTGGGTTCGAATGCTTTAGTAATACCATTTCGCCGAGTAGTCACTTCGCTGAACTGT +CGTAAATTGCTATGACATAATCGAAAAGGATTGTCAAGAGTCGATTACTGCGGACTAATA +ATCCCCACGGGGGTGGTCTCATGTCTCCCCAGGCGAGTGGGGACGGTTGATAAACACGCT +GCATCGCGGACTGATGTTCCCAGTATTACATAGTCACATTGGATTGCGAGTAGTCTACCT +ATTTATGAGCGAGAGATGCCTCTAACTACTTCGACTTTTAAAACCTTTCCACGCCAGTAT +TCGGCGAAAGGGAAGTATTAAGGGTTGTCATAATTAAGCTGATACCACTTCAGACTTTGC +TCTACTTCTGTCTTTCATTGGTTTAGTAAAGTCTGTCCATTCGTCGAGACCGTCTTTTGC +AGCCTCATTCTACCAACTGCTCCGACTCTTAGTCTGCTTCTCCCAGCGTTATAACAAGAG +GCATTTTGTCATCCTTAAAACAATAATAAAGAACTCGGAGCACTGATATAATGACTGAAT +TAGAACCGCTTAAAAATACAACGAATAGATAAGACTATCGGATAAGATCTAATATGTAGT +GATTAAGCCCTTTATTAATTAATAATAGTTACCCTTTCTGATGTAACGCGACATATTACG +ATTTAGTGGCACGTCTGAATTGCAAAGCAGATCTCTACCCGATTTTTATTATAAATCCCG +TATACATCTTGACTTGAGTAATTGTTCATCTTTTTATATCTCTTCGTACTACAAATAATT +AATATCTCAACCCGTATTGTGTGATTCTAATTACCAACAGAATACGAGGAGGTTTTTGCT +TAGGGCCATATATAATGAATCTATCTCGTTTATTCGCGGAACCCGAGATAACATTACGAT +GTAACTATTTTAGAGAACTTAATACAAGAAACATTGCTGATTACTCATAACTAAATGCTT +GGTAATATATCCTCAGTGCCCCTACCATCTTTTACGCAGGGATGTAATTACTTAGGATTC +ATTGTGTAAGAATTACAATGAACGATGGATATGAAGGCATGTTGCGAGGTGTTCCTTGGT +ATGTGAAGTTCGCAGGGCAACAAAAATTTCGCAGAATAGGCCTCAAAGTATTGGTAAAGA +AGACAACTAATCATCACGAGCTTCTGATATCAATACGAACGAGTCCTGTGATGGATGAAA +GAAAGTCGTATCGAAAATGTCAAGAGTCTGCCCAATGTAACTTACTTCAAAAAATAACGC +TTCCGCCAAGTACGTTCGAATAAACGTAATTTTAAAAATACATAAGGGGTGTTAGAAAGT +AAGCGACGGGATATAAGTTAGACTCAAGATTCCGCCGTAAAACGAGACTGATTCCGAAGA +TTGTTCGTGGATCTGGTCATGACTTTCACTGAGTAAGGAGTTTCGACATATGTCAATAAA +CACAAAAATAGAAGCTATTCGATCTGAAAAATATTAGGACAAGAAACTATCTCACGCTAG +CCCAGAATATTCACTCACCCACGGGCGATACTAAAGCACTATATAGTCGCGTGATTACTA +TACATATGGTACACATAAGAATCACGATCAGGTTCTCAATTTTCAACAATATATGTTTAT +TTGCATAGGTAATATTAGGCCTTTAAGAGAAGGATGGGTGAGATACTCCGGGGATGGCGG +CAATAAAGAAAAACACGATATGAGTAATAGGATCCTAATATCTTGGCGAGAGACTTAAGG +TACGAATTTTGCGCAATCTATTTTTTACTTGGCCAGAATTCATGTATGGTATAAGTACGA +ACTTTTTTGATCACTTTCATGGCTACCTGATTAGGATAGTTTGAGGAATTTCCCAAATAT +ACCGATTTAATATACACTAGGGCTTGTCACTTTGAGTCAGAAAAAGAATATAATTACTTA +GGGTAATGCTGCATACATATTCTTATATTGCAAAGGTTCTCTGGGTAATCTTGAGCCTTC +ACGATACCTGGTGAAGTGTT diff --git a/test/pending/shootout/revcomp.scala-3.scala b/test/pending/shootout/revcomp.scala-3.scala new file mode 100644 index 0000000000..ae12f0499b --- /dev/null +++ b/test/pending/shootout/revcomp.scala-3.scala @@ -0,0 +1,147 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy +*/ + +import java.io._ +import scala.collection.mutable.Stack + +object revcomp { + def main(args: Array[String]) = { + val out = new FastaOutputStream(System.out) + val in = new FastaInputStream(System.in) + + out.writeReverseComplement( in.readSequenceStack ) + out.writeReverseComplement( in.readSequenceStack ) + out.writeReverseComplement( in.readSequenceStack ) + + in.close + out.close + } +} + + +trait FastaByteStream { + val nl = '\n'.toByte + + type Line = Array[Byte] + type LineStack = Stack[Line] +} + + +// extend the Java BufferedInputStream class + +final class FastaInputStream(in: InputStream) + extends BufferedInputStream(in) with FastaByteStream { + + val gt = '>'.toByte + val sc = ';'.toByte + + def readSequenceStack(): Pair[Line,LineStack] = { + var header: Line = null + val lines: LineStack = new Stack + + var line = readLine() + while (line != null) { + val c = line(0) + if (c == gt){ // '>' + if (header == null){ + header = line + } else { + pos = pos - line.length - 1 // reposition to start of line + return Pair(header,lines) + } + } else { + if (c != sc) lines push line // ';' + } + line = readLine() + } + return Pair(header,lines) + } + + def readLine() = { + var bytes: Line = null + if (in == null) bytes + else { + mark(128) // mark the start of the line + if (count == 0) read() // fill buffer + + var i = markpos + while (i < count && buf(i) != nl) i = i + 1 + + if (i >= count){ // line extends past end of buffer + pos = i; read(); i = pos; // fill buffer again + while (i < count && buf(i) != nl) i = i + 1 + } + + if (i < count){ + bytes = new Array(i - markpos) + System.arraycopy(buf, markpos, bytes, 0, i - markpos); + pos = i+1 + } + } + bytes + } +} + + +// extend the Java BufferedOutputStream class + +final class FastaOutputStream(in: OutputStream) + extends BufferedOutputStream(in) with FastaByteStream { + + private val IUB = IUBCodeComplements + + private def IUBCodeComplements() = { + val code = "ABCDGHKMNRSTVWYabcdghkmnrstvwy".getBytes + val comp = "TVGHCDMKNYSABWRTVGHCDMKNYSABWR".getBytes + val iub: Array[Byte] = new Array( 'z'.toByte ) + + for (indexValue <- code zip comp) + indexValue match { case Pair(i,v) => iub(i) = v } + + iub + } + + def writeReverseComplement(sequence: Pair[Line,LineStack]) = { + + def inplaceComplementReverse(b: Array[Byte]) = { + var i = 0 + var j = b.length - 1 + while (i < j){ + val swap = b(i) + b(i) = IUB( b(j) ) + b(j) = IUB( swap ) + i = i + 1 + j = j - 1 + } + if (i == j) b(i) = IUB( b(i) ) + } + + sequence match { + case Pair(header,lines) => { + + write(header); write(nl) + + val k = if (lines.isEmpty) 0 else lines.top.length + val LineLength = 60 + val isSplitLine = k < LineLength + var isFirstLine = true + + while (!lines.isEmpty) { + val line = lines.pop + inplaceComplementReverse(line) + + if (isSplitLine){ + if (isFirstLine){ write(line); isFirstLine = false } + else { write(line,0,LineLength-k); write(nl); write(line,LineLength-k,k) } + } + else { write(line); write(nl) } + } + + if (isSplitLine && !isFirstLine) write(nl) + } + } + } + +} diff --git a/test/pending/shootout/revcomp.scala-3.scala.runner b/test/pending/shootout/revcomp.scala-3.scala.runner new file mode 100644 index 0000000000..f51d6170c8 --- /dev/null +++ b/test/pending/shootout/revcomp.scala-3.scala.runner @@ -0,0 +1,6 @@ +object Test extends Application { + for(n <- List(25000,250000,2500000)) { + System.setIn(new java.io.FileInputStream(System.getProperty("partest.cwd")+"/revcomp-input"+n+".txt")) + revcomp.main(Array(n.toString)) + } +} diff --git a/test/pending/shootout/sieve.scala b/test/pending/shootout/sieve.scala new file mode 100644 index 0000000000..b494980ee4 --- /dev/null +++ b/test/pending/shootout/sieve.scala @@ -0,0 +1,43 @@ +/* The Computer Language Shootout + http://shootout.alioth.debian.org/ + contributed by Isaac Gouy (Scala novice) +*/ + +object sieve { + def main(args: Array[String]) = { + var n = toPositiveInt(args); + val start = 2; + val stop = 8192; + val isPrime = new Array[Boolean](stop+1); + var count: Int = 0; + + while (n>0) { + count = 0; + + for (i <- Iterator.range(start,stop+1)) + isPrime(i)=true; + + for (i <- Iterator.range(start,stop+1)) { + if( isPrime(i) ) { + var k = i+i; + while (k<=stop) { isPrime(k)=false; k=k+i; } + count = count+1; + } + } + n=n-1; + } + + Console.println("Count: " + count); + } + + + private def toPositiveInt(s: Array[String]) = { + val i = + try { Integer.parseInt(s(0)); } + catch { case _ => 1 } + if (i>0) i; else 1; + } +} + + + diff --git a/test/pending/shootout/sieve.scala.runner b/test/pending/shootout/sieve.scala.runner new file mode 100644 index 0000000000..893c3abe90 --- /dev/null +++ b/test/pending/shootout/sieve.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(n <- List(300,600,900,1200)) sieve.main(Array(n.toString)) +} |