diff options
author | Antonio Cunei <antonio.cunei@epfl.ch> | 2011-11-07 09:55:10 +0000 |
---|---|---|
committer | Antonio Cunei <antonio.cunei@epfl.ch> | 2011-11-07 09:55:10 +0000 |
commit | da929738ccfcf21cc3d8fdb9ce7734e59c6847f0 (patch) | |
tree | 90e335ca1fb60fde22ad345df72aeb0f08aace22 | |
parent | c4e1b28cf79f73e4f8972263efb85ee879c39ebd (diff) | |
download | scala-da929738ccfcf21cc3d8fdb9ce7734e59c6847f0.tar.gz scala-da929738ccfcf21cc3d8fdb9ce7734e59c6847f0.tar.bz2 scala-da929738ccfcf21cc3d8fdb9ce7734e59c6847f0.zip |
Backport of r25948
684 files changed, 7260 insertions, 3486 deletions
diff --git a/docs/examples/actors/producers.scala b/docs/examples/actors/producers.scala index d3ff903f5b..80e5ae33d3 100644 --- a/docs/examples/actors/producers.scala +++ b/docs/examples/actors/producers.scala @@ -6,13 +6,13 @@ import scala.actors.Actor._ abstract class Producer[T] { /** A signal that the next value should be produced. */ - private val Next = new Object + private val Next = new Object /** A label for an undefined state of the iterators. */ private val Undefined = new Object /** A signal to stop the coordinator. */ - private val Stop = new Object + private val Stop = new Object protected def produce(x: T) { coordinator ! Some(x) @@ -53,10 +53,10 @@ abstract class Producer[T] { } private val producer: Actor = actor { - receive { - case Next => + receive { + case Next => produceValues - coordinator ! None + coordinator ! None } } } @@ -70,7 +70,7 @@ object producers extends Application { def tree = node(node(node(3), 4, node(6)), 8, node(node(9), 10, node(11))) class PreOrder(n: Tree) extends Producer[Int] { - def produceValues = traverse(n) + def produceValues = traverse(n) def traverse(n: Tree) { if (n != null) { produce(n.elem) @@ -81,7 +81,7 @@ object producers extends Application { } class PostOrder(n: Tree) extends Producer[Int] { - def produceValues = traverse(n) + def produceValues = traverse(n) def traverse(n: Tree) { if (n != null) { traverse(n.left) @@ -92,7 +92,7 @@ object producers extends Application { } class InOrder(n: Tree) extends Producer[Int] { - def produceValues = traverse(n) + def produceValues = traverse(n) def traverse(n: Tree) { if (n != null) { traverse(n.left) diff --git a/docs/examples/jolib/Ref.scala b/docs/examples/jolib/Ref.scala index 39c0123f09..5f655f16b1 100644 --- a/docs/examples/jolib/Ref.scala +++ b/docs/examples/jolib/Ref.scala @@ -12,7 +12,7 @@ import concurrent.SyncVar; import concurrent.jolib._; class Ref[a](init: a) extends Join { - + object get extends Synchr[a](this) { case class C() extends SyncVar[a]; } object set extends Synchr[unit](this) { case class C(x: a) extends SyncVar[unit]; } object state extends Asynchr(this) { case class C(x: a); } @@ -25,7 +25,7 @@ class Ref[a](init: a) extends Join { ); state(state.C(init)); - + def Get: a = get(get.C()); def Set(x: a): unit = set(set.C(x)); } diff --git a/docs/examples/jolib/parallelOr.scala b/docs/examples/jolib/parallelOr.scala index 4c4a852c4a..72d282bee3 100644 --- a/docs/examples/jolib/parallelOr.scala +++ b/docs/examples/jolib/parallelOr.scala @@ -13,27 +13,27 @@ import concurrent.SyncVar; /** Implementation in the join-calculus of a parallel OR. */ object or extends Join { - + object res extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] }; object res1 extends Asynchr(this) { case class C(b: boolean); } object res2 extends Asynchr(this) { case class C(b: boolean); } object res1False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] }; object res2False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] }; - + rules( Pair(List(res, res1), { case List(r @ res.C(), res1.C(b)) => if (b) r.set(b) else r.set(res1False(res1False.C())) }), - + Pair(List(res, res2), { case List(r @ res.C(), res2.C(b)) => if (b) r.set(b) else r.set(res2False(res2False.C())) }), - + Pair(List(res1False, res2), { case List(r @ res1False.C(), res2.C(b)) => r.set(b) }), - + Pair(List(res2False, res1), { case List(r @ res2False.C(), res1.C(b)) => r.set(b) }) ); - + def apply(b1: => boolean, b2: => boolean): boolean = { concurrent.ops.spawn(res1(res1.C(b1))); concurrent.ops.spawn(res2(res2.C(b2))); @@ -42,7 +42,7 @@ object or extends Join { } */ object parallelOr { - + def main(args: Array[String]): unit = { def loop: boolean = { while (true) {}; true }; /* diff --git a/docs/examples/monads/callccInterpreter.scala b/docs/examples/monads/callccInterpreter.scala index 5b09b4c285..5b556bd8fa 100644 --- a/docs/examples/monads/callccInterpreter.scala +++ b/docs/examples/monads/callccInterpreter.scala @@ -14,7 +14,7 @@ object callccInterpreter { def showM(m: M[Value]): String = (m in id).toString(); - def callCC[A](h: (A => M[A]) => M[A]) = + def callCC[A](h: (A => M[A]) => M[A]) = M[A](c => h(a => M[A](d => c(a))) in c); type Name = String; @@ -30,7 +30,7 @@ object callccInterpreter { trait Value; case object Wrong extends Value { override def toString() = "wrong" - } + } case class Num(n: Int) extends Value { override def toString() = n.toString(); } @@ -70,7 +70,7 @@ object callccInterpreter { case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e)) } - def test(t: Term): String = + def test(t: Term): String = showM(interp(t, List())); val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11))); diff --git a/docs/examples/monads/directInterpreter.scala b/docs/examples/monads/directInterpreter.scala index a80c9e4ed0..06fffba8e2 100644 --- a/docs/examples/monads/directInterpreter.scala +++ b/docs/examples/monads/directInterpreter.scala @@ -45,11 +45,11 @@ object directInterpreter { case App(f, t) => apply(interp(f, e), interp(t, e)) } - def test(t: Term): String = + def test(t: Term): String = showval(interp(t, List())); val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11))); - def main(args: Array[String]) = + def main(args: Array[String]) = System.out.println(test(term0)); } diff --git a/docs/examples/monads/simpleInterpreter.scala b/docs/examples/monads/simpleInterpreter.scala index 219b137c31..cde3a92dbb 100644 --- a/docs/examples/monads/simpleInterpreter.scala +++ b/docs/examples/monads/simpleInterpreter.scala @@ -22,7 +22,7 @@ object simpleInterpreter { trait Value; case object Wrong extends Value { override def toString() = "wrong" - } + } case class Num(n: Int) extends Value { override def toString() = n.toString(); } @@ -61,7 +61,7 @@ object simpleInterpreter { yield c } - def test(t: Term): String = + def test(t: Term): String = showM(interp(t, List())); val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11))); diff --git a/docs/examples/monads/stateInterpreter.scala b/docs/examples/monads/stateInterpreter.scala index 35568fb314..97f3335dab 100644 --- a/docs/examples/monads/stateInterpreter.scala +++ b/docs/examples/monads/stateInterpreter.scala @@ -7,7 +7,7 @@ object stateInterpreter { val tickS = new M(s => Pair((), s + 1)); case class M[A](in: State => Pair[A, State]) { - def bind[B](k: A => M[B]) = M[B]{ s0 => + def bind[B](k: A => M[B]) = M[B]{ s0 => val Pair(a, s1) = this in s0; k(a) in s1 } def map[B](f: A => B): M[B] = bind(x => unitM(f(x))); @@ -72,7 +72,7 @@ object stateInterpreter { yield c } - def test(t: Term): String = + def test(t: Term): String = showM(interp(t, List())); val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11))); diff --git a/docs/examples/parsing/ArithmeticParser.scala b/docs/examples/parsing/ArithmeticParser.scala index 0a79dc7501..cbd8493453 100644 --- a/docs/examples/parsing/ArithmeticParser.scala +++ b/docs/examples/parsing/ArithmeticParser.scala @@ -15,16 +15,16 @@ import scala.util.parsing.combinator.syntactical.StdTokenParsers * a term is a sequence of factors, separated by * or / * a factor is a parenthesized expression or a number * - * @author Adriaan Moors - */ -object arithmeticParser extends StdTokenParsers { + * @author Adriaan Moors + */ +object arithmeticParser extends StdTokenParsers { type Tokens = StdLexical ; val lexical = new StdLexical lexical.delimiters ++= List("(", ")", "+", "-", "*", "/") lazy val expr = term*("+" ^^^ {(x: int, y: int) => x + y} | "-" ^^^ {(x: int, y: int) => x - y}) lazy val term = factor*("*" ^^^ {(x: int, y: int) => x * y} | "/" ^^^ {(x: int, y: int) => x / y}) lazy val factor: Parser[int] = "(" ~> expr <~ ")" | numericLit ^^ (_.toInt) - + def main(args: Array[String]) { println( if (args.length == 1) { @@ -37,14 +37,14 @@ object arithmeticParser extends StdTokenParsers { } -object arithmeticParserDesugared extends StdTokenParsers { +object arithmeticParserDesugared extends StdTokenParsers { type Tokens = StdLexical ; val lexical = new StdLexical lexical.delimiters ++= List("(", ")", "+", "-", "*", "/") lazy val expr = chainl1(term, (keyword("+").^^^{(x: int, y: int) => x + y}).|(keyword("-").^^^{(x: int, y: int) => x - y})) lazy val term = chainl1(factor, (keyword("*").^^^{(x: int, y: int) => x * y}).|(keyword("/").^^^{(x: int, y: int) => x / y})) - lazy val factor: Parser[int] = keyword("(").~>(expr.<~(keyword(")"))).|(numericLit.^^(x => x.toInt)) - + lazy val factor: Parser[int] = keyword("(").~>(expr.<~(keyword(")"))).|(numericLit.^^(x => x.toInt)) + def main(args: Array[String]) { println( if (args.length == 1) { diff --git a/docs/examples/parsing/ArithmeticParsers.scala b/docs/examples/parsing/ArithmeticParsers.scala index 8fb3af7acb..62d7a61862 100644 --- a/docs/examples/parsing/ArithmeticParsers.scala +++ b/docs/examples/parsing/ArithmeticParsers.scala @@ -2,7 +2,7 @@ package examples.parsing import scala.util.parsing.combinator1.syntactical.StandardTokenParsers -object ArithmeticParsers extends StandardTokenParsers { +object ArithmeticParsers extends StandardTokenParsers { lexical.delimiters ++= List("(", ")", "+", "-", "*", "/") def expr: Parser[Any] = term ~ rep("+" ~ term | "-" ~ term) @@ -16,11 +16,11 @@ object ArithmeticParsers extends StandardTokenParsers { } } -object ArithmeticParsers1 extends StandardTokenParsers { +object ArithmeticParsers1 extends StandardTokenParsers { lexical.delimiters ++= List("(", ")", "+", "-", "*", "/") val reduceList: Int ~ List[String ~ Int] => Int = { - case i ~ ps => (i /: ps)(reduce) + case i ~ ps => (i /: ps)(reduce) } def reduce(x: Int, r: String ~ Int) = (r: @unchecked) match { @@ -45,11 +45,11 @@ class Expr case class BinOp(op: String, l: Expr, r: Expr) extends Expr case class Num(n: Int) extends Expr -object ArithmeticParsers2 extends StandardTokenParsers { +object ArithmeticParsers2 extends StandardTokenParsers { lexical.delimiters ++= List("(", ")", "+", "-", "*", "/") val reduceList: Expr ~ List[String ~ Expr] => Expr = { - case i ~ ps => (i /: ps)(reduce) + case i ~ ps => (i /: ps)(reduce) } def reduce(l: Expr, r: String ~ Expr) = BinOp(r._1, l, r._2) diff --git a/docs/examples/parsing/JSON.scala b/docs/examples/parsing/JSON.scala index bbba25f744..abfa242e9f 100644 --- a/docs/examples/parsing/JSON.scala +++ b/docs/examples/parsing/JSON.scala @@ -2,14 +2,14 @@ package examples.parsing import scala.util.parsing.combinator1.syntactical.StandardTokenParsers -object JSON extends StandardTokenParsers { +object JSON extends StandardTokenParsers { lexical.delimiters += ("{", "}", "[", "]", ":", ",") lexical.reserved += ("null", "true", "false") def obj : Parser[Any] = "{" ~ repsep(member, ",") ~ "}" def arr : Parser[Any] = "[" ~ repsep(value, ",") ~ "]" def member: Parser[Any] = ident ~ ":" ~ value - def value : Parser[Any] = ident | numericLit | obj | arr | + def value : Parser[Any] = ident | numericLit | obj | arr | "null" | "true" | "false" def main(args: Array[String]) { @@ -18,20 +18,20 @@ object JSON extends StandardTokenParsers { println(phrase(value)(tokens)) } } -object JSON1 extends StandardTokenParsers { +object JSON1 extends StandardTokenParsers { lexical.delimiters += ("{", "}", "[", "]", ":", ",") lexical.reserved += ("null", "true", "false") - def obj: Parser[Map[String, Any]] = + def obj: Parser[Map[String, Any]] = "{" ~> repsep(member, ",") <~ "}" ^^ (Map() ++ _) def arr: Parser[List[Any]] = - "[" ~> repsep(value, ",") <~ "]" + "[" ~> repsep(value, ",") <~ "]" - def member: Parser[(String, Any)] = + def member: Parser[(String, Any)] = ident ~ ":" ~ value ^^ { case name ~ ":" ~ value => (name -> value) } - def value: Parser[Any] = + def value: Parser[Any] = ident | numericLit ^^ (_.toInt) | obj | arr | "null" ^^^ null | "true" ^^^ true | "false" ^^^ false diff --git a/docs/examples/parsing/ListParser.scala b/docs/examples/parsing/ListParser.scala index 12805e5e50..59fc292c1d 100644 --- a/docs/examples/parsing/ListParser.scala +++ b/docs/examples/parsing/ListParser.scala @@ -14,7 +14,7 @@ object listParser { class ListParsers extends Parsers { type Elem = Char - + lazy val ident = rep1(elem("letter", isLetter), elem("letter or digit", isLetterOrDigit)) ^^ {cs => Id(mkString(cs))} lazy val number = chainl1(elem("digit", isDigit) ^^ (_ - '0'), success{(accum: Int, d: Int) => accum * 10 + d}) ^^ Num lazy val list = '(' ~> repsep(expr, ',') <~ ')' ^^ Lst diff --git a/docs/examples/parsing/ListParsers.scala b/docs/examples/parsing/ListParsers.scala index f503a0139f..b449c4a641 100644 --- a/docs/examples/parsing/ListParsers.scala +++ b/docs/examples/parsing/ListParsers.scala @@ -2,7 +2,7 @@ package examples.parsing import scala.util.parsing.combinator1.syntactical.StandardTokenParsers -object ListParsers extends StandardTokenParsers { +object ListParsers extends StandardTokenParsers { lexical.delimiters ++= List("(", ")", ",") def expr: Parser[Any] = "(" ~ exprs ~ ")" | ident | numericLit @@ -15,7 +15,7 @@ object ListParsers extends StandardTokenParsers { } } -object ListParsers1 extends StandardTokenParsers { +object ListParsers1 extends StandardTokenParsers { lexical.delimiters ++= List("(", ")", ",") def expr: Parser[Any] = "(" ~> exprs <~ ")" | ident | numericLit diff --git a/docs/examples/parsing/MiniML.scala b/docs/examples/parsing/MiniML.scala index ffc7c2ac92..f7f7172e8d 100644 --- a/docs/examples/parsing/MiniML.scala +++ b/docs/examples/parsing/MiniML.scala @@ -3,7 +3,7 @@ package examples.parsing import scala.util.parsing.combinator1.syntactical.StandardTokenParsers import scala.util.parsing.combinator1.syntactical.StandardTokenParsers -object MiniML extends StandardTokenParsers { +object MiniML extends StandardTokenParsers { lexical.delimiters += ("(", ")", ".", "=") lexical.reserved += ("lambda", "let", "in") @@ -30,7 +30,7 @@ case class Lambda(x: String, expr: Expr) extends Expr case class Apply(fun: Expr, arg: Expr) extends Expr case class Var(x: String) extends Expr -object MiniML1 extends StandardTokenParsers { +object MiniML1 extends StandardTokenParsers { lexical.delimiters += ("(", ")", ".", "=") lexical.reserved += ("lambda", "let", "in") @@ -41,7 +41,7 @@ object MiniML1 extends StandardTokenParsers { ) def simpleExpr: Parser[Expr] = ( ident ^^ { Var } - | "(" ~> expr <~ ")" + | "(" ~> expr <~ ")" ) def main(args: Array[String]) { diff --git a/docs/examples/parsing/lambda/Main.scala b/docs/examples/parsing/lambda/Main.scala index 81a175de77..165e82b670 100644 --- a/docs/examples/parsing/lambda/Main.scala +++ b/docs/examples/parsing/lambda/Main.scala @@ -27,8 +27,8 @@ object Main extends Application with TestParser { Console.println("Term: \n"+term) } - case Failure(msg, remainder) => Console.println("Failure: "+msg+"\n"+"Remainder: \n"+remainder.pos.longString) - case Error(msg, remainder) => Console.println("Error: "+msg+"\n"+"Remainder: \n"+remainder.pos.longString) + case Failure(msg, remainder) => Console.println("Failure: "+msg+"\n"+"Remainder: \n"+remainder.pos.longString) + case Error(msg, remainder) => Console.println("Error: "+msg+"\n"+"Remainder: \n"+remainder.pos.longString) } } } diff --git a/docs/examples/parsing/lambda/TestParser.scala b/docs/examples/parsing/lambda/TestParser.scala index 623b597337..d26589da1b 100644 --- a/docs/examples/parsing/lambda/TestParser.scala +++ b/docs/examples/parsing/lambda/TestParser.scala @@ -17,9 +17,9 @@ trait TestParser extends StdTokenParsers with ImplicitConversions with TestSynt lexical.reserved ++= List("unit", "let", "in", "if", "then", "else") lexical.delimiters ++= List("=>", "->", "==", "(", ")", "=", "\\", "+", "-", "*", "/") - + def name : Parser[Name] = ident ^^ Name - + // meaning of the arguments to the closure during subsequent iterations // (...(expr2 op1 expr1) ... op1 expr1) // ^a^^^ ^o^ ^b^^^ @@ -29,10 +29,10 @@ trait TestParser extends StdTokenParsers with ImplicitConversions with TestSynt def expr2 : Parser[Term] = chainl1(expr3, expr2, op2 ^^ {o => (a: Term, b: Term) => App(App(o, a), b)}) - + def expr3 : Parser[Term] = chainl1(expr4, expr3, op3 ^^ {o => (a: Term, b: Term) => App(App(o, a), b)}) - + def expr4 : Parser[Term] = ( "\\" ~> lambdas | ("let" ~> name) ~ ("=" ~> expr1) ~ ("in" ~> expr1) ^^ flatten3(Let) @@ -42,27 +42,27 @@ trait TestParser extends StdTokenParsers with ImplicitConversions with TestSynt def lambdas : Parser[Term] = name ~ ("->" ~> expr1 | lambdas) ^^ flatten2(Lam) - + def aexpr : Parser[Term] = ( numericLit ^^ (_.toInt) ^^ Lit | name ^^ Ref | "unit" ^^^ Unit() | "(" ~> expr1 <~ ")" ) - + def op1 : Parser[Term] = "==" ^^^ Ref(Name("==")) - + def op2 : Parser[Term] = ( "+" ^^^ Ref(Name("+")) | "-" ^^^ Ref(Name("-")) ) - + def op3 : Parser[Term] = ( "*" ^^^ Ref(Name("*")) | "/" ^^^ Ref(Name("/")) ) - + def parse(r: Reader[char]) : ParseResult[Term] = phrase(expr1)(new lexical.Scanner(r)) } diff --git a/docs/examples/parsing/lambda/TestSyntax.scala b/docs/examples/parsing/lambda/TestSyntax.scala index 531ae4bd54..7edca6ccdc 100644 --- a/docs/examples/parsing/lambda/TestSyntax.scala +++ b/docs/examples/parsing/lambda/TestSyntax.scala @@ -5,25 +5,25 @@ package examples.parsing.lambda * * @author Miles Sabin (adapted slightly by Adriaan Moors) */ -trait TestSyntax +trait TestSyntax { - trait Term - + trait Term + case class Unit extends Term { override def toString = "unit" } - + case class Lit(n: int) extends Term { override def toString = n.toString } - + case class Bool(b: boolean) extends Term { override def toString = b.toString } - + case class Name(name: String) extends Term { override def toString = name @@ -33,27 +33,27 @@ trait TestSyntax { def value = n } - + case class Lam(n: Name, l: Term) extends Term { override def toString = "(\\ "+n+" -> "+l+")" - } - + } + case class App(t1: Term, t2: Term) extends Term { override def toString = "("+t1+" "+t2+")" - } - + } + case class Let(n: Name, t1: Term, t2: Term) extends Term { override def toString = "let "+n+" = "+t1+" in "+t2 } - + case class If(c: Term, t1: Term, t2: Term) extends Term { override def toString = "if "+c+" then "+t1+" else "+t2 } - + trait PrimTerm extends Term { def apply(n: Lit) : Term @@ -68,7 +68,7 @@ trait TestSyntax { def apply(x: Lit) = new PrimTerm { def apply(y: Lit) = Lit(x.n-y.n) } } - + case class PrimMultiply extends PrimTerm { def apply(x: Lit) = new PrimTerm { def apply(y: Lit) = Lit(x.n*y.n) } diff --git a/docs/examples/pilib/elasticBuffer.scala b/docs/examples/pilib/elasticBuffer.scala index a0e8bb6a7c..5fec96ab6c 100644 --- a/docs/examples/pilib/elasticBuffer.scala +++ b/docs/examples/pilib/elasticBuffer.scala @@ -25,7 +25,7 @@ object elasticBuffer { /** * A buffer cell containing a value, ready to receive (o,r) from the right. */ - def Cl(i: Chan[String], l: MetaChan, + def Cl(i: Chan[String], l: MetaChan, o: Chan[String], r: MetaChan, content: String): Unit = choice ( o(content) * (Bl(i,l,o,r)), diff --git a/docs/examples/pilib/handover.scala b/docs/examples/pilib/handover.scala index 9725382c96..c9b6156c2c 100644 --- a/docs/examples/pilib/handover.scala +++ b/docs/examples/pilib/handover.scala @@ -32,7 +32,7 @@ object handoverRecursive { * Control center. */ def Control(talk1: Chan[unit], switch1: Switch, - gain1: Switch, lose1: Switch, + gain1: Switch, lose1: Switch, talk2: Chan[unit], switch2: Switch, gain2: Switch, lose2: Switch): unit = { @@ -108,7 +108,7 @@ object handoverCast { def Car(talk: Chan[Any], switch: Chan[Any]): unit = choice ( switch * (o => { - val Pair(t,s) = o.asInstanceOf[Pair[Chan[Any],Chan[Any]]]; + val Pair(t,s) = o.asInstanceOf[Pair[Chan[Any],Chan[Any]]]; Car(t, s) }), talk(()) * ( { @@ -122,7 +122,7 @@ object handoverCast { * Control center. */ def Control(talk1: Chan[Any], switch1: Chan[Any], - gain1: Chan[Any], lose1: Chan[Any], + gain1: Chan[Any], lose1: Chan[Any], talk2: Chan[Any], switch2: Chan[Any], gain2: Chan[Any], lose2: Chan[Any]): unit = { diff --git a/docs/examples/pilib/mobilePhoneProtocol.scala b/docs/examples/pilib/mobilePhoneProtocol.scala index 0805253ae0..e8c0ac1dc4 100644 --- a/docs/examples/pilib/mobilePhoneProtocol.scala +++ b/docs/examples/pilib/mobilePhoneProtocol.scala @@ -21,7 +21,7 @@ object mobilePhoneProtocol { case class HoCom() extends Message; // handover complete case class HoFail() extends Message; // handover fail case class ChRel() extends Message; // release - case class Voice(s: String) extends Message; // voice + case class Voice(s: String) extends Message; // voice case class Channel(n: Chan[Message]) extends Message; // channel def MobileSystem(in: Chan[String], out: Chan[String]): unit = { @@ -144,9 +144,9 @@ object mobilePhoneProtocol { } //***************** Entry function ******************// - + def main(args: Array[String]): unit = { - + def Producer(n: Int, put: Chan[String]): unit = { Thread.sleep(1 + random.nextInt(1000)); val msg = "object " + n; @@ -154,14 +154,14 @@ object mobilePhoneProtocol { System.out.println("Producer gave " + msg); Producer(n + 1, put) } - + def Consumer(get: Chan[String]): unit = { Thread.sleep(1 + random.nextInt(1000)); val msg = get.read; System.out.println("Consumer took " + msg); Consumer(get) } - + val put = new Chan[String]; val get = new Chan[String]; spawn < Producer(0, put) | Consumer(get) | MobileSystem(put, get) > diff --git a/docs/examples/pilib/piNat.scala b/docs/examples/pilib/piNat.scala index ee9e5ba1af..a1a0e682e1 100644 --- a/docs/examples/pilib/piNat.scala +++ b/docs/examples/pilib/piNat.scala @@ -4,7 +4,7 @@ import scala.concurrent.pilib._ /** Church encoding of naturals in the Pi-calculus */ object piNat extends Application { - + /** Locations of Pi-calculus natural */ class NatChan extends Chan[Triple[Chan[Unit], Chan[NatChan], Chan[NatChan]]] diff --git a/docs/examples/pilib/rwlock.scala b/docs/examples/pilib/rwlock.scala index 931f622f5a..bb1c26bdf2 100644 --- a/docs/examples/pilib/rwlock.scala +++ b/docs/examples/pilib/rwlock.scala @@ -250,7 +250,7 @@ object rwlock { def endRead = er.send def endWrite = ew.send - private def Reading(nr: int, nw: int): unit = + private def Reading(nr: int, nw: int): unit = if (nr == 0 && nw == 0) choice ( sr * (x => Reading(1, 0)), @@ -264,7 +264,7 @@ object rwlock { choice ( sr * (x => Reading(nr + 1, 0)), er * (x => Reading(nr - 1, 0)), - ww * (x => Reading(nr, 1)) + ww * (x => Reading(nr, 1)) ) else if (nr != 0 && nw != 0) choice ( diff --git a/docs/examples/pilib/scheduler.scala b/docs/examples/pilib/scheduler.scala index 9205ae3f0c..fd8fd52600 100644 --- a/docs/examples/pilib/scheduler.scala +++ b/docs/examples/pilib/scheduler.scala @@ -87,7 +87,7 @@ object scheduler { /** * A cell is modelled as a function that takes as parameters - * input and output channels and which returns nothing. + * input and output channels and which returns nothing. */ type Cell = (Chan[Unit], Chan[Unit]) => Unit diff --git a/docs/examples/pilib/semaphore.scala b/docs/examples/pilib/semaphore.scala index ed224890e2..951c90e8d4 100644 --- a/docs/examples/pilib/semaphore.scala +++ b/docs/examples/pilib/semaphore.scala @@ -65,7 +65,7 @@ object semaphore { println("b1"); Thread.sleep(1 + random.nextInt(100)); println("b2") - } ) + } ) } >; } } diff --git a/docs/examples/pilib/twoPlaceBuffer.scala b/docs/examples/pilib/twoPlaceBuffer.scala index f0f278317a..255f70ca06 100644 --- a/docs/examples/pilib/twoPlaceBuffer.scala +++ b/docs/examples/pilib/twoPlaceBuffer.scala @@ -16,7 +16,7 @@ object twoPlaceBuffer extends Application { def B1(x: A): Unit = choice ( out(x) * (B0), - in * (y => B2(x, y)) + in * (y => B2(x, y)) ) def B2(x: A, y: A): Unit = choice ( diff --git a/docs/examples/plugintemplate/src/plugintemplate/TemplatePlugin.scala b/docs/examples/plugintemplate/src/plugintemplate/TemplatePlugin.scala index b241072301..6cda37d4e3 100644 --- a/docs/examples/plugintemplate/src/plugintemplate/TemplatePlugin.scala +++ b/docs/examples/plugintemplate/src/plugintemplate/TemplatePlugin.scala @@ -16,7 +16,7 @@ class TemplatePlugin(val global: Global) extends Plugin { /** A short description of the plugin, read from the properties file */ val description = PluginProperties.pluginDescription - + /** @todo A description of the plugin's options */ override val optionsHelp = Some( " -P:"+ name +":option sets some option for this plugin") diff --git a/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala b/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala index ff1d1b50c5..19d2613649 100644 --- a/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala +++ b/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala @@ -5,7 +5,7 @@ import scala.tools.nsc.CompilerCommand import scala.tools.nsc.Settings /** An object for running the plugin as standalone application. - * + * * @todo: print, parse and apply plugin options !!! * ideally re-use the TemplatePlugin (-> runsAfter, optionsHelp, * processOptions, components, annotationChecker) instead of diff --git a/docs/examples/tcpoly/collection/HOSeq.scala b/docs/examples/tcpoly/collection/HOSeq.scala index a9414e3b3c..a6757b95ba 100644 --- a/docs/examples/tcpoly/collection/HOSeq.scala +++ b/docs/examples/tcpoly/collection/HOSeq.scala @@ -6,40 +6,40 @@ trait HOSeq { // values implementing this interface, in order to provide more performant ways of building that structure trait Accumulator[+coll[x], elT] { def += (el: elT): Unit - def result: coll[elT] + def result: coll[elT] } - - + + // Iterable abstracts over the type of its structure as well as its elements (see PolyP's Bifunctor) - // m[x] is intentionally unbounded: fold can then be defined nicely - // variance: if we write m[+x] instead of +m[+x], x is an invariant position because its enclosing type + // m[x] is intentionally unbounded: fold can then be defined nicely + // variance: if we write m[+x] instead of +m[+x], x is an invariant position because its enclosing type // is an invariant position -- should probably rule that out? trait Iterable[+m[+x], +t] { //def unit[a](orig: a): m[a] def iterator: Iterator[t] - + // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t def accumulator[t]: Accumulator[m, t] - + def filter(p: t => Boolean): m[t] = { val buf = accumulator[t] val elems = elements while (elems.hasNext) { val x = elems.next; if (p(x)) buf += x } buf.result } - + def map[s](f: t => s): m[s] = { val buf = accumulator[s] val elems = elements while (elems.hasNext) buf += f(elems.next) buf.result } - + // flatMap is a more specialized map, it only works if the mapped function produces Iterable values, // which are then added to the result one by one // the compiler should be able to find the right accumulator (implicit buf) to build the result // to get concat, resColl = SingletonIterable, f = unit for SingletonIterable - def flatMap[resColl[x] <: Iterable[resColl, x], s](f: t => resColl[s])(implicit buf: Accumulator[resColl, s]): resColl[s] = { + def flatMap[resColl[x] <: Iterable[resColl, x], s](f: t => resColl[s])(implicit buf: Accumulator[resColl, s]): resColl[s] = { // TODO: would a viewbound for resColl[x] be better? // -- 2nd-order type params are not yet in scope in view bound val elems = elements @@ -48,9 +48,9 @@ trait HOSeq { while (elemss.hasNext) buf += elemss.next } buf.result - } + } } - + final class ListBuffer[A] { private var start: List[A] = Nil private var last: ::[A] = _ @@ -78,7 +78,7 @@ trait HOSeq { exported = !start.isEmpty start } - + /** Clears the buffer contents. */ def clear: unit = { @@ -97,13 +97,13 @@ trait HOSeq { } } } - + implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] { private[this] val buff = new ListBuffer[elT] def += (el: elT): Unit = buff += el def result: List[elT] = buff.toList } - + trait List[+t] extends Iterable[List, t] { def head: t def tail: List[t] @@ -111,16 +111,16 @@ trait HOSeq { def iterator: Iterator[t] = error("TODO") // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t - def accumulator[t]: Accumulator[List, t] = error("TODO") + def accumulator[t]: Accumulator[List, t] = error("TODO") } - + // TODO: the var tl approach does not seem to work because subtyping isn't fully working yet final case class ::[+b](hd: b, private val tl: List[b]) extends List[b] { def head = hd def tail = if(tl==null) this else tl // hack override def isEmpty: boolean = false } - + case object Nil extends List[Nothing] { def isEmpty = true def head: Nothing = @@ -149,18 +149,18 @@ trait HOSeq { def filter(f: T=>Boolean): FilterResult def subseq(from: int, to: int): Subseq def flatMap[S <: Seq[K], K](f: T => S): S#Concat // legal? - def concat(others: Seq[T]): Concat + def concat(others: Seq[T]): Concat */ - + /*trait Iterator[t] { // @post hasAdvanced implies hasNext // model def hasAdvanced: Boolean - + def hasNext: Boolean // pure - + // @pre hasAdvanced def current: t // pure - + // @pre hasNext // @post hasAdvanced def advance: Unit diff --git a/docs/examples/tcpoly/monads/Monads.scala b/docs/examples/tcpoly/monads/Monads.scala index 5a966ce960..b6e3d5b9a8 100644 --- a/docs/examples/tcpoly/monads/Monads.scala +++ b/docs/examples/tcpoly/monads/Monads.scala @@ -6,18 +6,18 @@ trait Monads { * (>>=) :: m a -> (a -> m b) -> m b * return :: a -> m a * - * MonadTC encodes the above Haskell type class, + * MonadTC encodes the above Haskell type class, * an instance of MonadTC corresponds to a method dictionary. * (see http://lampwww.epfl.ch/~odersky/talks/wg2.8-boston06.pdf) * * Note that the identity (`this') of the method dictionary does not really correspond - * to the instance of m[x] (`self') that is `wrapped': e.g., unit does not use `self' (which + * to the instance of m[x] (`self') that is `wrapped': e.g., unit does not use `self' (which * corresponds to the argument of the implicit conversion that encodes an instance of this type class) */ // Option =:= [x] => Option[x] <: [x] => Any -// trait MonadTC[m <: [x] => Any, a] { +// trait MonadTC[m <: [x] => Any, a] { // MonadTC[m[x], a] x is a type parameter too -- should not write e.g., m[Int] here - trait MonadTC[m[x], a] { + trait MonadTC[m[x], a] { def unit[a](orig: a): m[a] // >>='s first argument comes from the implicit definition constructing this "method dictionary" @@ -32,7 +32,7 @@ trait Monads { */ trait OptionMonad extends Monads { // this implicit method encodes the Monad type class instance for Option - implicit def OptionInstOfMonad[a](self: Option[a]): MonadTC[Option, a] + implicit def OptionInstOfMonad[a](self: Option[a]): MonadTC[Option, a] = new MonadTC[Option, a] { def unit[a](orig: a) = Some(orig) def >>=[b](fun: a => Option[b]): Option[b] = self match { @@ -47,8 +47,8 @@ object main extends OptionMonad with Application { } -/* -trait MonadTC[m[x], a] requires m[x] { +/* +trait MonadTC[m[x], a] requires m[x] { def unit[a](orig: a): m[a] // >>='s first argument comes from the implicit definition constructing this "method dictionary" diff --git a/docs/examples/typeinf.scala b/docs/examples/typeinf.scala index 80980ebc9a..d4bc8bf3e1 100644 --- a/docs/examples/typeinf.scala +++ b/docs/examples/typeinf.scala @@ -69,14 +69,14 @@ object typeInfer { case Tycon(k, ts) => (List[Tyvar]() /: ts) ((tvs, t) => tvs union tyvars(t)) } - def tyvars(ts: TypeScheme): List[Tyvar] = + def tyvars(ts: TypeScheme): List[Tyvar] = tyvars(ts.tpe) diff ts.tyvars; def tyvars(env: Env): List[Tyvar] = (List[Tyvar]() /: env) ((tvs, nt) => tvs union tyvars(nt._2)) def mgu(t: Type, u: Type, s: Subst): Subst = Pair(s(t), s(u)) match { - case Pair(Tyvar(a), Tyvar(b)) if (a == b) => + case Pair(Tyvar(a), Tyvar(b)) if (a == b) => s case Pair(Tyvar(a), _) if !(tyvars(u) contains a) => s.extend(Tyvar(a), u) @@ -181,7 +181,7 @@ object typeInfer { yield Lam(x, t): Term ) ||| ( for ( - letid <- id if letid == "let"; + letid <- id if letid == "let"; x <- ident; _ <- wschr('='); t <- term; diff --git a/docs/examples/xml/phonebook/embeddedBook.scala b/docs/examples/xml/phonebook/embeddedBook.scala index 8ea9628212..3286485f0b 100644 --- a/docs/examples/xml/phonebook/embeddedBook.scala +++ b/docs/examples/xml/phonebook/embeddedBook.scala @@ -1,5 +1,5 @@ /* examples/phonebook/embeddedBook.scala */ -package phonebook +package phonebook object embeddedBook { @@ -8,14 +8,14 @@ object embeddedBook { val last = "Emir" val location = "work" - val embBook = + val embBook = <phonebook> <descr> - This is the <b>phonebook</b> of the + This is the <b>phonebook</b> of the {company} corporation. </descr> <entry> - <name>{ first+" "+last }</name> + <name>{ first+" "+last }</name> <phone where={ location }>+41 21 693 68 {val x = 60 + 7; x}</phone> </entry> </phonebook>; diff --git a/docs/examples/xml/phonebook/phonebook.scala b/docs/examples/xml/phonebook/phonebook.scala index 4813c2d20d..3c0dfbd837 100644 --- a/docs/examples/xml/phonebook/phonebook.scala +++ b/docs/examples/xml/phonebook/phonebook.scala @@ -2,14 +2,14 @@ package phonebook ; object phonebook { - val labPhoneBook = + val labPhoneBook = <phonebook> <descr> - This is the <b>phonebook</b> of the + This is the <b>phonebook</b> of the <a href="http://acme.org">ACME</a> corporation. </descr> <entry> - <name>Burak</name> + <name>Burak</name> <phone where="work"> +41 21 693 68 67</phone> <phone where="mobile">+41 79 602 23 23</phone> </entry> @@ -22,14 +22,14 @@ object phonebook { import scala.xml.{ Node, Text }; def add( phonebook:Node, newEntry:Node ):Node = phonebook match { - case <phonebook>{ ch @ _* }</phonebook> => + case <phonebook>{ ch @ _* }</phonebook> => <phonebook>{ ch }{ newEntry }</phonebook> } - val pb2 = - add( labPhoneBook, + val pb2 = + add( labPhoneBook, <entry> - <name>Kim</name> + <name>Kim</name> <phone where="work"> +41 21 111 11 11</phone> </entry> ); diff --git a/docs/examples/xml/phonebook/phonebook1.scala b/docs/examples/xml/phonebook/phonebook1.scala index 3a7a165202..316c6c1995 100644 --- a/docs/examples/xml/phonebook/phonebook1.scala +++ b/docs/examples/xml/phonebook/phonebook1.scala @@ -1,16 +1,16 @@ /* examples/phonebook/phonebook1.scala */ -package phonebook +package phonebook object phonebook1 { - val labPhoneBook = + val labPhoneBook = <phonebook> <descr> - This is the <b>phonebook</b> of the + This is the <b>phonebook</b> of the <a href="http://acme.org">ACME</a> corporation. </descr> <entry> - <name>Burak Emir</name> + <name>Burak Emir</name> <phone where="work">+41 21 693 68 67</phone> </entry> </phonebook>; diff --git a/docs/examples/xml/phonebook/phonebook2.scala b/docs/examples/xml/phonebook/phonebook2.scala index ba50379369..2a708daf7c 100644 --- a/docs/examples/xml/phonebook/phonebook2.scala +++ b/docs/examples/xml/phonebook/phonebook2.scala @@ -8,18 +8,18 @@ object phonebook2 { /** adds an entry to a phonebook */ def add( p: Node, newEntry: Node ): Node = p match { - case <phonebook>{ ch @ _* }</phonebook> => + case <phonebook>{ ch @ _* }</phonebook> => <phonebook>{ ch }{ newEntry }</phonebook> } - val pb2 = - add( phonebook1.labPhoneBook, + val pb2 = + add( phonebook1.labPhoneBook, <entry> - <name>Kim</name> + <name>Kim</name> <phone where="work">+41 21 111 11 11</phone> </entry> ); - def main( args: Array[String] ) = + def main( args: Array[String] ) = Console.println( pb2 ) } diff --git a/docs/examples/xml/phonebook/phonebook3.scala b/docs/examples/xml/phonebook/phonebook3.scala index 0dfae351b5..12f2deaa79 100644 --- a/docs/examples/xml/phonebook/phonebook3.scala +++ b/docs/examples/xml/phonebook/phonebook3.scala @@ -17,57 +17,57 @@ object phonebook3 { import xml.Utility.{trim,trimProper} //removes whitespace nodes, which are annoying in matches - for( val c <- ch ) yield + for( val c <- ch ) yield trimProper(c) match { // if the node is the particular entry we are looking for, return an updated copy - case x @ <entry><name>{ Text(Name) }</name>{ ch1 @ _* }</entry> => + case x @ <entry><name>{ Text(Name) }</name>{ ch1 @ _* }</entry> => var updated = false; val ch2 = for(c <- ch1) yield c match { // does it have the phone number? - case y @ <phone>{ _* }</phone> if y \ "@where" == Where => + case y @ <phone>{ _* }</phone> if y \ "@where" == Where => updated = true <phone where={ Where }>{ newPhone }</phone> - + case y => y - + } if( !updated ) { // no, so we add as first entry - + <entry> <name>{ Name }</name> <phone where={ Where }>{ newPhone }</phone> { ch1 } </entry> - + } else { // yes, and we changed it as we should - + <entry> { ch2 } </entry> - - } + + } // end case x @ <entry>... - + // other entries are copied without changing them - case x => + case x => x - + } } ; // for ... yield ... returns an Iterator[Node] - + // decompose phonebook, apply updates phonebook match { case <phonebook>{ ch @ _* }</phonebook> => <phonebook>{ copyOrChange( ch.iterator ) }</phonebook> } - + } - val pb2 = + val pb2 = change( phonebook1.labPhoneBook, "John", "work", "+41 55 555 55 55" ); val pp = new PrettyPrinter( 80, 5 ); diff --git a/docs/examples/xml/phonebook/verboseBook.scala b/docs/examples/xml/phonebook/verboseBook.scala index 611cf5370e..2dcb155480 100644 --- a/docs/examples/xml/phonebook/verboseBook.scala +++ b/docs/examples/xml/phonebook/verboseBook.scala @@ -1,24 +1,24 @@ /* examples/xml/phonebook/verboseBook.scala */ -package phonebook +package phonebook object verboseBook { - import scala.xml.{ UnprefixedAttribute, Elem, Node, Null, Text, TopScope } + import scala.xml.{ UnprefixedAttribute, Elem, Node, Null, Text, TopScope } - val pbookVerbose = + val pbookVerbose = Elem(null, "phonebook", Null, TopScope, Elem(null, "descr", Null, TopScope, - Text("This is a "), + Text("This is a "), Elem(null, "b", Null, TopScope, Text("sample")), Text("description") ), Elem(null, "entry", Null, TopScope, Elem(null, "name", Null, TopScope, Text("Burak Emir")), - Elem(null, "phone", new UnprefixedAttribute("where","work", Null), TopScope, + Elem(null, "phone", new UnprefixedAttribute("where","work", Null), TopScope, Text("+41 21 693 68 67")) ) ) - def main(args: Array[String]) = + def main(args: Array[String]) = Console.println( pbookVerbose ) } diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index bc3490c6e5..c7a4204222 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -154,6 +154,7 @@ class Global(settings: Settings, reporter: Reporter, projectName: String = "") protected[interactive] def getUnit(s: SourceFile): Option[RichCompilationUnit] = { toBeRemoved.synchronized { for (f <- toBeRemoved) { + informIDE("removed: "+s) unitOfFile -= f allSources = allSources filter (_.file != f) } @@ -731,7 +732,7 @@ class Global(settings: Settings, reporter: Reporter, projectName: String = "") val originalTypeParams = sym.owner.typeParams parseAndEnter(unit) val pre = adaptToNewRunMap(ThisType(sym.owner)) - val newsym = pre.decl(sym.name) filter { alt => + val newsym = pre.typeSymbol.info.decl(sym.name) filter { alt => sym.isType || { try { val tp1 = pre.memberType(alt) onTypeError NoType diff --git a/test/attic/files/cli/test2/Main.scala b/test/attic/files/cli/test2/Main.scala index 1d43759fdf..11c878b9c0 100644 --- a/test/attic/files/cli/test2/Main.scala +++ b/test/attic/files/cli/test2/Main.scala @@ -1,5 +1,5 @@ // @info 1 dependency -package test2 +package test2 object Main { def main(args: Array[String]) = { Console.print("2: ") diff --git a/test/disabled-windows/script/utf8.scala b/test/disabled-windows/script/utf8.scala index f294498cd2..5dfade0bb2 100755 --- a/test/disabled-windows/script/utf8.scala +++ b/test/disabled-windows/script/utf8.scala @@ -1,5 +1,5 @@ #!/bin/sh -# +# # Checks if UTF-8 output makes it through unmangled. cygwin=false; @@ -9,7 +9,7 @@ esac SOURCE="$0"; if $cygwin; then - if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; + if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then format=mixed else diff --git a/test/disabled/pos/spec-traits.scala b/test/disabled/pos/spec-traits.scala index 9e339a14ad..49a59d5391 100644 --- a/test/disabled/pos/spec-traits.scala +++ b/test/disabled/pos/spec-traits.scala @@ -11,12 +11,12 @@ class Lazy { // issue 3307 class Bug3307 { - def f[Z](block: String => Z) { - block("abc") + def f[Z](block: String => Z) { + block("abc") } - - ({ () => - f { implicit x => println(x) } })() + + ({ () => + f { implicit x => println(x) } })() } // issue 3301 diff --git a/test/disabled/run/script-positions.scala b/test/disabled/run/script-positions.scala index 6982ed8440..2c80d550c0 100644 --- a/test/disabled/run/script-positions.scala +++ b/test/disabled/run/script-positions.scala @@ -4,9 +4,9 @@ import util.stringFromStream // Testing "scripts" without the platform delights which accompany actual scripts. object Scripts { - val test1 = -"""#!/bin/sh - exec scala $0 $@ + val test1 = +"""#!/bin/sh + exec scala $0 $@ !# println("statement 1") @@ -29,7 +29,7 @@ val x = "line 6" val y = "line 7" val z "line 8"""" - val output2 = + val output2 = """bob.scala:8: error: '=' expected but string literal found. val z "line 8" ^ @@ -41,10 +41,10 @@ two errors found""" object Test { import Scripts._ - + def settings = new GenericRunnerSettings(println _) settings.nocompdaemon.value = true - + def runScript(code: String): String = stringFromStream(stream => Console.withOut(stream) { @@ -53,7 +53,7 @@ object Test { } } ) - + val tests: List[(String, String)] = List( test1 -> output1, test2 -> output2 @@ -67,14 +67,14 @@ object Test { case idx => s drop (idx + 7) } def toLines(text: String) = lines(text) map stripFilename - + def main(args: Array[String]): Unit = { - for ((code, expected) <- tests) { + for ((code, expected) <- tests) { val out = toLines(runScript(code)) val exp = toLines(expected) val nomatch = out zip exp filter { case (x, y) => x != y } val success = out.size == exp.size && nomatch.isEmpty - + assert( success, "Output doesn't match expected:\n" + diff --git a/test/disabled/run/sigtp.scala b/test/disabled/run/sigtp.scala index f0cac859f5..8cba5a748b 100644 --- a/test/disabled/run/sigtp.scala +++ b/test/disabled/run/sigtp.scala @@ -10,7 +10,7 @@ final class Bug[A, B](val key: A) extends BugBase[A, Bug[A, B]] { object Test { def f(clazz: Class[_]) = clazz.getDeclaredMethods.toList.map(_.toGenericString).sorted foreach println - + def main(args: Array[String]): Unit = { f(classOf[Bug[_, _]]) f(classOf[BugBase[_, _]]) diff --git a/test/disabled/scalacheck/redblack.scala b/test/disabled/scalacheck/redblack.scala index 0334c1218d..301d332334 100644 --- a/test/disabled/scalacheck/redblack.scala +++ b/test/disabled/scalacheck/redblack.scala @@ -1,157 +1,157 @@ -import org.scalacheck._ -import Prop._ -import Gen._ - -/* -Properties of a Red & Black Tree: - -A node is either red or black. -The root is black. (This rule is used in some definitions and not others. Since the -root can always be changed from red to black but not necessarily vice-versa this -rule has little effect on analysis.) -All leaves are black. -Both children of every red node are black. -Every simple path from a given node to any of its descendant leaves contains the same number of black nodes. -*/ - -abstract class RedBlackTest extends Properties("RedBlack") { - object RedBlackTest extends scala.collection.immutable.RedBlack[Int] { - def isSmaller(x: Int, y: Int) = x < y - } - - import RedBlackTest._ - - def rootIsBlack[A](t: Tree[A]) = t.isBlack - - def areAllLeavesBlack[A](t: Tree[A]): Boolean = t match { - case Empty => t.isBlack - case ne: NonEmpty[_] => List(ne.left, ne.right) forall areAllLeavesBlack - } - - def areRedNodeChildrenBlack[A](t: Tree[A]): Boolean = t match { - case RedTree(_, _, left, right) => List(left, right) forall (t => t.isBlack && areRedNodeChildrenBlack(t)) - case BlackTree(_, _, left, right) => List(left, right) forall areRedNodeChildrenBlack - case Empty => true - } - - def blackNodesToLeaves[A](t: Tree[A]): List[Int] = t match { - case Empty => List(1) - case BlackTree(_, _, left, right) => List(left, right) flatMap blackNodesToLeaves map (_ + 1) - case RedTree(_, _, left, right) => List(left, right) flatMap blackNodesToLeaves - } - - def areBlackNodesToLeavesEqual[A](t: Tree[A]): Boolean = t match { - case Empty => true - case ne: NonEmpty[_] => - ( - blackNodesToLeaves(ne).removeDuplicates.size == 1 - && areBlackNodesToLeavesEqual(ne.left) - && areBlackNodesToLeavesEqual(ne.right) - ) - } - - def orderIsPreserved[A](t: Tree[A]): Boolean = t match { - case Empty => true - case ne: NonEmpty[_] => - ( - (ne.left.iterator map (_._1) forall (isSmaller(_, ne.key))) - && (ne.right.iterator map (_._1) forall (isSmaller(ne.key, _))) - && (List(ne.left, ne.right) forall orderIsPreserved) - ) - } - - def setup(l: List[Int], invariant: Tree[Unit] => Boolean): (Boolean, Tree[Unit]) - - def listNoRepetitions(size: Int) = for { - s <- Gen.choose(1, size) - l <- Gen.listOfN(size, Gen.choose(0, Int.MaxValue)) suchThat (l => l.size == l.removeDuplicates.size) - } yield l - def listFewRepetitions(size: Int) = for { - s <- Gen.choose(1, size) - l <- Gen.listOfN(s, Gen.choose(0, size * 4)) suchThat (l => l.size != l.removeDuplicates.size) - } yield l - def listManyRepetitions(size: Int) = for { - s <- Gen.choose(1, size) - l <- Gen.listOfN(s, Gen.choose(0, size)) suchThat (l => l.size != l.removeDuplicates.size) - } yield l - def listEvenRepetitions(size: Int) = listFewRepetitions(size) map (x => - scala.util.Random.shuffle(x zip x flatMap { case (a, b) => List(a, b) }) - ) - - // Arbitrarily weighted list distribution types - val seqType: Gen[Int => Gen[List[Int]]] - - def myGen(sized: Int) = for { - size <- Gen.choose(0, sized) - seq <- seqType - list <- seq(size) - } yield list - - property("root is black") = forAll(myGen(10)) { l => - setup(l, rootIsBlack)._1 :| setup(l, rootIsBlack)._2.toString - } - property("all leaves are black") = forAll(myGen(50)) { l => - setup(l, areAllLeavesBlack)._1 :| setup(l, areAllLeavesBlack)._2.toString - } - property("children of red nodes are black") = forAll(myGen(50)) { l => - setup(l, areRedNodeChildrenBlack)._1 :| setup(l, areRedNodeChildrenBlack)._2.toString - } - property("Every path from a node to its descendant leaves contains the same number of black nodes") = forAll(myGen(50)) { l => - setup(l, areBlackNodesToLeavesEqual)._1 :| setup(l, areBlackNodesToLeavesEqual)._2.toString - } - property("Ordering of keys is preserved") = forAll(myGen(50)) { l => - setup(l, orderIsPreserved)._1 :| setup(l, orderIsPreserved)._2.toString - } -} - -object TestInsertion extends RedBlackTest { - import RedBlackTest._ - override val seqType = Gen.frequency( - (1, listNoRepetitions _), - (1, listManyRepetitions _) - ) - - property("update adds elements") = forAll(myGen(50)) { l => - val tree = l.foldLeft(Empty: Tree[Unit])((acc, n) => acc update (n, ())) - forAll(Gen.pick(1, l)) ( n => !(tree lookup n.head isEmpty) :| "Tree: "+tree+" N: "+n.head ) - } - - override def setup(l: List[Int], invariant: Tree[Unit] => Boolean) = l.foldLeft((true, Empty: Tree[Unit])) { - case ((true, acc), n) => - val newRoot = acc update (n, ()) - (invariant(newRoot), newRoot) - case (failed, _) => failed - } -} - -object TestDeletion extends RedBlackTest { - import RedBlackTest._ - override val seqType = Gen.frequency( - (2, listFewRepetitions _), - (3, listManyRepetitions _), - (1, listEvenRepetitions _) - ) - - property("delete removes elements") = forAll(myGen(50)) { l => - val tree = l.foldLeft(Empty: Tree[Unit])((acc, n) => acc update (n, ())) - forAll(Gen.choose(1, l.size)) { numberOfElementsToRemove => - forAll(Gen.pick(numberOfElementsToRemove, l)) { elementsToRemove => - val newTree = elementsToRemove.foldLeft(tree)((acc, n) => acc delete n) - (elementsToRemove forall (n => newTree lookup n isEmpty)) :| "Tree: "+tree+"New Tree: "+newTree+" Elements to Remove: "+elementsToRemove - } - } - } - - override def setup(l: List[Int], invariant: Tree[Unit] => Boolean) = l.foldLeft((true, Empty: Tree[Unit])) { - case ((true, acc), n) => - val newRoot = if (acc lookup n isEmpty) acc update (n, ()) else acc delete n - (invariant(newRoot), newRoot) - case (failed, _) => failed - } -} - -object Test extends Properties("RedBlack") { - include(TestInsertion) - include(TestDeletion) -} - +import org.scalacheck._
+import Prop._
+import Gen._
+
+/*
+Properties of a Red & Black Tree:
+
+A node is either red or black.
+The root is black. (This rule is used in some definitions and not others. Since the
+root can always be changed from red to black but not necessarily vice-versa this
+rule has little effect on analysis.)
+All leaves are black.
+Both children of every red node are black.
+Every simple path from a given node to any of its descendant leaves contains the same number of black nodes.
+*/
+
+abstract class RedBlackTest extends Properties("RedBlack") {
+ object RedBlackTest extends scala.collection.immutable.RedBlack[Int] {
+ def isSmaller(x: Int, y: Int) = x < y
+ }
+
+ import RedBlackTest._
+
+ def rootIsBlack[A](t: Tree[A]) = t.isBlack
+
+ def areAllLeavesBlack[A](t: Tree[A]): Boolean = t match {
+ case Empty => t.isBlack
+ case ne: NonEmpty[_] => List(ne.left, ne.right) forall areAllLeavesBlack
+ }
+
+ def areRedNodeChildrenBlack[A](t: Tree[A]): Boolean = t match {
+ case RedTree(_, _, left, right) => List(left, right) forall (t => t.isBlack && areRedNodeChildrenBlack(t))
+ case BlackTree(_, _, left, right) => List(left, right) forall areRedNodeChildrenBlack
+ case Empty => true
+ }
+
+ def blackNodesToLeaves[A](t: Tree[A]): List[Int] = t match {
+ case Empty => List(1)
+ case BlackTree(_, _, left, right) => List(left, right) flatMap blackNodesToLeaves map (_ + 1)
+ case RedTree(_, _, left, right) => List(left, right) flatMap blackNodesToLeaves
+ }
+
+ def areBlackNodesToLeavesEqual[A](t: Tree[A]): Boolean = t match {
+ case Empty => true
+ case ne: NonEmpty[_] =>
+ (
+ blackNodesToLeaves(ne).removeDuplicates.size == 1
+ && areBlackNodesToLeavesEqual(ne.left)
+ && areBlackNodesToLeavesEqual(ne.right)
+ )
+ }
+
+ def orderIsPreserved[A](t: Tree[A]): Boolean = t match {
+ case Empty => true
+ case ne: NonEmpty[_] =>
+ (
+ (ne.left.iterator map (_._1) forall (isSmaller(_, ne.key)))
+ && (ne.right.iterator map (_._1) forall (isSmaller(ne.key, _)))
+ && (List(ne.left, ne.right) forall orderIsPreserved)
+ )
+ }
+
+ def setup(l: List[Int], invariant: Tree[Unit] => Boolean): (Boolean, Tree[Unit])
+
+ def listNoRepetitions(size: Int) = for {
+ s <- Gen.choose(1, size)
+ l <- Gen.listOfN(size, Gen.choose(0, Int.MaxValue)) suchThat (l => l.size == l.removeDuplicates.size)
+ } yield l
+ def listFewRepetitions(size: Int) = for {
+ s <- Gen.choose(1, size)
+ l <- Gen.listOfN(s, Gen.choose(0, size * 4)) suchThat (l => l.size != l.removeDuplicates.size)
+ } yield l
+ def listManyRepetitions(size: Int) = for {
+ s <- Gen.choose(1, size)
+ l <- Gen.listOfN(s, Gen.choose(0, size)) suchThat (l => l.size != l.removeDuplicates.size)
+ } yield l
+ def listEvenRepetitions(size: Int) = listFewRepetitions(size) map (x =>
+ scala.util.Random.shuffle(x zip x flatMap { case (a, b) => List(a, b) })
+ )
+
+ // Arbitrarily weighted list distribution types
+ val seqType: Gen[Int => Gen[List[Int]]]
+
+ def myGen(sized: Int) = for {
+ size <- Gen.choose(0, sized)
+ seq <- seqType
+ list <- seq(size)
+ } yield list
+
+ property("root is black") = forAll(myGen(10)) { l =>
+ setup(l, rootIsBlack)._1 :| setup(l, rootIsBlack)._2.toString
+ }
+ property("all leaves are black") = forAll(myGen(50)) { l =>
+ setup(l, areAllLeavesBlack)._1 :| setup(l, areAllLeavesBlack)._2.toString
+ }
+ property("children of red nodes are black") = forAll(myGen(50)) { l =>
+ setup(l, areRedNodeChildrenBlack)._1 :| setup(l, areRedNodeChildrenBlack)._2.toString
+ }
+ property("Every path from a node to its descendant leaves contains the same number of black nodes") = forAll(myGen(50)) { l =>
+ setup(l, areBlackNodesToLeavesEqual)._1 :| setup(l, areBlackNodesToLeavesEqual)._2.toString
+ }
+ property("Ordering of keys is preserved") = forAll(myGen(50)) { l =>
+ setup(l, orderIsPreserved)._1 :| setup(l, orderIsPreserved)._2.toString
+ }
+}
+
+object TestInsertion extends RedBlackTest {
+ import RedBlackTest._
+ override val seqType = Gen.frequency(
+ (1, listNoRepetitions _),
+ (1, listManyRepetitions _)
+ )
+
+ property("update adds elements") = forAll(myGen(50)) { l =>
+ val tree = l.foldLeft(Empty: Tree[Unit])((acc, n) => acc update (n, ()))
+ forAll(Gen.pick(1, l)) ( n => !(tree lookup n.head isEmpty) :| "Tree: "+tree+" N: "+n.head )
+ }
+
+ override def setup(l: List[Int], invariant: Tree[Unit] => Boolean) = l.foldLeft((true, Empty: Tree[Unit])) {
+ case ((true, acc), n) =>
+ val newRoot = acc update (n, ())
+ (invariant(newRoot), newRoot)
+ case (failed, _) => failed
+ }
+}
+
+object TestDeletion extends RedBlackTest {
+ import RedBlackTest._
+ override val seqType = Gen.frequency(
+ (2, listFewRepetitions _),
+ (3, listManyRepetitions _),
+ (1, listEvenRepetitions _)
+ )
+
+ property("delete removes elements") = forAll(myGen(50)) { l =>
+ val tree = l.foldLeft(Empty: Tree[Unit])((acc, n) => acc update (n, ()))
+ forAll(Gen.choose(1, l.size)) { numberOfElementsToRemove =>
+ forAll(Gen.pick(numberOfElementsToRemove, l)) { elementsToRemove =>
+ val newTree = elementsToRemove.foldLeft(tree)((acc, n) => acc delete n)
+ (elementsToRemove forall (n => newTree lookup n isEmpty)) :| "Tree: "+tree+"New Tree: "+newTree+" Elements to Remove: "+elementsToRemove
+ }
+ }
+ }
+
+ override def setup(l: List[Int], invariant: Tree[Unit] => Boolean) = l.foldLeft((true, Empty: Tree[Unit])) {
+ case ((true, acc), n) =>
+ val newRoot = if (acc lookup n isEmpty) acc update (n, ()) else acc delete n
+ (invariant(newRoot), newRoot)
+ case (failed, _) => failed
+ }
+}
+
+object Test extends Properties("RedBlack") {
+ include(TestInsertion)
+ include(TestDeletion)
+}
+
diff --git a/test/files/bench/equality/eq.scala b/test/files/bench/equality/eq.scala index 8ac5b5ef5c..4e57a81734 100755 --- a/test/files/bench/equality/eq.scala +++ b/test/files/bench/equality/eq.scala @@ -1,34 +1,34 @@ -object eq extends testing.Benchmark { - - def eqtest[T](creator: Int => T, n: Int): Int = { - val elems = Array.tabulate[AnyRef](n)(i => creator(i % 2).asInstanceOf[AnyRef]) - - var sum = 0 - var i = 0 - while (i < n) { - var j = 0 - while (j < n) { - if (elems(i) eq elems(j)) sum += 1 - j += 1 - } - i += 1 - } - sum - } - - val obj1 = new Object - val obj2 = new Object - - def run() { - var sum = 0 - sum += eqtest(x => if (x == 0) obj1 else obj2, 2000) - sum += eqtest(x => x, 1000) - sum += eqtest(x => x.toChar, 550) - sum += eqtest(x => x.toByte, 550) - sum += eqtest(x => x.toLong, 550) - sum += eqtest(x => x.toShort, 100) - sum += eqtest(x => x.toFloat, 100) - sum += eqtest(x => x.toDouble, 100) - assert(sum == 2958950) - } -} +object eq extends testing.Benchmark {
+
+ def eqtest[T](creator: Int => T, n: Int): Int = {
+ val elems = Array.tabulate[AnyRef](n)(i => creator(i % 2).asInstanceOf[AnyRef])
+
+ var sum = 0
+ var i = 0
+ while (i < n) {
+ var j = 0
+ while (j < n) {
+ if (elems(i) eq elems(j)) sum += 1
+ j += 1
+ }
+ i += 1
+ }
+ sum
+ }
+
+ val obj1 = new Object
+ val obj2 = new Object
+
+ def run() {
+ var sum = 0
+ sum += eqtest(x => if (x == 0) obj1 else obj2, 2000)
+ sum += eqtest(x => x, 1000)
+ sum += eqtest(x => x.toChar, 550)
+ sum += eqtest(x => x.toByte, 550)
+ sum += eqtest(x => x.toLong, 550)
+ sum += eqtest(x => x.toShort, 100)
+ sum += eqtest(x => x.toFloat, 100)
+ sum += eqtest(x => x.toDouble, 100)
+ assert(sum == 2958950)
+ }
+}
diff --git a/test/files/bench/equality/eqeq.scala b/test/files/bench/equality/eqeq.scala index afccece88a..e1fda69c0c 100755 --- a/test/files/bench/equality/eqeq.scala +++ b/test/files/bench/equality/eqeq.scala @@ -1,46 +1,46 @@ -/** benchmark for testing equality. - * Mix: == between non-numbers ith Object.equals as equality: 66% - * 50% of these are tests where eq is true. - * == between boxed integers: 17% - * == between boxed characters: 5% - * == between boxed bytes: 5% - * == between boxed longs: 5% - * == between boxed shorts: < 1% - * == between boxed floats: < 1% - * == between boxed doubles: < 1% - * In all cases 50% of the tests return true. - */ -object eqeq extends testing.Benchmark { - - def eqeqtest[T](creator: Int => T, n: Int): Int = { - val elems = Array.tabulate[AnyRef](n)(i => creator(i % 2).asInstanceOf[AnyRef]) - - var sum = 0 - var i = 0 - while (i < n) { - var j = 0 - while (j < n) { - if (elems(i) == elems(j)) sum += 1 - j += 1 - } - i += 1 - } - sum - } - - val obj1 = new Object - val obj2 = new Object - - def run() { - var sum = 0 - sum += eqeqtest(x => if (x == 0) obj1 else obj2, 2000) - sum += eqeqtest(x => x, 1000) - sum += eqeqtest(x => x.toChar, 550) - sum += eqeqtest(x => x.toByte, 550) - sum += eqeqtest(x => x.toLong, 550) - sum += eqeqtest(x => x.toShort, 100) - sum += eqeqtest(x => x.toFloat, 100) - sum += eqeqtest(x => x.toDouble, 100) - assert(sum == 2968750) - } -} +/** benchmark for testing equality.
+ * Mix: == between non-numbers ith Object.equals as equality: 66%
+ * 50% of these are tests where eq is true.
+ * == between boxed integers: 17%
+ * == between boxed characters: 5%
+ * == between boxed bytes: 5%
+ * == between boxed longs: 5%
+ * == between boxed shorts: < 1%
+ * == between boxed floats: < 1%
+ * == between boxed doubles: < 1%
+ * In all cases 50% of the tests return true.
+ */
+object eqeq extends testing.Benchmark {
+
+ def eqeqtest[T](creator: Int => T, n: Int): Int = {
+ val elems = Array.tabulate[AnyRef](n)(i => creator(i % 2).asInstanceOf[AnyRef])
+
+ var sum = 0
+ var i = 0
+ while (i < n) {
+ var j = 0
+ while (j < n) {
+ if (elems(i) == elems(j)) sum += 1
+ j += 1
+ }
+ i += 1
+ }
+ sum
+ }
+
+ val obj1 = new Object
+ val obj2 = new Object
+
+ def run() {
+ var sum = 0
+ sum += eqeqtest(x => if (x == 0) obj1 else obj2, 2000)
+ sum += eqeqtest(x => x, 1000)
+ sum += eqeqtest(x => x.toChar, 550)
+ sum += eqeqtest(x => x.toByte, 550)
+ sum += eqeqtest(x => x.toLong, 550)
+ sum += eqeqtest(x => x.toShort, 100)
+ sum += eqeqtest(x => x.toFloat, 100)
+ sum += eqeqtest(x => x.toDouble, 100)
+ assert(sum == 2968750)
+ }
+}
diff --git a/test/files/buildmanager/freshnames/A.scala b/test/files/buildmanager/freshnames/A.scala index 88ea44b3c7..e8ab26ca1e 100644 --- a/test/files/buildmanager/freshnames/A.scala +++ b/test/files/buildmanager/freshnames/A.scala @@ -1,11 +1,11 @@ abstract class A { var t: List[B] - + def foo(n: String): Option[B] = { t.reverse find (_.names contains n) } - + def bar(n: Int): Option[B] = { t.reverse find (_.names contains n) } diff --git a/test/files/buildmanager/infer/A.scala b/test/files/buildmanager/infer/A.scala index 5e0e268122..46b5391609 100644 --- a/test/files/buildmanager/infer/A.scala +++ b/test/files/buildmanager/infer/A.scala @@ -1,5 +1,5 @@ class Foo(flag: Boolean) { - val classpath = + val classpath = if (flag) new AClasspath else diff --git a/test/files/buildmanager/overloaded_1/A.scala b/test/files/buildmanager/overloaded_1/A.scala index c070faf978..33b63b8006 100644 --- a/test/files/buildmanager/overloaded_1/A.scala +++ b/test/files/buildmanager/overloaded_1/A.scala @@ -3,7 +3,7 @@ trait As { override def foo = this /// Shouldn't cause the change override def foo(act: List[D]) = this } - + abstract class D{ def foo: D = this def foo(act: List[D]) = this diff --git a/test/files/buildmanager/t2559/D.scala b/test/files/buildmanager/t2559/D.scala index 4b8422db04..906b69a3e7 100644 --- a/test/files/buildmanager/t2559/D.scala +++ b/test/files/buildmanager/t2559/D.scala @@ -1,5 +1,5 @@ object D { - def x(a: A) = + def x(a: A) = a match { case _: B => () case _: C => () diff --git a/test/files/buildmanager/t2562/A.scala b/test/files/buildmanager/t2562/A.scala index 2208585eed..740cd1e868 100644 --- a/test/files/buildmanager/t2562/A.scala +++ b/test/files/buildmanager/t2562/A.scala @@ -1,6 +1,6 @@ object A { - def x0 = B.x0 + def x0 = B.x0 def x1 = B.x1 def x2 = B.x2 def x3 = 3 diff --git a/test/files/buildmanager/t2562/B.scala b/test/files/buildmanager/t2562/B.scala index 6f658954e1..a524e5cc84 100644 --- a/test/files/buildmanager/t2562/B.scala +++ b/test/files/buildmanager/t2562/B.scala @@ -1,6 +1,6 @@ object B { - def x0 = A.x1 + def x0 = A.x1 def x1 = A.x2 def x2 = A.x3 } diff --git a/test/files/buildmanager/t2562/t2562.changes/A2.scala b/test/files/buildmanager/t2562/t2562.changes/A2.scala index 743609eb18..c560e1e816 100644 --- a/test/files/buildmanager/t2562/t2562.changes/A2.scala +++ b/test/files/buildmanager/t2562/t2562.changes/A2.scala @@ -1,6 +1,6 @@ object A { - def x0 = B.x0 + def x0 = B.x0 def x1 = B.x1 def x2 = B.x2 def x3 = "3" diff --git a/test/files/buildmanager/t3133/A.java b/test/files/buildmanager/t3133/A.java index 9cf4d96bd4..c4e7f3af0e 100644 --- a/test/files/buildmanager/t3133/A.java +++ b/test/files/buildmanager/t3133/A.java @@ -1,7 +1,7 @@ public class A { - class Foo {} - + class Foo {} + public A(Foo a) {} - + private void bar(Foo z) {} } diff --git a/test/files/continuations-neg/function0.scala b/test/files/continuations-neg/function0.scala index 4112ee3835..6ef0d98b90 100644 --- a/test/files/continuations-neg/function0.scala +++ b/test/files/continuations-neg/function0.scala @@ -4,13 +4,13 @@ import scala.util.continuations._ object Test { - + def main(args: Array[String]): Any = { - + val f = () => shift { k: (Int=>Int) => k(7) } val g: () => Int = f - + println(reset(g())) } - + }
\ No newline at end of file diff --git a/test/files/continuations-neg/function2.scala b/test/files/continuations-neg/function2.scala index ae0fda509d..402c6dcad8 100644 --- a/test/files/continuations-neg/function2.scala +++ b/test/files/continuations-neg/function2.scala @@ -4,13 +4,13 @@ import scala.util.continuations._ object Test { - + def main(args: Array[String]): Any = { - + val f = () => 7 val g: () => Int @cps[Int] = f - + println(reset(g())) } - + }
\ No newline at end of file diff --git a/test/files/continuations-neg/function3.scala b/test/files/continuations-neg/function3.scala index 0c3f1667e5..c4acc4c2e9 100644 --- a/test/files/continuations-neg/function3.scala +++ b/test/files/continuations-neg/function3.scala @@ -4,12 +4,12 @@ import scala.util.continuations._ object Test { - + def main(args: Array[String]): Any = { - + val g: () => Int = () => shift { k: (Int=>Int) => k(7) } - + println(reset(g())) } - + }
\ No newline at end of file diff --git a/test/files/continuations-neg/infer0.scala b/test/files/continuations-neg/infer0.scala index 894d5228b1..9cf69c5d35 100644 --- a/test/files/continuations-neg/infer0.scala +++ b/test/files/continuations-neg/infer0.scala @@ -4,11 +4,11 @@ import scala.util.continuations._ object Test { - + def test(x: => Int @cpsParam[String,Int]) = 7 - + def main(args: Array[String]): Any = { test(8) } - + }
\ No newline at end of file diff --git a/test/files/continuations-neg/infer2.scala b/test/files/continuations-neg/infer2.scala index a890ac1fc4..eaffbc17fc 100644 --- a/test/files/continuations-neg/infer2.scala +++ b/test/files/continuations-neg/infer2.scala @@ -4,16 +4,16 @@ import scala.util.continuations._ object Test { - + def test(x: => Int @cpsParam[String,Int]) = 7 - + def sym() = shift { k: (Int => String) => 9 } - - + + def main(args: Array[String]): Any = { - test { sym(); sym() } + test { sym(); sym() } } - + } diff --git a/test/files/continuations-neg/lazy.scala b/test/files/continuations-neg/lazy.scala index dffc57ffa0..d150d5fe51 100644 --- a/test/files/continuations-neg/lazy.scala +++ b/test/files/continuations-neg/lazy.scala @@ -1,16 +1,16 @@ -import scala.util.continuations._ - -object Test { +import scala.util.continuations._ + +object Test { def foo = { lazy val x = shift((k:Unit=>Unit)=>k()) println(x) } - - def main(args: Array[String]) { + + def main(args: Array[String]) { reset { foo } - } - + } + }
\ No newline at end of file diff --git a/test/files/continuations-neg/t2285.scala b/test/files/continuations-neg/t2285.scala index f3c7f4c89c..b906dc455a 100644 --- a/test/files/continuations-neg/t2285.scala +++ b/test/files/continuations-neg/t2285.scala @@ -5,7 +5,7 @@ import scala.util.continuations._ object Test { def bar() = shift { k: (String => String) => k("1") } - + def foo() = reset { bar(); 7 } - + } diff --git a/test/files/continuations-neg/t2949.scala b/test/files/continuations-neg/t2949.scala index ce27c7c0e8..2d426a4d89 100644 --- a/test/files/continuations-neg/t2949.scala +++ b/test/files/continuations-neg/t2949.scala @@ -8,7 +8,7 @@ object Test { def reify[A, B](x : A @cpsParam[List[A], B]) = reset{ List(x) } def main(args: Array[String]): Unit = println(reify { - val x = reflect[Int, Int](List(1,2,3)) + val x = reflect[Int, Int](List(1,2,3)) val y = reflect[Int, Int](List(2,4,8)) x * y }) diff --git a/test/files/continuations-neg/trycatch2.scala b/test/files/continuations-neg/trycatch2.scala index 761cee52ac..d61419169b 100644 --- a/test/files/continuations-neg/trycatch2.scala +++ b/test/files/continuations-neg/trycatch2.scala @@ -7,7 +7,7 @@ object Test { def fatal[T]: T = throw new Exception def cpsIntStringInt = shift { k:(Int=>String) => k(3); 7 } def cpsIntIntString = shift { k:(Int=>Int) => k(3); "7" } - + def foo1 = try { fatal[Int] cpsIntStringInt diff --git a/test/files/continuations-run/basics.scala b/test/files/continuations-run/basics.scala index 9df209b11c..b63710bc64 100755 --- a/test/files/continuations-run/basics.scala +++ b/test/files/continuations-run/basics.scala @@ -14,10 +14,10 @@ object Test { } def main(args: Array[String]) = { - + println(reset(m0())) println(reset(m1())) - + } - + } diff --git a/test/files/continuations-run/function1.scala b/test/files/continuations-run/function1.scala index 3b39722e3a..fbd413ed9d 100644 --- a/test/files/continuations-run/function1.scala +++ b/test/files/continuations-run/function1.scala @@ -4,13 +4,13 @@ import scala.util.continuations._ object Test { - + def main(args: Array[String]): Any = { - + val f = () => shift { k: (Int=>Int) => k(7) } val g: () => Int @cps[Int] = f - + println(reset(g())) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/function4.scala b/test/files/continuations-run/function4.scala index b73eedb02c..2ccd0b4ff2 100644 --- a/test/files/continuations-run/function4.scala +++ b/test/files/continuations-run/function4.scala @@ -4,12 +4,12 @@ import scala.util.continuations._ object Test { - + def main(args: Array[String]): Any = { - + val g: () => Int @cps[Int] = () => shift { k: (Int=>Int) => k(7) } - + println(reset(g())) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/function5.scala b/test/files/continuations-run/function5.scala index a689ccf243..fe528e14e7 100644 --- a/test/files/continuations-run/function5.scala +++ b/test/files/continuations-run/function5.scala @@ -4,12 +4,12 @@ import scala.util.continuations._ object Test { - + def main(args: Array[String]): Any = { - + val g: () => Int @cps[Int] = () => 7 - + println(reset(g())) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/function6.scala b/test/files/continuations-run/function6.scala index 1a2792370a..54a6ffcc93 100644 --- a/test/files/continuations-run/function6.scala +++ b/test/files/continuations-run/function6.scala @@ -4,13 +4,13 @@ import scala.util.continuations._ object Test { - + def main(args: Array[String]): Any = { - + val g: PartialFunction[Int, Int @cps[Int]] = { case x => 7 } - + println(reset(g(2))) - + } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/ifelse0.scala b/test/files/continuations-run/ifelse0.scala index e34b86ee84..2facab4b98 100644 --- a/test/files/continuations-run/ifelse0.scala +++ b/test/files/continuations-run/ifelse0.scala @@ -4,15 +4,15 @@ import scala.util.continuations._ object Test { - + def test(x:Int) = if (x <= 7) shift { k: (Int=>Int) => k(k(k(x))) } else shift { k: (Int=>Int) => k(x) } - + def main(args: Array[String]): Any = { println(reset(1 + test(7))) println(reset(1 + test(8))) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/ifelse1.scala b/test/files/continuations-run/ifelse1.scala index 2ccc1ed730..c624b84b75 100644 --- a/test/files/continuations-run/ifelse1.scala +++ b/test/files/continuations-run/ifelse1.scala @@ -4,12 +4,12 @@ import scala.util.continuations._ object Test { - + def test1(x:Int) = if (x <= 7) shift { k: (Int=>Int) => k(k(k(x))) } else x - + def test2(x:Int) = if (x <= 7) x else @@ -21,5 +21,5 @@ object Test { println(reset(1 + test2(7))) println(reset(1 + test2(8))) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/ifelse2.scala b/test/files/continuations-run/ifelse2.scala index 536e350190..506acc4d00 100644 --- a/test/files/continuations-run/ifelse2.scala +++ b/test/files/continuations-run/ifelse2.scala @@ -4,13 +4,13 @@ import scala.util.continuations._ object Test { - + def test(x:Int) = if (x <= 7) shift { k: (Unit=>Unit) => println("abort") } - + def main(args: Array[String]): Any = { println(reset{ test(7); println("alive") }) println(reset{ test(8); println("alive") }) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/ifelse3.scala b/test/files/continuations-run/ifelse3.scala index 5dbd079d1c..54566a421c 100644 --- a/test/files/continuations-run/ifelse3.scala +++ b/test/files/continuations-run/ifelse3.scala @@ -4,18 +4,18 @@ import scala.util.continuations._ object Test { - + def util(x: Boolean) = shift { k: (Boolean=>Int) => k(x) } - + def test(x:Int) = if (util(x <= 7)) x - 1 else x + 1 - - + + def main(args: Array[String]): Any = { println(reset(test(7))) println(reset(test(8))) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/infer1.scala b/test/files/continuations-run/infer1.scala index a6c6c07215..10822508e7 100644 --- a/test/files/continuations-run/infer1.scala +++ b/test/files/continuations-run/infer1.scala @@ -4,9 +4,9 @@ import scala.util.continuations._ object Test { - + def test(x: => Int @cpsParam[String,Int]) = 7 - + def test2() = { val x = shift { k: (Int => String) => 9 } x @@ -14,9 +14,9 @@ object Test { def test3(x: => Int @cpsParam[Int,Int]) = 7 - + def util() = shift { k: (String => String) => "7" } - + def main(args: Array[String]): Any = { test { shift { k: (Int => String) => 9 } } test { shift { k: (Int => String) => 9 }; 2 } @@ -29,5 +29,5 @@ object Test { test3 { { test3(0); 2 } } } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/match0.scala b/test/files/continuations-run/match0.scala index bd36238d7f..b65d343c07 100644 --- a/test/files/continuations-run/match0.scala +++ b/test/files/continuations-run/match0.scala @@ -4,15 +4,15 @@ import scala.util.continuations._ object Test { - + def test(x:Int) = x match { case 7 => shift { k: (Int=>Int) => k(k(k(x))) } case 8 => shift { k: (Int=>Int) => k(x) } } - + def main(args: Array[String]): Any = { println(reset(1 + test(7))) println(reset(1 + test(8))) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/match1.scala b/test/files/continuations-run/match1.scala index ea4e219666..20671f26ba 100644 --- a/test/files/continuations-run/match1.scala +++ b/test/files/continuations-run/match1.scala @@ -4,15 +4,15 @@ import scala.util.continuations._ object Test { - + def test(x:Int) = x match { case 7 => shift { k: (Int=>Int) => k(k(k(x))) } case _ => x } - + def main(args: Array[String]): Any = { println(reset(1 + test(7))) println(reset(1 + test(8))) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/match2.scala b/test/files/continuations-run/match2.scala index 8d4f04870f..8b0fb946df 100644 --- a/test/files/continuations-run/match2.scala +++ b/test/files/continuations-run/match2.scala @@ -4,23 +4,23 @@ import scala.util.continuations._ object Test { - + def test1() = { val (a, b) = shift { k: (((String,String)) => String) => k("A","B") } b } case class Elem[T,U](a: T, b: U) - + def test2() = { val Elem(a,b) = shift { k: (Elem[String,String] => String) => k(Elem("A","B")) } b } - + def main(args: Array[String]): Any = { println(reset(test1())) println(reset(test2())) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/t3199.scala b/test/files/continuations-run/t3199.scala index 3fd2f1959a..7b54793e05 100644 --- a/test/files/continuations-run/t3199.scala +++ b/test/files/continuations-run/t3199.scala @@ -1,20 +1,20 @@ -import _root_.scala.collection.Seq -import _root_.scala.util.control.Exception -import _root_.scala.util.continuations._ - -object Test { - - trait AbstractResource[+R <: AnyRef] { - def reflect[B] : R @cpsParam[B,Either[Throwable, B]] = shift(acquireFor) - def acquireFor[B](f : R => B) : Either[Throwable, B] = { - import Exception._ - catching(List(classOf[Throwable]) : _*) either (f(null.asInstanceOf[R])) - } - } - - def main(args: Array[String]) : Unit = { - val x = new AbstractResource[String] { } - val result = x.acquireFor( x => 7 ) - println(result) - } - } +import _root_.scala.collection.Seq +import _root_.scala.util.control.Exception +import _root_.scala.util.continuations._ + +object Test { + + trait AbstractResource[+R <: AnyRef] { + def reflect[B] : R @cpsParam[B,Either[Throwable, B]] = shift(acquireFor) + def acquireFor[B](f : R => B) : Either[Throwable, B] = { + import Exception._ + catching(List(classOf[Throwable]) : _*) either (f(null.asInstanceOf[R])) + } + } + + def main(args: Array[String]) : Unit = { + val x = new AbstractResource[String] { } + val result = x.acquireFor( x => 7 ) + println(result) + } + } diff --git a/test/files/continuations-run/t3199b.scala b/test/files/continuations-run/t3199b.scala index 950c584153..2122c963ac 100644 --- a/test/files/continuations-run/t3199b.scala +++ b/test/files/continuations-run/t3199b.scala @@ -1,11 +1,11 @@ object Test { - + def test() = { java.util.Arrays.asList(Array(1,2,3):_*) } - + def main(args: Array[String]) = { println(test()) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/t3223.scala b/test/files/continuations-run/t3223.scala index 4e510178e6..efed1ff581 100644 --- a/test/files/continuations-run/t3223.scala +++ b/test/files/continuations-run/t3223.scala @@ -2,16 +2,16 @@ import scala.util.continuations._ object Test { def foo(x:Int) = { - try { + try { throw new Exception shiftUnit0[Int,Int](7) } catch { - case ex => + case ex => val g = (a:Int)=>a 9 } } - + def main(args: Array[String]) { println(reset(foo(0))) } diff --git a/test/files/continuations-run/t3225.scala b/test/files/continuations-run/t3225.scala index ecfde279cf..5b6259c43f 100644 --- a/test/files/continuations-run/t3225.scala +++ b/test/files/continuations-run/t3225.scala @@ -31,10 +31,10 @@ object Test { } def blaX[A] = shift { k:(Bla=>A) => k(new Bla) } - + def fooX[A] = blaX[A].x def fooY[A] = blaX[A].y[A] - + def testPoly() = { println(reset(blaX[Bla]).x) println(reset(blaX[Int].x)) @@ -52,5 +52,5 @@ object Test { testMono() testPoly() } - + } diff --git a/test/files/continuations-run/trycatch0.scala b/test/files/continuations-run/trycatch0.scala index 74a078b5ef..ec39863f3f 100644 --- a/test/files/continuations-run/trycatch0.scala +++ b/test/files/continuations-run/trycatch0.scala @@ -3,7 +3,7 @@ import scala.util.continuations._ object Test { - + def foo = try { shift((k: Int=>Int) => k(7)) } catch { @@ -17,7 +17,7 @@ object Test { case ex => shiftUnit0[Int,Int](9) } - + def main(args: Array[String]): Unit = { println(reset { foo + 3 }) println(reset { bar + 3 }) diff --git a/test/files/continuations-run/trycatch1.scala b/test/files/continuations-run/trycatch1.scala index ade13794e3..10dfd30bb2 100644 --- a/test/files/continuations-run/trycatch1.scala +++ b/test/files/continuations-run/trycatch1.scala @@ -5,7 +5,7 @@ import scala.util.continuations._ object Test { def fatal: Int = throw new Exception() - + def foo1 = try { fatal shift((k: Int=>Int) => k(7)) diff --git a/test/files/continuations-run/while0.scala b/test/files/continuations-run/while0.scala index 9735f9d2c3..46005a4a77 100644 --- a/test/files/continuations-run/while0.scala +++ b/test/files/continuations-run/while0.scala @@ -4,9 +4,9 @@ import scala.util.continuations._ object Test { - + def foo(): Int @cps[Unit] = 2 - + def test(): Unit @cps[Unit] = { var x = 0 while (x < 9000) { // pick number large enough to require tail-call opt @@ -18,5 +18,5 @@ object Test { def main(args: Array[String]): Any = { reset(test()) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/while1.scala b/test/files/continuations-run/while1.scala index fb5dc0079a..fd41ab36ee 100644 --- a/test/files/continuations-run/while1.scala +++ b/test/files/continuations-run/while1.scala @@ -4,9 +4,9 @@ import scala.util.continuations._ object Test { - + def foo(): Int @cps[Unit] = shift { k => println("up"); k(2); println("down") } - + def test(): Unit @cps[Unit] = { var x = 0 while (x < 9) { @@ -18,5 +18,5 @@ object Test { def main(args: Array[String]): Any = { reset(test()) } - + }
\ No newline at end of file diff --git a/test/files/continuations-run/while2.scala b/test/files/continuations-run/while2.scala index f36288929e..63f9cb99fe 100644 --- a/test/files/continuations-run/while2.scala +++ b/test/files/continuations-run/while2.scala @@ -4,10 +4,10 @@ import scala.util.continuations._ object Test { - + def foo1(): Int @cps[Unit] = 2 def foo2(): Int @cps[Unit] = shift { k => println("up"); k(2); println("down") } - + def test(): Unit @cps[Unit] = { var x = 0 while (x < 9000) { // pick number large enough to require tail-call opt @@ -19,5 +19,5 @@ object Test { def main(args: Array[String]): Any = { reset(test()) } - + }
\ No newline at end of file diff --git a/test/files/jvm/actor-sync-send-timeout.scala b/test/files/jvm/actor-sync-send-timeout.scala index ed330900b2..21e624bd0a 100644 --- a/test/files/jvm/actor-sync-send-timeout.scala +++ b/test/files/jvm/actor-sync-send-timeout.scala @@ -2,9 +2,9 @@ import scala.actors.Actor /* This test is a regression test for SI-4759. */ -object Test { +object Test { val Runs = 5 - + def main(args: Array[String]) = { var i = 0 while (i < Runs) { diff --git a/test/files/jvm/actor-uncaught-exception.scala b/test/files/jvm/actor-uncaught-exception.scala index 882362272d..5ae66de640 100644 --- a/test/files/jvm/actor-uncaught-exception.scala +++ b/test/files/jvm/actor-uncaught-exception.scala @@ -4,60 +4,60 @@ class MyException(msg: String) extends Exception(msg) { override def fillInStackTrace() = this } -object Test { +object Test { - case object StartError extends Actor { - def act() { + case object StartError extends Actor { + def act() { try { - throw new MyException("I don't want to run!") + throw new MyException("I don't want to run!") } catch { case e: Throwable if (!e.isInstanceOf[scala.util.control.ControlThrowable] && !e.isInstanceOf[MyException]) => e.printStackTrace() } - } - } + } + } - case object MessageError extends Actor { - def act() { + case object MessageError extends Actor { + def act() { try { - react { - case _ => throw new MyException("No message for me!") - } + react { + case _ => throw new MyException("No message for me!") + } } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => e.printStackTrace() } - } - } + } + } - case object Supervisor extends Actor { - def act() { + case object Supervisor extends Actor { + def act() { try { - trapExit = true + trapExit = true link(StartError) link(MessageError) - StartError.start() + StartError.start() MessageError.start() - Actor.loop { - react { + Actor.loop { + react { case Exit(actor, reason) => println("OK") if (actor == StartError) MessageError ! 'ping else exit() - } - } + } + } } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => e.printStackTrace() } - } - } + } + } - def main(args: Array[String]) { - Supervisor.start() - } -} + def main(args: Array[String]) { + Supervisor.start() + } +} diff --git a/test/files/jvm/actor-uncaught-exception2.scala b/test/files/jvm/actor-uncaught-exception2.scala index 36b6f0c52e..0364cbeb03 100644 --- a/test/files/jvm/actor-uncaught-exception2.scala +++ b/test/files/jvm/actor-uncaught-exception2.scala @@ -4,60 +4,60 @@ class MyException(msg: String) extends Exception(msg) { override def fillInStackTrace() = this } -object Test { +object Test { - case object StartError extends Actor { - def act() { + case object StartError extends Actor { + def act() { try { - throw new MyException("I don't want to run!") + throw new MyException("I don't want to run!") } catch { case e: Throwable if (!e.isInstanceOf[scala.util.control.ControlThrowable] && !e.isInstanceOf[MyException]) => e.printStackTrace() } - } - } + } + } - case object MessageError extends Actor { - def act() { + case object MessageError extends Actor { + def act() { try { - react { - case _ => throw new MyException("No message for me!") - } + react { + case _ => throw new MyException("No message for me!") + } } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => e.printStackTrace() } - } - } + } + } - case object Supervisor extends Actor { - def act() { + case object Supervisor extends Actor { + def act() { try { - trapExit = true + trapExit = true link(StartError) link(MessageError) - StartError.start() + StartError.start() MessageError.start() - Actor.loop { - react { + Actor.loop { + react { case Exit(actor, reason) => println(reason) if (actor == StartError) MessageError ! 'ping else exit() - } - } + } + } } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => e.printStackTrace() } - } - } + } + } - def main(args: Array[String]) { - Supervisor.start() - } -} + def main(args: Array[String]) { + Supervisor.start() + } +} diff --git a/test/files/jvm/bigints.scala b/test/files/jvm/bigints.scala index f4ca2d17a3..7a797879f2 100644 --- a/test/files/jvm/bigints.scala +++ b/test/files/jvm/bigints.scala @@ -1,5 +1,5 @@ //############################################################################ -// BigInt, BigDecimal +// BigInt, BigDecimal //############################################################################ //############################################################################ diff --git a/test/files/jvm/bug560bis.scala b/test/files/jvm/bug560bis.scala index 13bf4b1ae0..b04303c8a0 100644 --- a/test/files/jvm/bug560bis.scala +++ b/test/files/jvm/bug560bis.scala @@ -5,14 +5,14 @@ import scala.xml._; case Seq(a,b,c,d @ _*) => Console.println("cool!") case _ => Console.println("bah") } - def foo(args: List[String]) = + def foo(args: List[String]) = Elem(null,"bla",Null, TopScope, (args map {x => Text(x)}):_*) match { case Elem(_,_,_,_,Text("1"),_*) => Console.println("cool!") case _ => Console.println("bah") } - + def main(args: Array[String]) = { val li = List("1","2","3","4") bar(li) diff --git a/test/files/jvm/console.scala b/test/files/jvm/console.scala index b07765675c..6d1aa1eafd 100644 --- a/test/files/jvm/console.scala +++ b/test/files/jvm/console.scala @@ -9,6 +9,6 @@ object Test extends Application { flush println("..") println(1) - printf("Argument nr. %d has value %1.2f\n", + printf("Argument nr. %d has value %1.2f\n", 1, 10.0/3) } diff --git a/test/files/jvm/deprecation/Test_1.scala b/test/files/jvm/deprecation/Test_1.scala index 92173f94e2..5bd87b89c4 100644 --- a/test/files/jvm/deprecation/Test_1.scala +++ b/test/files/jvm/deprecation/Test_1.scala @@ -7,7 +7,7 @@ class Test { val i = new d.Inner val w = i.buz() } - + @deprecated("no longer!") class Inner { @deprecated("uncool") def f: Int = 1 @deprecated("this one as well!") var g = -1 diff --git a/test/files/jvm/future-termination.scala b/test/files/jvm/future-termination.scala index 688de60c3b..f51642cb7a 100644 --- a/test/files/jvm/future-termination.scala +++ b/test/files/jvm/future-termination.scala @@ -1,19 +1,19 @@ -import scala.actors.Futures - -/* Test that unevaluated futures do not prevent program termination */ - -object Test { - def main(args: Array[String]) { +import scala.actors.Futures + +/* Test that unevaluated futures do not prevent program termination */ + +object Test { + def main(args: Array[String]) { try { - val meaningOfLife = Futures.future { - Thread.sleep(5000) // pretend this is a harder problem than it is - println("I have the answer!") - 42 - } - println("I can't wait that long, bye.") + val meaningOfLife = Futures.future { + Thread.sleep(5000) // pretend this is a harder problem than it is + println("I have the answer!") + 42 + } + println("I can't wait that long, bye.") } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => e.printStackTrace() } - } + } } diff --git a/test/files/jvm/inner.scala b/test/files/jvm/inner.scala index d0d2226de6..156d9e69a8 100644 --- a/test/files/jvm/inner.scala +++ b/test/files/jvm/inner.scala @@ -14,7 +14,7 @@ class A { trait Itf { def method1(x: Int): Int - + trait Itf2 extends Itf { def method2: Unit } diff --git a/test/files/jvm/interpreter.scala b/test/files/jvm/interpreter.scala index 2c2756828b..1437b97f79 100644 --- a/test/files/jvm/interpreter.scala +++ b/test/files/jvm/interpreter.scala @@ -30,7 +30,7 @@ val atom = new scala.xml.Atom() class S(override val toString : String) val fish = new S("fish") // Test that arrays pretty print nicely. -val arr = Array("What's", "up", "doc?") +val arr = Array("What's", "up", "doc?") // Test that arrays pretty print nicely, even when we give them type Any val arrInt : Any = Array(1,2,3) // Test that nested arrays are pretty-printed correctly @@ -133,8 +133,8 @@ there // defining and using quoted names should work (ticket #323) -def `match` = 1 -val x = `match` +def `match` = 1 +val x = `match` // multiple classes defined on one line sealed class Exp; class Fact extends Exp; class Term extends Exp @@ -151,8 +151,8 @@ def f(e: Exp) = e match {{ // non-exhaustive warning here var seenNL = false def write(cbuf: Array[Char], off: Int, len: Int) { - if (seenNL) - writer.write(cbuf, off, len) + if (seenNL) + writer.write(cbuf, off, len) else { val slice : Array[Char] = cbuf.slice(off, off+len) val i = slice.indexOf('\n') diff --git a/test/files/jvm/methvsfield.java b/test/files/jvm/methvsfield.java index dadc98669a..c1b2b87b48 100644 --- a/test/files/jvm/methvsfield.java +++ b/test/files/jvm/methvsfield.java @@ -1,11 +1,11 @@ // This should be compiled with javac and saved // in ../lib/methvsfield.jar . -class MethVsField +class MethVsField { int three = 3; - int three() - { + int three() + { return 3; } } diff --git a/test/files/jvm/protectedacc.scala b/test/files/jvm/protectedacc.scala index c3b07a0a7e..525725f2b9 100644 --- a/test/files/jvm/protectedacc.scala +++ b/test/files/jvm/protectedacc.scala @@ -16,7 +16,7 @@ object Test { val ji = new p.b.JavaInteraction(Array('a', 'b', 'c')); (new ji.Inner).m; - + (new p.b.OuterObj.Inner).m } } @@ -36,13 +36,13 @@ package p { def getA: this.type = this; } - + /** Test type members */ trait HighlighterXXX { type Node; protected def highlight(node : Node) : Unit; } - + /** Test type parameters */ abstract class PolyA[a] { protected def m(x: a): Unit; @@ -119,22 +119,22 @@ package p { val inc = meth2(1)_; Console.println("100 = " + inc("10")); - + getA.x; } } } - + trait ScalaAutoEditXXX extends HighlighterXXX { - trait NodeImpl { + trait NodeImpl { def self : Node; highlight(self); } } - + abstract class X[T] extends PolyA[T] { - trait Inner extends B { + trait Inner extends B { def self: T; def self2: Node; def getB: Inner; diff --git a/test/files/jvm/serialization.scala b/test/files/jvm/serialization.scala index b8656888c6..336e339fd4 100644 --- a/test/files/jvm/serialization.scala +++ b/test/files/jvm/serialization.scala @@ -536,7 +536,7 @@ object Test6 { // they would be null (they are treated as lazy vals) @serializable class Outer { - + @serializable object Inner } @@ -553,7 +553,7 @@ object Test7 { case e: Exception => println("Error in Test7: " + e) } - + } //############################################################################ diff --git a/test/files/jvm/stringbuilder.scala b/test/files/jvm/stringbuilder.scala index c86a8a7713..8f73cfab7b 100644 --- a/test/files/jvm/stringbuilder.scala +++ b/test/files/jvm/stringbuilder.scala @@ -35,7 +35,7 @@ Scala is a general purpose programming language designed to express common progr val j3 = j2; j3 setCharAt (0, j3 charAt 2) val s3 = s2; s3(0) = s3(2) //println("j3="+j3+", s3="+s3)//debug - assertEquals("s3.toString equals j3.toString", true, s3.toString equals j3.toString) + assertEquals("s3.toString equals j3.toString", true, s3.toString equals j3.toString) } } diff --git a/test/files/jvm/t1461.scala b/test/files/jvm/t1461.scala index f0e3cea6cd..a963ec6a12 100644 --- a/test/files/jvm/t1461.scala +++ b/test/files/jvm/t1461.scala @@ -3,7 +3,7 @@ object Test { def main(args: Array[String]) { val jl = classOf[Foo].getMethod("jl", classOf[Baz[_]]) jl.getGenericParameterTypes // works fine - + val l = classOf[Foo].getMethod("l", classOf[Baz[_]]) // By debugger inspection l.signature is (Ltest/Baz<J>;)V l.getGenericParameterTypes // throws GenericSignatureFormatError diff --git a/test/files/jvm/t1464/MyTrait.scala b/test/files/jvm/t1464/MyTrait.scala index 0b8ccc412b..014ddf86c3 100644 --- a/test/files/jvm/t1464/MyTrait.scala +++ b/test/files/jvm/t1464/MyTrait.scala @@ -1,5 +1,5 @@ trait MyTrait { type K def findChildByClass[T <: K with MyTrait]: Unit - + } diff --git a/test/files/jvm/t1600.scala b/test/files/jvm/t1600.scala index 79391b7e76..7e23687425 100644 --- a/test/files/jvm/t1600.scala +++ b/test/files/jvm/t1600.scala @@ -4,23 +4,23 @@ * changes on deserialization. */ object Test { - + import collection._ def main(args: Array[String]) { for (i <- Seq(0, 1, 2, 10, 100)) { def entries = (0 until i).map(i => (new Foo, i)).toList def elements = entries.map(_._1) - + val maps = Seq[Map[Foo, Int]](new mutable.HashMap, new mutable.LinkedHashMap, immutable.HashMap.empty).map(_ ++ entries) test[Map[Foo, Int]](maps, entries.size, assertMap _) - + val sets = Seq[Set[Foo]](new mutable.HashSet, new mutable.LinkedHashSet, immutable.HashSet.empty).map(_ ++ elements) test[Set[Foo]](sets, entries.size, assertSet _) } } - + private def test[A <: AnyRef](collections: Seq[A], expectedSize: Int, assertFunction: (A, Int) => Unit) { for (collection <- collections) { assertFunction(collection, expectedSize) @@ -28,19 +28,19 @@ object Test { val bytes = toBytes(collection) Foo.hashCodeModifier = 1 val deserializedCollection = toObject[A](bytes) - + assertFunction(deserializedCollection, expectedSize) assert(deserializedCollection.getClass == collection.getClass, "collection class should remain the same after deserialization ("+deserializedCollection.getClass+" != "+collection.getClass+")") Foo.hashCodeModifier = 0 } } - + private def toObject[A](bytes: Array[Byte]): A = { val in = new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(bytes)) in.readObject.asInstanceOf[A] } - + private def toBytes(o: AnyRef): Array[Byte] = { val bos = new java.io.ByteArrayOutputStream val out = new java.io.ObjectOutputStream(bos) @@ -48,7 +48,7 @@ object Test { out.close bos.toByteArray } - + private def assertMap[A, B](map: Map[A, B], expectedSize: Int) { assert(expectedSize == map.size, "expected map size: " + expectedSize + ", actual size: " + map.size) map.foreach { case (k, v) => @@ -56,19 +56,19 @@ object Test { assert(map(k) == v) } } - + private def assertSet[A](set: Set[A], expectedSize: Int) { assert(expectedSize == set.size, "expected set size: " + expectedSize + ", actual size: " + set.size) set.foreach { e => assert(set.contains(e), "contains should return true for element in the set, element: " + e) } } - + object Foo { - /* Used to simulate a hashCode change caused by deserializing an instance with an + /* Used to simulate a hashCode change caused by deserializing an instance with an * identity-based hashCode in another JVM. */ var hashCodeModifier = 0 } - + @serializable class Foo { override def hashCode = System.identityHashCode(this) + Foo.hashCodeModifier diff --git a/test/files/jvm/t2570/Test.scala b/test/files/jvm/t2570/Test.scala index d7b7632e22..7944aedae6 100644 --- a/test/files/jvm/t2570/Test.scala +++ b/test/files/jvm/t2570/Test.scala @@ -1,3 +1,3 @@ class Test2 extends Test1[Test3[Test4]] class Test4 -object Test extends Application {}
\ No newline at end of file +object Test extends Application {}
\ No newline at end of file diff --git a/test/files/jvm/throws-annot.scala b/test/files/jvm/throws-annot.scala index 90b58b9976..b679b6c121 100644 --- a/test/files/jvm/throws-annot.scala +++ b/test/files/jvm/throws-annot.scala @@ -43,24 +43,24 @@ object TestThrows { /** Test the top-level mirror that is has the annotations. */ object TL { - + @throws(classOf[IOException]) def read(): Int = 0 - + @throws(classOf[ClassCastException]) @throws(classOf[IOException]) def readWith2(): Int = 0 - + @throws(classOf[IOException]) @Deprecated @throws(classOf[NullPointerException]) def readMixed(): Int = 0 - + @Deprecated @throws(classOf[IOException]) @throws(classOf[NullPointerException]) def readMixed2(): Int = 0 - + @Deprecated def readNoEx(): Int = 0 } diff --git a/test/files/jvm/typerep.scala b/test/files/jvm/typerep.scala index 51a848240a..cb00da4c29 100644 --- a/test/files/jvm/typerep.scala +++ b/test/files/jvm/typerep.scala @@ -109,7 +109,7 @@ object testFuncs { def f5(f: Int => Int, x: Int) = f(x) println(getType(f5 _)) println(getType(f5(f1, 1))) - println + println } class Foo { diff --git a/test/files/jvm/unittest_io.scala b/test/files/jvm/unittest_io.scala index fd5889cb86..42c793f35a 100644 --- a/test/files/jvm/unittest_io.scala +++ b/test/files/jvm/unittest_io.scala @@ -8,8 +8,8 @@ object Test extends TestConsoleMain { ) class ReadlinesTest extends TestCase("scala.io.Source method getLines()") { - - val src = Source.fromString(""" + + val src = Source.fromString(""" This is a file it is split on several lines. diff --git a/test/files/jvm/unittest_xml.scala b/test/files/jvm/unittest_xml.scala index 1569bb13af..1c36e746ea 100644 --- a/test/files/jvm/unittest_xml.scala +++ b/test/files/jvm/unittest_xml.scala @@ -12,7 +12,7 @@ object Test { val hasBar = new HasKeyValue("bar") x match { //case Node("foo", hasBar(z), _*) => z - case Node("foo", md, _*) if !hasBar.unapplySeq(md).isEmpty => + case Node("foo", md, _*) if !hasBar.unapplySeq(md).isEmpty => md("bar")(0) case _ => new Atom(3) } @@ -22,8 +22,8 @@ object Test { var x: MetaData = Null var s: NamespaceBinding = TopScope - // testing method def apply(uri:String, scp:NamespaceBinding, k:String): Seq[Node] - // def apply(k:String): Seq[Node] + // testing method def apply(uri:String, scp:NamespaceBinding, k:String): Seq[Node] + // def apply(k:String): Seq[Node] assertEquals("absent element (prefixed) 1", null, x("za://foo.com", s, "bar" )) assertEquals("absent element (unprefix) 1", null, x("bar")) @@ -51,8 +51,8 @@ object Test { val z = <foo bar="gar"/> val z2 = <foo/> - assertEquals("attribute extractor 1", Text("gar"), domatch(z)) - assertEquals("attribute extractor 2", new Atom(3), domatch(z2)) + assertEquals("attribute extractor 1", Text("gar"), domatch(z)) + assertEquals("attribute extractor 2", new Atom(3), domatch(z2)) } } @@ -61,14 +61,14 @@ object Test { def runTest() = { assertTrue(Utility.isNameStart('b')) assertFalse(Utility.isNameStart(':')) - - + + val x = <foo> <toomuchws/> </foo> val y = xml.Utility.trim(x) - + assertEquals("trim 1 ", 1, y match { case <foo><toomuchws/></foo> => 1 }) val x2 = <foo> @@ -100,7 +100,7 @@ object Test { def main(args:Array[String]) = { val ts = new TestSuite( new MetaDataTest, - new UtilityTest + new UtilityTest ) val tr = new TestResult() ts.run(tr) diff --git a/test/files/jvm/xml01.scala b/test/files/jvm/xml01.scala index 56e1c4ef96..574d20720f 100644 --- a/test/files/jvm/xml01.scala +++ b/test/files/jvm/xml01.scala @@ -1,7 +1,7 @@ import java.io.StringReader import org.xml.sax.InputSource -import scala.testing.SUnit._ +import scala.testing.SUnit._ import scala.util.logging._ import scala.xml._ @@ -18,7 +18,7 @@ object Test extends Application with Assert { val c = new Node { def label = "hello" - override def hashCode() = + override def hashCode() = Utility.hashCode(prefix, label, attributes.hashCode(), scope.hashCode(), child); def child = Elem(null, "world", e, sc); //def attributes = e; @@ -37,8 +37,8 @@ object Test extends Application with Assert { val x2p = XML.load(i) assertEqualsXML(x2p, Elem(null, "book" , e, sc, - Elem(null, "author", e, sc,Text("Peter Buneman")), - Elem(null, "author", e, sc,Text("Dan Suciu")), + Elem(null, "author", e, sc,Text("Peter Buneman")), + Elem(null, "author", e, sc,Text("Dan Suciu")), Elem(null, "title" , e, sc,Text("Data on ze web")))); val xmlFile2 = "<bib><book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book><book><author>John Mitchell</author><title>Foundations of Programming Languages</title></book></bib>"; @@ -61,13 +61,13 @@ object Test extends Application with Assert { }; */ - assertSameElementsXML( - parsedxml2 \ "_" , - + assertSameElementsXML( + parsedxml2 \ "_" , + List( Elem(null,"book", e, sc, - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), + Elem(null,"author", e, sc, Text("Peter Buneman")), + Elem(null,"author", e, sc, Text("Dan Suciu")), Elem(null,"title" , e, sc, Text("Data on ze web"))), Elem(null,"book",e,sc, Elem(null,"author",e,sc,Text("John Mitchell")), @@ -75,13 +75,13 @@ object Test extends Application with Assert { ); assertEquals( (parsedxml2 \ "author").length, 0 ); - assertSameElementsXML( - parsedxml2 \ "book", - + assertSameElementsXML( + parsedxml2 \ "book", + List( Elem(null,"book",e,sc, - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), + Elem(null,"author", e, sc, Text("Peter Buneman")), + Elem(null,"author", e, sc, Text("Dan Suciu")), Elem(null,"title" , e, sc, Text("Data on ze web"))), Elem(null,"book",e,sc, Elem(null,"author", e, sc, Text("John Mitchell")), @@ -89,49 +89,49 @@ object Test extends Application with Assert { ) ); - assertSameElementsXML( + assertSameElementsXML( parsedxml2 \ "_" \ "_", List( - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), + Elem(null,"author", e, sc, Text("Peter Buneman")), + Elem(null,"author", e, sc, Text("Dan Suciu")), Elem(null,"title" , e, sc, Text("Data on ze web")), Elem(null,"author", e, sc, Text("John Mitchell")), Elem(null,"title" , e, sc, Text("Foundations of Programming Languages")) ) ); - assertSameElementsXML( + assertSameElementsXML( parsedxml2 \ "_" \ "author", List( - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), + Elem(null,"author", e, sc, Text("Peter Buneman")), + Elem(null,"author", e, sc, Text("Dan Suciu")), Elem(null,"author", e, sc, Text("John Mitchell")) ) - + ); assertSameElementsXML( (parsedxml2 \ "_" \ "_" \ "author"), List() ); Console.println("xpath \\\\ DESCENDANTS"); - assertSameElementsXML( + assertSameElementsXML( parsedxml2 \\ "author", List( - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), + Elem(null,"author", e, sc, Text("Peter Buneman")), + Elem(null,"author", e, sc, Text("Dan Suciu")), Elem(null,"author", e, sc, Text("John Mitchell")) ) ); - assertSameElementsXML( + assertSameElementsXML( parsedxml2 \\ "title", @@ -145,22 +145,22 @@ object Test extends Application with Assert { (parsedxml2 \\ "book" ){ n:Node => (n \ "title") xml_== "Data on ze web" } ); - assertEqualsXML( + assertEqualsXML( (new NodeSeq { val theSeq = List( parsedxml2 ) }) \\ "_", List( Elem(null,"bib",e,sc, Elem(null,"book",e,sc, - Elem(null, "author", e, sc, Text("Peter Buneman")), - Elem(null, "author", e, sc, Text("Dan Suciu")), + Elem(null, "author", e, sc, Text("Peter Buneman")), + Elem(null, "author", e, sc, Text("Dan Suciu")), Elem(null, "title" , e, sc, Text("Data on ze web"))), Elem(null,"book",e,sc, Elem(null,"author",e,sc,Text("John Mitchell")), Elem(null,"title",e,sc,Text("Foundations of Programming Languages")))), Elem(null,"book",e,sc, - Elem(null,"author",e,sc,Text("Peter Buneman")), - Elem(null,"author",e,sc,Text("Dan Suciu")), + Elem(null,"author",e,sc,Text("Peter Buneman")), + Elem(null,"author",e,sc,Text("Dan Suciu")), Elem(null,"title",e,sc,Text("Data on ze web"))), Elem(null,"author",e,sc,Text("Peter Buneman")), //Text("Peter Buneman"), @@ -196,7 +196,7 @@ object Test extends Application with Assert { // val uup = <xml:unparsed>&<<>""^%@$!#</xml:unparsed> // assertTrue(uup == "&<<>\"\"^%@$!#") - // test unicode escapes backslash u + // test unicode escapes backslash u println("attribute value normalization") val xmlAttrValueNorm = "<personne id='p0003' nom='Şahingöz' />"; diff --git a/test/files/jvm/xml02.scala b/test/files/jvm/xml02.scala index 11f77cc90f..02aabf3678 100644 --- a/test/files/jvm/xml02.scala +++ b/test/files/jvm/xml02.scala @@ -31,26 +31,26 @@ object Test extends TestConsoleMain { val z = ax \ "@{the namespace from outer space}foo" assertTrue("@six", (ax \ "@{the namespace from outer space}foo") xml_== "baz") assertTrue("@eight", (cx \ "@{the namespace from outer space}foo") xml_== "baz") - + try { ax \ "@" assertTrue("wrong1", false) } catch { - case _: IllegalArgumentException => + case _: IllegalArgumentException => } try { ax \ "@{" assertTrue("wrong2", false) } catch { - case _: IllegalArgumentException => + case _: IllegalArgumentException => } try { ax \ "@{}" assertTrue("wrong3", false) } catch { - case _: IllegalArgumentException => + case _: IllegalArgumentException => } - + } } diff --git a/test/files/jvm/xmlattr.scala b/test/files/jvm/xmlattr.scala index a947adf231..4dda84373a 100644 --- a/test/files/jvm/xmlattr.scala +++ b/test/files/jvm/xmlattr.scala @@ -3,7 +3,7 @@ import xml.{NodeSeq, Null, Text, UnprefixedAttribute} object Test extends TestConsoleMain { def suite = new TestSuite(UnprefixedAttributeTest, AttributeWithOptionTest) - + object UnprefixedAttributeTest extends TestCase("UnprefixedAttribute") with Assert { override def runTest { var x = new UnprefixedAttribute("foo","bar", Null) @@ -13,13 +13,13 @@ object Test extends TestConsoleMain { assertEquals(Text("bar"), x("foo")) assertEquals(None, x.get("no_foo")) assertEquals(null, x("no_foo")) - + val y = x.remove("foo") assertEquals(Null, y) val z = new UnprefixedAttribute("foo", null:NodeSeq, x) assertEquals(None, z.get("foo")) - + var appended = x append x append x append x var len = 0; while (appended ne Null) { appended = appended.next diff --git a/test/files/jvm/xmlmore.scala b/test/files/jvm/xmlmore.scala index 0ba60b05b7..9f37ad61e6 100644 --- a/test/files/jvm/xmlmore.scala +++ b/test/files/jvm/xmlmore.scala @@ -11,7 +11,7 @@ Ours is the portal of hope, come as you are." Mevlana Celaleddin Rumi]]> val nazim = <foo>{myBreak}</foo> // shows use of unparsed - + Console println com Console println pi Console println crz // this guy will escaped, and rightly so diff --git a/test/files/jvm/xmlpull.scala b/test/files/jvm/xmlpull.scala index d2bb72a071..9ba7d4cf02 100644 --- a/test/files/jvm/xmlpull.scala +++ b/test/files/jvm/xmlpull.scala @@ -5,7 +5,7 @@ import scala.io.Source object Test { val src = Source.fromString("<hello><world/>!</hello>") - + def main(args: Array[String]) { var er = new XMLEventReader(src) er.next match { @@ -28,4 +28,4 @@ object Test { //println("6") } } - + diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala index 6e711a0f86..3508070007 100644 --- a/test/files/jvm/xmlstuff.scala +++ b/test/files/jvm/xmlstuff.scala @@ -59,7 +59,7 @@ passed ok <baz bazValue="8"/> <bar value="5" gi='go'/> </foo>; - + val pelems_1 = for( val x <- p \ "bar"; val y <- p \ "baz" ) yield { Text(x.attributes("value").toString + y.attributes("bazValue").toString+ "!") }; @@ -68,14 +68,14 @@ passed ok assertEqualsXML(p \\ "@bazValue", Text("8")) - val books = + val books = <bks> <book><title>Blabla</title></book> <book><title>Blubabla</title></book> <book><title>Baaaaaaalabla</title></book> </bks>; - val reviews = + val reviews = <reviews> <entry><title>Blabla</title> <remarks> @@ -105,32 +105,32 @@ passed ok )); // example - println( + println( for (t @ <book><title>Blabla</title></book> <- new NodeSeq { val theSeq = books.child }.toList) yield t ); -val phoneBook = +val phoneBook = <phonebook> <descr> - This is the <b>phonebook</b> of the + This is the <b>phonebook</b> of the <a href="http://acme.org">ACME</a> corporation. </descr> <entry> - <name>John</name> + <name>John</name> <phone where="work"> +41 21 693 68 67</phone> <phone where="mobile">+41 79 602 23 23</phone> </entry> </phonebook>; -val addrBook = +val addrBook = <addrbook> <descr> - This is the <b>addressbook</b> of the + This is the <b>addressbook</b> of the <a href="http://acme.org">ACME</a> corporation. </descr> <entry> - <name>John</name> + <name>John</name> <street> Elm Street</street> <city>Dolphin City</city> </entry> @@ -146,7 +146,7 @@ val addrBook = </result> )); - + /* namespaces */ // begin tmp println("namespaces") @@ -168,9 +168,9 @@ val addrBook = import scala.xml.dtd.ELEMENTS import scala.xml.dtd.ContentModel._ vtor.setContentModel( - ELEMENTS( + ELEMENTS( Sequ( - Letter(ElemName("bar")), + Letter(ElemName("bar")), Star(Letter(ElemName("baz"))) ))); } @@ -178,11 +178,11 @@ val addrBook = { import scala.xml.dtd.MIXED import scala.xml.dtd.ContentModel._ - + vtor.setContentModel( MIXED( - Alt(Letter(ElemName("bar")), - Letter(ElemName("baz")), + Alt(Letter(ElemName("bar")), + Letter(ElemName("baz")), Letter(ElemName("bal"))))); } @@ -194,20 +194,20 @@ val addrBook = vtor.setContentModel(null) vtor.setMetaData(List()) assertEquals(vtor( <foo bar="hello"/> ), false) - - { - import scala.xml.dtd._ + + { + import scala.xml.dtd._ vtor setMetaData List(AttrDecl("bar", "CDATA", IMPLIED)) } assertEquals(vtor(<foo href="http://foo.com" bar="hello"/>), false) assertEquals(vtor(<foo bar="hello"/>), true) - { + { import scala.xml.dtd._ vtor.setMetaData(List(AttrDecl("bar","CDATA",REQUIRED))) } assertEquals( vtor( <foo href="http://foo.com" /> ), false ) assertEquals( vtor( <foo bar="http://foo.com" /> ), true ) - + } } diff --git a/test/files/neg/accesses.scala b/test/files/neg/accesses.scala index 2a6b45c35b..934e83e705 100644 --- a/test/files/neg/accesses.scala +++ b/test/files/neg/accesses.scala @@ -6,7 +6,7 @@ abstract class A { private[p1] def f4: Unit protected[p1] def f5: Unit } - + abstract class OK1 extends A { private[p1] def f2: Unit protected[p2] def f3: Unit diff --git a/test/files/neg/array-not-seq.scala b/test/files/neg/array-not-seq.scala index 07a2898d88..5f367bdd85 100644 --- a/test/files/neg/array-not-seq.scala +++ b/test/files/neg/array-not-seq.scala @@ -9,9 +9,9 @@ object Test { case _: Array[_] => true case _ => false } - + def f4(x: Any) = x.isInstanceOf[Traversable[_]] - + def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match { case (Some(_: Seq[_]), Nil, _) => 1 case (None, List(_: List[_], _), _) => 2 diff --git a/test/files/neg/bug1011.scala b/test/files/neg/bug1011.scala index 7dc3f49469..57a6ad7b45 100644 --- a/test/files/neg/bug1011.scala +++ b/test/files/neg/bug1011.scala @@ -3,7 +3,7 @@ import scala.xml._; abstract class Test { //val entity : String; - def primitiveHeader : NodeSeq = + def primitiveHeader : NodeSeq = Group({ <dl><code>{Text(entity)}</code> <code>{Text(entity)}</code> diff --git a/test/files/neg/bug1112.scala b/test/files/neg/bug1112.scala index 1a88629faf..b2a374c785 100644 --- a/test/files/neg/bug1112.scala +++ b/test/files/neg/bug1112.scala @@ -1,13 +1,13 @@ // checks that error doesn't crash the compiler -// (due to isFunctionType normalizing Type1 to a function type, +// (due to isFunctionType normalizing Type1 to a function type, // but then the code that used that test not using the normalized type for further operations) class Test { type Type1 = () => Unit - + def call(p: Int)(f: => Type1) = { f() } - + def run = { call(0,() => System.out.println("here we are")) } diff --git a/test/files/neg/bug112706A.scala b/test/files/neg/bug112706A.scala index 11304720bc..b7799af96d 100644 --- a/test/files/neg/bug112706A.scala +++ b/test/files/neg/bug112706A.scala @@ -2,7 +2,7 @@ package test; trait Test { def foo(p : List[Tuple2[String,String]]) = { for (t <- p) t._1 match { - case Tuple2(node,_) => + case Tuple2(node,_) => } } } diff --git a/test/files/neg/bug1183.scala b/test/files/neg/bug1183.scala index a845126488..ee9385fc1a 100644 --- a/test/files/neg/bug1183.scala +++ b/test/files/neg/bug1183.scala @@ -13,7 +13,7 @@ object Test extends TestConsoleMain { case class Bar(i:Int) } - + class Test717 extends TestCase("#717 test path of case classes") { val foo1 = new Foo(1) @@ -31,7 +31,7 @@ object Test extends TestConsoleMain { class Baz object Bam object Bar - + def unapply(s : String) : Option[Bar] = Some(new Bar(s)) } diff --git a/test/files/neg/bug1523.scala b/test/files/neg/bug1523.scala index 219fb0c060..b8754f4e15 100644 --- a/test/files/neg/bug1523.scala +++ b/test/files/neg/bug1523.scala @@ -1,5 +1,5 @@ -object test { +object test { def bug(x: Any) = x - + def go() = bug("a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a") } diff --git a/test/files/neg/bug1623.scala b/test/files/neg/bug1623.scala index 1c368e7ef5..d4bd6f4e86 100644 --- a/test/files/neg/bug1623.scala +++ b/test/files/neg/bug1623.scala @@ -1,7 +1,7 @@ package test -trait A -trait B +trait A +trait B class BImpl extends B { this: A => diff --git a/test/files/neg/bug1878.scala b/test/files/neg/bug1878.scala index df0e1b6caf..32d5ce5e0f 100644 --- a/test/files/neg/bug1878.scala +++ b/test/files/neg/bug1878.scala @@ -1,13 +1,13 @@ object Test extends Application { - // illegal + // illegal val err1 = "" match { case Seq(f @ _*, ',') => f } - + // no error val List(List(arg1, _*), _) = List(List(1,2,3), List(4,5,6)) - + // illegal val List(List(_*, arg2), _) = List(List(1,2,3), List(4,5,6)) - + // illegal - bug #1764 null match { case <p> { _* } </p> => diff --git a/test/files/neg/bug2148.scala b/test/files/neg/bug2148.scala index 25788be84a..c0521d9864 100644 --- a/test/files/neg/bug2148.scala +++ b/test/files/neg/bug2148.scala @@ -1,6 +1,6 @@ -class A { +class A { var i = 0 - trait A1 extends A { + trait A1 extends A { i += 1 } } diff --git a/test/files/neg/bug520.scala b/test/files/neg/bug520.scala index 076aca3122..949a509518 100644 --- a/test/files/neg/bug520.scala +++ b/test/files/neg/bug520.scala @@ -4,6 +4,6 @@ object test { assert(keyword != null); } - def verifyKeyword(source : java.io.File, pos : Int) = + def verifyKeyword(source : java.io.File, pos : Int) = verifyKeyword("", source, pos); } diff --git a/test/files/neg/bug558.scala b/test/files/neg/bug558.scala index 58b030347c..4941a06c3b 100644 --- a/test/files/neg/bug558.scala +++ b/test/files/neg/bug558.scala @@ -11,7 +11,7 @@ abstract class NewModel { val parent : SymbolURL; final val top = parent.top; final val source = top.file; - + } abstract class RootURL extends SymbolURL { final val top : RootURL = this; diff --git a/test/files/neg/bug563.scala b/test/files/neg/bug563.scala index 624b83b1fa..3261491dcd 100644 --- a/test/files/neg/bug563.scala +++ b/test/files/neg/bug563.scala @@ -1,6 +1,6 @@ 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 (n <- sn) map(n,ptr => new Cell(ptr.elem)); diff --git a/test/files/neg/bug576.scala b/test/files/neg/bug576.scala index fd83217a45..fa7ee6019f 100644 --- a/test/files/neg/bug576.scala +++ b/test/files/neg/bug576.scala @@ -4,16 +4,16 @@ abstract class BaseListXXX { type Node <: BaseNode; abstract class BaseNode { } -} +} trait PriorityTreeXXX extends BaseListXXX { type Node <: BasicTreeNode; - + trait BasicTreeNode extends BaseNode { - def sibling: Node; + def sibling: Node; def insert(dir : Int, node : Node) = { if (true) sibling.insert(node); //else insert(node); - + } def insert(node : Node) : Unit = {} } diff --git a/test/files/neg/bug588.scala b/test/files/neg/bug588.scala index f30937377e..1bc6d2680f 100644 --- a/test/files/neg/bug588.scala +++ b/test/files/neg/bug588.scala @@ -1,15 +1,15 @@ abstract class Test0 { - def visit(f: Int => Unit): Boolean + def visit(f: Int => Unit): Boolean def visit(f: Int => String): Boolean } trait Test { type TypeA <: TraitA; type TypeB <: TypeA with TraitB; - + def f(node : TypeA) : Unit; def f(brac : TypeB) : Unit; - + trait TraitA; trait TraitB; - + } diff --git a/test/files/neg/bug591.scala b/test/files/neg/bug591.scala index 0f0b02395c..5f2397e6a9 100644 --- a/test/files/neg/bug591.scala +++ b/test/files/neg/bug591.scala @@ -1,17 +1,17 @@ abstract class BaseList { type Node <: BaseNode; - - + + abstract class BaseNode { protected def self : Node; private[BaseList] def self00 = self; def dirty : Unit = {} def replaceWith(node : Node) = {} } - + implicit def baseNode2Node(bnode : BaseNode): Node = bnode.self00; - + } @@ -20,22 +20,22 @@ trait BaseFlow extends BaseList { type Flow <: FlowBase; type Output <: OutputBase; type Input <: InputBase; - + abstract class FlowBase { - + } trait OutputBase extends FlowBase { - + } trait InputBase extends FlowBase { - + } - + trait BFNode extends BaseNode { private var input : Input = _; private var output : Output = _; - + def input_=(in : Input) = {} - + } } diff --git a/test/files/neg/bug608.scala b/test/files/neg/bug608.scala index 34dc4c0352..1f12764dd1 100644 --- a/test/files/neg/bug608.scala +++ b/test/files/neg/bug608.scala @@ -2,7 +2,7 @@ trait CrashDueToTypeError { def id[a](x :a) :a = x trait Bifunctor { - type a; // content + type a; // content type s <: Bifunctor // uncomment this-vvvvvvvvvvvvvvvvvvvvvvvvvvvv, and it compiles diff --git a/test/files/neg/bug692.scala b/test/files/neg/bug692.scala index 24e1d2fea3..f230a6bacf 100644 --- a/test/files/neg/bug692.scala +++ b/test/files/neg/bug692.scala @@ -5,15 +5,15 @@ abstract class test3 { abstract class RefType[C <: AnyRef] extends Type[C]; case class ObjectType() extends RefType[AnyRef]; abstract class ClassType[C <: Z, Z <: AnyRef](zuper : RefType[Z]) extends RefType[C]; - + case class FooType() extends ClassType[Foo,AnyRef](ObjectType()); implicit def typeOfFoo = FooType(); case class BarType[T3 <: Foo](tpeT : RefType[T3]) extends ClassType[Bar[T3],Foo](FooType); - implicit def typeOfBar[T4 <: Foo](implicit elem : RefType[T4]) : RefType[Bar[T4]] = + implicit def typeOfBar[T4 <: Foo](implicit elem : RefType[T4]) : RefType[Bar[T4]] = BarType(elem); - + class Foo[A <: AnyRef]; class Bar[A <: Foo](implicit tpeA : Type[A]) extends Foo; diff --git a/test/files/neg/bug693.scala b/test/files/neg/bug693.scala index 3a9e6247a8..d2074bee38 100644 --- a/test/files/neg/bug693.scala +++ b/test/files/neg/bug693.scala @@ -1,5 +1,5 @@ abstract class test4 { trait Type; val x : Type = null; - val x : Int = 10; + val x : Int = 10; } diff --git a/test/files/neg/bug715.scala b/test/files/neg/bug715.scala index 87b2525a63..a5ccd567f9 100644 --- a/test/files/neg/bug715.scala +++ b/test/files/neg/bug715.scala @@ -1,4 +1,4 @@ -package test; +package test; trait B { type Node <: NodeImpl; trait NodeImpl { diff --git a/test/files/neg/bug783.scala b/test/files/neg/bug783.scala index 3818910b8e..0920089509 100644 --- a/test/files/neg/bug783.scala +++ b/test/files/neg/bug783.scala @@ -18,7 +18,7 @@ object Main extends Application { def globalInit : Global; final def globalInit0 = globalInit.asInstanceOf[global.type]; } - + object global0 extends Global { object analyzer extends Analyzer { type Global = global0.type; diff --git a/test/files/neg/bug798.scala b/test/files/neg/bug798.scala index a2bf66d19b..b4a1939444 100644 --- a/test/files/neg/bug798.scala +++ b/test/files/neg/bug798.scala @@ -4,5 +4,5 @@ trait Test[Bracks <: Bracks] { class C[T] val bracks : Bracks; val singletons = f(bracks); - + } diff --git a/test/files/neg/bug836.scala b/test/files/neg/bug836.scala index 3633b816c6..de23cf5387 100644 --- a/test/files/neg/bug836.scala +++ b/test/files/neg/bug836.scala @@ -10,7 +10,7 @@ abstract class A { } class B extends A { - type MyObj = ObjImpl + type MyObj = ObjImpl val myString: S = "hello" val realString: String = myString // error: type missmatch } diff --git a/test/files/neg/bug856.scala b/test/files/neg/bug856.scala index fea216bfad..e50084b6bd 100644 --- a/test/files/neg/bug856.scala +++ b/test/files/neg/bug856.scala @@ -1,4 +1,4 @@ -trait Complex extends Product2[Double,Double] +trait Complex extends Product2[Double,Double] class ComplexRect(val _1:Double, _2:Double) extends Complex { override def toString = "ComplexRect("+_1+","+_2+")" diff --git a/test/files/neg/bug876.scala b/test/files/neg/bug876.scala index 8a94dd9db5..f5e1f9c663 100644 --- a/test/files/neg/bug876.scala +++ b/test/files/neg/bug876.scala @@ -11,11 +11,11 @@ object AssertionError extends AnyRef with Application class Manager { final class B {} - + val map = new HashMap[A, B] } - - + + def test[T](f: => T) { f } test { diff --git a/test/files/neg/bug877.scala b/test/files/neg/bug877.scala index 5e132a1dd4..8cb98279db 100644 --- a/test/files/neg/bug877.scala +++ b/test/files/neg/bug877.scala @@ -1,3 +1,3 @@ -class A +class A trait Foo extends A(22A, Bug!) {} diff --git a/test/files/neg/bug944.scala b/test/files/neg/bug944.scala index dc80e5f49f..352269a80b 100644 --- a/test/files/neg/bug944.scala +++ b/test/files/neg/bug944.scala @@ -1,6 +1,6 @@ object TooManyArgsFunction { - val f = (a1:Int, a2:Int, a3:Int, a4:Int, a5:Int, a6:Int, a7:Int, a8:Int, - a9:Int, a10:Int, a11:Int, a12:Int, a13:Int, a14:Int, a15:Int, - a16:Int, a17:Int, a18:Int, a19:Int, a20:Int, a21:Int, a22:Int, + val f = (a1:Int, a2:Int, a3:Int, a4:Int, a5:Int, a6:Int, a7:Int, a8:Int, + a9:Int, a10:Int, a11:Int, a12:Int, a13:Int, a14:Int, a15:Int, + a16:Int, a17:Int, a18:Int, a19:Int, a20:Int, a21:Int, a22:Int, a23:Int) => 1 } diff --git a/test/files/neg/checksensible.scala b/test/files/neg/checksensible.scala index 092c08592f..06452e5674 100644 --- a/test/files/neg/checksensible.scala +++ b/test/files/neg/checksensible.scala @@ -18,7 +18,7 @@ class Test { def main(args: Array[String]) = { val in = new java.io.FileInputStream(args(0)) - var c = 0 + var c = 0 while ((c = in.read) != -1) print(c.toChar) diff --git a/test/files/neg/forward.scala b/test/files/neg/forward.scala index d5c0851f09..3774fa838f 100644 --- a/test/files/neg/forward.scala +++ b/test/files/neg/forward.scala @@ -5,20 +5,20 @@ object Test { { def f: Int = x; val x: Int = f; - } + } { def f: Int = g; val x: Int = f; def g: Int = x; - } + } { def f: Int = g; var x: Int = f; def g: Int = x; - } + } { def f: Int = g; Console.println("foo"); def g: Int = f; - } + } } diff --git a/test/files/neg/gadts1.scala b/test/files/neg/gadts1.scala index 07200ff7aa..1b455f408d 100644 --- a/test/files/neg/gadts1.scala +++ b/test/files/neg/gadts1.scala @@ -10,9 +10,9 @@ case class NumTerm(val n: Number) extends Term[Number] class IntTerm(n: Int) extends NumTerm(n) with Term[Int] -def f[a](t:Term[a], c:Cell[a]): Unit = - t match { - case NumTerm(n) => c.x = Double(1.0) +def f[a](t:Term[a], c:Cell[a]): Unit = + t match { + case NumTerm(n) => c.x = Double(1.0) } diff --git a/test/files/neg/implicits.scala b/test/files/neg/implicits.scala index 846591e22d..e908fb03e8 100644 --- a/test/files/neg/implicits.scala +++ b/test/files/neg/implicits.scala @@ -4,14 +4,14 @@ class Super object Super { implicit def pos2int(p: Pos): Int = 0 -} +} object Sub extends Super { class Plus(x: Any) { def +(y: String): String = x.toString + y } implicit def any2plus(x: Any): Plus = new Plus(x) -} +} object Test { import Super._ @@ -33,7 +33,7 @@ object test2 { val set = HEmpty + 3 + "3" implicit def select[T](t: HSome[T,_]) = t.head implicit def selectTail[L](t: HSome[_,L]) = t.tail - + def foo(x: Int) = 3 foo(set) } @@ -55,4 +55,4 @@ class Mxml { } -} +} diff --git a/test/files/neg/java-access-neg/J.java b/test/files/neg/java-access-neg/J.java index b6bc3363a1..4f2024673c 100644 --- a/test/files/neg/java-access-neg/J.java +++ b/test/files/neg/java-access-neg/J.java @@ -4,11 +4,11 @@ public abstract class J { public J() { } J(int x1) { } protected J(int x1, int x2) { } - + abstract void packageAbstract(); protected abstract void protectedAbstract(); public abstract void publicAbstract(); - + void packageConcrete() { return; } protected void protectedConcrete() { return; } public void publicConcrete() { return; } diff --git a/test/files/neg/java-access-neg/S2.scala b/test/files/neg/java-access-neg/S2.scala index b082bb7174..dd0af8d39d 100644 --- a/test/files/neg/java-access-neg/S2.scala +++ b/test/files/neg/java-access-neg/S2.scala @@ -12,7 +12,7 @@ class S1 extends J { override private[b] def packageAbstract() = () // fail override protected[b] def protectedAbstract() = () override def publicAbstract() = () - + override private[b] def packageConcrete() = () // fail override protected[b] def protectedConcrete() = () override def publicConcrete() = () @@ -32,7 +32,7 @@ class S3 extends J { protected[b] def packageAbstract() = () // fail protected[b] def protectedAbstract() = () def publicAbstract() = () - + override protected[b] def packageConcrete() = () // fail override protected[b] def protectedConcrete() = () override def publicConcrete() = () @@ -43,7 +43,7 @@ class S4 extends J { private[a] def packageAbstract() = () // fail protected[a] def protectedAbstract() = () def publicAbstract() = () - + override private[a] def packageConcrete() = () // fail override protected[a] def protectedConcrete() = () override def publicConcrete() = () @@ -54,7 +54,7 @@ class S5 extends J { def packageAbstract() = () // fail def protectedAbstract() = () def publicAbstract() = () - + override def packageConcrete() = () // fail override def protectedConcrete() = () override def publicConcrete() = () diff --git a/test/files/neg/lazy-override.scala b/test/files/neg/lazy-override.scala index f41d7f038b..a0f6e3bd73 100644 --- a/test/files/neg/lazy-override.scala +++ b/test/files/neg/lazy-override.scala @@ -5,7 +5,7 @@ lazy val y: Int = { print("/*A.y*/"); 2 } } - + class B extends A { // lazy overrides strict val override lazy val x: Int = { print("/*B.x*/"); 3 } diff --git a/test/files/neg/lazyvals.scala b/test/files/neg/lazyvals.scala index f92534f506..bbc4fe114a 100644 --- a/test/files/neg/lazyvals.scala +++ b/test/files/neg/lazyvals.scala @@ -1,7 +1,7 @@ /** Test which should fail compilation */ class Lazy { - + // no abstract lazy values lazy val t: Int @@ -31,7 +31,7 @@ object T2 { lazy val y: Int = { print("/*A.y*/"); 2 } } - + class B extends A { // lazy overrides strict val override lazy val x: Int = { print("/*B.x*/"); 3 } diff --git a/test/files/neg/lubs.scala b/test/files/neg/lubs.scala index 3524fa4d87..639117f7bf 100644 --- a/test/files/neg/lubs.scala +++ b/test/files/neg/lubs.scala @@ -18,7 +18,7 @@ object test2 { class D extends A { type T = D } def f = if (1 == 2) new C else new D - + val x1: A { type T } = f val x2: A { type T >: Null <: A } = f val x3: A { type T >: Null <: A { type T >: Null <: A } } = f diff --git a/test/files/neg/migration28.scala b/test/files/neg/migration28.scala index 090b32d690..346c1a6448 100644 --- a/test/files/neg/migration28.scala +++ b/test/files/neg/migration28.scala @@ -1,12 +1,12 @@ object Test { import scala.collection.mutable._ - + val s = new Stack[Int] s ++= List(1,2,3) s map (_ + 1) s foreach (_ => ()) - + def main(args: Array[String]): Unit = { - + } } diff --git a/test/files/neg/null-unsoundness.scala b/test/files/neg/null-unsoundness.scala index 15dedfbb97..f4ba859bc0 100644 --- a/test/files/neg/null-unsoundness.scala +++ b/test/files/neg/null-unsoundness.scala @@ -12,4 +12,4 @@ object Test extends A with Application { type A = C y = 42 } - + diff --git a/test/files/neg/overload-msg.scala b/test/files/neg/overload-msg.scala index 8715c156a2..896722262d 100644 --- a/test/files/neg/overload-msg.scala +++ b/test/files/neg/overload-msg.scala @@ -1,4 +1,4 @@ // type parameter shadows actual type, massive overload error confuses. -class A(x: Int) { +class A(x: Int) { def f[Int](y: Int) = x + y } diff --git a/test/files/neg/pat_unreachable.scala b/test/files/neg/pat_unreachable.scala index 04a7fa580c..527731e58a 100644 --- a/test/files/neg/pat_unreachable.scala +++ b/test/files/neg/pat_unreachable.scala @@ -8,7 +8,7 @@ object Test extends Application { case Seq(x, y, _*) => x::y::Nil case Seq(x, y) => List(x, y) } - + def not_unreachable(xs:Seq[Char]) = xs match { case Seq(x, y, _*) => x::y::Nil case Seq(x) => List(x) diff --git a/test/files/neg/patmat-type-check.scala b/test/files/neg/patmat-type-check.scala index c6c689b256..f6658b0187 100644 --- a/test/files/neg/patmat-type-check.scala +++ b/test/files/neg/patmat-type-check.scala @@ -1,15 +1,15 @@ object Test { def s1 = "bob".toList match { case Seq('b', 'o', 'b') => true } // list ok - + // not final, allowed - class Bop + class Bop def s2(x: Bop) = x match { case Seq('b', 'o', 'b') => true } - + // covariance, allowed final class Bop4[+T] def s3[T](x: Bop4[T]) = x match { case Seq('b', 'o', 'b') => true } - + // contravariance, allowed final class Bop5[T, U, -V] def s4[T1, T2](x: Bop5[_, T1, T2]) = x match { case Seq('b', 'o', 'b') => true } @@ -21,7 +21,7 @@ object Test // final, no type parameters, should be disallowed final class Bop2 def f3(x: Bop2) = x match { case Seq('b', 'o', 'b') => true } // fail - + // final, invariant type parameter, should be disallowed final class Bop3[T] def f4[T](x: Bop3[T]) = x match { case Seq('b', 'o', 'b') => true } // fail diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala index b172df8740..81812d6fd3 100644 --- a/test/files/neg/patmatexhaust.scala +++ b/test/files/neg/patmatexhaust.scala @@ -22,14 +22,14 @@ class TestSealedExhaustive { // compile only def ma3(x:Mult) = (x,x) match { // not exhaustive case (Kult(_), Qult()) => // Kult missing - //case Pair(Kult(_), Kult(_)) => + //case Pair(Kult(_), Kult(_)) => case (Qult(), Kult(_)) => // Qult missing - //case Pair(Qult(), Qult()) => + //case Pair(Qult(), Qult()) => } def ma3u(x:Mult) = ((x,x) : @unchecked) match { // not exhaustive, but not checked! - case (Kult(_), Qult()) => - case (Qult(), Kult(_)) => + case (Kult(_), Qult()) => + case (Qult(), Kult(_)) => } sealed abstract class Deep @@ -37,22 +37,22 @@ class TestSealedExhaustive { // compile only case object Ga extends Deep sealed class Gp extends Deep case object Gu extends Gp - + def zma3(x:Deep) = x match { // exhaustive! case _ => } def zma4(x:Deep) = x match { // exhaustive! - case Ga => + case Ga => case _ => } def ma4(x:Deep) = x match { // missing cases: Gu, Gp - case Ga => + case Ga => } def ma5(x:Deep) = x match { // Gp case Gu => - case _ if 1 == 0 => + case _ if 1 == 0 => case Ga => } @@ -65,7 +65,7 @@ class TestSealedExhaustive { // compile only case 1::2::Nil => case _ => } - + sealed class B case class B1() extends B case object B2 extends B @@ -85,11 +85,11 @@ class TestSealedExhaustive { // compile only def ma10(x: C) = x match { // exhaustive case C4() => true case C2 | C6 => true - } - + } + def redundant = 1 match { // include this otherwise script won't test this in files/neg case 1 => - case 1 => + case 1 => } } diff --git a/test/files/neg/patternalts.scala b/test/files/neg/patternalts.scala index 539df43201..56b682b0ec 100644 --- a/test/files/neg/patternalts.scala +++ b/test/files/neg/patternalts.scala @@ -1,5 +1,5 @@ object Test { List(1) match { case List(x) | List() => Console.println(x) - } + } } diff --git a/test/files/neg/saito.scala b/test/files/neg/saito.scala index b4fcd598e4..bfabb4edf4 100644 --- a/test/files/neg/saito.scala +++ b/test/files/neg/saito.scala @@ -2,13 +2,13 @@ class B {} class A { self: B => def m(): B = { this - } + } } object Exec{ def main(args: Array[String]): Unit = { val a: A = new A; // should not be allowed - val b: B = a.m(); + val b: B = a.m(); } } diff --git a/test/files/neg/sensitive.scala b/test/files/neg/sensitive.scala index f435a385e1..fa1b940844 100644 --- a/test/files/neg/sensitive.scala +++ b/test/files/neg/sensitive.scala @@ -5,8 +5,8 @@ object Admin extends Certificate; class SecurityViolationException extends Exception object Sensitive { - def makeSensitive(credentials: Certificate): Sensitive = - if (credentials == Admin) new Sensitive() + def makeSensitive(credentials: Certificate): Sensitive = + if (credentials == Admin) new Sensitive() else throw new SecurityViolationException } class Sensitive private () { @@ -16,4 +16,4 @@ object Attacker { val x = Sensitive.makeSensitive(null) val y = new Sensitive() } - + diff --git a/test/files/neg/spec-overrides.scala b/test/files/neg/spec-overrides.scala index 8c92b8ee25..27d39ad4a4 100644 --- a/test/files/neg/spec-overrides.scala +++ b/test/files/neg/spec-overrides.scala @@ -15,7 +15,7 @@ class FX2 extends P { object Test extends Application { val fx = new FX val p = new P - + println(fx.a(3)) println((fx: P).a(3)) println((fx: P).a(3.0)) diff --git a/test/files/neg/structural.scala b/test/files/neg/structural.scala index 181a32654e..de7b6efed2 100644 --- a/test/files/neg/structural.scala +++ b/test/files/neg/structural.scala @@ -1,54 +1,54 @@ object Test extends Application { - + def f(x: { type D; def m: D }): Null = null - + class Tata - + abstract class Toto[A <: Object] { type B <: Object - + def f1[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: A): Object; val x: A }) = x.m[Tata](x.x) //fail def f2[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: B): Object; val x: B }) = x.m[Tata](x.x) //fail def f3[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: C): Object; val x: C }) = x.m[Tata](x.x) //fail def f4[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: D): Object; val x: D }) = x.m[Tata](x.x) //fail def f5[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: E): Object; val x: Tata }) = x.m[Tata](x.x) //suceed - + def f6[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: Object): A }) = x.m[Tata](null) //suceed def f7[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: Object): B }) = x.m[Tata](null) //suceed def f8[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: Object): C }) = x.m[Tata](null) //suceed def f9[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: Object): D }) = x.m[Tata](null) //fail def f0[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: Object): E }) = x.m[Tata](null) //suceed - + } - + val tata = new Tata val toto = new Toto[Tata] { type B = Tata } - + //toto.f1[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Tata): Object = null; val x = tata }) //toto.f2[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Tata): Object = null; val x = tata }) //toto.f3[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Tata): Object = null; val x = tata }) //toto.f4[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: D): Object = null; val x = tata }) toto.f5[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: E): Object = null; val x: Test.Tata = tata }) - + toto.f6[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Object): Tata = null }) toto.f7[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Object): Tata = null }) toto.f8[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Object): Tata = null }) //toto.f9[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Object): D = null }) toto.f0[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Object): E = null }) - + /* Bug #1246 */ type Summable[T] = { def +(v : T) : T } def sum[T <: Summable[T]](xs : List[T]) = xs.reduceLeft[T](_ + _) - + /* Bug #1004 & #967 */ type S1 = { def f(p: this.type): Unit } val s1 = new { def f(p: this.type): Unit = () } - + type S2 = { type T; def f(p: T): Unit } //val s2: S2 = new { type T = A; def f(p: T): Unit = () } - + def s3[U >: Null <: Object](p: { def f(p: U): Unit; def u: U }) = () - + } diff --git a/test/files/neg/switch.scala b/test/files/neg/switch.scala index da7c867ba0..a3dfd869d6 100644 --- a/test/files/neg/switch.scala +++ b/test/files/neg/switch.scala @@ -16,44 +16,44 @@ object Main { case 'f' | 'g' => true case _ => false } - + def succ2(c: Char) = (c: @switch) match { case 'A' | 'B' | 'C' => true case Other.C2 => true case Other.C4 => true case _ => false } - + // has a guard def fail1(c: Char) = (c: @switch) match { case 'A' | 'B' | 'C' => true case x if x == 'A' => true case _ => false } - + // throwing in @unchecked on the next two to make sure // multiple annotations are processed correctly - + // thinks a val in an object is constant... so naive def fail2(c: Char) = (c: @switch @unchecked) match { case 'A' => true case Other.C1 => true case _ => false } - + // more naivete def fail3(c: Char) = (c: @unchecked @switch) match { case 'A' => true case Other.C3 => true case _ => false } - + // guard case done correctly def succ3(c: Char) = (c: @switch) match { case 'A' | 'B' | 'C' => true case x => x == 'A' } - + // some ints just to mix it up a bit def succ4(x: Int, y: Int) = ((x+y): @switch) match { case 1 => 5 @@ -62,5 +62,5 @@ object Main { case 4 => 50 case 5|6|7|8 => 100 case _ => -1 - } + } } diff --git a/test/files/neg/t0117.scala b/test/files/neg/t0117.scala index dd200b1cf9..81167205a7 100644 --- a/test/files/neg/t0117.scala +++ b/test/files/neg/t0117.scala @@ -3,4 +3,4 @@ trait B extends A { println(super[A].a) } object Test extends Application { new B {} } - + diff --git a/test/files/neg/t0152.scala b/test/files/neg/t0152.scala index eef69bf767..8b2cae685f 100644 --- a/test/files/neg/t0152.scala +++ b/test/files/neg/t0152.scala @@ -8,6 +8,6 @@ trait PlusOne extends Value[Int] { object Test extends Application { object boom extends Value[java.lang.String]("foo") with PlusOne - + println(boom.value) // class cast exception! } diff --git a/test/files/neg/t0218.scala b/test/files/neg/t0218.scala index 319be82a7a..3d1f52e39a 100644 --- a/test/files/neg/t0218.scala +++ b/test/files/neg/t0218.scala @@ -1,4 +1,4 @@ -trait APQ { +trait APQ { class Placement { } @@ -7,6 +7,6 @@ trait APQ { type PP = P def pq(numQueens: Int, numRows: Int) : List[Placement] = { - List(new PP) + List(new PP) } } diff --git a/test/files/neg/t0503.scala b/test/files/neg/t0503.scala index 322e1ad132..a9b5dcb1dd 100644 --- a/test/files/neg/t0503.scala +++ b/test/files/neg/t0503.scala @@ -1,3 +1,3 @@ val x = new { } with { } -trait A +trait A val y = new { } with A diff --git a/test/files/neg/t0764.scala b/test/files/neg/t0764.scala index daeeb21d91..9aebe04b79 100644 --- a/test/files/neg/t0764.scala +++ b/test/files/neg/t0764.scala @@ -9,6 +9,6 @@ trait Node extends NotNull { outer => class Main[NextType <: Node](value: Node { type T = NextType }) extends Top[Node { type T = NextType }] { - + new Main[AType]( (value: AType).prepend ) } diff --git a/test/files/neg/t1477.scala b/test/files/neg/t1477.scala index 0cc0cd5f7a..3ecd275a55 100644 --- a/test/files/neg/t1477.scala +++ b/test/files/neg/t1477.scala @@ -8,7 +8,7 @@ object Test extends Application { type V <: D val y: V#T = new B { } } - + trait Middle extends C { type V <: (D with U) } diff --git a/test/files/neg/t1705.scala b/test/files/neg/t1705.scala index fabdca0ec6..bf1fcea815 100644 --- a/test/files/neg/t1705.scala +++ b/test/files/neg/t1705.scala @@ -17,7 +17,7 @@ object crashing { } } } -/* +/* Infinite loop in Typer.addLocals. Printing all calls to it: diff --git a/test/files/neg/t2421b.scala b/test/files/neg/t2421b.scala index d8159a8c37..a8d22f285e 100644 --- a/test/files/neg/t2421b.scala +++ b/test/files/neg/t2421b.scala @@ -12,6 +12,6 @@ object Test { f } -/* bug: +/* bug: error: type arguments [Test2.A] do not conform to method b's type parameter bounds [X <: Test2.B] */
\ No newline at end of file diff --git a/test/files/neg/t2641.scala b/test/files/neg/t2641.scala index 5529035f79..68a4ca35b2 100644 --- a/test/files/neg/t2641.scala +++ b/test/files/neg/t2641.scala @@ -8,7 +8,7 @@ abstract class ManagedSeqStrict[+A] with GenericTraversableTemplate[A, ManagedSeqStrict] { override def companion: GenericCompanion[ManagedSeqStrict] = null - + override def foreach[U](f: A => U): Unit = null } @@ -18,9 +18,9 @@ trait ManagedSeq[+A, +Coll] with TraversableView[A, ManagedSeqStrict[A]] with TraversableViewLike[A, ManagedSeqStrict[A], ManagedSeq[A]] { self => - + override def underlying = throw new Exception("no underlying") - + //trait Transformed[+B] extends ManagedSeq[B] with super.Transformed[B] trait Transformed[+B] extends ManagedSeq[B, Coll] with super.Transformed[B] diff --git a/test/files/neg/t2870.scala b/test/files/neg/t2870.scala index 4de19242e3..59fba3e76d 100755 --- a/test/files/neg/t2870.scala +++ b/test/files/neg/t2870.scala @@ -1,9 +1,9 @@ class Jars(jar: Jar) -object Jars { +object Jars { import scala.util.Properties.javaClassPath - val scala = fromClasspathString(javaClassPath) - + val scala = fromClasspathString(javaClassPath) + def fromClasspathString(s: String): Jars = null } diff --git a/test/files/neg/t2918.scala b/test/files/neg/t2918.scala index ff2be39ae0..03477ccfbf 100755 --- a/test/files/neg/t2918.scala +++ b/test/files/neg/t2918.scala @@ -1,3 +1,3 @@ object Test { - def g[X, A[X] <: A[X]](x: A[X]) = x + def g[X, A[X] <: A[X]](x: A[X]) = x } diff --git a/test/files/neg/t3015.scala b/test/files/neg/t3015.scala index 0bd53e7a03..a23e96776d 100644 --- a/test/files/neg/t3015.scala +++ b/test/files/neg/t3015.scala @@ -4,5 +4,5 @@ class UnApp[P] { object Test extends Application { val b: UnApp[_] = new UnApp[String] - val b(foo) = "foo" + val b(foo) = "foo" } diff --git a/test/files/neg/t3118.scala b/test/files/neg/t3118.scala index 9be24c1ed4..75f3b8f50c 100644 --- a/test/files/neg/t3118.scala +++ b/test/files/neg/t3118.scala @@ -1,8 +1,8 @@ class O1 { private[this] case class C() - + val x = new O1 - + println(x.C()) // should not be accessible println(new x.C) // is correctly not accessible } diff --git a/test/files/neg/t3224.scala b/test/files/neg/t3224.scala index 0e24baf28a..6b6ed95bcf 100755 --- a/test/files/neg/t3224.scala +++ b/test/files/neg/t3224.scala @@ -1,16 +1,16 @@ object Texts{ - def textL[T](list: List[T]) = { - list match{ - case List() => "Empty" - case List(_) => "One" + def textL[T](list: List[T]) = { + list match{ + case List() => "Empty" + case List(_) => "One" case List(_*) => "Many" } } - def textA[T](array: Array[T]) = { - array match{ - case Array() => "Empty" - case Array(_) => "One" + def textA[T](array: Array[T]) = { + array match{ + case Array() => "Empty" + case Array(_) => "One" case Array(_*) => "Many" } } @@ -23,7 +23,7 @@ object Test extends Application { array.toList } - + println(Texts textL List()); println(Texts textL List(1)); println(Texts textL List(1, 1)); println(Texts textL Array()); println(Texts textL Array(1)); println(Texts textL Array(1, 1)) diff --git a/test/files/neg/t3399.scala b/test/files/neg/t3399.scala index 3edaa0724f..b1fe4e5ee2 100644 --- a/test/files/neg/t3399.scala +++ b/test/files/neg/t3399.scala @@ -10,7 +10,7 @@ object Nats { type FoldR[Init <: Type, Type, F <: Fold[Nat, Type]] = F#Apply[Succ[N], N#FoldR[Init, Type, F]] } - + type Add[A <: Nat, B <: Nat] = A#FoldR[B, Nat, Inc] trait Fold[-Elem, Value] { type Apply[N <: Elem, Acc <: Value] <: Value @@ -18,7 +18,7 @@ object Nats { type Inc = Fold[Any, Nat] { type Apply[N <: Any, Acc <: Nat] = Succ[Acc] } - + type _1 = Succ[_0] implicitly[ Add[_1, _1] =:= _1] }
\ No newline at end of file diff --git a/test/files/neg/t3453.scala b/test/files/neg/t3453.scala index 090b777151..0f1c6e0282 100644 --- a/test/files/neg/t3453.scala +++ b/test/files/neg/t3453.scala @@ -25,7 +25,7 @@ object O { class T2a { import O._ - + def x: B = { val aToB = 3 // ok: doesn't compile, because aToB method requires 'T.this.' prefix @@ -39,7 +39,7 @@ class T2a { class T2b { import O.aToB - + def x: B = { val aToB = 3 // ok: doesn't compile, because aToB method requires 'T.this.' prefix @@ -53,7 +53,7 @@ class T2b { class T3 { implicit def aToB(a: A): B = new B - + def x: B = { val aToB = 3 // ok: doesn't compile, because aToB method requires 'T.this.' prefix diff --git a/test/files/neg/t3507.scala b/test/files/neg/t3507.scala index 9a8c7c5462..32688d3934 100644 --- a/test/files/neg/t3507.scala +++ b/test/files/neg/t3507.scala @@ -8,7 +8,7 @@ class A { object Test { var a: A = new A // mutable val c /*: object _1.b.c forSome { val _1: A } */ = a.m // widening using existential - + def mani[T: Manifest](x: T) = () mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier // --> _1 is not in scope here diff --git a/test/files/neg/t3757/B.scala b/test/files/neg/t3757/B.scala index 7c78fb634e..68766a9f6e 100644 --- a/test/files/neg/t3757/B.scala +++ b/test/files/neg/t3757/B.scala @@ -1,5 +1,5 @@ package b -class B extends a.A { +class B extends a.A { override def foo = "B" }
\ No newline at end of file diff --git a/test/files/neg/t3776.scala b/test/files/neg/t3776.scala index 6e368165aa..454f914316 100644 --- a/test/files/neg/t3776.scala +++ b/test/files/neg/t3776.scala @@ -5,6 +5,6 @@ object MyParser extends RegexParsers with PackratParsers { object Test { class ParsedAs(a: String) (implicit pattern: MyParser.Parser[_]) { - def parsedAs[T](v: T) = MyParser.parse(pattern, a).get someOperation v + def parsedAs[T](v: T) = MyParser.parse(pattern, a).get someOperation v } } diff --git a/test/files/neg/tailrec.scala b/test/files/neg/tailrec.scala index a77f439cfe..6d836df0e3 100644 --- a/test/files/neg/tailrec.scala +++ b/test/files/neg/tailrec.scala @@ -9,21 +9,21 @@ object Winners { @tailrec def loopsucc1(x: Int): Int = loopsucc1(x - 1) @tailrec def loopsucc2[T](x: Int): Int = loopsucc2[T](x - 1) - + def ding { object dong { @tailrec def loopsucc3(x: Int): Int = loopsucc3(x) } () } - + def inner(q: Int) = { @tailrec def loopsucc4(x: Int): Int = loopsucc4(x + 1) - + loopsucc4(q) } - + object innerBob { @tailrec def loopsucc5(x: Int): Int = loopsucc5(x) } @@ -45,19 +45,19 @@ object Failures { else n * facfail(n - 1) } -class Failures { +class Failures { // not private, not final @tailrec def fail1(x: Int): Int = fail1(x) - + // a typical between-chair-and-keyboard error @tailrec final def fail2[T](xs: List[T]): List[T] = xs match { case Nil => Nil case x :: xs => x :: fail2[T](xs) } - + // unsafe @tailrec final def fail3[T](x: Int): Int = fail3(x - 1) - + // unsafe class Tom[T](x: Int) { @tailrec final def fail4[U](other: Tom[U], x: Int): Int = other.fail4[U](other, x - 1) diff --git a/test/files/neg/tcpoly_infer_ticket1162.scala b/test/files/neg/tcpoly_infer_ticket1162.scala index 0552b42a22..b88bd358d9 100644 --- a/test/files/neg/tcpoly_infer_ticket1162.scala +++ b/test/files/neg/tcpoly_infer_ticket1162.scala @@ -1,8 +1,8 @@ object Test { - trait Expression[A,B] + trait Expression[A,B] case class Lift[A,B,F[_]]() extends Expression[F[A],F[B]] - + def simplify[A,B]: Expression[A,B] = Lift[A,B]() } diff --git a/test/files/neg/tcpoly_ticket2101.scala b/test/files/neg/tcpoly_ticket2101.scala index 68f061ce70..3af07acfac 100644 --- a/test/files/neg/tcpoly_ticket2101.scala +++ b/test/files/neg/tcpoly_ticket2101.scala @@ -4,10 +4,10 @@ class T2[X] extends T[T2, X] // ill-typed // Forall Y. T2[Y] <: T[T2, X] // debugging before fix: -// def isSubType0 --> +// def isSubType0 --> // case (PolyType(tparams1, res1), PolyType(tparams2, res2)) => println("<:<PT: "+((tparams1, res1), (tparams2, res2))) //@MDEBUG // (tparams1.length == tparams2.length && -// List.forall2(tparams1, tparams2) +// List.forall2(tparams1, tparams2) // ((p1, p2) => p2.info.substSym(tparams2, tparams1) <:< p1.info) && // res1 <:< res2.substSym(tparams2, tparams1)) @@ -22,7 +22,7 @@ class T2[X] extends T[T2, X] // ill-typed // (tparams1.length == tparams2.length && // { // val tpsFresh = cloneSymbols(tparams1) // @M cloneSymbols(tparams2) should be equivalent -- TODO: check -// List.forall2(tparams1, tparams2) +// List.forall2(tparams1, tparams2) // ((p1, p2) => p2.info.substSym(tparams2, tpsFresh) <:< p1.info.substSym(tparams1, tpsFresh)) && -// res1.substSym(tparams1, tpsFresh) <:< res2.substSym(tparams2, tpsFresh) +// res1.substSym(tparams1, tpsFresh) <:< res2.substSym(tparams2, tpsFresh) // }) diff --git a/test/files/neg/tcpoly_typealias.scala b/test/files/neg/tcpoly_typealias.scala index 6c7f80cc0b..96e9349298 100644 --- a/test/files/neg/tcpoly_typealias.scala +++ b/test/files/neg/tcpoly_typealias.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/files/neg/tcpoly_variance_enforce.scala b/test/files/neg/tcpoly_variance_enforce.scala index f3962d6757..417fc5470a 100644 --- a/test/files/neg/tcpoly_variance_enforce.scala +++ b/test/files/neg/tcpoly_variance_enforce.scala @@ -6,7 +6,7 @@ trait coll3[m[x]] trait coll4[m[x <: y], y] -class FooInvar[x] +class FooInvar[x] class FooContra[-x] class FooCov[+x] class FooString[+x <: String] @@ -15,15 +15,15 @@ object fcollok extends coll[FooCov] object fcollinv extends coll[FooInvar] // error object fcollcon extends coll[FooContra] // error object fcollwb extends coll[FooString] // error - + object fcoll2ok extends coll2[FooCov] // error object fcoll2inv extends coll2[FooInvar] // error -object fcoll2con extends coll2[FooContra] +object fcoll2con extends coll2[FooContra] object fcoll2wb extends coll2[FooString] // error - -object fcoll3ok extends coll3[FooCov] -object fcoll3inv extends coll3[FooInvar] -object fcoll3con extends coll3[FooContra] + +object fcoll3ok extends coll3[FooCov] +object fcoll3inv extends coll3[FooInvar] +object fcoll3con extends coll3[FooContra] object fcoll3wb extends coll3[FooString] // error object fcoll4ok extends coll4[FooString, String] @@ -33,7 +33,7 @@ object fcoll4_2 extends coll4[FooString, Any] // error object test { var ok: coll[FooCov] = _ - + def x: coll[FooInvar] = error("foo") // error def y: coll[FooContra] = error("foo") // error } diff --git a/test/files/neg/variances.scala b/test/files/neg/variances.scala index 181783f48a..57abba130d 100644 --- a/test/files/neg/variances.scala +++ b/test/files/neg/variances.scala @@ -1,7 +1,7 @@ package test trait Vector[+A] { - def append(x: Vector[A]): Vector[A] + def append(x: Vector[A]): Vector[A] private[this] def append3(x: Vector[A]): Vector[A] = append(x) } @@ -11,8 +11,8 @@ object Covariant { class Foo[+A] { private[this] var a : A = _ def getA : A = a - private[this] def setA(a : A) = this.a = a - + private[this] def setA(a : A) = this.a = a + object Baz extends C[A] trait Convert[B] { def b2a(b : B) : A @@ -22,8 +22,8 @@ object Covariant { class Foo2[+A] { private[this] var a : A = _ def getA : A = a - private[this] def setA(a : A) = this.a = a - + private[this] def setA(a : A) = this.a = a + { trait Convert[B] { def b2a(b : B) : A @@ -35,8 +35,8 @@ object Covariant { class Foo3[+A] { private[this] var a : A = _ def getA : A = a - private[this] def setA(a : A) = this.a = a - + private[this] def setA(a : A) = this.a = a + private[this] trait Convert[B] { def b2a(b : B) : A def doit(b : B) = setA(b2a(b)) diff --git a/test/files/neg/viewtest.scala b/test/files/neg/viewtest.scala index 5e7d624d23..ddb7fa4a3b 100644 --- a/test/files/neg/viewtest.scala +++ b/test/files/neg/viewtest.scala @@ -37,7 +37,7 @@ object O { } } - implicit def view3[a <% Ordered[a]](x: List[a]): Ordered[List[a]] = + implicit def view3[a <% Ordered[a]](x: List[a]): Ordered[List[a]] = new Ordered[List[a]] { def compareTo [b >: List[a] <% Ordered[b]](y: b): Int = y match { case y1: List[a] => compareLists(x, y1) @@ -72,7 +72,7 @@ class Node[a <% Ordered[a]](elem: a, l: Tree[a], r: Tree[a]) extends Tree[a] { if (x == elem) this else if (x < elem) new Node(elem, l insert x, r) else new Node(elem, l, r insert x) - def elements: List[a] = + def elements: List[a] = l.elements ::: List(elem) ::: r.elements } @@ -86,7 +86,7 @@ case class Str(elem: String) extends Ordered[Str] { object Test { import O._ - private def toCharList(s: String): List[Char] = + private def toCharList(s: String): List[Char] = if (s.length() == 0) List() else s.charAt(0) :: toCharList(s.substring(1)) diff --git a/test/files/pos/List1.scala b/test/files/pos/List1.scala index 1321d95c20..9d3a51f4e3 100644 --- a/test/files/pos/List1.scala +++ b/test/files/pos/List1.scala @@ -17,7 +17,7 @@ object lists { def isEmpty = false; def head = x; def tail = xs; - } + } def foo = { val intnil = Nil[Int]; diff --git a/test/files/pos/MailBox.scala b/test/files/pos/MailBox.scala index 67b923ea3e..35b38f4725 100644 --- a/test/files/pos/MailBox.scala +++ b/test/files/pos/MailBox.scala @@ -23,7 +23,7 @@ class MailBox { private val sent = new LinkedList[Any]; private var lastSent = sent; private val receivers = new LinkedList[Receiver]; - private var lastReceiver = receivers; + private var lastReceiver = receivers; def send(msg: Any): Unit = synchronized { var r = receivers; @@ -58,7 +58,7 @@ class MailBox { } f(msg) } - + def receiveWithin[a](msec: Long)(f: PartialFunction[Any, a]): a = { val msg: Any = synchronized { var s = sent; diff --git a/test/files/pos/Transactions.scala b/test/files/pos/Transactions.scala index ed989e178e..9b4388300b 100644 --- a/test/files/pos/Transactions.scala +++ b/test/files/pos/Transactions.scala @@ -28,7 +28,7 @@ class Transaction { var next: Transaction = null def this(hd: Transaction, tl: Transaction) = { this(); this.head = head; this.next = next } - + def makeAbort() = synchronized { while (status != Transaction.Aborted && status != Transaction.Committed) { status = Transaction.Abortable @@ -48,7 +48,7 @@ class Transaction { case ex: AbortException => abort(); None case ex: Throwable => abort(); throw ex } - + } trait Transactional { @@ -58,7 +58,7 @@ trait Transactional { /** copy back snapshot */ def rollBack(): Unit - + var readers: Transaction var writer: Transaction @@ -66,11 +66,11 @@ trait Transactional { if (writer == null) null else if (writer.status == Transaction.Running) writer else { - if (writer.status != Transaction.Committed) rollBack(); - writer = null; - null + if (writer.status != Transaction.Committed) rollBack(); + writer = null; + null } - + def getter(thisTrans: Transaction) { if (writer == thisTrans) return var r = readers @@ -96,7 +96,7 @@ trait Transactional { synchronized { val w = currentWriter() if (w != null) - if (thisTrans.id < w.id) { w.makeAbort(); rollBack() } + if (thisTrans.id < w.id) { w.makeAbort(); rollBack() } else throw new AbortException var r = readers while (r != null && r.head.status != Transaction.Running) { r = r.next; readers = r } @@ -111,4 +111,4 @@ trait Transactional { } } } - + diff --git a/test/files/pos/arrays2.scala b/test/files/pos/arrays2.scala index 795c486e37..2d5409cbb8 100644 --- a/test/files/pos/arrays2.scala +++ b/test/files/pos/arrays2.scala @@ -11,8 +11,8 @@ object arrays2 { // #2422 object arrays4 { - val args = Array[String]("World") - "Hello %1$s".format(args: _*) + val args = Array[String]("World") + "Hello %1$s".format(args: _*) } // #2461 diff --git a/test/files/pos/bug0031.scala b/test/files/pos/bug0031.scala index aa787ca794..ec6eae9282 100644 --- a/test/files/pos/bug0031.scala +++ b/test/files/pos/bug0031.scala @@ -4,7 +4,7 @@ object Main { def ensure(postcondition: a => Boolean): a } - def require[a](precondition: => Boolean)(command: => a): Ensure[a] = + def require[a](precondition: => Boolean)(command: => a): Ensure[a] = if (precondition) new Ensure[a] { def ensure(postcondition: a => Boolean): a = { diff --git a/test/files/pos/bug0066.scala b/test/files/pos/bug0066.scala index 2153264e7a..9317da7165 100644 --- a/test/files/pos/bug0066.scala +++ b/test/files/pos/bug0066.scala @@ -3,5 +3,5 @@ class GBTree[A, B] /*with Map[A, B, GBTree[A,B]]*/ { case class Node[A,B](key:A,value:B,smaller:Node[A,B],bigger:Node[A,B]) extends Tree[A,B]; case class Nil[A,B]() extends Tree[A,B]; - + } diff --git a/test/files/pos/bug0069.scala b/test/files/pos/bug0069.scala index 113820613f..5a8c15cd5a 100644 --- a/test/files/pos/bug0069.scala +++ b/test/files/pos/bug0069.scala @@ -8,4 +8,4 @@ object testCQ { */ } - + diff --git a/test/files/pos/bug0599.scala b/test/files/pos/bug0599.scala index 885159af66..6125b99ce2 100644 --- a/test/files/pos/bug0599.scala +++ b/test/files/pos/bug0599.scala @@ -15,4 +15,4 @@ abstract class FooA { a.xxx; doB.xxx; } - } + } diff --git a/test/files/pos/bug0646.scala b/test/files/pos/bug0646.scala index a56e857223..6146e60020 100644 --- a/test/files/pos/bug0646.scala +++ b/test/files/pos/bug0646.scala @@ -2,7 +2,7 @@ object xfor { import scala.xml.NodeSeq - val books = + val books = <bks> <title>Blabla</title> <title>Blubabla</title> @@ -13,7 +13,7 @@ object xfor { case t @ Seq(<title>Blabla</title>) => t } - //val n: NodeSeq = new NodeSeq { val theSeq = books.child } + //val n: NodeSeq = new NodeSeq { val theSeq = books.child } //n match { // case t @ <title>Blabla</title> => t //} diff --git a/test/files/pos/bug1090.scala b/test/files/pos/bug1090.scala index a9bce90b00..dca762af4f 100644 --- a/test/files/pos/bug1090.scala +++ b/test/files/pos/bug1090.scala @@ -10,7 +10,7 @@ object Test { type Node = Core.this.Node } def f(manager : Manager) = manager.iterator.foreach{ - case node : NodeImpl => + case node : NodeImpl => } } } diff --git a/test/files/pos/bug1123.scala b/test/files/pos/bug1123.scala index 3812fa3eb3..a7b009cbbe 100644 --- a/test/files/pos/bug1123.scala +++ b/test/files/pos/bug1123.scala @@ -7,5 +7,5 @@ object Test { } def f = extraListener.h } - def main(args : Array[String]) : Unit = (new Editor).f + def main(args : Array[String]) : Unit = (new Editor).f } diff --git a/test/files/pos/bug1168.scala b/test/files/pos/bug1168.scala index 58407e328e..ae0ffb3cac 100644 --- a/test/files/pos/bug1168.scala +++ b/test/files/pos/bug1168.scala @@ -1,5 +1,5 @@ object Test extends Application { - + trait SpecialException {} try { diff --git a/test/files/pos/bug1210a.scala b/test/files/pos/bug1210a.scala index b3492f96e4..fbb0a611d6 100644 --- a/test/files/pos/bug1210a.scala +++ b/test/files/pos/bug1210a.scala @@ -1,9 +1,9 @@ // both styles of abstraction should behave the same // related to 1210 because that bug broke the OO version below -trait OO { +trait OO { abstract class Test { self => type T - + val v: Test {type T = self.T} = self.v.v } } diff --git a/test/files/pos/bug122.scala b/test/files/pos/bug122.scala index 630e24ce4a..e3daeef73e 100644 --- a/test/files/pos/bug122.scala +++ b/test/files/pos/bug122.scala @@ -1,4 +1,4 @@ class L { - val List(v:Int, 2) = List(2, v:Int) + val List(v:Int, 2) = List(2, v:Int) val (a:Int, b:Int) = (1, a) } diff --git a/test/files/pos/bug1237.scala b/test/files/pos/bug1237.scala index 7777372138..0d1dd05d50 100644 --- a/test/files/pos/bug1237.scala +++ b/test/files/pos/bug1237.scala @@ -1,11 +1,11 @@ -class HelloWorld { - def main(args: Array[String]) { +class HelloWorld { + def main(args: Array[String]) { object TypeBool; trait Fct { def g(x : Int) = TypeBool // breaks. - + // def g(x : Int) = 3 // fine. } diff --git a/test/files/pos/bug1272.scala b/test/files/pos/bug1272.scala index d86a909ae5..aab1a886c7 100644 --- a/test/files/pos/bug1272.scala +++ b/test/files/pos/bug1272.scala @@ -2,8 +2,8 @@ object ImplicitTest { implicit val i : Int = 10 implicit def a(implicit i : Int) : Array[Byte] = null implicit def b[T](implicit i : Int) : Array[T] = null - + def fn[T](implicit x : T) = 0 - + val x = fn[Array[Byte]] }
\ No newline at end of file diff --git a/test/files/pos/bug1292.scala b/test/files/pos/bug1292.scala index 83a996d530..3ed153abf2 100644 --- a/test/files/pos/bug1292.scala +++ b/test/files/pos/bug1292.scala @@ -1,5 +1,5 @@ trait Foo[T <: Foo[T, Enum], Enum <: Enumeration] { - type StV = Enum#Value + type StV = Enum#Value type Meta = MegaFoo[T, Enum] type Slog <: Enumeration diff --git a/test/files/pos/bug1385.scala b/test/files/pos/bug1385.scala index 55356c1f25..59953bcc39 100644 --- a/test/files/pos/bug1385.scala +++ b/test/files/pos/bug1385.scala @@ -1,3 +1,3 @@ -@serializable object Test { +@serializable object Test { private def readResolve:AnyRef = this } diff --git a/test/files/pos/bug1560.scala b/test/files/pos/bug1560.scala index 384e808e4b..b1d04153b3 100644 --- a/test/files/pos/bug1560.scala +++ b/test/files/pos/bug1560.scala @@ -2,10 +2,10 @@ object Test extends Application { trait C[T] { def t: T } - + def b: Option[C[_]] = null - + def c = b match { case Some(b) => b.t - } + } } diff --git a/test/files/pos/bug1565.scala b/test/files/pos/bug1565.scala index df333151d5..030086c541 100644 --- a/test/files/pos/bug1565.scala +++ b/test/files/pos/bug1565.scala @@ -3,7 +3,7 @@ object Bug1565 { def x() = { 0; (a : Int, b : Int) => println(List(a, b)) ; 0 } (a : Int, b : Int) => println(List(a, b)) - + // various function syntaxes to exercise the parser val xs = List(1,2,3) xs.filter(x => x < 2) diff --git a/test/files/pos/bug2023.scala b/test/files/pos/bug2023.scala index 21c6fc96a6..de3e848fbd 100644 --- a/test/files/pos/bug2023.scala +++ b/test/files/pos/bug2023.scala @@ -3,11 +3,11 @@ trait C[A] object C { implicit def ipl[A](implicit from: A => Ordered[A]): C[A] = null } - + object P { def foo[A](i: A, j: A)(implicit c: C[A]): Unit = () } - + class ImplicitChainTest { def testTrivial: Unit = { P.foo('0', '9') diff --git a/test/files/pos/bug2081.scala b/test/files/pos/bug2081.scala index 52388464a5..d772c02dc2 100644 --- a/test/files/pos/bug2081.scala +++ b/test/files/pos/bug2081.scala @@ -7,5 +7,5 @@ object ScalaForRubyists { val x = 10.days // a couple parser corner cases I wanted not to break - val y = 5.e0 + 5e7 + val y = 5.e0 + 5e7 } diff --git a/test/files/pos/bug2168.scala b/test/files/pos/bug2168.scala index 1cf73446a8..d7bfa9687b 100644 --- a/test/files/pos/bug2168.scala +++ b/test/files/pos/bug2168.scala @@ -2,5 +2,5 @@ object Test extends Application { def foo1(x: AnyRef) = x match { case x: Function0[_] => x() } def foo2(x: AnyRef) = x match { case x: Function0[Any] => x() } } - - + + diff --git a/test/files/pos/bug2310.scala b/test/files/pos/bug2310.scala index 68912b4961..e08411a3df 100644 --- a/test/files/pos/bug2310.scala +++ b/test/files/pos/bug2310.scala @@ -1,15 +1,15 @@ import scala.Stream._ object consistencyError { - /* this gives an error: + /* this gives an error: Consistency problem compiling (virtual file)! Trying to call method body%1(List(scala.collection.immutable.Stream[A])) with arguments (List(tp2, temp6, temp5)) case (l #:: ls, rs) => None ^ scala.tools.nsc.symtab.Types$TypeError: too many arguments for method body%1: (val rs: scala.collection.immutable.Stream[A])None.type - + two errors found - vss(0) = + vss(0) = args = List(tp2, temp6, temp5) vss(1) = value rs, value ls, value l args = List(tp2, temp6, temp5) @@ -18,19 +18,19 @@ object consistencyError { labels(1) = method body%1 labels(0) = method body%0 bx = 1 - label.tpe = (val rs: scala.collection.immutable.Stream[A])None.type + label.tpe = (val rs: scala.collection.immutable.Stream[A])None.type */ def crash[A](lefts: Stream[A], rights: Stream[A]) = (lefts, rights) match { case (Stream.Empty, Stream.Empty) => None case (l #:: ls, rs) => None } - + // These work // def works1[A](lefts: Stream[A]) = lefts match { // case Stream.Empty => None // case l #:: ls => None // } - // + // // def works2[A](lefts: Stream[A], rights: Stream[A]) = (lefts, rights) match { // case (Stream.Empty, Stream.Empty) => None // case (ls, rs) => None diff --git a/test/files/pos/bug247.scala b/test/files/pos/bug247.scala index e976404e61..983b7998a9 100644 --- a/test/files/pos/bug247.scala +++ b/test/files/pos/bug247.scala @@ -12,7 +12,7 @@ class TreeMapFactory[KEY](newOrder:Order[KEY]) extends MapFactory[KEY] { def Empty[V] = new TreeMap[KEY,V](new TreeMapFactory[KEY](order)); } -class Tree[KEY,Entry](order:Order[KEY]) { +class Tree[KEY,Entry](order:Order[KEY]) { def size =0; } diff --git a/test/files/pos/bug262.scala b/test/files/pos/bug262.scala index ec6187b36b..b81490977c 100644 --- a/test/files/pos/bug262.scala +++ b/test/files/pos/bug262.scala @@ -1,11 +1,11 @@ object O { abstract class A { - def f:A; + def f:A; } class B extends A { def f = if(1 == 2) new C else new D; } - class C extends A { + class C extends A { def f = this; } class D extends A { diff --git a/test/files/pos/bug2691.scala b/test/files/pos/bug2691.scala index 1037b53601..d289605ba6 100644 --- a/test/files/pos/bug2691.scala +++ b/test/files/pos/bug2691.scala @@ -1,5 +1,5 @@ object Breakdown { - def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there")) + def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there")) } object Test { 42 match { diff --git a/test/files/pos/bug2939.scala b/test/files/pos/bug2939.scala index 3be4d4d561..67677f2f18 100644 --- a/test/files/pos/bug2939.scala +++ b/test/files/pos/bug2939.scala @@ -4,10 +4,10 @@ object Proxies { class C1 extends MapProxy[Int,Int] { def self = Map[Int,Int]() } class C2 extends mutable.MapProxy[Int,Int] { def self = mutable.Map[Int,Int]() } class C3 extends immutable.MapProxy[Int,Int] { def self = immutable.Map[Int,Int]() } - + class C4 extends SetProxy[Int] { def self = Set[Int]() } class C5 extends mutable.SetProxy[Int] { def self = mutable.Set[Int]() } class C6 extends immutable.SetProxy[Int] { def self = immutable.Set[Int]() } - + class C7 extends SeqProxy[Int] { def self = Seq[Int]() } }
\ No newline at end of file diff --git a/test/files/pos/bug3020.scala b/test/files/pos/bug3020.scala index 016563e27f..cb429cd94f 100644 --- a/test/files/pos/bug3020.scala +++ b/test/files/pos/bug3020.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { var x = true - + ( { if (x) new scala.util.Random() } .asInstanceOf[Runnable] ) } } diff --git a/test/files/pos/bug3136.scala b/test/files/pos/bug3136.scala index 33d42c2f3c..6a5850aeb0 100644 --- a/test/files/pos/bug3136.scala +++ b/test/files/pos/bug3136.scala @@ -11,7 +11,7 @@ object NullaryMethodType { } object Test { - def TEST(tp: Type): String = + def TEST(tp: Type): String = tp match { case PolyType(ps1, PolyType(ps2, res @ PolyType(a, b))) => "1"+tp // couldn't find a simpler version that still crashes case NullaryMethodType(meh) => "2"+meh diff --git a/test/files/pos/bug3175.scala b/test/files/pos/bug3175.scala index 89bbf8b5fc..497ff8255c 100644 --- a/test/files/pos/bug3175.scala +++ b/test/files/pos/bug3175.scala @@ -1,7 +1,7 @@ object Test { - def f(g:{val update:Unit}) = g.update - + def f(g:{val update:Unit}) = g.update + def main(args: Array[String]): Unit = { - + } } diff --git a/test/files/pos/bug3411.scala b/test/files/pos/bug3411.scala index b58e52db8d..b76fec66a6 100644 --- a/test/files/pos/bug3411.scala +++ b/test/files/pos/bug3411.scala @@ -1,6 +1,6 @@ object A { def g(c: PartialFunction[Any,Unit]) {} - + def f { lazy val x = 0 g { case `x` => } diff --git a/test/files/pos/bug3430.scala b/test/files/pos/bug3430.scala index 3129c6276a..4990abb2a1 100644 --- a/test/files/pos/bug3430.scala +++ b/test/files/pos/bug3430.scala @@ -1,6 +1,6 @@ // package com.example -object A { +object A { def f1(f: String => Boolean) = f("a") def f2(): Boolean = diff --git a/test/files/pos/bug3521/DoubleValue.java b/test/files/pos/bug3521/DoubleValue.java index e8c093890b..28f05cd972 100644 --- a/test/files/pos/bug3521/DoubleValue.java +++ b/test/files/pos/bug3521/DoubleValue.java @@ -4,4 +4,4 @@ import java.lang.annotation.*; @Target(ElementType.FIELD) public @interface DoubleValue { double value(); -}
\ No newline at end of file +}
\ No newline at end of file diff --git a/test/files/pos/bug3568.scala b/test/files/pos/bug3568.scala index 7cfb927138..950c16539b 100644 --- a/test/files/pos/bug3568.scala +++ b/test/files/pos/bug3568.scala @@ -14,7 +14,7 @@ package buffer { // ArrayVec2 can be compiled, instantiated and used. def main(args: Array[String]) { println(works) } } - + trait ElemType { type Element; type Component <: ElemType } trait Float1 extends ElemType { type Element = Float; type Component = Float1} class Vec2 extends ElemType { type Element = Vec2; type Component = Float1 } diff --git a/test/files/pos/bug3578.scala b/test/files/pos/bug3578.scala index d984118208..306cde811b 100644 --- a/test/files/pos/bug3578.scala +++ b/test/files/pos/bug3578.scala @@ -24,7 +24,7 @@ object Test { case class JInt(num: BigInt) extends JValue case class JBool(value: Boolean) extends JValue case class JField(name: String, value: JValue) extends JValue - case class JObject(obj: List[JField]) extends JValue + case class JObject(obj: List[JField]) extends JValue case class JArray(arr: List[JValue]) extends JValue } diff --git a/test/files/pos/bug430-feb09.scala b/test/files/pos/bug430-feb09.scala index 1499f32b7a..bba8996e4e 100644 --- a/test/files/pos/bug430-feb09.scala +++ b/test/files/pos/bug430-feb09.scala @@ -13,12 +13,12 @@ package c.scala { case class C[T]() } -// Doesn't compile: type Nothing is not a member of d.scala +// Doesn't compile: type Nothing is not a member of d.scala package d.scala.d { case class D[T]() } -// Doesn't compile: type Any is not a member of e.scala +// Doesn't compile: type Any is not a member of e.scala package e.scala { case class E[T >: Nothing]() } diff --git a/test/files/pos/bug460.scala b/test/files/pos/bug460.scala index 3fc13e4dd0..466d06c2ad 100644 --- a/test/files/pos/bug460.scala +++ b/test/files/pos/bug460.scala @@ -1,8 +1,8 @@ object Bug460 { def testFun(x : Int, y : Int) = x + y - val fn = testFun _ - - fn(1, 2) // Ok + val fn = testFun _ + + fn(1, 2) // Ok (testFun(_, _))(1, 2) // Ok (testFun _).apply(1, 2) (testFun _)(1, 2) // Error! (but no longer) diff --git a/test/files/pos/bug516.scala b/test/files/pos/bug516.scala index ce4e0e3dd6..735b259436 100644 --- a/test/files/pos/bug516.scala +++ b/test/files/pos/bug516.scala @@ -4,7 +4,7 @@ import scala.collection.script._; class Members; object subscriber extends Subscriber[Message[String] with Undoable, Members] { - def notify(pub: Members, event: Message[String] with Undoable): Unit = + def notify(pub: Members, event: Message[String] with Undoable): Unit = (event: Message[String]) match { case Include(l, elem) => Console.println("ADD: " + elem); case Remove(l, elem) => Console.println("REM: " + elem); @@ -12,4 +12,4 @@ object subscriber extends Subscriber[Message[String] with Undoable, Members] { //case r : Remove [HasTree] with Undoable => } } - + diff --git a/test/files/pos/bug577.scala b/test/files/pos/bug577.scala index ede45399a0..236c1395e2 100644 --- a/test/files/pos/bug577.scala +++ b/test/files/pos/bug577.scala @@ -1,15 +1,15 @@ trait PriorityTree { type Node <: BasicTreeNode; - + val top = initTree; top.next = (initTree); top.next.prev = (top); - + def initTree : Node; + + - - - + trait BasicTreeNode { private[PriorityTree] var next : Node = _; private[PriorityTree] var prev : Node = _; diff --git a/test/files/pos/bug599.scala b/test/files/pos/bug599.scala index 968e2deaee..53f205a26b 100644 --- a/test/files/pos/bug599.scala +++ b/test/files/pos/bug599.scala @@ -16,4 +16,4 @@ abstract class FooA { val aaa: InnerB.this.B = doB aaa.xxx; } - } + } diff --git a/test/files/pos/bug602.scala b/test/files/pos/bug602.scala index 18dd405645..6062b976b6 100644 --- a/test/files/pos/bug602.scala +++ b/test/files/pos/bug602.scala @@ -10,5 +10,5 @@ case class Span[K <: Ordered[K]](low: Option[K], high: Option[K]) extends Functi case Span(Some(low), None) => (k >= low) case Span(None, Some(high)) => (k <= high) case _ => false - } + } } diff --git a/test/files/pos/bug613.scala b/test/files/pos/bug613.scala index cf179420f4..92bdd1b8ee 100644 --- a/test/files/pos/bug613.scala +++ b/test/files/pos/bug613.scala @@ -3,9 +3,9 @@ class Outer extends Application { abstract class C { val x: Int } - val foo = new C { + val foo = new C { class I { - val z = y + val z = y } val x = (new I).z } diff --git a/test/files/pos/bug616.scala b/test/files/pos/bug616.scala index bb91c732a6..074ad190da 100644 --- a/test/files/pos/bug616.scala +++ b/test/files/pos/bug616.scala @@ -1,7 +1,7 @@ object testImplicit { implicit def foo2bar(foo: Foo): Bar = foo.bar class Foo(val bar: Bar) { - def testCoercion = {val a = this; a.baz} // here, foo2bar is inferred by the compiler, as expected + def testCoercion = {val a = this; a.baz} // here, foo2bar is inferred by the compiler, as expected //def testCoercionThisImplicit = baz // --> error: not found: value baz def testCoercionThisExplicit: Any = this.baz // --> error: value baz is not a member of Foo } diff --git a/test/files/pos/bug651.scala b/test/files/pos/bug651.scala index c146446af9..44d20ad580 100644 --- a/test/files/pos/bug651.scala +++ b/test/files/pos/bug651.scala @@ -4,12 +4,12 @@ trait Test3 { trait MatchableImpl { trait MatchImpl; } - + trait BracePairImpl { trait BraceImpl extends MatchableImpl { private object MyMatch1 extends MatchImpl; protected def match0 : MatchImpl = MyMatch1; - + } } } diff --git a/test/files/pos/bug675.scala b/test/files/pos/bug675.scala index 51f56920b5..3deb7a2b14 100644 --- a/test/files/pos/bug675.scala +++ b/test/files/pos/bug675.scala @@ -7,7 +7,7 @@ trait T { } trait X { def foo : Foo = FOO_0; - } + } } object Test extends Application { @@ -15,5 +15,5 @@ object Test extends Application { val x = new t.X{} Console.println(x.foo) } - - + + diff --git a/test/files/pos/bug690.scala b/test/files/pos/bug690.scala index a93c54f007..3fcdca785d 100644 --- a/test/files/pos/bug690.scala +++ b/test/files/pos/bug690.scala @@ -10,5 +10,5 @@ trait test { override def foo(t : T) = super.foo(t); } def t : T; - M0.foo(t); + M0.foo(t); } diff --git a/test/files/pos/bug711.scala b/test/files/pos/bug711.scala index 70fcc7f0d0..25cd6d3c13 100644 --- a/test/files/pos/bug711.scala +++ b/test/files/pos/bug711.scala @@ -2,7 +2,7 @@ abstract class Component class Button extends Component { def sayHey: Unit = Console.println("Hey, I'm a button") } - + abstract class Origin { val delegate: Component } diff --git a/test/files/pos/bug715/meredith_1.scala b/test/files/pos/bug715/meredith_1.scala index 4be7b48908..3ed2e57d7a 100644 --- a/test/files/pos/bug715/meredith_1.scala +++ b/test/files/pos/bug715/meredith_1.scala @@ -9,7 +9,7 @@ trait XMLRenderer { classOf[java.lang.Boolean], classOf[java.lang.Integer], classOf[java.lang.Float], - classOf[java.lang.String] + classOf[java.lang.String] // more to come ) @@ -21,14 +21,14 @@ trait XMLRenderer { value match { case null => Text( "null" ) case vUnmatched => - if (value.isInstanceOf[java.lang.Boolean]) + if (value.isInstanceOf[java.lang.Boolean]) Text( value.asInstanceOf[java.lang.Boolean].toString ) - else if (value.isInstanceOf[java.lang.Integer]) + else if (value.isInstanceOf[java.lang.Integer]) Text( value.asInstanceOf[java.lang.Integer].toString ) - else if (value.isInstanceOf[java.lang.Float]) + else if (value.isInstanceOf[java.lang.Float]) Text( value.asInstanceOf[java.lang.Float].toString ) - // else if (value.isInstanceOf[T]) - // pojo2XML( value.asInstanceOf[T] ) + // else if (value.isInstanceOf[T]) + // pojo2XML( value.asInstanceOf[T] ) else <unmatchedType> <theType> @@ -57,7 +57,7 @@ trait XMLRenderer { null, field.getName, null, - TopScope, + TopScope, fldValXML ) } @@ -73,7 +73,7 @@ trait XMLRenderer { null, TopScope, progeny.asInstanceOf[Array[scala.xml.Node]] : _* - ) + ) } } diff --git a/test/files/pos/bug757.scala b/test/files/pos/bug757.scala index cc6527f3f2..f722128acc 100644 --- a/test/files/pos/bug757.scala +++ b/test/files/pos/bug757.scala @@ -1,4 +1,4 @@ -package foo { +package foo { object C { def foo { Console.println("foo") @@ -6,7 +6,7 @@ package foo { } } -package bar { +package bar { object Main extends Application { foo.C.foo } diff --git a/test/files/pos/bug758.scala b/test/files/pos/bug758.scala index 160bf37172..44769d54f1 100644 --- a/test/files/pos/bug758.scala +++ b/test/files/pos/bug758.scala @@ -1,7 +1,7 @@ trait A { type T; type M >: T } -trait B extends A { - val x : String; - val u : A { type T = B.this.T } ; - type T = x.type; - type M = u.M +trait B extends A { + val x : String; + val u : A { type T = B.this.T } ; + type T = x.type; + type M = u.M } diff --git a/test/files/pos/bug767.scala b/test/files/pos/bug767.scala index 0c4067f022..d4d7eae870 100644 --- a/test/files/pos/bug767.scala +++ b/test/files/pos/bug767.scala @@ -4,7 +4,7 @@ abstract class AbsCell { private var value: T = init def get: T = value def set (x: T) { value = x } - + class Node { val foo = 1 } diff --git a/test/files/pos/bug788.scala b/test/files/pos/bug788.scala index 19638dd170..3da88a2d26 100644 --- a/test/files/pos/bug788.scala +++ b/test/files/pos/bug788.scala @@ -4,7 +4,7 @@ trait Test { type Node <: NodeImpl; trait NodeImpl; type Expression <: Node with ExpressionImpl; - trait ExpressionImpl extends NodeImpl { + trait ExpressionImpl extends NodeImpl { def self : Expression; } type Named <: Node with NamedImpl; diff --git a/test/files/pos/bug802.scala b/test/files/pos/bug802.scala index 2dea7036d6..124d4915bc 100644 --- a/test/files/pos/bug802.scala +++ b/test/files/pos/bug802.scala @@ -1,17 +1,17 @@ package test; trait Test { - abstract class BracesImpl { + abstract class BracesImpl { type Singleton; type Brace <: Singleton with BraceImpl; - trait BraceImpl; + trait BraceImpl; trait ForFile; } - abstract class ParensImpl extends BracesImpl { + abstract class ParensImpl extends BracesImpl { type Brace <: Singleton with BraceImpl; trait BraceImpl extends super.BraceImpl; } val parens : ParensImpl; - abstract class BracksImpl extends BracesImpl { + abstract class BracksImpl extends BracesImpl { type Brace <: Singleton with BraceImpl; trait BraceImpl extends super.BraceImpl; } diff --git a/test/files/pos/bug807.scala b/test/files/pos/bug807.scala index 0eeb92ea24..ed73fe3f97 100644 --- a/test/files/pos/bug807.scala +++ b/test/files/pos/bug807.scala @@ -6,7 +6,7 @@ trait Matcher { trait HasLinks { def link(b : Boolean) : Link = null; } - + } trait BraceMatcher extends Matcher { trait BracePair { diff --git a/test/files/pos/bug927.scala b/test/files/pos/bug927.scala index 7d4c59d94c..8f3cdac20f 100644 --- a/test/files/pos/bug927.scala +++ b/test/files/pos/bug927.scala @@ -7,5 +7,5 @@ object Test { } val str: Stream[Int] = Stream.fromIterator(List(1,2,3).iterator) assert(sum(str) == 6) - + } diff --git a/test/files/pos/bug946.scala b/test/files/pos/bug946.scala index c4bd6e9ba4..9f4cdbc043 100644 --- a/test/files/pos/bug946.scala +++ b/test/files/pos/bug946.scala @@ -1,7 +1,7 @@ object pmbugbounds { trait Bar class Foo[t <: Bar] {} - + (new Foo[Bar]) match { case _ : Foo[x] => null } diff --git a/test/files/pos/builders.scala b/test/files/pos/builders.scala index 0b620769c0..51d8af88f8 100644 --- a/test/files/pos/builders.scala +++ b/test/files/pos/builders.scala @@ -18,16 +18,16 @@ object builders { def += (elem: B) { buf += elem } def result: List[B] = buf.toList } -/* +/* def fill[A, Dim1, Dim2, Coll](n1: Int, n2: Int, elem: A)(implicit b1: Builder[Coll, Dim1, A], b2: Builder[Coll, Dim2, Dim1]) = { for (i <- 0 until n1) { for (j <- 0 until n2) { b1 += elem - } + } b2 += b1.result } b2.result - } + } */ /* implicit def arrayBuilder[A, B] = new Builder[Array[A], Array[B], B] { @@ -35,7 +35,7 @@ object builders { private val buf = new scala.collection.mutable.ListBuffer[B] def += (elem: B) { buf += elem } def result: Array[B] = buf.toArray - } + } */ class Iter[A, C](elems: List[A]) { def ++ [B >: A, D](xs: Iterable[B])(implicit b: Builder[C, D, B]): D = { @@ -48,7 +48,7 @@ object builders { b.result } } - + def main(args : Array[String]) : Unit = { val x1 = new Iter[Int, List[Int]](List(1, 2, 3)) // val x2 = new Iter[Int, Array[Int]](List(1, 2, 3)) diff --git a/test/files/pos/channels.scala b/test/files/pos/channels.scala index 4c7be2cc82..ce6b79feaf 100644 --- a/test/files/pos/channels.scala +++ b/test/files/pos/channels.scala @@ -6,7 +6,7 @@ case class ![a](chan: Channel[a], data: a) /* object Bang { - def unapply[a](x: ![a]): Option[{Channel[a], a}] = + def unapply[a](x: ![a]): Option[{Channel[a], a}] = Some(x.chan, x.data) } @@ -14,7 +14,7 @@ object Bang { object Test extends Application { object IC extends Channel[Int] def f[b](x: ![b]): Int = x match { - case send: ![c] => + case send: ![c] => send.chan match { case IC => send.data } @@ -27,4 +27,4 @@ object Test2 extends Application { case IC ! x => x } } - + diff --git a/test/files/pos/clsrefine.scala b/test/files/pos/clsrefine.scala index 0a016dec07..b29c01db8b 100644 --- a/test/files/pos/clsrefine.scala +++ b/test/files/pos/clsrefine.scala @@ -25,9 +25,9 @@ object test { val y1, y2 = 1; } val a: A { type X1 = Int; type X2 = Int } = b; - val a1 = new A { + val a1 = new A { type X1 = Int; - type X2 = String; + type X2 = String; val x1 = 1; val x2 = "hello" } diff --git a/test/files/pos/collectGenericCC.scala b/test/files/pos/collectGenericCC.scala index 099a53d3f5..750475207f 100644 --- a/test/files/pos/collectGenericCC.scala +++ b/test/files/pos/collectGenericCC.scala @@ -7,8 +7,8 @@ object Test { for (a <- r) b += a b.result } - - collect[Int, Vector[Int]](List(1,2,3,4)) + + collect[Int, Vector[Int]](List(1,2,3,4)) collect[Char, String](List('1','2','3','4')) - collect[Char, Array[Char]](List('1','2','3','4')) + collect[Char, Array[Char]](List('1','2','3','4')) }
\ No newline at end of file diff --git a/test/files/pos/context.scala b/test/files/pos/context.scala index 4e11d07eb4..13f6bb43c5 100644 --- a/test/files/pos/context.scala +++ b/test/files/pos/context.scala @@ -12,10 +12,10 @@ class Context { abstract class SymbolWrapper { val context: Context; import context._; - + class Symbols { self: context.symbols.type => - + abstract class Symbol { def typ: types.Type; def sym: Symbol = typ.sym; @@ -29,7 +29,7 @@ abstract class TypeWrapper { class Types { self: context.types.type => - + abstract class Type { def sym: symbols.Symbol; def typ: Type = sym.typ; diff --git a/test/files/pos/cyclics.scala b/test/files/pos/cyclics.scala index 395e88815a..051bdd6ed8 100644 --- a/test/files/pos/cyclics.scala +++ b/test/files/pos/cyclics.scala @@ -1,26 +1,26 @@ trait Param[T] trait Abs { type T } trait Cyclic1[A <: Param[A]] // works -trait Cyclic2[A <: Abs { type T <: A }] -trait Cyclic3 { type A <: Abs { type T = A } } +trait Cyclic2[A <: Abs { type T <: A }] +trait Cyclic3 { type A <: Abs { type T = A } } trait Cyclic4 { type A <: Param[A] } // works -trait Cyclic5 { type AA <: Abs; type A <: AA { type T = A } } +trait Cyclic5 { type AA <: Abs; type A <: AA { type T = A } } trait IterableTemplate { type Elem type Constr <: IterableTemplate type ConstrOf[A] = Constr { type Elem = A } - + def iterator: Iterator[Elem] - + def map [B] (f: Elem => B): ConstrOf[B] - + def foreach(f: Elem => Unit) = iterator.foreach(f) } trait Iterable[A] extends IterableTemplate { self => - type Elem + type Elem type Constr <: Iterable[A] { type Constr <: Iterable.this.Constr } } diff --git a/test/files/pos/depmet_implicit_chaining_zw.scala b/test/files/pos/depmet_implicit_chaining_zw.scala index e3a145ab38..93da3b0f8e 100644 --- a/test/files/pos/depmet_implicit_chaining_zw.scala +++ b/test/files/pos/depmet_implicit_chaining_zw.scala @@ -15,7 +15,7 @@ object ZipWith { type T = Stream[S] => zWith.T // dependent types replace the associated types functionality } - // can't use implicitly[ZipWith[Succ[Succ[Zero]], Int => String => Boolean]], + // can't use implicitly[ZipWith[Succ[Succ[Zero]], Int => String => Boolean]], // since that will chop of the {type T = ... } refinement in adapt (pt = ZipWith[Succ[Succ[Zero]], Int => String => Boolean]) // this works // def zipWith(implicit zw: ZipWith[Succ[Succ[Zero]], Int => String => Boolean]): zw.T = zw.x diff --git a/test/files/pos/depmet_implicit_norm_ret.scala b/test/files/pos/depmet_implicit_norm_ret.scala index 4cdb2931c6..bafd2f7c51 100644 --- a/test/files/pos/depmet_implicit_norm_ret.scala +++ b/test/files/pos/depmet_implicit_norm_ret.scala @@ -1,29 +1,29 @@ object Test{ def ?[S <: AnyRef](implicit w : S) : w.type = w - + // fallback, lower priority (overloading rules apply: pick alternative in subclass lowest in subtyping lattice) class ZipWithDefault { implicit def ZeroZipWith[S] = new ZipWith[S] { type T = Stream[S] - } + } } - + object ZipWith extends ZipWithDefault { // def apply[S: ZipWith](s : S) = ?[ZipWith[S]].zipWith(s) // TODO: bug return type should be inferred def apply[S](s : S)(implicit zw: ZipWith[S]): zw.T = zw.zipWith(s) implicit def SuccZipWith[S,R](implicit zWith : ZipWith[R]) = new ZipWith[S => R] { type T = Stream[S] => zWith.T // dependent types replace the associated types functionality - } + } } - + trait ZipWith[S] { type T def zipWith : S => T = error("") } - + // bug: inferred return type = (Stream[A]) => java.lang.Object with Test.ZipWith[B]{type T = Stream[B]}#T // this seems incompatible with vvvvvvvvvvvvvvvvvvvvvv -- #3731 - def map[A,B](f : A => B) /* : Stream[A] => Stream[B]*/ = ZipWith(f) - val tst: Stream[Int] = map{x: String => x.length}(Stream("a")) -}
\ No newline at end of file + def map[A,B](f : A => B) /* : Stream[A] => Stream[B]*/ = ZipWith(f) + val tst: Stream[Int] = map{x: String => x.length}(Stream("a")) +}
\ No newline at end of file diff --git a/test/files/pos/depmet_implicit_oopsla_session.scala b/test/files/pos/depmet_implicit_oopsla_session.scala index 21588a56ad..e2c67d7c32 100644 --- a/test/files/pos/depmet_implicit_oopsla_session.scala +++ b/test/files/pos/depmet_implicit_oopsla_session.scala @@ -11,19 +11,19 @@ object Sessions { def run(p: Stop, dp: Stop): Unit = {} } - implicit def InDual[A, B](implicit sessionDIn: Session[B]) = + implicit def InDual[A, B](implicit sessionDIn: Session[B]) = new Session[In[A, B]] { type Dual = Out[A, sessionDIn.Dual] - def run(p: In[A, B], dp: Dual): Unit = + def run(p: In[A, B], dp: Dual): Unit = sessionDIn.run(p.func(dp.x), dp.y) } - implicit def OutDual[A, B](implicit sessionDOut: Session[B]) = + implicit def OutDual[A, B](implicit sessionDOut: Session[B]) = new Session[Out[A, B]] { type Dual = In[A, sessionDOut.Dual] - def run(p: Out[A, B], dp: Dual): Unit = + def run(p: Out[A, B], dp: Dual): Unit = sessionDOut.run(p.y, dp.func(p.x)) } @@ -32,7 +32,7 @@ object Sessions { sealed case class Out[+A, +B](x: A, y: B) def addServer = - In{x: Int => + In{x: Int => In{y: Int => System.out.println("Thinking") Out(x+y, Stop())}} @@ -48,7 +48,7 @@ object Sessions { // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]#HasDual[D]) = // s.run(p, dp) - // + // // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]{type Dual=D}) = // s.run(p, dp) diff --git a/test/files/pos/depmet_implicit_oopsla_session_2.scala b/test/files/pos/depmet_implicit_oopsla_session_2.scala index 5c3b78e3f5..8d7daa6dc6 100644 --- a/test/files/pos/depmet_implicit_oopsla_session_2.scala +++ b/test/files/pos/depmet_implicit_oopsla_session_2.scala @@ -36,7 +36,7 @@ object Sessions { implicit def InDual[Data, Cont](implicit cont: Session[Cont]) = new Session[In[Data, Cont]] { type Dual = Out[Data, cont.Dual] - def run(self: Self, dual: Dual): Unit = + def run(self: Self, dual: Dual): Unit = cont.run(self.recv(dual.data), dual.cont) } @@ -46,13 +46,13 @@ object Sessions { implicit def OutDual[Data, Cont](implicit cont: Session[Cont]) = new Session[Out[Data, Cont]] { type Dual = In[Data, cont.Dual] - def run(self: Self, dual: Dual): Unit = + def run(self: Self, dual: Dual): Unit = cont.run(self.cont, dual.recv(self.data)) } // a concrete session def addServer = - In{x: Int => + In{x: Int => In{y: Int => System.out.println("Thinking") Out(x+y, Stop())}} @@ -71,7 +71,7 @@ object Sessions { // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]#HasDual[D]) = // s.run(p, dp) - // + // // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]{type Dual=D}) = // s.run(p, dp) diff --git a/test/files/pos/depmet_implicit_oopsla_session_simpler.scala b/test/files/pos/depmet_implicit_oopsla_session_simpler.scala index 37bc0958d3..d2986ef56f 100644 --- a/test/files/pos/depmet_implicit_oopsla_session_simpler.scala +++ b/test/files/pos/depmet_implicit_oopsla_session_simpler.scala @@ -14,7 +14,7 @@ object Sessions { // can't write B <: Session{type Dual = BDual} due to limitations in type inference algorithm // (type variables cannot occur on both sides of <:) // using B#Dual instead of BDual is too imprecise, since it is disconnected from the actual argument that is passed for B - // would be nice if we could introduce a universal quantification over BDual that is not part of the + // would be nice if we could introduce a universal quantification over BDual that is not part of the // type parameter list sealed case class In[A, B <: Session, BDual <: Session](recv: A => B)(implicit dual: B <:< Session{type Dual=BDual}) extends Session { type Dual = Out[A, BDual] @@ -29,7 +29,7 @@ object Sessions { } def addServer = - In{x: Int => + In{x: Int => In{y: Int => System.out.println("Thinking") Out(x+y, Stop())}} diff --git a/test/files/pos/depmet_implicit_oopsla_zipwith.scala b/test/files/pos/depmet_implicit_oopsla_zipwith.scala index c76d02c1ae..fe69802d26 100644 --- a/test/files/pos/depmet_implicit_oopsla_zipwith.scala +++ b/test/files/pos/depmet_implicit_oopsla_zipwith.scala @@ -15,7 +15,7 @@ object ZipWith { def manyApp = n => xs => xs } - implicit def SuccZipWith[N, S, R](implicit zw: ZipWith[N, R]) = + implicit def SuccZipWith[N, S, R](implicit zw: ZipWith[N, R]) = new ZipWith[Succ[N],S => R] { type T = Stream[S] => zw.T @@ -33,12 +33,12 @@ object ZipWith { object Test { def zWith[N, S](n: N, s: S)(implicit zw: ZipWith[N, S]): zw.T = zw.zipWith(n)(s) - def zipWith0: Stream[Int] = zWith(Zero(),0) + def zipWith0: Stream[Int] = zWith(Zero(),0) // (Stream[A]) => java.lang.Object with ZipWith[Zero,B]{type T = Stream[B]}#T // should normalise to: Stream[A] => Stream[B] def map[A, B](f: A => B) = zWith(Succ(Zero()),f) - + def zipWith3[A, B, C, D](f: A => B => C => D) = //: Stream[A] => Stream[B] => Stream[C] => Stream[D] = // BUG why do we need a return type? zWith(Succ(Succ(Succ(Zero()))),f) }
\ No newline at end of file diff --git a/test/files/pos/depmet_implicit_tpbetareduce.scala b/test/files/pos/depmet_implicit_tpbetareduce.scala index 35d260683b..c0b9b4e8e4 100644 --- a/test/files/pos/depmet_implicit_tpbetareduce.scala +++ b/test/files/pos/depmet_implicit_tpbetareduce.scala @@ -1,10 +1,10 @@ trait HOSeq { trait Accumulator[+coll[x], elT] trait Iterable[+t] { - type m[+x] + type m[+x] def accumulator[t]: Accumulator[m, t] } - implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] {} + implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] {} trait List[+t] extends Iterable[t] { type m[+x] = List[x] def accumulator[t]: Accumulator[List, t] = listAccumulator[t] diff --git a/test/files/pos/gadt-gilles.scala b/test/files/pos/gadt-gilles.scala index 662be9017d..309168c1e0 100644 --- a/test/files/pos/gadt-gilles.scala +++ b/test/files/pos/gadt-gilles.scala @@ -6,7 +6,7 @@ object Test { val x: A[C with D] = new B[C, D] {} val y: A[C with D] = x match { case b: B[u, v] => (new B[u, v] {}): A[u with v] } // OK - + def f[T, U](p: A[T with U]): A[T with U] = p match { case b: B[u, v] => new A[u with v] {} } // Not OK } diff --git a/test/files/pos/gadts2.scala b/test/files/pos/gadts2.scala index fc2a7e4333..2263cf13a6 100644 --- a/test/files/pos/gadts2.scala +++ b/test/files/pos/gadts2.scala @@ -9,8 +9,8 @@ object Test { final case class NumTerm(val n: Number) extends Term[Number] def f[a](t: Term[a], c: Cell[a]) { - t match { - case NumTerm(n) => c.x = MyDouble(1.0) + t match { + case NumTerm(n) => c.x = MyDouble(1.0) } } diff --git a/test/files/pos/gosh.scala b/test/files/pos/gosh.scala index 183ce9df1d..af49cbf16b 100644 --- a/test/files/pos/gosh.scala +++ b/test/files/pos/gosh.scala @@ -7,35 +7,35 @@ object ShapeTest extends Application { abstract class Shape { def draw(): Unit } - + class Line(s: Point, e: Point) extends Shape { def draw() { Console.println("draw line " + s + "," + e) } } - + abstract class Foo { type T <: Object - + def show(o: T): Unit def print() { Console.println("in Foo") } } - + abstract class ShapeFoo extends Foo { type T <: Shape def show(o: T) { o.draw() } override def print() { Console.println("in ShapeFoo") } } - + class LineFoo extends ShapeFoo { type T = Line override def print() { Console.println("in LineFoo") } } - + val p1 = new Point(1,4) val p2 = new Point(12, 28) - + val l1 = new Line(p1, p2) - + val l = new ShapeFoo { // ** // type T = Line // ** // override def print() { Console.println("in LineFoo") } // ** // diff --git a/test/files/pos/gui.scala b/test/files/pos/gui.scala index 9d87d1b869..5070339f47 100644 --- a/test/files/pos/gui.scala +++ b/test/files/pos/gui.scala @@ -2,7 +2,7 @@ object Geom { trait Shape case class Point(x: Int, y: Int) extends Shape case class Rectangle(ll: Point, ur: Point) extends Shape { - def inset(delta: Int) = + def inset(delta: Int) = Rectangle(Point(ll.x - delta, ll.y - delta), Point(ur.x + delta, ur.y + delta)); } } @@ -20,7 +20,7 @@ trait Screen { } object DummyScreen extends Screen { - def drawRect(r: Geom.Rectangle, c: Color) { + def drawRect(r: Geom.Rectangle, c: Color) { Console.println("draw " + r + " with " + c) } def fillRect(r: Geom.Rectangle, c: Color) { @@ -55,7 +55,7 @@ object GUI { def mouseDown(p: Geom.Point): Unit } - abstract class Button(scr: Screen, p: Geom.Point, name: String) + abstract class Button(scr: Screen, p: Geom.Point, name: String) extends Glyph with MouseCtl { var enabled: Boolean = false val label = new Label(scr, p, name) @@ -86,7 +86,7 @@ object GUIClient { def quit() { Console.println("application exited") } } - class QuitButton (scr: Screen, p: Geom.Point, name: String, a: Application) + class QuitButton (scr: Screen, p: Geom.Point, name: String, a: Application) extends GUI.Button(scr, p, name) { def doit() { a.quit() } } diff --git a/test/files/pos/imp2.scala b/test/files/pos/imp2.scala index 5460c60015..407b07f3fd 100644 --- a/test/files/pos/imp2.scala +++ b/test/files/pos/imp2.scala @@ -1,5 +1,5 @@ object Test { - import collection.mutable._ + import collection.mutable._ import collection.mutable._ val x = new HashMap } diff --git a/test/files/pos/implicits.scala b/test/files/pos/implicits.scala index 960c265e55..2c01dd0ba8 100644 --- a/test/files/pos/implicits.scala +++ b/test/files/pos/implicits.scala @@ -45,7 +45,7 @@ object Test1625 { implicit def byName[A](x: =>A) = new Wrapped(x) implicit def byVal[A](x: A) = x - + def main(args: Array[String]) = { // val res:Wrapped = 7 // works @@ -57,7 +57,7 @@ object Test1625 { } object Test2188 { - implicit def toJavaList[A: ClassManifest](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*) + implicit def toJavaList[A: ClassManifest](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*) val x: java.util.List[String] = List("foo") } @@ -67,21 +67,21 @@ object TestNumericWidening { val x: java.lang.Long = y } -// #2709 -package foo2709 { - class A - class B - - package object bar { - implicit def a2b(a: A): B = new B - } - - package bar { - object test { - new A: B - } - } -} +// #2709 +package foo2709 { + class A + class B + + package object bar { + implicit def a2b(a: A): B = new B + } + + package bar { + object test { + new A: B + } + } +} // Problem with specs object specsProblem { diff --git a/test/files/pos/imports.scala b/test/files/pos/imports.scala index f6a55e5e07..5f70a5d2da 100644 --- a/test/files/pos/imports.scala +++ b/test/files/pos/imports.scala @@ -7,10 +7,10 @@ object test { val foo = 1; - p("hello"); print("world"); S.out.println("!"); + p("hello"); print("world"); S.out.println("!"); S.out.flush(); } object test1 { import test._; foo -} +} diff --git a/test/files/pos/infer2.scala b/test/files/pos/infer2.scala index e065219a80..06d0f5814f 100644 --- a/test/files/pos/infer2.scala +++ b/test/files/pos/infer2.scala @@ -5,4 +5,4 @@ case class nil[T] extends Lst[T] object test { Console.println(cons(1, nil())) } - + diff --git a/test/files/pos/inferbroadtype.scala b/test/files/pos/inferbroadtype.scala index de8f7aa184..467bd0f186 100644 --- a/test/files/pos/inferbroadtype.scala +++ b/test/files/pos/inferbroadtype.scala @@ -2,7 +2,7 @@ object Test { abstract class Base { val changesBaseClasses: Boolean } class Concrete extends Base { val changesBaseClasses = true } def getBase : Base = new Concrete - + var c = new Base { val changesBaseClasses = true } c = getBase } diff --git a/test/files/pos/java-access-pos/J.java b/test/files/pos/java-access-pos/J.java index b6bc3363a1..4f2024673c 100644 --- a/test/files/pos/java-access-pos/J.java +++ b/test/files/pos/java-access-pos/J.java @@ -4,11 +4,11 @@ public abstract class J { public J() { } J(int x1) { } protected J(int x1, int x2) { } - + abstract void packageAbstract(); protected abstract void protectedAbstract(); public abstract void publicAbstract(); - + void packageConcrete() { return; } protected void protectedConcrete() { return; } public void publicConcrete() { return; } diff --git a/test/files/pos/java-access-pos/S1.scala b/test/files/pos/java-access-pos/S1.scala index 10730e3a70..cc739d9555 100644 --- a/test/files/pos/java-access-pos/S1.scala +++ b/test/files/pos/java-access-pos/S1.scala @@ -6,7 +6,7 @@ class S1 extends J { override private[b] def packageAbstract() = () override protected[b] def protectedAbstract() = () override def publicAbstract() = () - + override private[b] def packageConcrete() = () override protected[b] def protectedConcrete() = () override def publicConcrete() = () @@ -26,7 +26,7 @@ class S3 extends J { protected[b] def packageAbstract() = () protected[b] def protectedAbstract() = () def publicAbstract() = () - + override protected[b] def packageConcrete() = () override protected[b] def protectedConcrete() = () override def publicConcrete() = () @@ -37,7 +37,7 @@ class S4 extends J { private[a] def packageAbstract() = () protected[a] def protectedAbstract() = () def publicAbstract() = () - + override private[a] def packageConcrete() = () override protected[a] def protectedConcrete() = () override def publicConcrete() = () @@ -48,14 +48,14 @@ class S5 extends J { def packageAbstract() = () def protectedAbstract() = () def publicAbstract() = () - + override def packageConcrete() = () override def protectedConcrete() = () override def publicConcrete() = () } /** Constructors. */ -class S6 extends J(1) { +class S6 extends J(1) { def packageAbstract() = () def protectedAbstract() = () def publicAbstract() = () diff --git a/test/files/pos/lambdalift.scala b/test/files/pos/lambdalift.scala index bc997d6f81..10bbf3ac12 100644 --- a/test/files/pos/lambdalift.scala +++ b/test/files/pos/lambdalift.scala @@ -11,5 +11,5 @@ object test { def h() = x; } g() + new inner().g(); - } + } } diff --git a/test/files/pos/listpattern.scala b/test/files/pos/listpattern.scala index 47145bf037..b64068474c 100644 --- a/test/files/pos/listpattern.scala +++ b/test/files/pos/listpattern.scala @@ -1,7 +1,7 @@ trait Value {} case class FloatValue(x: Double) extends Value object Test { - def applyNumeric(op: (Double, Double) => Double): + def applyNumeric(op: (Double, Double) => Double): PartialFunction[List[Value], Value] = { case List(FloatValue(x), FloatValue(y)) => FloatValue(op(x, y)) } diff --git a/test/files/pos/looping-jsig.scala b/test/files/pos/looping-jsig.scala index 6e3313c463..e2d9e76229 100644 --- a/test/files/pos/looping-jsig.scala +++ b/test/files/pos/looping-jsig.scala @@ -1,15 +1,15 @@ import scala.collection.mutable._ trait BugTrack { - trait B[+T] + trait B[+T] val cache : HashMap[A[_], B[_]] = HashMap.empty - def A[T](f: Int => B[T]): A[T] + def A[T](f: Int => B[T]): A[T] = new A[T]{def apply(in: Int) = f(in)} - + abstract class A[+T] extends (Int => B[T]) { def giveMeSame = this - } + } def amethod[T](p: =>A[T]): A[T] = A(in => cache.get(p) match { case Some(res) => res diff --git a/test/files/pos/michel6.scala b/test/files/pos/michel6.scala index b32e8bed75..f312bf1796 100644 --- a/test/files/pos/michel6.scala +++ b/test/files/pos/michel6.scala @@ -1,6 +1,6 @@ object M { def f(x: Int): Unit = {} - + def g(): Int => Unit = if (0 == 0) f else g() } diff --git a/test/files/pos/needstypeearly.scala b/test/files/pos/needstypeearly.scala index a90c2575f2..bd93b5c45d 100644 --- a/test/files/pos/needstypeearly.scala +++ b/test/files/pos/needstypeearly.scala @@ -1,4 +1,4 @@ -abstract class NeedsXEarly { - val x: Int +abstract class NeedsXEarly { + val x: Int } class Foo extends { val x = 1 } with NeedsXEarly diff --git a/test/files/pos/nothing_manifest_disambig.scala b/test/files/pos/nothing_manifest_disambig.scala index 9a3db0c6d4..076742033f 100644 --- a/test/files/pos/nothing_manifest_disambig.scala +++ b/test/files/pos/nothing_manifest_disambig.scala @@ -1,10 +1,10 @@ object Test { def mani[T: Manifest](xs: T) = xs mani(List()) - + def listElMani[T: Manifest](xs: List[T]) = xs listElMani(List()) - + def foo[A, C](m : C)(implicit ev: C <:< Traversable[A], mani: Manifest[A]): (C, A, Manifest[A]) = (m, m.head, mani) - foo(List(1,2,3)) + foo(List(1,2,3)) }
\ No newline at end of file diff --git a/test/files/pos/nullary.scala b/test/files/pos/nullary.scala index 614fcdf480..8e5a834012 100644 --- a/test/files/pos/nullary.scala +++ b/test/files/pos/nullary.scala @@ -2,7 +2,7 @@ abstract class NullaryTest[T, m[s]] { def nullary: String = "a" val x = nullary - def nullary2: T + def nullary2: T val x2 = nullary2 def nullary3: m[T] @@ -16,5 +16,5 @@ class Concrete extends NullaryTest[Int, List] { object test { (new Concrete).nullary2 - (new Concrete).nullary3 + (new Concrete).nullary3 } diff --git a/test/files/pos/nullary_poly.scala b/test/files/pos/nullary_poly.scala index d2e1e127a1..4de7235a1c 100644 --- a/test/files/pos/nullary_poly.scala +++ b/test/files/pos/nullary_poly.scala @@ -2,9 +2,9 @@ class A { // built-in synchronized {} - + val x: String = "a".asInstanceOf[String] - + // user-defined: def polyNullary[T]: List[T] = Nil } diff --git a/test/files/pos/partialfun.scala b/test/files/pos/partialfun.scala index 9f32a22023..d8971e56fb 100644 --- a/test/files/pos/partialfun.scala +++ b/test/files/pos/partialfun.scala @@ -1,6 +1,6 @@ object partialfun { - def applyPartial[b](f: PartialFunction[Option[String], b])(x: Option[String]) = + def applyPartial[b](f: PartialFunction[Option[String], b])(x: Option[String]) = if (f.isDefinedAt(x)) f(x) else "<undefined>"; applyPartial { diff --git a/test/files/pos/pat_gilles.scala b/test/files/pos/pat_gilles.scala index 704d5b9c00..567d700eba 100644 --- a/test/files/pos/pat_gilles.scala +++ b/test/files/pos/pat_gilles.scala @@ -1,7 +1,7 @@ abstract class Table2 { - val x: Any => Unit = { zz:Any => + val x: Any => Unit = { zz:Any => zz match { case Table2.CellUpdated(row, column) => val foo = Table2.CellUpdated(2,2) diff --git a/test/files/pos/propagate.scala b/test/files/pos/propagate.scala index 84f4f5d6d2..a7f9d6ce6d 100644 --- a/test/files/pos/propagate.scala +++ b/test/files/pos/propagate.scala @@ -14,4 +14,4 @@ class C { - + diff --git a/test/files/pos/return_thistype.scala b/test/files/pos/return_thistype.scala index c0736c0ad9..f164e06cc0 100644 --- a/test/files/pos/return_thistype.scala +++ b/test/files/pos/return_thistype.scala @@ -1,8 +1,8 @@ // tests transformation of return type in typedTypeApply (see also tcpoly_gm.scala) -class As { - class A { +class As { + class A { def foo: A.this.type = bar.asInstanceOf[A.this.type] def foo2: this.type = bar.asInstanceOf[this.type] - def bar: A = null + def bar: A = null } } diff --git a/test/files/pos/scala-singleton.scala b/test/files/pos/scala-singleton.scala index 08038db93b..5e0baa0cb2 100644 --- a/test/files/pos/scala-singleton.scala +++ b/test/files/pos/scala-singleton.scala @@ -3,12 +3,12 @@ object Test { def f1(x: AnyRef with Singleton): AnyRef with Singleton = x def f2[T <: AnyRef with Singleton](x: T): T = x - + val x1: AnyRef with Singleton = "abc" val x2 = "def" final val x3 = "ghi" val x4: String = "jkl" - + // compiles... def narrow1(x: AnyRef): AnyRef with Singleton = x @@ -17,26 +17,26 @@ object Test { // fails, wait, what? This fails and narrow1 compiles? def narrow3(x: AnyRef): AnyRef with Singleton = x.asInstanceOf[AnyRef with Singleton] - + // ok def narrow4[T <: AnyRef](x: T): AnyRef with Singleton = x - + object imp { implicit def narrow4[T <: AnyRef](x: T): AnyRef with Singleton = x val x5: String = "mno" def imp1 = f1(x5) - + // f2(x5) // doesn't work but I think it should def imp2 = f2(narrow4(x5)) } - + def main(args: Array[String]): Unit = { // compiles f1(x1) f1(x2) f1(x3) f1(x4) - + f2(x1) // f2(x2) // f2(x3) // maybe this one should work diff --git a/test/files/pos/scan.scala b/test/files/pos/scan.scala index 47e0a7d976..f056c77ba1 100644 --- a/test/files/pos/scan.scala +++ b/test/files/pos/scan.scala @@ -6,17 +6,17 @@ object Test { def main(args: Array[String]) { val lst = List(1, 2, 3, 4, 5) - + assert(lst.scanLeft(0)(_ + _) == List(0, 1, 3, 6, 10, 15)) assert(lst.scanRight(0)(_ + _) == List(15, 14, 12, 9, 5, 0)) - + val emp = List[Int]() assert(emp.scanLeft(0)(_ + _) == List(0)) assert(emp.scanRight(0)(_ + _) == List(0)) - + val stream = Stream(1, 2, 3, 4, 5) assert(stream.scanLeft(0)(_ + _) == Stream(0, 1, 3, 6, 10, 15)) - + assert(Stream.from(1).scanLeft(0)(_ + _).take(5) == Stream(0, 1, 3, 6, 10)) } diff --git a/test/files/pos/scoping1.scala b/test/files/pos/scoping1.scala index c9c0489e69..e695110c13 100644 --- a/test/files/pos/scoping1.scala +++ b/test/files/pos/scoping1.scala @@ -9,4 +9,4 @@ object This extends Application { def foo() = () } val c: C = new D -} +} diff --git a/test/files/pos/selftails.scala b/test/files/pos/selftails.scala index a4253b80c7..7c58543747 100644 --- a/test/files/pos/selftails.scala +++ b/test/files/pos/selftails.scala @@ -1,10 +1,10 @@ package net.liftweb.util - + /** * This trait adds functionality to Scala standard types */ trait BasicTypesHelpers { self: StringHelpers with ControlHelpers => - + /** * Compare two arrays of Byte for byte equality. * @return true if two Byte arrays contain the same bytes @@ -19,5 +19,5 @@ trait BasicTypesHelpers { self: StringHelpers with ControlHelpers => } } -trait StringHelpers +trait StringHelpers trait ControlHelpers diff --git a/test/files/pos/signatures/Test.java b/test/files/pos/signatures/Test.java index 3d1e3756a7..78c196526b 100644 --- a/test/files/pos/signatures/Test.java +++ b/test/files/pos/signatures/Test.java @@ -3,7 +3,7 @@ import test.Outer; /* Test correct generation of java signatures. The Outer class should not * have a Java signature attribute for the inner method definition. Trait - * Mutable should have one, even though it is also a nested definition. + * Mutable should have one, even though it is also a nested definition. * (but for classes there is a way to tell about nesting to the JVM). */ class Test { diff --git a/test/files/pos/signatures/sig.scala b/test/files/pos/signatures/sig.scala index 4236f27bed..3feb9c456a 100644 --- a/test/files/pos/signatures/sig.scala +++ b/test/files/pos/signatures/sig.scala @@ -1,7 +1,7 @@ package test /* Tests correct generation of Java signatures. The local method 'bar' should - * not get a generic signature, as it may refer to type parameters of the enclosing + * not get a generic signature, as it may refer to type parameters of the enclosing * method, and the JVM does not know about nested methods. */ class Outer { diff --git a/test/files/pos/spec-Function1.scala b/test/files/pos/spec-Function1.scala index 62789ed12a..24ee6c0de8 100644 --- a/test/files/pos/spec-Function1.scala +++ b/test/files/pos/spec-Function1.scala @@ -36,11 +36,11 @@ package scala trait Function1[@specialized -T1, @specialized +R] extends AnyRef { self => def apply(v1:T1): R override def toString() = "<function>" - + /** (f compose g)(x) == f(g(x)) */ def compose[A](g: A => T1): A => R = { x => apply(g(x)) } - + /** (f andThen g)(x) == g(f(x)) */ def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) } diff --git a/test/files/pos/spec-List.scala b/test/files/pos/spec-List.scala index c5bc3aa5fd..17acb40de2 100644 --- a/test/files/pos/spec-List.scala +++ b/test/files/pos/spec-List.scala @@ -23,8 +23,8 @@ import annotation.tailrec * @author Martin Odersky and others * @version 2.8 */ -sealed trait List[@specialized +A] extends LinearSeq[A] - with Product +sealed trait List[@specialized +A] extends LinearSeq[A] + with Product with GenericTraversableTemplate[A, List] with LinearSeqOptimized[A, List[A]] { override def companion: GenericCompanion[List] = List @@ -65,7 +65,7 @@ sealed trait List[@specialized +A] extends LinearSeq[A] /** <p> * Returns a list resulting from the concatenation of the given - * list <code>prefix</code> and this list. + * list <code>prefix</code> and this list. * </p> * * @param prefix the list to concatenate at the beginning of this list. @@ -140,7 +140,7 @@ sealed trait List[@specialized +A] extends LinearSeq[A] } // Overridden methods from IterableLike or overloaded variants of such methods - + /** Create a new list which contains all elements of this list * followed by all elements of Traversable `that' */ @@ -156,7 +156,7 @@ sealed trait List[@specialized +A] extends LinearSeq[A] */ override def toList: List[A] = this - /** Returns the <code>n</code> first elements of this list, or else the whole + /** Returns the <code>n</code> first elements of this list, or else the whole * list, if it has less than <code>n</code> elements. * @param n the number of elements to take. @@ -216,7 +216,7 @@ sealed trait List[@specialized +A] extends LinearSeq[A] } loop(drop(n), this) } - + // dropRight is inherited from Stream /** Split the list at a given point and return the two parts thus @@ -302,7 +302,7 @@ sealed trait List[@specialized +A] extends LinearSeq[A] override def stringPrefix = "List" - override def toStream : Stream[A] = + override def toStream : Stream[A] = if (isEmpty) Stream.Empty else new Stream.Cons(head, tail.toStream) @@ -487,10 +487,10 @@ final case class ::[@specialized B](private var hd: B, private[scala] var tl: Li * @version 2.8 */ object List extends SeqFactory[List] { - + import collection.{Iterable, Seq} - implicit def builderFactory[A]: CanBuildFrom[Coll, A, List[A]] = + implicit def builderFactory[A]: CanBuildFrom[Coll, A, List[A]] = new GenericCanBuildFrom[A] { override def apply() = newBuilder[A] } @@ -552,8 +552,8 @@ object List extends SeqFactory[List] { * @return the concatenation of all the lists */ @deprecated("use `xss.flatten' instead") - def flatten[A](xss: List[List[A]]): List[A] = { - val b = new ListBuffer[A] + def flatten[A](xss: List[List[A]]): List[A] = { + val b = new ListBuffer[A] for (xs <- xss) { var xc = xs while (!xc.isEmpty) { @@ -588,7 +588,7 @@ object List extends SeqFactory[List] { * @return a pair of lists. */ @deprecated("use `xs.unzip' instead") - def unzip[A,B](xs: Iterable[(A,B)]): (List[A], List[B]) = + def unzip[A,B](xs: Iterable[(A,B)]): (List[A], List[B]) = xs.foldRight[(List[A], List[B])]((Nil, Nil)) { case ((x, y), (xs, ys)) => (x :: xs, y :: ys) } @@ -598,17 +598,17 @@ object List extends SeqFactory[List] { * of <code>Either</code>s. */ @deprecated("use `Either.lefts' instead") - def lefts[A, B](es: Iterable[Either[A, B]]) = + def lefts[A, B](es: Iterable[Either[A, B]]) = es.foldRight[List[A]](Nil)((e, as) => e match { case Left(a) => a :: as case Right(_) => as - }) - + }) + /** * Returns the <code>Right</code> values in the given<code>Iterable</code> of <code>Either</code>s. */ @deprecated("use `Either.rights' instead") - def rights[A, B](es: Iterable[Either[A, B]]) = + def rights[A, B](es: Iterable[Either[A, B]]) = es.foldRight[List[B]](Nil)((e, bs) => e match { case Left(_) => bs case Right(b) => b :: bs @@ -739,7 +739,7 @@ object List extends SeqFactory[List] { /** Returns the list resulting from applying the given function <code>f</code> * to corresponding elements of the argument lists. * @param f function to apply to each pair of elements. - * @return <code>[f(a0,b0), ..., f(an,bn)]</code> if the lists are + * @return <code>[f(a0,b0), ..., f(an,bn)]</code> if the lists are * <code>[a0, ..., ak]</code>, <code>[b0, ..., bl]</code> and * <code>n = min(k,l)</code> */ @@ -782,7 +782,7 @@ object List extends SeqFactory[List] { b.toList } - /** Tests whether the given predicate <code>p</code> holds + /** Tests whether the given predicate <code>p</code> holds * for all corresponding elements of the argument lists. * * @param p function to apply to each pair of elements. diff --git a/test/files/pos/spec-arrays.scala b/test/files/pos/spec-arrays.scala index 96c75dd8de..84f6eef071 100644 --- a/test/files/pos/spec-arrays.scala +++ b/test/files/pos/spec-arrays.scala @@ -20,7 +20,7 @@ abstract class AbsArray[T] { def updateBoolean(idx: Int, elem: Boolean) = update(idx, elem.asInstanceOf[T]) def applyObject(idx: Int): Object = apply(idx).asInstanceOf[Object] def updateObject(idx: Int, elem: Object) = update(idx, elem.asInstanceOf[T]) -} +} final class IntArray(arr: Array[Int]) extends AbsArray[Int] { def apply(idx: Int): Int = applyInt(idx) @@ -64,7 +64,7 @@ class ScalaSpecTest extends Test { while (i < arr.length) { acc = acc + arr.applyInt(i); i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -74,7 +74,7 @@ class ScalaSpecTest extends Test { } } } - + class ScalaSpec2Test extends Test { val arr: AbsArray[Int] = new IntArray(new Array[Int](1000)) @@ -84,7 +84,7 @@ class ScalaSpec2Test extends Test { while (i < arr.length) { acc = acc + arr.applyInt(i); i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -94,7 +94,7 @@ class ScalaSpec2Test extends Test { } } } - + class ScalaWrapTest extends Test { val arr: AbsArray[Int] = new ArraySeq(new Array[Int](1000)) @@ -104,7 +104,7 @@ class ScalaWrapTest extends Test { while (i < arr.length) { acc = acc + arr.applyInt(i); i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -114,7 +114,7 @@ class ScalaWrapTest extends Test { } } } - + class ScalaGenTest extends Test { val arr: AbsArray[Integer] = new ArraySeq(new Array[Integer](1000)) for (i <- 0 until arr.length) arr(i) = new Integer(0) @@ -125,7 +125,7 @@ class ScalaGenTest extends Test { while (i < arr.length) { acc = acc + arr.apply(i).intValue; i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -135,7 +135,7 @@ class ScalaGenTest extends Test { } } } - + class JavaTest extends Test { val arr = new Array[Int](1000) @@ -145,7 +145,7 @@ class JavaTest extends Test { while (i < arr.length) { acc = acc + arr(i); i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -166,7 +166,7 @@ class ScalaSpec3Test extends Test { while (i < arr.length) { acc = acc + arr(i); i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -188,25 +188,25 @@ object TestSpec extends scala.testing.Benchmark { (new ScalaSpecTest).run() } } - + object TestSpec2 extends scala.testing.Benchmark { def run() { (new ScalaSpec2Test).run() } } - + object TestGen extends scala.testing.Benchmark { def run() { (new ScalaGenTest).run() } } - + object TestWrap extends scala.testing.Benchmark { def run() { (new ScalaWrapTest).run() } } - + object TestSpec3 extends scala.testing.Benchmark { def run() { (new ScalaSpec3Test).run() diff --git a/test/files/pos/spec-asseenfrom.scala b/test/files/pos/spec-asseenfrom.scala index edd801071a..cf20fc5ffa 100644 --- a/test/files/pos/spec-asseenfrom.scala +++ b/test/files/pos/spec-asseenfrom.scala @@ -1,4 +1,4 @@ -class Automaton[@specialized(Double) W,State] { +class Automaton[@specialized(Double) W,State] { def finalWeight(s: State): W = error("todo"); diff --git a/test/files/pos/spec-cyclic.scala b/test/files/pos/spec-cyclic.scala index 65da297989..b983caa6db 100644 --- a/test/files/pos/spec-cyclic.scala +++ b/test/files/pos/spec-cyclic.scala @@ -6,18 +6,18 @@ trait MyPartialFunction[-A, +B] extends AnyRef with AbsFun[A, B] trait ColMap[A, +B] extends MyPartialFunction[A, B] /*with Collection[(A, B)] */ -trait ColSorted[K,+A] extends ColRanged[K,A] +trait ColSorted[K,+A] extends ColRanged[K,A] -trait ColSortedMap[K,+E] extends ColMap[K,E] with ColSorted[K,Tuple2[K,E]] +trait ColSortedMap[K,+E] extends ColMap[K,E] with ColSorted[K,Tuple2[K,E]] trait MutMap[A, B] extends AnyRef with ColMap[A, B] -trait ColRanged[K, +A] //extends Iterable[A] +trait ColRanged[K, +A] //extends Iterable[A] trait JclRanged[K,A] extends ColRanged[K,A] //with MutableIterable[A] { -trait JclMap[K,E] extends /*collection.jcl.MutableIterable[Tuple2[K,E]] with*/ MutMap[K,E] +trait JclMap[K,E] extends /*collection.jcl.MutableIterable[Tuple2[K,E]] with*/ MutMap[K,E] trait JclSorted[K,A] extends ColSorted[K,A] with JclRanged[K,A] diff --git a/test/files/pos/spec-funs.scala b/test/files/pos/spec-funs.scala index 5fea5e9560..9acc5054c9 100644 --- a/test/files/pos/spec-funs.scala +++ b/test/files/pos/spec-funs.scala @@ -19,7 +19,7 @@ final class IntTest { val xs = new Array[Int](10000) val f = new AbsFunction1[Int, Int] { def apply(x: Int): Int = x * x - } + } for (j <- 0 until niters) { transF(xs, f) } diff --git a/test/files/pos/spec-params.scala b/test/files/pos/spec-params.scala index 33a252120c..f522512846 100644 --- a/test/files/pos/spec-params.scala +++ b/test/files/pos/spec-params.scala @@ -10,7 +10,7 @@ class Foo[@specialized A: ClassManifest] { def m2[@specialized B <: String](x: B) = x.concat("a") // conflicting in bounds, no mention of other spec members - // expect an overload here plus implementation in + // expect an overload here plus implementation in // compatible specialized subclasses def m3[@specialized B >: A](x: B) = () @@ -19,10 +19,10 @@ class Foo[@specialized A: ClassManifest] { // non-conflicting, expect a normalized overload implementation here def m5[@specialized B](x: B) = x - + // non-conflicting, expect a normalized implementation here // and specialized implementations for all expansions in specialized subclasses - def m6[@specialized B](x: B, y: A) = + def m6[@specialized B](x: B, y: A) = goal(y) def goal(x: A) = { diff --git a/test/files/pos/spec-sealed.scala b/test/files/pos/spec-sealed.scala index 8c06148d3e..73256ac906 100644 --- a/test/files/pos/spec-sealed.scala +++ b/test/files/pos/spec-sealed.scala @@ -2,7 +2,7 @@ sealed abstract class MyList[@specialized +A] { def head: A def tail: MyList[A] - def ::[@specialized B >: A](x: B): MyList[B] = + def ::[@specialized B >: A](x: B): MyList[B] = new Cons[B](x, this) } @@ -19,7 +19,7 @@ case class Cons[@specialized a](private val hd: a, tl: MyList[a]) extends MyList abstract class IntList extends MyList[Int] object Main extends Application { - val xs = 1 :: 2 :: 3 :: MyNil + val xs = 1 :: 2 :: 3 :: MyNil println(xs) } diff --git a/test/files/pos/spec-short.scala b/test/files/pos/spec-short.scala index 71e56a485a..94a8007c6e 100644 --- a/test/files/pos/spec-short.scala +++ b/test/files/pos/spec-short.scala @@ -5,7 +5,7 @@ abstract class AbsFun[@specialized T, @specialized U] { // abstract function, specialized def sum(xs: List[T]): Int - def prod(xs: List[T], mul: (Int, T) => Int): Int = + def prod(xs: List[T], mul: (Int, T) => Int): Int = (1 /: xs)(mul) // concrete function, not specialized @@ -18,9 +18,9 @@ abstract class AbsFun[@specialized T, @specialized U] { class Square extends AbsFun[Int, Int] { def apply(x: Int): Int = x * x - def sum(xs: List[Int]): Int = + def sum(xs: List[Int]): Int = (0 /: xs) (_ + _) - def abs(m: Int): Int = + def abs(m: Int): Int = sum(List(1, 2, 3)) } diff --git a/test/files/pos/spec-t3497.scala b/test/files/pos/spec-t3497.scala index ff054aa7de..6cc0e24f89 100644 --- a/test/files/pos/spec-t3497.scala +++ b/test/files/pos/spec-t3497.scala @@ -10,7 +10,7 @@ object B extends A[ Array[Byte], Int ] { return -1 } } - + return 0 } } diff --git a/test/files/pos/spec-tailcall.scala b/test/files/pos/spec-tailcall.scala index 703ec011ad..d91e2f59ce 100644 --- a/test/files/pos/spec-tailcall.scala +++ b/test/files/pos/spec-tailcall.scala @@ -1,5 +1,5 @@ class TailCall[@specialized T] { - final def dropLeft(n: Int, xs: List[T]): List[T] = + final def dropLeft(n: Int, xs: List[T]): List[T] = if (n == 0) xs else dropLeft(n - 1, xs.tail) /* @@ -7,7 +7,7 @@ class TailCall[@specialized T] { def crash(o: Option[String]) = filter { case None if { - def dropLeft[T](n: Int, xs: List[T]): List[T] = + def dropLeft[T](n: Int, xs: List[T]): List[T] = if (n == 0) xs else dropLeft(n - 1, xs.tail) dropLeft(2, List(1, 2, 3)).isEmpty diff --git a/test/files/pos/spec-vector.scala b/test/files/pos/spec-vector.scala index 392949c669..06e49b521f 100644 --- a/test/files/pos/spec-vector.scala +++ b/test/files/pos/spec-vector.scala @@ -1,4 +1,4 @@ // ticket #3379, abstract overrides trait Vector extends (Int=>Double) { - override def apply(i: Int): Double + override def apply(i: Int): Double } diff --git a/test/files/pos/strings.scala b/test/files/pos/strings.scala index 9fe8cfd94b..83b8179706 100644 --- a/test/files/pos/strings.scala +++ b/test/files/pos/strings.scala @@ -6,5 +6,5 @@ object test { } // #1000 object A { - println("""This a "raw" string ending with a "double quote"""") + println("""This a "raw" string ending with a "double quote"""") } diff --git a/test/files/pos/sudoku.scala b/test/files/pos/sudoku.scala index 9875b22cfd..be05665809 100644 --- a/test/files/pos/sudoku.scala +++ b/test/files/pos/sudoku.scala @@ -3,22 +3,22 @@ object SudokuSolver extends Application { // held in a global variable m. The program begins by reading 9 lines // of input to fill the board var m: Array[Array[Char]] = Array.tabulate(9)((x: Int) => readLine.toArray) - + // For printing m, a method print is defined def print = { println(""); m map (carr => println(new String(carr))) } - + // The test for validity is performed by looping over i=0..8 and // testing the row, column and 3x3 square containing the given // coordinate def invalid(i: Int, x: Int, y: Int, n: Char): Boolean = i<9 && (m(y)(i) == n || m(i)(x) == n || m(y/3*3 + i/3)(x/3*3 + i % 3) == n || invalid(i+1, x, y, n)) - + // Looping over a half-closed range of consecutive integers [l..u) // is factored out into a higher-order function def fold(f: (Int, Int) => Int, accu: Int, l: Int, u: Int): Int = if(l==u) accu else fold(f, f(accu, l), l+1, u) - + // The search function examines each position on the board in turn, // trying the numbers 1..9 in each unfilled position // The function is itself a higher-order fold, accumulating the value @@ -34,7 +34,7 @@ object SudokuSolver extends Application { val newaccu = search(x+1, y, f, accu); m(y)(x) = '0'; newaccu}, accu, 1, 10)} - + // The main part of the program uses the search function to accumulate // the total number of solutions println("\n"+search(0,0,i => {print; i+1},0)+" solution(s)") diff --git a/test/files/pos/super/Super_1.java b/test/files/pos/super/Super_1.java index 9acbba0ec4..418ae96bc0 100644 --- a/test/files/pos/super/Super_1.java +++ b/test/files/pos/super/Super_1.java @@ -1,6 +1,6 @@ // A.java interface Inter<T> { } -class Super implements Inter<Super.Inner> { +class Super implements Inter<Super.Inner> { public class Inner { }; } diff --git a/test/files/pos/switchUnbox.scala b/test/files/pos/switchUnbox.scala index 4f5467de29..b8942e2559 100644 --- a/test/files/pos/switchUnbox.scala +++ b/test/files/pos/switchUnbox.scala @@ -1,6 +1,6 @@ -// this test has accompanying .flags file +// this test has accompanying .flags file // that contains -Xsqueeze:on -// +// object Foo { var xyz: (Int, String) = (1, "abc") xyz._1 match { diff --git a/test/files/pos/t0227.scala b/test/files/pos/t0227.scala index a52a9798fc..8650350c4a 100644 --- a/test/files/pos/t0227.scala +++ b/test/files/pos/t0227.scala @@ -19,7 +19,7 @@ class SA(val settings: Settings) extends Base { SD ) ::: settings.f( SC - ) + ) } object SC extends Factory { diff --git a/test/files/pos/t0288/Foo.scala b/test/files/pos/t0288/Foo.scala index 778ba65f58..1f7d81327d 100644 --- a/test/files/pos/t0288/Foo.scala +++ b/test/files/pos/t0288/Foo.scala @@ -6,4 +6,4 @@ class Foo extends Outer{ val bar = new Inner(); // Shouldn't this work? -} +} diff --git a/test/files/pos/t0288/Outer.java b/test/files/pos/t0288/Outer.java index bea3e3f8d0..7a3754fb5d 100644 --- a/test/files/pos/t0288/Outer.java +++ b/test/files/pos/t0288/Outer.java @@ -6,4 +6,4 @@ public class Outer{ } -} +} diff --git a/test/files/pos/t0438.scala b/test/files/pos/t0438.scala index fa5b7711ff..33b7efeaac 100644 --- a/test/files/pos/t0438.scala +++ b/test/files/pos/t0438.scala @@ -1,9 +1,9 @@ class Foo { - implicit def pair2fun2[A, B, C](f: (A, B) => C) = + implicit def pair2fun2[A, B, C](f: (A, B) => C) = {p: (A, B) => f(p._1, p._2) } def foo(f: ((Int, Int)) => Int) = f - def bar(x: Int, y: Int) = x + y + def bar(x: Int, y: Int) = x + y foo({ (x: Int, y: Int) => x + y }) // works foo(pair2fun2(bar _)) // works diff --git a/test/files/pos/t0453.scala b/test/files/pos/t0453.scala index dfacc5eed7..d59a3d22f2 100644 --- a/test/files/pos/t0453.scala +++ b/test/files/pos/t0453.scala @@ -1,5 +1,5 @@ object Test { - val foo = new { + val foo = new { trait Bar def l () : Bar = { new Bar {} } } diff --git a/test/files/pos/t0770.scala b/test/files/pos/t0770.scala index 7a0a2bf9bb..bb438f1918 100644 --- a/test/files/pos/t0770.scala +++ b/test/files/pos/t0770.scala @@ -1,7 +1,7 @@ trait A { private[this] val p = 5 - + def f = (b: Byte) => p } diff --git a/test/files/pos/t0774/unrelated.scala b/test/files/pos/t0774/unrelated.scala index 1efdb2505e..483f836d0c 100644 --- a/test/files/pos/t0774/unrelated.scala +++ b/test/files/pos/t0774/unrelated.scala @@ -1,8 +1,8 @@ object Outer { import Inner._ - + deathname - + object Inner { def deathname: Int = 1 } diff --git a/test/files/pos/t0786.scala b/test/files/pos/t0786.scala index f40cf7d2e1..4d9f1d0dc9 100644 --- a/test/files/pos/t0786.scala +++ b/test/files/pos/t0786.scala @@ -2,15 +2,15 @@ object ImplicitProblem { class M[T] def nullval[T] = null.asInstanceOf[T]; - + trait Rep[T] { def eval: Int } - + implicit def toRep0(n: Int) = new Rep[Int] { def eval = 0 } - + implicit def toRepN[T](n: M[T])(implicit f: T => Rep[T]) = new Rep[M[T]] { def eval = f(nullval[T]).eval + 1 } @@ -18,11 +18,11 @@ object ImplicitProblem { def depth[T <% Rep[T]](n: T) = n.eval def main(args: Array[String]) { - println(depth(nullval[M[Int]])) // (1) this works + println(depth(nullval[M[Int]])) // (1) this works println(nullval[M[Int]].eval) // (2) this works - + type m = M[Int] - println(depth(nullval[m])) // (3) this doesn't compile on 2.7.RC1 + println(depth(nullval[m])) // (3) this doesn't compile on 2.7.RC1 println(nullval[m].eval) // (4) this works } diff --git a/test/files/pos/t0816.scala b/test/files/pos/t0816.scala index 0128a0ad72..738a634166 100644 --- a/test/files/pos/t0816.scala +++ b/test/files/pos/t0816.scala @@ -6,7 +6,7 @@ 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 Ctest(data) => Console.println("C") case Btest(data, b) => Console.println("B") } } diff --git a/test/files/pos/t1000.scala b/test/files/pos/t1000.scala index 38f71863d8..31d7c7e902 100644 --- a/test/files/pos/t1000.scala +++ b/test/files/pos/t1000.scala @@ -1,3 +1,3 @@ object A { - println("""This a "raw" string ending with a "double quote"""") + println("""This a "raw" string ending with a "double quote"""") } diff --git a/test/files/pos/t1035.scala b/test/files/pos/t1035.scala index a280a415d2..5c8670aae3 100644 --- a/test/files/pos/t1035.scala +++ b/test/files/pos/t1035.scala @@ -7,7 +7,7 @@ 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){ @@ -18,15 +18,15 @@ 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") - - + case B(n) => println("B") + case A(n) => println("A") + + } } diff --git a/test/files/pos/t1059.scala b/test/files/pos/t1059.scala index 659bf375ca..bcd8f0374f 100644 --- a/test/files/pos/t1059.scala +++ b/test/files/pos/t1059.scala @@ -25,4 +25,4 @@ object SafeNodeSeq { })) case _ => None } -} +} diff --git a/test/files/pos/t1107/O.scala b/test/files/pos/t1107/O.scala index 0198867704..aa605a6d09 100644 --- a/test/files/pos/t1107/O.scala +++ b/test/files/pos/t1107/O.scala @@ -4,10 +4,10 @@ object O case s: Sub => true case _ => false } - + def main(args: Array[String]): Unit = { val c = new AnyRef with C c.bob.toString + c.bob2.toString - } + } } diff --git a/test/files/pos/t1107/T.scala b/test/files/pos/t1107/T.scala index 0dff0b94fd..1f3712d529 100644 --- a/test/files/pos/t1107/T.scala +++ b/test/files/pos/t1107/T.scala @@ -1,6 +1,6 @@ sealed trait Top sealed trait Sub extends Top -trait C { +trait C { private object P extends Sub def bob() = P.getClass def bob2() = O.d(P) diff --git a/test/files/pos/t1164.scala b/test/files/pos/t1164.scala index ca780c9a26..307ca92c85 100644 --- a/test/files/pos/t1164.scala +++ b/test/files/pos/t1164.scala @@ -1,29 +1,29 @@ -object test { +object test { - class Foo[a](val arg : a) - - object Foo { - def apply [a](arg : a, right :a) = new Foo[a](arg) - def unapply [a](m : Foo[a]) = Some (m.arg) - } + class Foo[a](val arg : a) + object Foo { + def apply [a](arg : a, right :a) = new Foo[a](arg) + def unapply [a](m : Foo[a]) = Some (m.arg) + } + def matchAndGetArgFromFoo[a]( e:Foo[a]):a = {e match { case Foo(x) => x }} - - + + // Try the same thing as above but use function as argument to Bar // constructor - + type FunIntToA [a] = (Int) => a - class Bar[a] (var f: FunIntToA[a]) - + class Bar[a] (var f: FunIntToA[a]) + object Bar { def apply[a](f: FunIntToA[a]) = new Bar[a](f) def unapply[a](m: Bar[a]) = Some (m.f) } - + def matchAndGetFunFromBar[a](b:Bar[a]) : FunIntToA[a] = { b match { case Bar(x) => x}} - + } diff --git a/test/files/pos/t1236.scala b/test/files/pos/t1236.scala index 5e221ce411..7028162ee0 100644 --- a/test/files/pos/t1236.scala +++ b/test/files/pos/t1236.scala @@ -1,5 +1,5 @@ trait Empty[E[_]] { - def e[A]: E[A] + def e[A]: E[A] } object T { diff --git a/test/files/pos/t1254/t1254.java b/test/files/pos/t1254/t1254.java index 17e1c60bf5..17dc391672 100644 --- a/test/files/pos/t1254/t1254.java +++ b/test/files/pos/t1254/t1254.java @@ -11,7 +11,7 @@ class NothingBug3 { scala.Option<?> o = scala.None$.MODULE$; test(o); - None.toLeft(new scala.runtime.AbstractFunction0<Integer>() { + None.toLeft(new scala.runtime.AbstractFunction0<Integer>() { public Integer apply() { return 0; } }); } diff --git a/test/files/pos/t1263/test.scala b/test/files/pos/t1263/test.scala index 92d8c1cdfa..7ced59083a 100644 --- a/test/files/pos/t1263/test.scala +++ b/test/files/pos/t1263/test.scala @@ -2,7 +2,7 @@ package test trait Map[A, +B] { def plus(key: A): MapTo = new MapTo(key) - + class MapTo(key: A) { def arrow [B1 >: B](value: B1) = null } diff --git a/test/files/pos/t1459/App.scala b/test/files/pos/t1459/App.scala index 651b285b17..1152fcb0c3 100755 --- a/test/files/pos/t1459/App.scala +++ b/test/files/pos/t1459/App.scala @@ -8,11 +8,11 @@ object App extends Application { val impl = new Concrete - //succeeds + //succeeds
impl.doStuff(null) val caller = new Caller - + // fails with AbstractMethodError caller.callDoStuff(impl) } diff --git a/test/files/pos/t1480.scala b/test/files/pos/t1480.scala index 1d9f94d2e9..3dc3062ca0 100644 --- a/test/files/pos/t1480.scala +++ b/test/files/pos/t1480.scala @@ -1,6 +1,6 @@ class Foo{ def compare(newP : Any, oldP : Any) : Boolean = (newP,oldP) match { - case (newP : AnyRef, oldP : AnyRef) if newP == oldP => newP == oldP - case (newS : Symbol, oldS: Symbol) if newS == oldS => newS == oldS + case (newP : AnyRef, oldP : AnyRef) if newP == oldP => newP == oldP + case (newS : Symbol, oldS: Symbol) if newS == oldS => newS == oldS } } diff --git a/test/files/pos/t1545.scala b/test/files/pos/t1545.scala index d7c0245725..d52cfa1659 100755 --- a/test/files/pos/t1545.scala +++ b/test/files/pos/t1545.scala @@ -9,8 +9,8 @@ object Main extends Application { case None => 99 } } - + println (x (Foo (None))) // prints 99 println (x (Foo (Some ("foo")))) // prints 42 - + } diff --git a/test/files/pos/t1560.scala b/test/files/pos/t1560.scala index 49cdaaed6a..c1d8a8164c 100644 --- a/test/files/pos/t1560.scala +++ b/test/files/pos/t1560.scala @@ -1,13 +1,13 @@ object Test extends Application { - + trait C[T] { def t: T } - + def b: Option[C[x] forSome { type x }] = null - + def c = b match { case Some(b) => b.t } - + } diff --git a/test/files/pos/t1591b.scala b/test/files/pos/t1591b.scala index c671ad6472..84372bb084 100644 --- a/test/files/pos/t1591b.scala +++ b/test/files/pos/t1591b.scala @@ -1,10 +1,10 @@ import scala.tools.nsc._ -class SemanticTokens(val compiler: Global) { - import compiler._ +class SemanticTokens(val compiler: Global) { + import compiler._ def build() = ErrorType - + class Process { def f() = analyzer // or to crash the compiler instead of a nice message, diff --git a/test/files/pos/t1711/Seq.scala b/test/files/pos/t1711/Seq.scala index c18f05cd73..5f426ea0f7 100644 --- a/test/files/pos/t1711/Seq.scala +++ b/test/files/pos/t1711/Seq.scala @@ -3,7 +3,7 @@ package com object Sequence { def filteringFunction[V](filter: V => Boolean): List[V] => List[V] = { - def include(v: V) = + def include(v: V) = filter(v) (l: List[V]) => l.filter(include) } diff --git a/test/files/pos/t1722-A.scala b/test/files/pos/t1722-A.scala index d059bf22f8..9e522a5059 100644 --- a/test/files/pos/t1722-A.scala +++ b/test/files/pos/t1722-A.scala @@ -1,8 +1,8 @@ sealed trait Top trait C { private object P extends Top -} -/* +} +/* $ scala -e 'new AnyRef with C' error: error while loading Top, class file '/private/tmp/bobobo/./Top.class' is broken (error reading Scala signature of /private/tmp/bobobo/./Top.class: malformed Scala signature of Top at 185; reference value P of trait C refers to nonexisting symbol.) diff --git a/test/files/pos/t1722/Test.scala b/test/files/pos/t1722/Test.scala index f236d3fdc4..5685d8f40a 100755 --- a/test/files/pos/t1722/Test.scala +++ b/test/files/pos/t1722/Test.scala @@ -1,5 +1,5 @@ package t1722 object Test { - val x = new AnyRef with C + val x = new AnyRef with C } diff --git a/test/files/pos/t1722/Top.scala b/test/files/pos/t1722/Top.scala index 4ac52412aa..cec4c531f9 100755 --- a/test/files/pos/t1722/Top.scala +++ b/test/files/pos/t1722/Top.scala @@ -3,8 +3,8 @@ package t1722 sealed trait Top trait C { private object P extends Top -} -/* +} +/* $ scala -e 'new AnyRef with C' error: error while loading Top, class file '/private/tmp/bobobo/./Top.class' is broken (error reading Scala signature of /private/tmp/bobobo/./Top.class: malformed Scala signature of Top at 185; reference value P of trait C refers to nonexisting symbol.) diff --git a/test/files/pos/t1745/J.java b/test/files/pos/t1745/J.java index 8444eabb24..d95efe8e6f 100644 --- a/test/files/pos/t1745/J.java +++ b/test/files/pos/t1745/J.java @@ -1,9 +1,9 @@ -class J { +class J { S1 s1; S2 s2; - + String s = bar(S3.foo(), S3.bar("def")); - + private String bar(String s1, String s2) { return s1 + s2; } diff --git a/test/files/pos/t1756.scala b/test/files/pos/t1756.scala index d5d3ddc624..7aea525f64 100755 --- a/test/files/pos/t1756.scala +++ b/test/files/pos/t1756.scala @@ -1,5 +1,5 @@ -/** +/** This is a tricky issue which has to do with the fact that too much conflicting type information is propagated into a single implicit search, where the intended solution applies two implicit searches. @@ -35,20 +35,20 @@ class Poly[C <: Ring[C]](val c: C) extends Ring[Poly[C]] { } object Test extends Application { - + implicit def coef2poly[C <: Ring[C]](c: C): Poly[C] = new Poly(c) val a = new A val x = new Poly(new A) - + println(x+a) // works println(a+x) // works - + val y = new Poly(new Poly(new A)) - + println(x+y*x) // works println(x*y+x) // works println(y*x+x) // works - + println(x+x*y) // failed before } diff --git a/test/files/pos/t1761.scala b/test/files/pos/t1761.scala index a3ceeea815..2af7280734 100644 --- a/test/files/pos/t1761.scala +++ b/test/files/pos/t1761.scala @@ -3,7 +3,7 @@ import scala.xml._ class Foo { val elements: Seq[Node] = Nil val innerTransform: PartialFunction[Elem, String] = { - case Elem(_, l: String, _, _, _ @ _*) if elements.exists(_.label == l) => + case Elem(_, l: String, _, _, _ @ _*) if elements.exists(_.label == l) => l } } diff --git a/test/files/pos/t1798.scala b/test/files/pos/t1798.scala index 1624e3025e..93df61e844 100644 --- a/test/files/pos/t1798.scala +++ b/test/files/pos/t1798.scala @@ -2,7 +2,7 @@ object Foo { private def bar(): Int = 55 } class Foo(x: Int) { def this() = this(Foo.bar()) } /* - * scalac28 a.scala + * scalac28 a.scala a.scala:2: error: method bar cannot be accessed in object Foo class Foo(x: Int) { def this() = this(Foo.bar()) } ^ diff --git a/test/files/pos/t1840/J.java b/test/files/pos/t1840/J.java index fd98b6c4a5..a697596fdd 100644 --- a/test/files/pos/t1840/J.java +++ b/test/files/pos/t1840/J.java @@ -1,4 +1,4 @@ package p; -class J { - J() {} +class J { + J() {} } diff --git a/test/files/pos/t2023.scala b/test/files/pos/t2023.scala index 21c6fc96a6..de3e848fbd 100644 --- a/test/files/pos/t2023.scala +++ b/test/files/pos/t2023.scala @@ -3,11 +3,11 @@ trait C[A] object C { implicit def ipl[A](implicit from: A => Ordered[A]): C[A] = null } - + object P { def foo[A](i: A, j: A)(implicit c: C[A]): Unit = () } - + class ImplicitChainTest { def testTrivial: Unit = { P.foo('0', '9') diff --git a/test/files/pos/t2060.scala b/test/files/pos/t2060.scala index 2c701150e4..cf7250f545 100755 --- a/test/files/pos/t2060.scala +++ b/test/files/pos/t2060.scala @@ -4,7 +4,7 @@ * line': * * val failure = 1.0 + new Op[Int] - * + * * we reduce the problem to finding a function from Double to * {+: _ >: Op[Int] <: Any}, that is, a method which takes * an argument which is an Op[Int] or a supertype thereof. diff --git a/test/files/pos/t2082.scala b/test/files/pos/t2082.scala index 3a160612fe..38937d78fb 100755 --- a/test/files/pos/t2082.scala +++ b/test/files/pos/t2082.scala @@ -1,10 +1,10 @@ trait Mapper[T <: Mapper[T]] -trait KeyedMapper[KeyType, T <: KeyedMapper[KeyType, T]] extends Mapper[T] +trait KeyedMapper[KeyType, T <: KeyedMapper[KeyType, T]] extends Mapper[T] -trait KeyedMetaMapper[KeyType, T <: KeyedMapper[KeyType, T]] +trait KeyedMetaMapper[KeyType, T <: KeyedMapper[KeyType, T]] trait MappedForeignKey[KeyType, Owner <: Mapper[Owner], Other <: KeyedMapper[KeyType, Other]] @@ -19,19 +19,19 @@ class TestRun extends KeyedMapper[Long, TestRun] with IdPK { object TestRun extends TestRun with KeyedMetaMapper[Long, TestRun] class MetaTestSubject extends TestSubject with KeyedMetaMapper[Long, TestSubject] -object TestSubject extends MetaTestSubject +object TestSubject extends MetaTestSubject object Main { - + def oneToOneJoin[PType <: KeyedMapper[Long, PType] with IdPK, CType <: KeyedMapper[Long, CType] with IdPK, - CMetaType <: CType with KeyedMetaMapper[Long, CType], + CMetaType <: CType with KeyedMetaMapper[Long, CType], FKType <: MappedForeignKey[Long, PType, CType]] - (parents: List[PType], metaMapper: CMetaType, keyGetter: (PType) => FKType ): + (parents: List[PType], metaMapper: CMetaType, keyGetter: (PType) => FKType ): Map[Long, CType] = Map.empty - + def callIt { - oneToOneJoin[TestRun, TestSubject, MetaTestSubject, + oneToOneJoin[TestRun, TestSubject, MetaTestSubject, MappedForeignKey[Long, TestRun, TestSubject]]( List(), TestSubject, (tr: TestRun) => tr.testSubject) } diff --git a/test/files/pos/t2133.scala b/test/files/pos/t2133.scala index c74d0a4bbf..99bac5c38b 100644 --- a/test/files/pos/t2133.scala +++ b/test/files/pos/t2133.scala @@ -13,6 +13,6 @@ trait Foo2 { class Bob extends AnyRef with Foo with Foo2 { import bip._ import bar._ - + def go() = fn() } diff --git a/test/files/pos/t2261.scala b/test/files/pos/t2261.scala index aac5c9e0fd..af24234235 100644 --- a/test/files/pos/t2261.scala +++ b/test/files/pos/t2261.scala @@ -5,5 +5,5 @@ object Test { x = List(1,2,3) // the problem here was that somehow the type variable that was used to infer the type argument for List.apply // would accumulate several conflicting constraints - // can't reproduce with + // can't reproduce with }
\ No newline at end of file diff --git a/test/files/pos/t2305.scala b/test/files/pos/t2305.scala index 8b5abccbe0..d0b103fdba 100644 --- a/test/files/pos/t2305.scala +++ b/test/files/pos/t2305.scala @@ -1,6 +1,6 @@ import java.util.ArrayList -trait Bind[Z[_]] +trait Bind[Z[_]] class MySerializable[X] extends java.io.Serializable @@ -17,7 +17,7 @@ object works { object breaks { def runbind(implicit bind: Bind[ArrayList]) {} - runbind + runbind /*java.lang.AssertionError: assertion failed: java.io.Serializable at scala.Predef$.assert(Predef.scala:107) at scala.tools.nsc.symtab.Types$TypeRef.transform(Types.scala:1417) diff --git a/test/files/pos/t2413/TestScalac.scala b/test/files/pos/t2413/TestScalac.scala index 098e852dd7..6992a30f2c 100644 --- a/test/files/pos/t2413/TestScalac.scala +++ b/test/files/pos/t2413/TestScalac.scala @@ -4,7 +4,7 @@ class Foo extends TestJava { // THIS METHOD YIELDS TO CRASH /* def foomethod : Option[String] => Unit = { - case None => + case None => val path = repeatParam("s","a","b","c") () case Some(error) => diff --git a/test/files/pos/t2421.scala b/test/files/pos/t2421.scala index 0d01be29fc..26e485c160 100644 --- a/test/files/pos/t2421.scala +++ b/test/files/pos/t2421.scala @@ -7,8 +7,8 @@ object Test { implicit val forcibleInt: (Int <~< Forcible[Int]) = error("") def headProxy[P <: Forcible[Int]](implicit w: Int <~< P): P = error("") - - headProxy - // trivial[Int] should not be considered a valid implicit, since w would have type Int <~< Int, + + headProxy + // trivial[Int] should not be considered a valid implicit, since w would have type Int <~< Int, // and headProxy's type parameter P cannot be instantiated to Int }
\ No newline at end of file diff --git a/test/files/pos/t2421_delitedsl.scala b/test/files/pos/t2421_delitedsl.scala index a05887023a..ad6afa7bd8 100644 --- a/test/files/pos/t2421_delitedsl.scala +++ b/test/files/pos/t2421_delitedsl.scala @@ -1,10 +1,10 @@ trait DeliteDSL { abstract class <~<[-From, +To] extends (From => To) - implicit def trivial[A]: A <~< A = new (A <~< A) {def apply(x: A) = x} + implicit def trivial[A]: A <~< A = new (A <~< A) {def apply(x: A) = x} trait Forcible[T] object Forcible { - def factory[T](f: T => Forcible[T]) = new (T <~< Forcible[T]){def apply(x: T) = f(x)} + def factory[T](f: T => Forcible[T]) = new (T <~< Forcible[T]){def apply(x: T) = f(x)} } case class DeliteInt(x: Int) extends Forcible[Int] @@ -22,16 +22,16 @@ trait DeliteDSL { // If T is already a proxy (it is forcible), the compiler should use // forcibleIdentity to deduce that P=T. If T is Int, the compiler // should use intToForcible to deduce that P=DeliteInt. - // + // // Without this feature, the user must write 'xs.proxyOfFirst[DeliteInt]', // with the feature they can write 'xs.proxyOfFirst', which is shorter and // avoids exposing internal DELITE types to the world. object Test { - val x = new DeliteCollection(List(1,2,3)).headProxy + val x = new DeliteCollection(List(1,2,3)).headProxy // inferred: val x: Forcible[Int] = new DeliteCollection[Int](List.apply[Int](1, 2, 3)).headProxy[Forcible[Int]](forcibleInt); - val xAlready = new DeliteCollection(List(DeliteInt(1),DeliteInt(2),DeliteInt(3))).headProxy + val xAlready = new DeliteCollection(List(DeliteInt(1),DeliteInt(2),DeliteInt(3))).headProxy // inferred: val xAlready: DeliteInt = new DeliteCollection[DeliteInt](List.apply[DeliteInt](DeliteInt(1), DeliteInt(2), DeliteInt(3))).headProxy[DeliteInt](trivial[DeliteInt]); } }
\ No newline at end of file diff --git a/test/files/pos/t2421b.scala b/test/files/pos/t2421b.scala index 0df3461662..8b848abb75 100644 --- a/test/files/pos/t2421b.scala +++ b/test/files/pos/t2421b.scala @@ -11,7 +11,7 @@ object Test { f } -/* bug: +/* bug: error: ambiguous implicit values: both method b in object Test1 of type [X <: Test1.B]Test1.F[X] and method a in object Test1 of type => Test1.F[Test1.A] diff --git a/test/files/pos/t2429.scala b/test/files/pos/t2429.scala index 9b9cb89de7..3ea3f9e2a5 100755 --- a/test/files/pos/t2429.scala +++ b/test/files/pos/t2429.scala @@ -1,8 +1,8 @@ object Msg { trait T - + trait TSeq - + object TSeq { implicit def fromSeq(s: Seq[T]): TSeq = error("stub") } diff --git a/test/files/pos/t2433/A.java b/test/files/pos/t2433/A.java index 340690c402..8ae23ff816 100755 --- a/test/files/pos/t2433/A.java +++ b/test/files/pos/t2433/A.java @@ -1,4 +1,4 @@ -class A223 extends B223.Inner { - static class Inner {} - void foo() {} +class A223 extends B223.Inner {
+ static class Inner {}
+ void foo() {}
}
\ No newline at end of file diff --git a/test/files/pos/t2433/B.java b/test/files/pos/t2433/B.java index 151dd71ca1..d0d5580ffb 100755 --- a/test/files/pos/t2433/B.java +++ b/test/files/pos/t2433/B.java @@ -1,4 +1,4 @@ -class B223 { - static class Inner {} - void m(A223.Inner x) {} +class B223 {
+ static class Inner {}
+ void m(A223.Inner x) {}
}
\ No newline at end of file diff --git a/test/files/pos/t2433/Test.scala b/test/files/pos/t2433/Test.scala index 02fd89b646..0e07231e07 100755 --- a/test/files/pos/t2433/Test.scala +++ b/test/files/pos/t2433/Test.scala @@ -1,3 +1,3 @@ -object Test { - (new A223).foo() -} +object Test {
+ (new A223).foo()
+}
diff --git a/test/files/pos/t2444.scala b/test/files/pos/t2444.scala index 6f07dcf92d..a052270196 100644 --- a/test/files/pos/t2444.scala +++ b/test/files/pos/t2444.scala @@ -2,14 +2,14 @@ object Test { trait Foo - class Bar { + class Bar { object baz extends Foo } - def frob[P1, P2<:Foo](f:P1 => P2) = () + def frob[P1, P2<:Foo](f:P1 => P2) = () def main(args:Array[String]) : Unit = { - frob((p:Bar) => p.baz) + frob((p:Bar) => p.baz) } } diff --git a/test/files/pos/t2464/ScalaOne_1.scala b/test/files/pos/t2464/ScalaOne_1.scala index 1caf8ecae4..0271b9ce72 100644 --- a/test/files/pos/t2464/ScalaOne_1.scala +++ b/test/files/pos/t2464/ScalaOne_1.scala @@ -1,6 +1,6 @@ class ScalaClassOne extends ClassTwo.Child { def func4() = { func2 - } + } } diff --git a/test/files/pos/t2484.scala b/test/files/pos/t2484.scala index 6990c46099..20c51b09a1 100755 --- a/test/files/pos/t2484.scala +++ b/test/files/pos/t2484.scala @@ -1,17 +1,17 @@ -class Admin extends javax.swing.JApplet { - val jScrollPane = new javax.swing.JScrollPane (null, 0, 0) - def bug2484: Unit = { - scala.concurrent.ops.spawn {jScrollPane.synchronized { - def someFunction () = {} - //scala.concurrent.ops.spawn {someFunction ()} - jScrollPane.addComponentListener (new java.awt.event.ComponentAdapter {override def componentShown (e: java.awt.event.ComponentEvent) = { - someFunction (); jScrollPane.removeComponentListener (this)}}) - }} - } -} -// t2630.scala -object Test { - def meh(xs: List[Any]) { - xs map { x => (new AnyRef {}) } - } -} +class Admin extends javax.swing.JApplet {
+ val jScrollPane = new javax.swing.JScrollPane (null, 0, 0)
+ def bug2484: Unit = {
+ scala.concurrent.ops.spawn {jScrollPane.synchronized {
+ def someFunction () = {}
+ //scala.concurrent.ops.spawn {someFunction ()}
+ jScrollPane.addComponentListener (new java.awt.event.ComponentAdapter {override def componentShown (e: java.awt.event.ComponentEvent) = {
+ someFunction (); jScrollPane.removeComponentListener (this)}})
+ }}
+ }
+}
+// t2630.scala
+object Test {
+ def meh(xs: List[Any]) {
+ xs map { x => (new AnyRef {}) }
+ }
+}
diff --git a/test/files/pos/t2504.scala b/test/files/pos/t2504.scala index 67f8226852..0abe7dd13e 100755 --- a/test/files/pos/t2504.scala +++ b/test/files/pos/t2504.scala @@ -1,5 +1,5 @@ object Test { val ys: Iterable[_] = Array("abc") - val xs = Array("abc") + val xs = Array("abc") xs sameElements Array("abc") } diff --git a/test/files/pos/t2545.scala b/test/files/pos/t2545.scala index 6ad994223c..b4238fb718 100755 --- a/test/files/pos/t2545.scala +++ b/test/files/pos/t2545.scala @@ -1,6 +1,6 @@ trait Frog[T] { - def hello: T - def size: Int + def hello: T + def size: Int } trait OnlyWithFrogs { diff --git a/test/files/pos/t2569/Child.scala b/test/files/pos/t2569/Child.scala index 64f4dc172f..3d7f4248b5 100644 --- a/test/files/pos/t2569/Child.scala +++ b/test/files/pos/t2569/Child.scala @@ -1,9 +1,9 @@ package varargs - + class Child extends Parent { - + override def concatenate(strings: String*): String = strings map("\"" + _ + "\"") mkString("(", ", ", ")") - + } diff --git a/test/files/pos/t2569/Parent.java b/test/files/pos/t2569/Parent.java index 89421becbd..133f2ee567 100644 --- a/test/files/pos/t2569/Parent.java +++ b/test/files/pos/t2569/Parent.java @@ -1,7 +1,7 @@ package varargs; - + public class Parent { - + public String concatenate(String... strings) { StringBuilder builder = new StringBuilder(); for (String s : strings) { @@ -9,5 +9,5 @@ package varargs; } return builder.toString(); } - + } diff --git a/test/files/pos/t2665.scala b/test/files/pos/t2665.scala index 3163e31326..108daf509a 100644 --- a/test/files/pos/t2665.scala +++ b/test/files/pos/t2665.scala @@ -1,3 +1,3 @@ object Test { - val x: Unit = Array("") + val x: Unit = Array("") }
\ No newline at end of file diff --git a/test/files/pos/t2669.scala b/test/files/pos/t2669.scala index 72e931178c..e34f08f0f5 100644 --- a/test/files/pos/t2669.scala +++ b/test/files/pos/t2669.scala @@ -23,6 +23,6 @@ import java.util.Vector // scalac cannot detect lack of type params, but then throws AssertionError later: class TVector2639 { - val b = new Vector // this line passed without error detected + val b = new Vector // this line passed without error detected val a = new Vector(1) // this line caused throwing AssertionError when scalac } diff --git a/test/files/pos/t2691.scala b/test/files/pos/t2691.scala index ba2e52f1fe..3c0d193e9a 100644 --- a/test/files/pos/t2691.scala +++ b/test/files/pos/t2691.scala @@ -1,5 +1,5 @@ object Breakdown { - def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there")) + def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there")) } object Test { 42 match { diff --git a/test/files/pos/t2726/SQLBuilder_1.scala b/test/files/pos/t2726/SQLBuilder_1.scala index 8d07a88265..7b3e3d8322 100644 --- a/test/files/pos/t2726/SQLBuilder_1.scala +++ b/test/files/pos/t2726/SQLBuilder_1.scala @@ -1,7 +1,7 @@ class SQLBuilder extends SQLBuilder.Segment -object SQLBuilder { - trait Segment +object SQLBuilder { + trait Segment } diff --git a/test/files/pos/t2741/2741-1.scala b/test/files/pos/t2741/2741-1.scala index 91c120ec1b..7a7ef412ae 100644 --- a/test/files/pos/t2741/2741-1.scala +++ b/test/files/pos/t2741/2741-1.scala @@ -1,13 +1,13 @@ -sealed trait Kleisli[M[_], A, B] - -trait PartialApplyKA[T[_[_], _, _], M[_], A] { - type Apply[B] = T[M, A, B] -} - -trait MA[M[_], A] - -trait MAs { - val a: MA[PartialApplyKA[Kleisli, List, String]#Apply, Int] = null -} - -object Scalaz extends MAs +sealed trait Kleisli[M[_], A, B]
+
+trait PartialApplyKA[T[_[_], _, _], M[_], A] {
+ type Apply[B] = T[M, A, B]
+}
+
+trait MA[M[_], A]
+
+trait MAs {
+ val a: MA[PartialApplyKA[Kleisli, List, String]#Apply, Int] = null
+}
+
+object Scalaz extends MAs
diff --git a/test/files/pos/t2741/2741-2.scala b/test/files/pos/t2741/2741-2.scala index 41f6a64260..d17c76efb2 100644 --- a/test/files/pos/t2741/2741-2.scala +++ b/test/files/pos/t2741/2741-2.scala @@ -1,5 +1,5 @@ -// object Test compiles jointly, but not separately. -object Test { - import Scalaz._ - Scalaz.a +// object Test compiles jointly, but not separately.
+object Test {
+ import Scalaz._
+ Scalaz.a
}
\ No newline at end of file diff --git a/test/files/pos/t2913.scala b/test/files/pos/t2913.scala index 11d8b92053..ee86b9e402 100755 --- a/test/files/pos/t2913.scala +++ b/test/files/pos/t2913.scala @@ -11,13 +11,13 @@ class RichA { object Test { implicit def AToRichA(a: A) = new RichA - + val a = new A a.foo() a.foo(1) a.foo("") // Without implicits, a type error regarding invalid argument types is generated at `""`. This is - // the same position as an argument, so the 'second try' typing with an Implicit View is tried, + // the same position as an argument, so the 'second try' typing with an Implicit View is tried, // and AToRichA(a).foo("") is found. // // My reading of the spec "7.3 Views" is that `a.foo` denotes a member of `a`, so the view should @@ -48,6 +48,6 @@ object Main { val fn = (a : Int, str : String) => "a: " + a + ", str: " + str implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null) println(fn(1)) - () + () } } diff --git a/test/files/pos/t2940/Error.scala b/test/files/pos/t2940/Error.scala index bf5a6bd0df..7c600667f3 100644 --- a/test/files/pos/t2940/Error.scala +++ b/test/files/pos/t2940/Error.scala @@ -5,8 +5,8 @@ abstract class Error { object Test { trait Quux[T] extends Cycle[Quux[T]] val x = new Quux[Int] { def doStuff() { } } - + def main(args: Array[String]): Unit = { - + } } diff --git a/test/files/pos/t2994a.scala b/test/files/pos/t2994a.scala index cb4a389e2f..f2d57c34ca 100644 --- a/test/files/pos/t2994a.scala +++ b/test/files/pos/t2994a.scala @@ -17,8 +17,8 @@ object Naturals { type _5 = SUCC[_4] type _6 = SUCC[_5] - - // crashes scala-2.8.0 beta1 + + // crashes scala-2.8.0 beta1 trait MUL[n <: NAT, m <: NAT] extends NAT { trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] } type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] diff --git a/test/files/pos/t3079.scala b/test/files/pos/t3079.scala index fa732ea516..4bead34ff3 100644 --- a/test/files/pos/t3079.scala +++ b/test/files/pos/t3079.scala @@ -10,8 +10,8 @@ object Coerce { def IdentityCoerce[B] = new Coerce[Identity[B], B] { // java.lang.Error: A in trait Identity cannot be instantiated from ?x$1.type def unwrap = _.value - + // Providing the type of _ works around the problem. - //def unwrap = (_: Identity[B]).value + //def unwrap = (_: Identity[B]).value } }
\ No newline at end of file diff --git a/test/files/pos/t3174b.scala b/test/files/pos/t3174b.scala index 4df1bfe837..002c4f090f 100755 --- a/test/files/pos/t3174b.scala +++ b/test/files/pos/t3174b.scala @@ -2,9 +2,9 @@ trait Foo[X] { def foo : Map[String,Foo[X]] } object Test { def f[T]() : Foo[T] = { - class Anon extends Foo[T] { - var foo: Map[String, Foo[T]] = Map[String,Foo[T]]() - //def foo = Map[String,Foo[T]]() + class Anon extends Foo[T] { + var foo: Map[String, Foo[T]] = Map[String,Foo[T]]() + //def foo = Map[String,Foo[T]]() //def foo_=(x: Map[String,Foo[T]]) {} } new Anon diff --git a/test/files/pos/t3177.scala b/test/files/pos/t3177.scala index 9f9528faec..21893c9422 100644 --- a/test/files/pos/t3177.scala +++ b/test/files/pos/t3177.scala @@ -1,17 +1,17 @@ trait InvariantFunctor[F[_]] { def xmap[A, B](ma: F[A], f: A => B, g: B => A): F[B] } - + object InvariantFunctor { import Endo._ - + implicit val EndoInvariantFunctor = new InvariantFunctor[Endo] { - def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) } - + // The definition about fails with: // anon-type.scala:9: error: not found: value b - // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) // ^ // anon-type.scala:8: error: not found: type $anon // implicit val EndoInvariantFunctor = new InvariantFunctor[Endo] { @@ -20,9 +20,9 @@ object InvariantFunctor { // These both work: // implicit val EndoInvariantFunctorAscribed: InvariantFunctor[Endo] = new InvariantFunctor[Endo] { - // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) // } - // + // // implicit val EndoInvariantFunctorStubbed = new InvariantFunctor[Endo] { // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = error("stub") // } diff --git a/test/files/pos/t3274.scala b/test/files/pos/t3274.scala index 15723184bb..dfa6a4ec01 100644 --- a/test/files/pos/t3274.scala +++ b/test/files/pos/t3274.scala @@ -1,7 +1,7 @@ -trait A { this: B => - trait X { +trait A { this: B => + trait X { class Y1 extends Y - } + } } trait B extends A { diff --git a/test/files/pos/t3349/AbstractTupleSet.java b/test/files/pos/t3349/AbstractTupleSet.java index 38e4743ef4..47b440a589 100644 --- a/test/files/pos/t3349/AbstractTupleSet.java +++ b/test/files/pos/t3349/AbstractTupleSet.java @@ -5,5 +5,5 @@ public abstract class AbstractTupleSet implements TupleSet { public void addColumn(String name, String expr) { throw new UnsupportedOperationException(); - } + } } diff --git a/test/files/pos/t3363.scala b/test/files/pos/t3363.scala index bae54084ea..302f8c43cc 100755 --- a/test/files/pos/t3363.scala +++ b/test/files/pos/t3363.scala @@ -1,18 +1,18 @@ -object TestCase { - - //now matter if you put (abstract) class or trait it will fail in all cases - trait MapOps[T] - - //if fs was reduced to List (generic type with one parameter) then the code compiles - //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine - implicit def map2ops[T,F](fs: Map[T,F]) = new MapOps[F] { - //if you remove this line, then code compiles - lazy val m: Manifest[T] = error("just something to make it compile") - def is(xs: List[T]) = List(xs) - } - - def main(args: Array[String]) { - println(Map(1 -> "2") is List(2)) - } - - } +object TestCase {
+
+ //now matter if you put (abstract) class or trait it will fail in all cases
+ trait MapOps[T]
+
+ //if fs was reduced to List (generic type with one parameter) then the code compiles
+ //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine
+ implicit def map2ops[T,F](fs: Map[T,F]) = new MapOps[F] {
+ //if you remove this line, then code compiles
+ lazy val m: Manifest[T] = error("just something to make it compile")
+ def is(xs: List[T]) = List(xs)
+ }
+
+ def main(args: Array[String]) {
+ println(Map(1 -> "2") is List(2))
+ }
+
+ }
diff --git a/test/files/pos/t3429/A.scala b/test/files/pos/t3429/A.scala index 80785db51d..4b705808c1 100644 --- a/test/files/pos/t3429/A.scala +++ b/test/files/pos/t3429/A.scala @@ -2,8 +2,8 @@ class A { @Test(exc = classOf[Exception]) def myTestMethod = 0 } -// rytz@chara:~/scala/trunk/sandbox$ javac Test.java -// rytz@chara:~/scala/trunk/sandbox$ ../build/pack/bin/scalac A.scala +// rytz@chara:~/scala/trunk/sandbox$ javac Test.java +// rytz@chara:~/scala/trunk/sandbox$ ../build/pack/bin/scalac A.scala // A.scala:2: error: type mismatch; // found : java.lang.Class[Exception](classOf[java.lang.Exception]) // required: java.lang.Class diff --git a/test/files/pos/t3568.scala b/test/files/pos/t3568.scala index c8e3fcc4be..0f26e2fad3 100755 --- a/test/files/pos/t3568.scala +++ b/test/files/pos/t3568.scala @@ -14,7 +14,7 @@ package buffer { // ArrayVec2 can be compiled, instantiated and used. def main(args: Array[String]) { println(works) } } - + trait ElemType { type Element; type Component <: ElemType } trait Float1 extends ElemType { type Element = Float; type Component = Float1} class Vec2 extends ElemType { type Element = Vec2; type Component = Float1 } diff --git a/test/files/pos/t3582.scala b/test/files/pos/t3582.scala index 0ac112efbf..e20af5e61d 100644 --- a/test/files/pos/t3582.scala +++ b/test/files/pos/t3582.scala @@ -6,7 +6,7 @@ object Test { // [[syntax trees at end of typer]] // abstract trait C#5[A#9116 >: Nothing#5832 <: Any#52] extends scala#33.AnyRef#2780; // final object Test#15 extends java.lang.Object#2485 with ScalaObject#1913 { -// def ImplicitParamCA#9123[CC#9124[A#10858 >: Nothing#5832 <: Any#52] >: [A#10858]Nothing#5832 <: [A#10858]Any#52, +// def ImplicitParamCA#9123[CC#9124[A#10858 >: Nothing#5832 <: Any#52] >: [A#10858]Nothing#5832 <: [A#10858]Any#52, // A#9125 >: Nothing#5832 <: Any#52](implicit ev#10856: C#5[A#9127]): Unit#3818 // = scala#34.this.Predef#1683.implicitly#8816[C#5[A#10858]]() // } diff --git a/test/files/pos/t3731.scala b/test/files/pos/t3731.scala index 9a617012b3..75938540c0 100644 --- a/test/files/pos/t3731.scala +++ b/test/files/pos/t3731.scala @@ -2,7 +2,7 @@ object Test{ trait ZW[S]{type T} def ZipWith[S, M <: ZW[S]]: M#T = error("ZW") - // meh must be parameterised to force an asSeenFrom that + // meh must be parameterised to force an asSeenFrom that // duplicates the refinement in the TR's pre without updating its sym def meh[A] = ZipWith[A, ZW[A]{type T=Stream[A]}] diff --git a/test/files/pos/t3864/tuples_1.scala b/test/files/pos/t3864/tuples_1.scala index ed0c63dc79..1d19af6e41 100644 --- a/test/files/pos/t3864/tuples_1.scala +++ b/test/files/pos/t3864/tuples_1.scala @@ -4,7 +4,7 @@ trait PimpedType[X] { trait Tuples { - + trait Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] extends PimpedType[Tuple15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple15[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15)} @@ -13,7 +13,7 @@ trait Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] extends PimpedType[T implicit def ToTuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)): Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] = new { val value = t } with Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] - + trait Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] extends PimpedType[Tuple16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple16[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16)} @@ -22,7 +22,7 @@ trait Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] extends PimpedTyp implicit def ToTuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)): Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] = new { val value = t } with Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] - + trait Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] extends PimpedType[Tuple17[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple17[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17)} @@ -31,7 +31,7 @@ trait Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] extends Pimped implicit def ToTuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)): Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] = new { val value = t } with Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] - + trait Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] extends PimpedType[Tuple18[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple18[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18)} @@ -40,7 +40,7 @@ trait Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] extends Pim implicit def ToTuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)): Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] = new { val value = t } with Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] - + trait Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] extends PimpedType[Tuple19[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple19[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19)} @@ -49,7 +49,7 @@ trait Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] extends implicit def ToTuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)): Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] = new { val value = t } with Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] - + trait Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] extends PimpedType[Tuple20[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple20[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20)} @@ -58,7 +58,7 @@ trait Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] exten implicit def ToTuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)): Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] = new { val value = t } with Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] - + trait Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] extends PimpedType[Tuple21[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple21[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21)} @@ -67,7 +67,7 @@ trait Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] ex implicit def ToTuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)): Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] = new { val value = t } with Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] - + trait Tuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] extends PimpedType[Tuple22[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple22[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22)} diff --git a/test/files/pos/tcpoly_boundedmonad.scala b/test/files/pos/tcpoly_boundedmonad.scala index ef02507b66..24a911769b 100644 --- a/test/files/pos/tcpoly_boundedmonad.scala +++ b/test/files/pos/tcpoly_boundedmonad.scala @@ -1,19 +1,19 @@ trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] { - def map[S <: Bound[S]](f: T => S): MyType[S] + def map[S <: Bound[S]](f: T => S): MyType[S] - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] + (f: T => Result[S]): Result[S] def filter(p: T => Boolean): MyType[T] } class Set[T <: Ordered[T]] extends Monad[T, Set, Ordered] { - def map[S <: Ordered[S]](f: T => S): Set[S] = error("TODO") - - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def map[S <: Ordered[S]](f: T => S): Set[S] = error("TODO") + + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] = error("TODO") - - def filter(p: T => Boolean): Set[T] = error("TODO") + (f: T => Result[S]): Result[S] = error("TODO") + + def filter(p: T => Boolean): Set[T] = error("TODO") } diff --git a/test/files/pos/tcpoly_bounds1.scala b/test/files/pos/tcpoly_bounds1.scala index 5874cc664d..142c0b7b7f 100644 --- a/test/files/pos/tcpoly_bounds1.scala +++ b/test/files/pos/tcpoly_bounds1.scala @@ -1,6 +1,6 @@ -class Foo[t[x]<: Pair[Int, x]] +class Foo[t[x]<: Pair[Int, x]] -// +// class MyPair[z](a: Int, b: z) extends Pair[Int, z](a,b) object foo extends Foo[MyPair] diff --git a/test/files/pos/tcpoly_checkkinds_mix.scala b/test/files/pos/tcpoly_checkkinds_mix.scala index 3734405f8b..2d265da6b9 100644 --- a/test/files/pos/tcpoly_checkkinds_mix.scala +++ b/test/files/pos/tcpoly_checkkinds_mix.scala @@ -2,9 +2,9 @@ trait Iterable[A <: Bound[A], Bound[_]] { type MyType[x <: Bound[x]] <: Iterable[x, Bound] def map[B <: Bound[B]](f: A => B): MyType[B] def flatMap[B <: Bound[B]](f: A => MyType[B]): MyType[B] - def filter(p: A => Boolean): MyType[A] + def filter(p: A => Boolean): MyType[A] } -trait OrderedSet[T <: Ordered[T]] extends Iterable[T, Ordered] { +trait OrderedSet[T <: Ordered[T]] extends Iterable[T, Ordered] { type MyType[x <: Ordered[x]] = OrderedSet[x] -} +} diff --git a/test/files/pos/tcpoly_gm.scala b/test/files/pos/tcpoly_gm.scala index 95361e0dac..ecaeef9679 100644 --- a/test/files/pos/tcpoly_gm.scala +++ b/test/files/pos/tcpoly_gm.scala @@ -1,4 +1,4 @@ -trait Rep[a] { +trait Rep[a] { def rep[m[x]]: m[a] // typedTypeApply must use asSeenFrom to adapt the return type // since rep is called on x: Rep[t] // a must become t @@ -9,7 +9,7 @@ case class ShowBin[b](app: b => String) object foo { def showBin[t](x: Rep[t], y: t): String = { val r: ShowBin[t] = x.rep[ShowBin] - r.app(y) + r.app(y) } } - + diff --git a/test/files/pos/tcpoly_higherorder_bound_method.scala b/test/files/pos/tcpoly_higherorder_bound_method.scala index 3905b3b96d..090bb8fcf3 100644 --- a/test/files/pos/tcpoly_higherorder_bound_method.scala +++ b/test/files/pos/tcpoly_higherorder_bound_method.scala @@ -1,3 +1,3 @@ trait SkolemisationOfHigherOrderBoundInMethod { def method[A, N[X <: A], M[X <: N[A]]]: Unit -} +} diff --git a/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala b/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala index de31efd565..97594d506d 100644 --- a/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala +++ b/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala @@ -7,9 +7,9 @@ class IterableOps[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], object Test { - implicit def tupleOfIterableWrapper[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], A1, A2](tuple: (CC[A1], Iterable[A2])) + implicit def tupleOfIterableWrapper[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], A1, A2](tuple: (CC[A1], Iterable[A2])) = new IterableOps[CC, A1, A2](tuple) - + val t = (List(1, 2, 3), List(6, 5, 4)) tupleOfIterableWrapper(t) unzip diff --git a/test/files/pos/tcpoly_late_method_params.scala b/test/files/pos/tcpoly_late_method_params.scala index e2f0bcffb3..c9298918a0 100644 --- a/test/files/pos/tcpoly_late_method_params.scala +++ b/test/files/pos/tcpoly_late_method_params.scala @@ -1,5 +1,5 @@ trait Foo { - def flatMap[RT <: RBound[RT], RBound[_], Result[x <: RBound[x]]]: Result[RT] + def flatMap[RT <: RBound[RT], RBound[_], Result[x <: RBound[x]]]: Result[RT] // bounds for RT& = >: scala.this.Nothing <: RBound&[RT&] // bounds for x = >: scala.this.Nothing <: RBound&[x] } diff --git a/test/files/pos/tcpoly_method.scala b/test/files/pos/tcpoly_method.scala index 294b53b915..80dc0482fd 100644 --- a/test/files/pos/tcpoly_method.scala +++ b/test/files/pos/tcpoly_method.scala @@ -1,6 +1,6 @@ trait Iterable[m[+x], +t] { def flatMap[resColl[+x] <: Iterable[resColl, x], s](f: t => resColl[s]): resColl[s] - + def foo[a[x]] = "a" val x = foo[List] } diff --git a/test/files/pos/tcpoly_overloaded.scala b/test/files/pos/tcpoly_overloaded.scala index f67e4a9fef..4240074d85 100644 --- a/test/files/pos/tcpoly_overloaded.scala +++ b/test/files/pos/tcpoly_overloaded.scala @@ -1,10 +1,10 @@ trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] { - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + (f: T => Result[S]): Result[S] + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S], foo: String): Result[S] + (f: T => Result[S], foo: String): Result[S] def flatMap[S <: Bound[S]] (f: T => MyType[S], foo: Int): MyType[S] } @@ -12,14 +12,14 @@ trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] { trait Test { def moo: MList[Int] class MList[T](el: T) extends Monad[T, List, Any] { - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] (f: T => Result[S]): Result[S] = error("foo") - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] (f: T => Result[S], foo: String): Result[S] = error("foo") def flatMap[S] - (f: T => List[S], foo: Int): List[S] = error("foo") + (f: T => List[S], foo: Int): List[S] = error("foo") } val l: MList[String] = moo.flatMap[String, List, Any, MList]((x: Int) => new MList("String")) } diff --git a/test/files/pos/tcpoly_poly.scala b/test/files/pos/tcpoly_poly.scala index 1ba04e29df..50ffc7837f 100644 --- a/test/files/pos/tcpoly_poly.scala +++ b/test/files/pos/tcpoly_poly.scala @@ -1,3 +1,3 @@ -class Monad[m[x]] +class Monad[m[x]] object ml extends Monad[List] diff --git a/test/files/pos/tcpoly_return_overriding.scala b/test/files/pos/tcpoly_return_overriding.scala index 57ec8da76c..0814e73fa4 100644 --- a/test/files/pos/tcpoly_return_overriding.scala +++ b/test/files/pos/tcpoly_return_overriding.scala @@ -2,7 +2,7 @@ trait Generic[g[x]] { def unit: g[Unit] } -trait Rep[t] { +trait Rep[t] { def rep[m[x]](implicit gen: Generic[m]): m[t] } diff --git a/test/files/pos/tcpoly_seq.scala b/test/files/pos/tcpoly_seq.scala index 48b3e1ce52..b5f46f6b6b 100644 --- a/test/files/pos/tcpoly_seq.scala +++ b/test/files/pos/tcpoly_seq.scala @@ -6,40 +6,40 @@ trait HOSeq { // values implementing this interface, in order to provide more performant ways of building that structure trait Accumulator[+coll[x], elT] { def += (el: elT): Unit - def result: coll[elT] + def result: coll[elT] } - - + + // Iterable abstracts over the type of its structure as well as its elements (see PolyP's Bifunctor) - // m[x] is intentionally unbounded: fold can then be defined nicely - // variance: if we write m[+x] instead of +m[+x], x is an invariant position because its enclosing type + // m[x] is intentionally unbounded: fold can then be defined nicely + // variance: if we write m[+x] instead of +m[+x], x is an invariant position because its enclosing type // is an invariant position -- should probably rule that out? trait Iterable[+m[+x], +t] { //def unit[a](orig: a): m[a] def iterator: Iterator[t] - + // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t def accumulator[t]: Accumulator[m, t] - + def filter(p: t => Boolean): m[t] = { val buf = accumulator[t] val elems = iterator while (elems.hasNext) { val x = elems.next; if (p(x)) buf += x } buf.result } - + def map[s](f: t => s): m[s] = { val buf = accumulator[s] val elems = iterator while (elems.hasNext) buf += f(elems.next) buf.result } - + // flatMap is a more specialized map, it only works if the mapped function produces Iterable values, // which are then added to the result one by one // the compiler should be able to find the right accumulator (implicit buf) to build the result // to get concat, resColl = SingletonIterable, f = unit for SingletonIterable - def flatMap[resColl[+x] <: Iterable[resColl, x], s](f: t => resColl[s])(implicit buf: Accumulator[resColl, s]): resColl[s] = { + def flatMap[resColl[+x] <: Iterable[resColl, x], s](f: t => resColl[s])(implicit buf: Accumulator[resColl, s]): resColl[s] = { // TODO: would a viewbound for resColl[x] be better? // -- 2nd-order type params are not yet in scope in view bound val elems = iterator @@ -48,9 +48,9 @@ trait HOSeq { while (elemss.hasNext) buf += elemss.next } buf.result - } + } } - + final class ListBuffer[A] { private var start: List[A] = Nil private var last: ::[A] = _ @@ -78,7 +78,7 @@ trait HOSeq { exported = !start.isEmpty start } - + /** Clears the buffer contents. */ def clear { @@ -97,13 +97,13 @@ trait HOSeq { } } } - + implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] { private[this] val buff = new ListBuffer[elT] def += (el: elT): Unit = buff += el def result: List[elT] = buff.toList } - + trait List[+t] extends Iterable[List, t] { def head: t def tail: List[t] @@ -121,14 +121,14 @@ trait HOSeq { // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t def accumulator[t]: Accumulator[List, t] = listAccumulator[t] } - + // TODO: the var tl approach does not seem to work because subtyping isn't fully working yet final case class ::[+b](hd: b, private val tl: List[b]) extends List[b] { def head = hd def tail = if(tl==null) this else tl // hack override def isEmpty: Boolean = false } - + case object Nil extends List[Nothing] { def isEmpty = true def head: Nothing = @@ -157,18 +157,18 @@ trait HOSeq { def filter(f: T=>Boolean): FilterResult def subseq(from: Int, to: Int): Subseq def flatMap[S <: Seq[K], K](f: T => S): S#Concat // legal? - def concat(others: Seq[T]): Concat + def concat(others: Seq[T]): Concat */ - + /*trait Iterator[t] { // @post hasAdvanced implies hasNext // model def hasAdvanced: Boolean - + def hasNext: Boolean // pure - + // @pre hasAdvanced def current: t // pure - + // @pre hasNext // @post hasAdvanced def advance: Unit diff --git a/test/files/pos/tcpoly_seq_typealias.scala b/test/files/pos/tcpoly_seq_typealias.scala index fb48126ce6..0651ad9760 100644 --- a/test/files/pos/tcpoly_seq_typealias.scala +++ b/test/files/pos/tcpoly_seq_typealias.scala @@ -6,42 +6,42 @@ trait HOSeq { // values implementing this interface, in order to provide more performant ways of building that structure trait Accumulator[+coll[x], elT] { def += (el: elT): Unit - def result: coll[elT] + def result: coll[elT] } - - + + // Iterable abstracts over the type of its structure as well as its elements (see PolyP's Bifunctor) - // m[x] is intentionally unbounded: fold can then be defined nicely - // variance: if we write m[+x] instead of +m[+x], x is an invariant position because its enclosing type + // m[x] is intentionally unbounded: fold can then be defined nicely + // variance: if we write m[+x] instead of +m[+x], x is an invariant position because its enclosing type // is an invariant position -- should probably rule that out? trait Iterable[+t] { - type m[+x] - + type m[+x] + //def unit[a](orig: a): m[a] def iterator: Iterator[t] - + // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t def accumulator[t]: Accumulator[m, t] - + def filter(p: t => Boolean): m[t] = { val buf = accumulator[t] val elems = iterator while (elems.hasNext) { val x = elems.next; if (p(x)) buf += x } buf.result } - + def map[s](f: t => s): m[s] = { val buf = accumulator[s] val elems = iterator while (elems.hasNext) buf += f(elems.next) buf.result } - + // flatMap is a more specialized map, it only works if the mapped function produces Iterable values, // which are then added to the result one by one // the compiler should be able to find the right accumulator (implicit buf) to build the result // to get concat, resColl = SingletonIterable, f = unit for SingletonIterable - def flatMap[resColl[+x] <: Iterable[x], s](f: t => resColl[s])(implicit buf: Accumulator[resColl, s]): resColl[s] = { + def flatMap[resColl[+x] <: Iterable[x], s](f: t => resColl[s])(implicit buf: Accumulator[resColl, s]): resColl[s] = { // TODO: would a viewbound for resColl[x] be better? // -- 2nd-order type params are not yet in scope in view bound val elems = iterator @@ -50,9 +50,9 @@ trait HOSeq { while (elemss.hasNext) buf += elemss.next } buf.result - } + } } - + final class ListBuffer[A] { private var start: List[A] = Nil private var last: ::[A] = _ @@ -80,7 +80,7 @@ trait HOSeq { exported = !start.isEmpty start } - + /** Clears the buffer contents. */ def clear { @@ -99,16 +99,16 @@ trait HOSeq { } } } - + implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] { private[this] val buff = new ListBuffer[elT] def += (el: elT): Unit = buff += el def result: List[elT] = buff.toList } - + trait List[+t] extends Iterable[t] { type m[+x] = List[x] - + def head: t def tail: List[t] def isEmpty: Boolean @@ -125,14 +125,14 @@ trait HOSeq { // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t def accumulator[t]: Accumulator[List, t] = listAccumulator[t] } - + // TODO: the var tl approach does not seem to work because subtyping isn't fully working yet final case class ::[+b](hd: b, private val tl: List[b]) extends List[b] { def head = hd def tail = if(tl==null) this else tl // hack override def isEmpty: Boolean = false } - + case object Nil extends List[Nothing] { def isEmpty = true def head: Nothing = diff --git a/test/files/pos/ted.scala b/test/files/pos/ted.scala index 314f109328..d8ae64f29b 100644 --- a/test/files/pos/ted.scala +++ b/test/files/pos/ted.scala @@ -9,7 +9,7 @@ object App case (b, e) => b * exponentiate(b, e - 1) } - + def main(args : Array[String]) = System.out.println(exponentiate(2, 2)) diff --git a/test/files/pos/test5.scala b/test/files/pos/test5.scala index 4dbafc9ac3..b04de5d613 100644 --- a/test/files/pos/test5.scala +++ b/test/files/pos/test5.scala @@ -53,7 +53,7 @@ object test { // Check type j.P j.chk_ip(val_mp); - j.chk_ip(val_np); + j.chk_ip(val_np); // Check type i.X i.chk_ix(i.val_ix); @@ -63,6 +63,6 @@ object test { // Check j.X j.chk_ix(j.val_ix); j.chk_ix(j.val_jx); - j.chk_ix(val_njx); + j.chk_ix(val_njx); } } diff --git a/test/files/pos/test5refine.scala b/test/files/pos/test5refine.scala index 5459b3b975..290449c3ed 100644 --- a/test/files/pos/test5refine.scala +++ b/test/files/pos/test5refine.scala @@ -60,7 +60,7 @@ object test { // Check type j.P j.chk_ip(val_mp); - j.chk_ip(val_np); + j.chk_ip(val_np); // Check type i.X i.chk_ix(i.val_ix); @@ -70,6 +70,6 @@ object test { // Check j.X j.chk_ix(j.val_ix); j.chk_ix(j.val_jx); - j.chk_ix(val_njx); + j.chk_ix(val_njx); } } diff --git a/test/files/pos/thistypes.scala b/test/files/pos/thistypes.scala index 7319cc1ecb..26339e07c4 100644 --- a/test/files/pos/thistypes.scala +++ b/test/files/pos/thistypes.scala @@ -5,4 +5,4 @@ trait B { trait C extends B { def foo: C.this.I; -} +} diff --git a/test/files/pos/ticket0137.scala b/test/files/pos/ticket0137.scala index 94ef8e49fc..72f955fe5e 100644 --- a/test/files/pos/ticket0137.scala +++ b/test/files/pos/ticket0137.scala @@ -1,7 +1,7 @@ -trait AbsM { - abstract class MonadCompanion[M[_]] +trait AbsM { + abstract class MonadCompanion[M[_]] abstract class AbsMonadCompanion extends MonadCompanion[AM] { - def newTag: Int + def newTag: Int } type AM[_] // to trigger the bug, this must be an abstract type member that comes after the reference to it diff --git a/test/files/pos/traits.scala b/test/files/pos/traits.scala index 8dcd9c0b5f..bd64d7215a 100644 --- a/test/files/pos/traits.scala +++ b/test/files/pos/traits.scala @@ -20,8 +20,8 @@ object Test { trait BorderedColoredShape extends Shape with Bordered with Colored { override def equals(other: Any) = other match { case that: BorderedColoredShape => ( - super.equals(that) && - super[Bordered].equals(that) && + super.equals(that) && + super[Bordered].equals(that) && super[Colored].equals(that)) case _ => false } diff --git a/test/files/pos/typealias_dubious.scala b/test/files/pos/typealias_dubious.scala index de6bb67fe3..587453a037 100644 --- a/test/files/pos/typealias_dubious.scala +++ b/test/files/pos/typealias_dubious.scala @@ -1,8 +1,8 @@ class MailBox { - //class Message + //class Message type Message = AnyRef -} - +} + abstract class Actor { private val in = new MailBox @@ -10,6 +10,6 @@ abstract class Actor { def unstable: Actor = error("foo") - def dubiousSend(msg: MailBox#Message) = + def dubiousSend(msg: MailBox#Message) = unstable.send(msg) // in.Message becomes unstable.Message, but that's ok since Message is a concrete type member -} +} diff --git a/test/files/pos/typealiases.scala b/test/files/pos/typealiases.scala index d03b521f77..5974921ed3 100644 --- a/test/files/pos/typealiases.scala +++ b/test/files/pos/typealiases.scala @@ -3,18 +3,18 @@ package foo trait Test[T] { type Check[T] = Array[T] => Unit; type MyPair[S] = (T, S) - + val pair1: (T, Int) val pair: MyPair[Int] = pair1 - + def check(xs: Array[T], c: Check[T]) = c(xs) - def check2[S](xs: Array[S], c: Check[S]) = c(xs) -} + def check2[S](xs: Array[S], c: Check[S]) = c(xs) +} -object main extends Test[Int] { - val pair1 = (1,1) +object main extends Test[Int] { + val pair1 = (1,1) implicit def topair(x: Int): Pair[Int, Int] = (x,x) - val pair2: MyPair[Int] = 1 + val pair2: MyPair[Int] = 1 val x: Short = 1 } diff --git a/test/files/pos/unapplyNeedsMemberType.scala b/test/files/pos/unapplyNeedsMemberType.scala index b423257e04..2581512a7b 100644 --- a/test/files/pos/unapplyNeedsMemberType.scala +++ b/test/files/pos/unapplyNeedsMemberType.scala @@ -8,7 +8,7 @@ trait Gunk[a] { def unapply(s: Seq) = unapply_Cons(s) } def unapply_Cons(s: Any): Option[Tuple2[a, Seq]] -} +} class Join[a] extends Gunk[a] { type Seq = JoinSeq diff --git a/test/files/pos/unapplySeq.scala b/test/files/pos/unapplySeq.scala index 6d13cc8b52..4d5409c6f7 100644 --- a/test/files/pos/unapplySeq.scala +++ b/test/files/pos/unapplySeq.scala @@ -4,7 +4,7 @@ object FooSeq { val y = x.asInstanceOf[Bar] Some(y.size, y.name) } else None - } + } def main(args:Array[String]) = { val b = new Bar diff --git a/test/files/pos/unapplyVal.scala b/test/files/pos/unapplyVal.scala index 338cdb1839..10a6ba7c2c 100644 --- a/test/files/pos/unapplyVal.scala +++ b/test/files/pos/unapplyVal.scala @@ -10,7 +10,7 @@ class Buffer { def joinPat(x: Any): Unit = { x match { - case Put => + case Put => case Put(y) => println("returning "+y) } @@ -29,7 +29,7 @@ object unapplyJoins extends Application { // bug #1257 object Get extends Sync val jp: PartialFunction[Any, Any] = { - case Get() => + case Get() => } } diff --git a/test/files/positions/Anon.scala b/test/files/positions/Anon.scala index 940fff035a..65eb7ae477 100644 --- a/test/files/positions/Anon.scala +++ b/test/files/positions/Anon.scala @@ -2,7 +2,7 @@ object Anon { trait Foo { val bar : Int } - + def foo = new Foo { override val bar = 23 } diff --git a/test/files/positions/Enclosing1.scala b/test/files/positions/Enclosing1.scala index e170187d60..7c8fbaf4a0 100644 --- a/test/files/positions/Enclosing1.scala +++ b/test/files/positions/Enclosing1.scala @@ -1,5 +1,5 @@ object Enclosing1 { do { - + } while (true) } diff --git a/test/files/positions/ExcludedPrefix1.scala b/test/files/positions/ExcludedPrefix1.scala index f3562c37f0..72d9756b2a 100644 --- a/test/files/positions/ExcludedPrefix1.scala +++ b/test/files/positions/ExcludedPrefix1.scala @@ -5,16 +5,16 @@ object ExcludedPrefix1 { case object BLAH - + val a = 1 - + var b = 2 - + def c = 23 - + private def d = 23 @@ -22,19 +22,19 @@ object ExcludedPrefix1 { lazy val e = 23 - + private type f = Int - + val g, h = 23 - + val (i, j) = (0, 0) - + val Pair( k, l) = (0, 0) diff --git a/test/files/positions/Overlap3.scala b/test/files/positions/Overlap3.scala index 4c5f8af9d1..657c12d4fd 100644 --- a/test/files/positions/Overlap3.scala +++ b/test/files/positions/Overlap3.scala @@ -1,3 +1,3 @@ object Overlap3 { - val (a, b) = (0, 0) + val (a, b) = (0, 0) } diff --git a/test/files/positions/Scaladoc2.scala b/test/files/positions/Scaladoc2.scala index e52263d86c..78bc4acb28 100644 --- a/test/files/positions/Scaladoc2.scala +++ b/test/files/positions/Scaladoc2.scala @@ -4,13 +4,13 @@ object Scaladoc2 { * Foo */ def g {} - + /* * Blah blah */ def h{} h } - + def h {} } diff --git a/test/files/positions/Scaladoc3.scala b/test/files/positions/Scaladoc3.scala index c331b7e396..bb9d66fdb4 100644 --- a/test/files/positions/Scaladoc3.scala +++ b/test/files/positions/Scaladoc3.scala @@ -3,6 +3,6 @@ object Scaladoc3 { * Foo */ import scala.collection.mutable.ArrayBuffer - + def f {} } diff --git a/test/files/positions/Scaladoc4.scala b/test/files/positions/Scaladoc4.scala index 133cde1c85..f613dda7f5 100644 --- a/test/files/positions/Scaladoc4.scala +++ b/test/files/positions/Scaladoc4.scala @@ -3,6 +3,6 @@ object Scaladoc4 { * Foo */ 2+2 - + def f {} } diff --git a/test/files/positions/Scaladoc6.scala b/test/files/positions/Scaladoc6.scala index 8beda625ae..5c230edeb2 100644 --- a/test/files/positions/Scaladoc6.scala +++ b/test/files/positions/Scaladoc6.scala @@ -5,6 +5,6 @@ object Scaladoc6 { */ val i = 23 } - + def f {} } diff --git a/test/files/res/bug597/Test.scala b/test/files/res/bug597/Test.scala index 2f63f46c3d..45b90bb17d 100644 --- a/test/files/res/bug597/Test.scala +++ b/test/files/res/bug597/Test.scala @@ -2,7 +2,7 @@ package test; abstract class Base { type A <: Ax; - + abstract class Ax { def a = null; def string = "A"; diff --git a/test/files/res/bug722/Parser.scala b/test/files/res/bug722/Parser.scala index 6d9739ed04..d36a20410b 100644 --- a/test/files/res/bug722/Parser.scala +++ b/test/files/res/bug722/Parser.scala @@ -2,7 +2,7 @@ package bug722; trait Parser { trait Link { - def foo = {} + def foo = {} } } diff --git a/test/files/res/bug735/ScalaExpressions.scala b/test/files/res/bug735/ScalaExpressions.scala index aacc412b68..eb00f49cb2 100644 --- a/test/files/res/bug735/ScalaExpressions.scala +++ b/test/files/res/bug735/ScalaExpressions.scala @@ -1,6 +1,6 @@ package bug735; trait ScalaExpressions { - trait ExpressionFactory { + trait ExpressionFactory { def foo = 10; def bar : Int; } diff --git a/test/files/res/bug743/BracesXXX.scala b/test/files/res/bug743/BracesXXX.scala index 8a2416caa8..545618daad 100644 --- a/test/files/res/bug743/BracesXXX.scala +++ b/test/files/res/bug743/BracesXXX.scala @@ -1,6 +1,6 @@ package bug743; trait BracesXXX extends ParserXXX { - trait Matchable extends IsLinked { + trait Matchable extends IsLinked { def foo : NodeImpl = null; } } diff --git a/test/files/res/bug743/ParserXXX.scala b/test/files/res/bug743/ParserXXX.scala index 6ecf13c1e1..449dd71a50 100644 --- a/test/files/res/bug743/ParserXXX.scala +++ b/test/files/res/bug743/ParserXXX.scala @@ -1,9 +1,9 @@ package bug743; trait ParserXXX { - val foo = null; - trait NodeImpl { + val foo = null; + trait NodeImpl { trait Link extends ParserXXX.this.Link { - val from = null; + val from = null; } } trait Link { diff --git a/test/files/res/bug785/ScalaNewTyper.scala b/test/files/res/bug785/ScalaNewTyper.scala index fb955572ed..582538e41e 100644 --- a/test/files/res/bug785/ScalaNewTyper.scala +++ b/test/files/res/bug785/ScalaNewTyper.scala @@ -1,7 +1,7 @@ package bug785; trait ScalaNewTyper { private var typed : String = null; - trait HasSymbol { + trait HasSymbol { protected def foo : Unit = {} } trait HasArgsTypeParametersImpl extends HasSymbol { diff --git a/test/files/res/bug831/NewScalaParserXXX.scala b/test/files/res/bug831/NewScalaParserXXX.scala index 88c81637f0..48f78a7b4b 100644 --- a/test/files/res/bug831/NewScalaParserXXX.scala +++ b/test/files/res/bug831/NewScalaParserXXX.scala @@ -10,33 +10,33 @@ trait ScalaNodeScannerXXX { //for (val ns <-n; val i <- 0.until(ns)) yield f; -trait NewScalaScannerXXX extends ScalaNodeScannerXXX { +trait NewScalaScannerXXX extends ScalaNodeScannerXXX { type Unfixed <: Node with UnfixedImpl; trait UnfixedImpl extends super.UnfixedImpl with NodeImpl; type Statement <: Unfixed with StatementImpl; trait StatementImpl extends UnfixedImpl { def self : Statement; } type NewLine <: Statement with NewLineImpl; - trait NewLineImpl extends StatementImpl { - def self : NewLine; + trait NewLineImpl extends StatementImpl { + def self : NewLine; def isActive : Boolean = true; } object ArrowMode extends Enumeration { val Def, Case, Expr = Value } } -trait ScalaPrecedenceXXX extends NewScalaScannerXXX { +trait ScalaPrecedenceXXX extends NewScalaScannerXXX { type NewLine <: Statement with NewLineImpl; - trait NewLineImpl extends super.NewLineImpl with StatementImpl { - def self : NewLine; + trait NewLineImpl extends super.NewLineImpl with StatementImpl { + def self : NewLine; override def isActive = super[NewLineImpl].isActive; } } trait NewScalaParserXXX extends NewScalaScannerXXX with ScalaPrecedenceXXX { type NewLine <: Statement with NewLineImpl; trait MyNewLine extends super[NewScalaScannerXXX].NewLineImpl; - trait NewLineImpl extends MyNewLine with + trait NewLineImpl extends MyNewLine with super[ScalaPrecedenceXXX].NewLineImpl with - StatementImpl { - def self : NewLine; + StatementImpl { + def self : NewLine; override def isActive = super[MyNewLine].isActive; } } diff --git a/test/files/run/Course-2002-02.scala b/test/files/run/Course-2002-02.scala index b8650108ed..56d7298aaf 100644 --- a/test/files/run/Course-2002-02.scala +++ b/test/files/run/Course-2002-02.scala @@ -100,7 +100,7 @@ object M4 { def sumInts = sum(x => x) def sumCubes = sum(x => x * x * x) - def sumReciprocals = sum(1.0/_) + def sumReciprocals = sum(1.0/_) def sumPi = { n: Int => 4 + sum(x => 4.0/(4*x+1) - 4.0/(4*x-1))(1, n) } Console.println(sumInts(1,4)) @@ -194,7 +194,7 @@ object M8 { //############################################################################ object M9 { - def accumulate[t](combiner: (t, t) => t, nullValue: t, f: Int => t, + def accumulate[t](combiner: (t, t) => t, nullValue: t, f: Int => t, next: Int => Int)(a: Int, b: Int): t = if (a > b) nullValue else combiner(f(a), accumulate(combiner, nullValue, f, next)(next(a), b)) @@ -328,9 +328,9 @@ object MD { iter(a, zero) } - def plus (x:Double,y:Double) = x+y; + def plus (x:Double,y:Double) = x+y; val sum: (Int => Double) => (Int, Int) => Double = reduce(plus , 0); - def times(x:Double,y:Double) = x*y; + def times(x:Double,y:Double) = x*y; val product: (Int => Double) => (Int, Int) => Double = reduce(times, 1); def factorial(n: Int) = product(x => x)(1 , n) diff --git a/test/files/run/Course-2002-05.scala b/test/files/run/Course-2002-05.scala index a1d71e2818..8ed8e041a7 100644 --- a/test/files/run/Course-2002-05.scala +++ b/test/files/run/Course-2002-05.scala @@ -129,7 +129,7 @@ object M3 { else { def isSafe(column: Int, placement: Placement): Boolean = placement forall { - pos => (pos._2 != column && + pos => (pos._2 != column && abs(pos._2 - column) != row - pos._1) } diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala index 2e4b5111a9..85b0bad527 100644 --- a/test/files/run/Course-2002-08.scala +++ b/test/files/run/Course-2002-08.scala @@ -520,7 +520,7 @@ abstract class CircuitSimulator() extends BasicCircuitSimulator() { val w1 = new Wire(); val w2 = new Wire(); val w3 = new Wire(); - + andGate(in, ctrl(1), w3); andGate(in, ctrl(1), w2); andGate(in, ctrlN(1), w1); diff --git a/test/files/run/MutableListTest.scala b/test/files/run/MutableListTest.scala index 322a368b16..70431570e9 100644 --- a/test/files/run/MutableListTest.scala +++ b/test/files/run/MutableListTest.scala @@ -1,126 +1,126 @@ - - - -import scala.collection.mutable.MutableList - - - -class ExtList[T] extends MutableList[T] { - def printState { - println("Length: " + len) - println("Last elem: " + last0.elem) - println("First elem: " + first0.elem) - println("After first elem: " + first0.next.elem) - println("After first: " + first0.next) - println("Last: " + last0) - } -} - -object Test { - - def main(args: Array[String]) { - testEmpty - testAddElement - testAddFewElements - testAddMoreElements - testTraversables - } - - def testEmpty { - val mlist = new MutableList[Int] - assert(mlist.isEmpty) - assert(mlist.get(0) == None) - } - - def testAddElement { - val mlist = new MutableList[Int] - mlist += 17 - assert(mlist.nonEmpty) - assert(mlist.length == 1) - assert(mlist.head == 17) - assert(mlist.last == 17) - assert(mlist(0) == 17) - assert(mlist.tail.isEmpty) - assert(mlist.tail.length == 0) - mlist(0) = 101 - assert(mlist(0) == 101) - assert(mlist.toList == List(101)) - assert(mlist.tail.get(0) == None) - assert((mlist.tail += 19).head == 19) - assert(mlist.tail.length == 0) - } - - def testAddFewElements { - val mlist = new MutableList[Int] - for (i <- 0 until 2) mlist += i -// mlist.printState - for (i <- 0 until 2) assert(mlist(i) == i) - assert(mlist.length == 2) - assert(mlist.nonEmpty) - assert(mlist.tail.length == 1) - assert(mlist.tail.tail.length == 0) - assert(mlist.tail.tail.isEmpty) - } - - def testAddMoreElements { - val mlist = new MutableList[Int] - for (i <- 0 until 10) mlist += i * i - assert(mlist.nonEmpty) - assert(mlist.length == 10) - for (i <- 0 until 10) assert(mlist(i) == i * i) - assert(mlist(5) == 5 * 5) - assert(mlist(9) == 9 * 9) - var sometail = mlist - for (i <- 0 until 10) { - assert(sometail.head == i * i) - sometail = sometail.tail - } - mlist(5) = -25 - assert(mlist(5) == -25) - mlist(0) = -1 - assert(mlist(0) == -1) - mlist(9) = -81 - assert(mlist(9) == -81) - assert(mlist(5) == -25) - assert(mlist(0) == -1) - assert(mlist.last == -81) - mlist.clear - assert(mlist.isEmpty) - mlist += 1001 - assert(mlist.head == 1001) - mlist += 9999 - assert(mlist.tail.head == 9999) - assert(mlist.last == 9999) - } - - def testTraversables { - val mlist = new MutableList[Int] - for (i <- 0 until 10) mlist += i * i - var lst = mlist.drop(5) - for (i <- 0 until 5) assert(lst(i) == (i + 5) * (i + 5)) - lst = lst.take(3) - for (i <- 0 until 3) assert(lst(i) == (i + 5) * (i + 5)) - lst += 129 - assert(lst(3) == 129) - assert(lst.last == 129) - assert(lst.length == 4) - lst += 7 - assert(lst.init.last == 129) - assert(lst.length == 5) - lst.clear - assert(lst.length == 0) - for (i <- 0 until 5) lst += i - assert(lst.reduceLeft(_ + _) == 10) - } - -} - - - - - - - - - - +
+
+
+import scala.collection.mutable.MutableList
+
+
+
+class ExtList[T] extends MutableList[T] {
+ def printState {
+ println("Length: " + len)
+ println("Last elem: " + last0.elem)
+ println("First elem: " + first0.elem)
+ println("After first elem: " + first0.next.elem)
+ println("After first: " + first0.next)
+ println("Last: " + last0)
+ }
+}
+
+object Test {
+
+ def main(args: Array[String]) {
+ testEmpty
+ testAddElement
+ testAddFewElements
+ testAddMoreElements
+ testTraversables
+ }
+
+ def testEmpty {
+ val mlist = new MutableList[Int]
+ assert(mlist.isEmpty)
+ assert(mlist.get(0) == None)
+ }
+
+ def testAddElement {
+ val mlist = new MutableList[Int]
+ mlist += 17
+ assert(mlist.nonEmpty)
+ assert(mlist.length == 1)
+ assert(mlist.head == 17)
+ assert(mlist.last == 17)
+ assert(mlist(0) == 17)
+ assert(mlist.tail.isEmpty)
+ assert(mlist.tail.length == 0)
+ mlist(0) = 101
+ assert(mlist(0) == 101)
+ assert(mlist.toList == List(101))
+ assert(mlist.tail.get(0) == None)
+ assert((mlist.tail += 19).head == 19)
+ assert(mlist.tail.length == 0)
+ }
+
+ def testAddFewElements {
+ val mlist = new MutableList[Int]
+ for (i <- 0 until 2) mlist += i
+// mlist.printState
+ for (i <- 0 until 2) assert(mlist(i) == i)
+ assert(mlist.length == 2)
+ assert(mlist.nonEmpty)
+ assert(mlist.tail.length == 1)
+ assert(mlist.tail.tail.length == 0)
+ assert(mlist.tail.tail.isEmpty)
+ }
+
+ def testAddMoreElements {
+ val mlist = new MutableList[Int]
+ for (i <- 0 until 10) mlist += i * i
+ assert(mlist.nonEmpty)
+ assert(mlist.length == 10)
+ for (i <- 0 until 10) assert(mlist(i) == i * i)
+ assert(mlist(5) == 5 * 5)
+ assert(mlist(9) == 9 * 9)
+ var sometail = mlist
+ for (i <- 0 until 10) {
+ assert(sometail.head == i * i)
+ sometail = sometail.tail
+ }
+ mlist(5) = -25
+ assert(mlist(5) == -25)
+ mlist(0) = -1
+ assert(mlist(0) == -1)
+ mlist(9) = -81
+ assert(mlist(9) == -81)
+ assert(mlist(5) == -25)
+ assert(mlist(0) == -1)
+ assert(mlist.last == -81)
+ mlist.clear
+ assert(mlist.isEmpty)
+ mlist += 1001
+ assert(mlist.head == 1001)
+ mlist += 9999
+ assert(mlist.tail.head == 9999)
+ assert(mlist.last == 9999)
+ }
+
+ def testTraversables {
+ val mlist = new MutableList[Int]
+ for (i <- 0 until 10) mlist += i * i
+ var lst = mlist.drop(5)
+ for (i <- 0 until 5) assert(lst(i) == (i + 5) * (i + 5))
+ lst = lst.take(3)
+ for (i <- 0 until 3) assert(lst(i) == (i + 5) * (i + 5))
+ lst += 129
+ assert(lst(3) == 129)
+ assert(lst.last == 129)
+ assert(lst.length == 4)
+ lst += 7
+ assert(lst.init.last == 129)
+ assert(lst.length == 5)
+ lst.clear
+ assert(lst.length == 0)
+ for (i <- 0 until 5) lst += i
+ assert(lst.reduceLeft(_ + _) == 10)
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/test/files/run/OrderingTest.scala b/test/files/run/OrderingTest.scala index fee15fc2f9..a3eca5f860 100644 --- a/test/files/run/OrderingTest.scala +++ b/test/files/run/OrderingTest.scala @@ -6,7 +6,7 @@ object Test extends Application { assert((cmp == 0) == (cmp2 == 0)) assert((cmp > 0) == (cmp2 < 0)) assert((cmp < 0) == (cmp2 > 0)) - } + } def testAll[T](t1 : T, t2 : T)(implicit ord : Ordering[T]) = { assert(ord.compare(t1, t2) < 0) @@ -16,8 +16,8 @@ object Test extends Application { } assert(Ordering[String].compare("australopithecus", "brontausaurus") < 0) - // assert(Ordering[Unit].compare((), ()) == 0) - + // assert(Ordering[Unit].compare((), ()) == 0) + testAll("bar", "foo"); testAll[Byte](0, 1); testAll(false, true) @@ -28,7 +28,7 @@ object Test extends Application { testAll[Iterable[Int]](List(1, 2), List(2)); testAll((1, "bar"), (1, "foo")) testAll((1, "foo"), (2, "bar")) - + // sortBy val words = "The quick brown fox jumped over the lazy dog".split(' ') val result = words.sortBy(x => (x.length, x.head)) diff --git a/test/files/run/QueueTest.scala b/test/files/run/QueueTest.scala index 859ce2071a..2f8ecaed4b 100644 --- a/test/files/run/QueueTest.scala +++ b/test/files/run/QueueTest.scala @@ -1,297 +1,297 @@ - - -import scala.collection.mutable.Queue - - - - -class ExtQueue[T] extends Queue[T] { - def printState { - println("-------------------") - println("Length: " + len) - println("First: " + first0) - println("First elem: " + first0.elem) - println("After first: " + first0.next) - } -} - -object Test { - - def main(args: Array[String]) { - testEmpty - testEnqueue - testTwoEnqueues - testFewEnqueues - testMoreEnqueues - } - - def testEmpty { - val queue = new Queue[Int] - - assert(queue.isEmpty) - assert(queue.size == 0) - assert(queue.length == 0) - assert(queue.dequeueFirst(_ > 500) == None) - assert(queue.dequeueAll(_ > 500).isEmpty) - - queue.clear - assert(queue.isEmpty) - assert(queue.size == 0) - assert(queue.length == 0) - assert(queue.dequeueFirst(_ > 500) == None) - assert(queue.dequeueAll(_ > 500).isEmpty) - } - - def testEnqueue { - val queue = new Queue[Int] - - queue.enqueue(10) - assert(queue.nonEmpty) - assert(queue.size == 1) - assert(queue.length == 1) - assert(queue.head == 10) - assert(queue(0) == 10) - assert(queue.init.isEmpty) - assert(queue.tail.isEmpty) - - queue.clear - assert(queue.isEmpty) - assert(queue.length == 0) - - queue.enqueue(11) - assert(queue.nonEmpty) - assert(queue.length == 1) - assert(queue.head == 11) - assert(queue.front == 11) - - val deq = queue.dequeue - assert(deq == 11) - assert(queue.isEmpty) - assert(queue.length == 0) - - queue.enqueue(12) - val pdopt = queue.dequeueFirst(_ > 999) - assert(pdopt == None) - assert(queue.nonEmpty && queue.length == 1) - - val somepd = queue.dequeueFirst(_ >= 1) - assert(somepd == Some(12)) - assert(queue.isEmpty && queue.length == 0) - } - - def testTwoEnqueues { - val queue = new ExtQueue[Int] - queue.enqueue(30) - queue.enqueue(40) - - assert(queue.length == 2) - assert(queue.size == 2) - assert(queue.nonEmpty) - assert(queue.front == 30) -// queue.printState - - val all = queue.dequeueAll(_ > 20) - assert(all.size == 2) - assert(all.contains(30)) - assert(all.contains(40)) - assert(queue.size == 0) - assert(queue.isEmpty) - } - - def testFewEnqueues { - val queue = new ExtQueue[Int] - queue.enqueue(10) - queue.enqueue(20) - - assert(queue.length == 2) - assert(queue.nonEmpty) - assert(queue.head == 10) - assert(queue.last == 20) - assert(queue.front == 10) -// queue.printState - - val ten = queue.dequeue - assert(ten == 10) - assert(queue.length == 1) -// queue.printState - - queue.enqueue(30) -// queue.printState - val gt25 = queue.dequeueFirst(_ > 25) - assert(gt25 == Some(30)) - assert(queue.nonEmpty) - assert(queue.length == 1) - assert(queue.head == 20) - assert(queue.front == 20) -// queue.printState - - queue.enqueue(30) -// queue.printState - val lt25 = queue.dequeueFirst(_ < 25) - assert(lt25 == Some(20)) - assert(queue.nonEmpty) - assert(queue.length == 1) -// queue.printState - - queue.enqueue(40) -// queue.printState - val all = queue.dequeueAll(_ > 20) -// queue.printState - assert(all.size == 2) - assert(all.contains(30)) - assert(all.contains(40)) - assert(queue.isEmpty) - assert(queue.length == 0) - - queue.enqueue(50) - queue.enqueue(60) -// queue.printState - val allgt55 = queue.dequeueAll(_ > 55) -// println(allgt55) -// queue.printState - assert(allgt55.size == 1) - assert(allgt55.contains(60)) - assert(queue.length == 1) - - queue.enqueue(70) - queue.enqueue(80) -// queue.printState - val alllt75 = queue.dequeueAll(_ < 75) -// queue.printState - assert(alllt75.size == 2) - assert(alllt75.contains(70)) - assert(alllt75.contains(50)) - assert(queue.length == 1) - assert(queue.head == 80) - assert(queue.last == 80) - assert(queue.front == 80) - } - - def testMoreEnqueues { - val queue = new ExtQueue[Int] - for (i <- 0 until 10) queue.enqueue(i * 2) - - for (i <- 0 until 10) { - val top = queue.dequeue - assert(top == i * 2) - assert(queue.length == 10 - i - 1) - } - assert(queue.isEmpty) - assert(queue.length == 0) - - for (i <- 0 until 10) queue.enqueue(i * i) - assert(queue.length == 10) - assert(queue.nonEmpty) - - //queue.printState - val gt5 = queue.dequeueAll(_ > 4) - //queue.printState - //println(gt5) - assert(gt5.size == 7) - assert(queue.length == 3) - assert(queue.nonEmpty) - - queue.clear - assert(queue.length == 0) - assert(queue.isEmpty) - - for (i <- 0 until 10) queue.enqueue(i) - assert(queue.length == 10) - - val even = queue.dequeueAll(_ % 2 == 0) - assert(even.size == 5) - assert(even.sameElements(List(0, 2, 4, 6, 8))) - assert(queue.length == 5) - assert(queue.head == 1) - assert(queue.last == 9) - - val odd = queue.dequeueAll(_ %2 == 1) - assert(odd.size == 5) - assert(queue.length == 0) - assert(queue.isEmpty) - assert(odd.sameElements(List(1, 3, 5, 7, 9))) - - for (i <- 0 until 10) queue.enqueue(i * i) - assert(queue.last == 81) - assert(queue.head == 0) - assert(queue.length == 10) - - val foddgt25 = queue.dequeueFirst(num => num > 25 && num % 2 == 1) - assert(foddgt25 == Some(49)) - assert(queue.length == 9) - assert(queue.nonEmpty) - - //queue.printState - val lt30 = queue.dequeueAll(_ < 30) - //println(lt30) - //queue.printState - assert(lt30.size == 6) - assert(queue.length == 3) - - val fgt60 = queue.dequeueFirst(_ > 60) - assert(fgt60 == Some(64)) - assert(queue.length == 2) - assert(queue.head == 36) - assert(queue.last == 81) - - val sgt60 = queue.dequeueFirst(_ > 60) - assert(sgt60 == Some(81)) - assert(queue.length == 1) - assert(queue.head == 36) - assert(queue.last == 36) - - val nogt60 = queue.dequeueFirst(_ > 60) - assert(nogt60 == None) - assert(queue.length == 1) - assert(queue.nonEmpty) - assert(queue.head == 36) - - val gt0 = queue.dequeueFirst(_ > 0) - assert(gt0 == Some(36)) - assert(queue.length == 0) - assert(queue.isEmpty) - - for (i <- 0 until 4) queue.enqueue(i) - val interv = queue.dequeueAll(n => n > 0 && n < 3) - assert(interv.sameElements(List(1, 2))) - assert(queue.length == 2) - assert(queue.head == 0) - assert(queue.last == 3) - - queue.dequeue - assert(queue.head == 3) - - queue.enqueue(9) - val three = queue.dequeueFirst(_ < 5) - assert(three == Some(3)) - assert(queue.length == 1) - assert(queue.head == 9) - - queue.clear - for (i <- -100 until 100) queue.enqueue(i * i + i % 7 + 5) - assert(queue.length == 200) - - val manyodds = queue.dequeueAll(_ % 2 == 1) - assert((manyodds.size + queue.length) == 200) - - queue.dequeueAll(_ > -10000) - assert(queue.isEmpty) - - for (i <- 0 until 100) queue.enqueue(i) - val multof3 = queue.dequeueAll(_ % 3 == 0) - assert(multof3.size == 34) - assert(queue.size == 66) - - val n98 = queue.dequeueFirst(_ == 98) - assert(n98 == Some(98)) - assert(queue.size == 65) - assert(queue.last == 97) - assert(queue.head == 1) - // well... seems to work - } - -} - - - - +
+
+import scala.collection.mutable.Queue
+
+
+
+
+class ExtQueue[T] extends Queue[T] {
+ def printState {
+ println("-------------------")
+ println("Length: " + len)
+ println("First: " + first0)
+ println("First elem: " + first0.elem)
+ println("After first: " + first0.next)
+ }
+}
+
+object Test {
+
+ def main(args: Array[String]) {
+ testEmpty
+ testEnqueue
+ testTwoEnqueues
+ testFewEnqueues
+ testMoreEnqueues
+ }
+
+ def testEmpty {
+ val queue = new Queue[Int]
+
+ assert(queue.isEmpty)
+ assert(queue.size == 0)
+ assert(queue.length == 0)
+ assert(queue.dequeueFirst(_ > 500) == None)
+ assert(queue.dequeueAll(_ > 500).isEmpty)
+
+ queue.clear
+ assert(queue.isEmpty)
+ assert(queue.size == 0)
+ assert(queue.length == 0)
+ assert(queue.dequeueFirst(_ > 500) == None)
+ assert(queue.dequeueAll(_ > 500).isEmpty)
+ }
+
+ def testEnqueue {
+ val queue = new Queue[Int]
+
+ queue.enqueue(10)
+ assert(queue.nonEmpty)
+ assert(queue.size == 1)
+ assert(queue.length == 1)
+ assert(queue.head == 10)
+ assert(queue(0) == 10)
+ assert(queue.init.isEmpty)
+ assert(queue.tail.isEmpty)
+
+ queue.clear
+ assert(queue.isEmpty)
+ assert(queue.length == 0)
+
+ queue.enqueue(11)
+ assert(queue.nonEmpty)
+ assert(queue.length == 1)
+ assert(queue.head == 11)
+ assert(queue.front == 11)
+
+ val deq = queue.dequeue
+ assert(deq == 11)
+ assert(queue.isEmpty)
+ assert(queue.length == 0)
+
+ queue.enqueue(12)
+ val pdopt = queue.dequeueFirst(_ > 999)
+ assert(pdopt == None)
+ assert(queue.nonEmpty && queue.length == 1)
+
+ val somepd = queue.dequeueFirst(_ >= 1)
+ assert(somepd == Some(12))
+ assert(queue.isEmpty && queue.length == 0)
+ }
+
+ def testTwoEnqueues {
+ val queue = new ExtQueue[Int]
+ queue.enqueue(30)
+ queue.enqueue(40)
+
+ assert(queue.length == 2)
+ assert(queue.size == 2)
+ assert(queue.nonEmpty)
+ assert(queue.front == 30)
+// queue.printState
+
+ val all = queue.dequeueAll(_ > 20)
+ assert(all.size == 2)
+ assert(all.contains(30))
+ assert(all.contains(40))
+ assert(queue.size == 0)
+ assert(queue.isEmpty)
+ }
+
+ def testFewEnqueues {
+ val queue = new ExtQueue[Int]
+ queue.enqueue(10)
+ queue.enqueue(20)
+
+ assert(queue.length == 2)
+ assert(queue.nonEmpty)
+ assert(queue.head == 10)
+ assert(queue.last == 20)
+ assert(queue.front == 10)
+// queue.printState
+
+ val ten = queue.dequeue
+ assert(ten == 10)
+ assert(queue.length == 1)
+// queue.printState
+
+ queue.enqueue(30)
+// queue.printState
+ val gt25 = queue.dequeueFirst(_ > 25)
+ assert(gt25 == Some(30))
+ assert(queue.nonEmpty)
+ assert(queue.length == 1)
+ assert(queue.head == 20)
+ assert(queue.front == 20)
+// queue.printState
+
+ queue.enqueue(30)
+// queue.printState
+ val lt25 = queue.dequeueFirst(_ < 25)
+ assert(lt25 == Some(20))
+ assert(queue.nonEmpty)
+ assert(queue.length == 1)
+// queue.printState
+
+ queue.enqueue(40)
+// queue.printState
+ val all = queue.dequeueAll(_ > 20)
+// queue.printState
+ assert(all.size == 2)
+ assert(all.contains(30))
+ assert(all.contains(40))
+ assert(queue.isEmpty)
+ assert(queue.length == 0)
+
+ queue.enqueue(50)
+ queue.enqueue(60)
+// queue.printState
+ val allgt55 = queue.dequeueAll(_ > 55)
+// println(allgt55)
+// queue.printState
+ assert(allgt55.size == 1)
+ assert(allgt55.contains(60))
+ assert(queue.length == 1)
+
+ queue.enqueue(70)
+ queue.enqueue(80)
+// queue.printState
+ val alllt75 = queue.dequeueAll(_ < 75)
+// queue.printState
+ assert(alllt75.size == 2)
+ assert(alllt75.contains(70))
+ assert(alllt75.contains(50))
+ assert(queue.length == 1)
+ assert(queue.head == 80)
+ assert(queue.last == 80)
+ assert(queue.front == 80)
+ }
+
+ def testMoreEnqueues {
+ val queue = new ExtQueue[Int]
+ for (i <- 0 until 10) queue.enqueue(i * 2)
+
+ for (i <- 0 until 10) {
+ val top = queue.dequeue
+ assert(top == i * 2)
+ assert(queue.length == 10 - i - 1)
+ }
+ assert(queue.isEmpty)
+ assert(queue.length == 0)
+
+ for (i <- 0 until 10) queue.enqueue(i * i)
+ assert(queue.length == 10)
+ assert(queue.nonEmpty)
+
+ //queue.printState
+ val gt5 = queue.dequeueAll(_ > 4)
+ //queue.printState
+ //println(gt5)
+ assert(gt5.size == 7)
+ assert(queue.length == 3)
+ assert(queue.nonEmpty)
+
+ queue.clear
+ assert(queue.length == 0)
+ assert(queue.isEmpty)
+
+ for (i <- 0 until 10) queue.enqueue(i)
+ assert(queue.length == 10)
+
+ val even = queue.dequeueAll(_ % 2 == 0)
+ assert(even.size == 5)
+ assert(even.sameElements(List(0, 2, 4, 6, 8)))
+ assert(queue.length == 5)
+ assert(queue.head == 1)
+ assert(queue.last == 9)
+
+ val odd = queue.dequeueAll(_ %2 == 1)
+ assert(odd.size == 5)
+ assert(queue.length == 0)
+ assert(queue.isEmpty)
+ assert(odd.sameElements(List(1, 3, 5, 7, 9)))
+
+ for (i <- 0 until 10) queue.enqueue(i * i)
+ assert(queue.last == 81)
+ assert(queue.head == 0)
+ assert(queue.length == 10)
+
+ val foddgt25 = queue.dequeueFirst(num => num > 25 && num % 2 == 1)
+ assert(foddgt25 == Some(49))
+ assert(queue.length == 9)
+ assert(queue.nonEmpty)
+
+ //queue.printState
+ val lt30 = queue.dequeueAll(_ < 30)
+ //println(lt30)
+ //queue.printState
+ assert(lt30.size == 6)
+ assert(queue.length == 3)
+
+ val fgt60 = queue.dequeueFirst(_ > 60)
+ assert(fgt60 == Some(64))
+ assert(queue.length == 2)
+ assert(queue.head == 36)
+ assert(queue.last == 81)
+
+ val sgt60 = queue.dequeueFirst(_ > 60)
+ assert(sgt60 == Some(81))
+ assert(queue.length == 1)
+ assert(queue.head == 36)
+ assert(queue.last == 36)
+
+ val nogt60 = queue.dequeueFirst(_ > 60)
+ assert(nogt60 == None)
+ assert(queue.length == 1)
+ assert(queue.nonEmpty)
+ assert(queue.head == 36)
+
+ val gt0 = queue.dequeueFirst(_ > 0)
+ assert(gt0 == Some(36))
+ assert(queue.length == 0)
+ assert(queue.isEmpty)
+
+ for (i <- 0 until 4) queue.enqueue(i)
+ val interv = queue.dequeueAll(n => n > 0 && n < 3)
+ assert(interv.sameElements(List(1, 2)))
+ assert(queue.length == 2)
+ assert(queue.head == 0)
+ assert(queue.last == 3)
+
+ queue.dequeue
+ assert(queue.head == 3)
+
+ queue.enqueue(9)
+ val three = queue.dequeueFirst(_ < 5)
+ assert(three == Some(3))
+ assert(queue.length == 1)
+ assert(queue.head == 9)
+
+ queue.clear
+ for (i <- -100 until 100) queue.enqueue(i * i + i % 7 + 5)
+ assert(queue.length == 200)
+
+ val manyodds = queue.dequeueAll(_ % 2 == 1)
+ assert((manyodds.size + queue.length) == 200)
+
+ queue.dequeueAll(_ > -10000)
+ assert(queue.isEmpty)
+
+ for (i <- 0 until 100) queue.enqueue(i)
+ val multof3 = queue.dequeueAll(_ % 3 == 0)
+ assert(multof3.size == 34)
+ assert(queue.size == 66)
+
+ val n98 = queue.dequeueFirst(_ == 98)
+ assert(n98 == Some(98))
+ assert(queue.size == 65)
+ assert(queue.last == 97)
+ assert(queue.head == 1)
+ // well... seems to work
+ }
+
+}
+
+
+
+
diff --git a/test/files/run/ReplacementMatching.scala b/test/files/run/ReplacementMatching.scala index 05040d98a3..faa46419dc 100644 --- a/test/files/run/ReplacementMatching.scala +++ b/test/files/run/ReplacementMatching.scala @@ -7,12 +7,12 @@ import util.matching._ object Test { - + def main(args: Array[String]) { replacementMatching groupsMatching } - + def replacementMatching { val regex = """\$\{(.+?)\}""".r val replaced = regex.replaceAllIn("Replacing: ${main}. And another method: ${foo}.", @@ -21,7 +21,7 @@ object Test { identifier }) assert(replaced == "Replacing: main. And another method: foo.") - + val regex3 = """\$\{(.+?)\}""".r val replaced3 = regex3.replaceSomeIn("Replacing: ${main}. And another: ${foo}.", (m: util.matching.Regex.Match) => { val id = m.group(1) @@ -29,7 +29,7 @@ object Test { }) assert(replaced3 == "Replacing: main. And another: ${foo}.") } - + def groupsMatching { val Date = """(\d+)/(\d+)/(\d+)""".r for (Regex.Groups(a, b, c) <- Date findFirstMatchIn "1/1/2001 marks the start of the millenium. 31/12/2000 doesn't.") { @@ -43,5 +43,5 @@ object Test { assert(c == "2001" || c == "2000") } } - + } diff --git a/test/files/run/ReverseSeqView.scala b/test/files/run/ReverseSeqView.scala index 836e4d6a1f..88394064c5 100644 --- a/test/files/run/ReverseSeqView.scala +++ b/test/files/run/ReverseSeqView.scala @@ -5,14 +5,14 @@ object Test extends Application { - + val lstv = List(1, 2, 3).view val lstvr = lstv.reverse assert(lstvr.iterator.toList == List(3, 2, 1)) assert(lstvr.reverse == List(1, 2, 3)) assert(lstvr.reverseIterator.toList == List(1, 2, 3)) assert(lstvr.reverseMap(_ + 1) == List(2, 3, 4)) - + } diff --git a/test/files/run/SymbolsTest.scala b/test/files/run/SymbolsTest.scala index 53caa5e62f..cdd68ab13e 100644 --- a/test/files/run/SymbolsTest.scala +++ b/test/files/run/SymbolsTest.scala @@ -1,283 +1,283 @@ - - - - -class Slazz { - val s1 = 'myFirstSymbol - val s2 = 'mySecondSymbol - def s3 = 'myThirdSymbol - var s4: Symbol = null - - s4 = 'myFourthSymbol -} - -class Base { - val basesymbol = 'symbase -} - -class Sub extends Base { - val subsymbol = 'symsub -} - -trait Signs { - val ind = 'indication - val trace = 'trace -} - -trait Lazy1 { - lazy val v1 = "lazy v1" - lazy val s1 = 'lazySymbol1 -} - -trait Lazy2 { - lazy val v2 = "lazy v2" - lazy val s2 = 'lazySymbol2 -} - -trait Lazy3 { - lazy val v3 = "lazy v3" - lazy val s3 = 'lazySymbol3 -} - -object SingletonOfLazyness { - lazy val lazysym = 'lazySymbol - lazy val another = 'another - lazy val lastone = 'lastone -} - -/* - * Tests symbols to see if they work correct. - */ -object Test { - class Inner { - val simba = 'smba - var mfs: Symbol = null - mfs = Symbol("mfsa") - } - - object InnerObject { - val o1 = 'aaa - val o2 = 'ddd - } - - def aSymbol = 'myFirstSymbol - val anotherSymbol = 'mySecondSymbol - - def main(args: Array[String]) { - testLiterals - testForLoop - testInnerClasses - testInnerObjects - testWithHashMaps - testLists - testAnonymous - testNestedObject - testInheritance - testTraits - testLazyTraits - testLazyObjects - } - - def testLiterals { - val scl = new Slazz - assert(scl.s1 == aSymbol) - assert(scl.s2 == anotherSymbol) - assert(scl.s3 == 'myThirdSymbol) - assert(scl.s4 == Symbol.apply("myFourthSymbol")) - assert(scl.s1 == Symbol("myFirstSymbol")) - } - - def testForLoop { - for (i <- 0 until 100) List("Val" + i) - } - - def testInnerClasses { - val innerPower = new Inner - assert(innerPower.simba == 'smba) - assert(innerPower.mfs == 'mfsa) - } - - def testInnerObjects { - assert(InnerObject.o1 == 'aaa) - assert(InnerObject.o2 == 'ddd) - } - - def testWithHashMaps { - val map = new collection.mutable.HashMap[Symbol, Symbol] - map.put(InnerObject.o1, 'smba) - map.put(InnerObject.o2, 'mfsa) - map.put(Symbol("WeirdKey" + 1), Symbol("Weird" + "Val" + 1)) - assert(map('aaa) == 'smba) - assert(map('ddd) == 'mfsa) - assert(map('WeirdKey1) == Symbol("WeirdVal1")) - - map.clear - for (i <- 0 until 100) map.put(Symbol("symKey" + i), Symbol("symVal" + i)) - assert(map(Symbol("symKey15")) == Symbol("symVal15")) - assert(map('symKey22) == 'symVal22) - assert(map('symKey73) == 'symVal73) - assert(map('symKey56) == 'symVal56) - assert(map('symKey91) == 'symVal91) - } - - def testLists { - var lst: List[Symbol] = Nil - for (i <- 0 until 100) lst ::= Symbol("lsym" + (99 - i)) - assert(lst(0) == 'lsym0) - assert(lst(10) == 'lsym10) - assert(lst(30) == 'lsym30) - assert(lst(40) == 'lsym40) - assert(lst(65) == 'lsym65) - assert(lst(90) == 'lsym90) - } - - def testAnonymous { // TODO complaints classdef can't be found for some reason, runs fine in my case - // val anon = () => { - // val simba = 'smba - // simba - // } - // val an2 = () => { - // object nested { - // val m = 'mfsa - // } - // nested.m - // } - // val an3 = () => { - // object nested { - // val f = () => { - // 'layered - // } - // def gets = f() - // } - // nested.gets - // } - // val inner = new Inner - // assert(anon() == inner.simba) - // assert(anon().toString == "'smba") - // assert(an2() == 'mfsa) - // assert(an3() == Symbol("layered" + "")) - } - - def testNestedObject { - object nested { - def sign = 'sign - def insignia = 'insignia - } - assert(nested.sign == 'sign) - assert(nested.insignia == 'insignia) - assert(('insignia).toString == "'insignia") - } - - def testInheritance { - val base = new Base - val sub = new Sub - assert(base.basesymbol == 'symbase) - assert(sub.subsymbol == 'symsub) - assert(sub.basesymbol == 'symbase) - - val anon = new Sub { - def subsubsymbol = 'symsubsub - } - assert(anon.subsubsymbol == 'symsubsub) - assert(anon.subsymbol == 'symsub) - assert(anon.basesymbol == 'symbase) - - object nested extends Sub { - def objsymbol = 'symobj - } - assert(nested.objsymbol == 'symobj) - assert(nested.subsymbol == 'symsub) - assert(nested.basesymbol == 'symbase) - assert(('symbase).toString == "'symbase") - } - - def testTraits { - val fromTrait = new AnyRef with Signs { - def traitsymbol = 'traitSymbol - } - - assert(fromTrait.traitsymbol == 'traitSymbol) - assert(fromTrait.ind == 'indication) - assert(fromTrait.trace == 'trace) - assert(('trace).toString == "'trace") - - trait Compl { - val s1 = 's1 - def s2 = 's2 - object inner { - val s3 = 's3 - val s4 = 's4 - } - } - - val compl = new Sub with Signs with Compl - assert(compl.s1 == 's1) - assert(compl.s2 == 's2) - assert(compl.inner.s3 == 's3) - assert(compl.inner.s4 == 's4) - assert(compl.ind == 'indication) - assert(compl.trace == 'trace) - assert(compl.subsymbol == 'symsub) - assert(compl.basesymbol == 'symbase) - - object Local extends Signs with Compl { - val s5 = 's5 - def s6 = 's6 - object inner2 { - val s7 = 's7 - def s8 = 's8 - } - } - assert(Local.s5 == 's5) - assert(Local.s6 == 's6) - assert(Local.inner2.s7 == 's7) - assert(Local.inner2.s8 == 's8) - assert(Local.inner.s3 == 's3) - assert(Local.inner.s4 == 's4) - assert(Local.s1 == 's1) - assert(Local.s2 == 's2) - assert(Local.trace == 'trace) - assert(Local.ind == 'indication) - assert(('s8).toString == "'s8") - } - - def testLazyTraits { - val l1 = new AnyRef with Lazy1 - val l2 = new AnyRef with Lazy2 - val l3 = new AnyRef with Lazy3 - - l1.v1 - l2.v2 - l3.v3 - assert((l1.s1).toString == "'lazySymbol1") - assert(l2.s2 == Symbol("lazySymbol" + 2)) - assert(l3.s3 == 'lazySymbol3) - } - - def testLazyObjects { - assert(SingletonOfLazyness.lazysym == 'lazySymbol) - assert(SingletonOfLazyness.another == Symbol("ano" + "ther")) - assert((SingletonOfLazyness.lastone).toString == "'lastone") - - object nested { - lazy val sym1 = 'snested1 - lazy val sym2 = 'snested2 - } - - assert(nested.sym1 == 'snested1) - assert(nested.sym2 == Symbol("snested" + "2")) - } - -} - - - - - - - - - - - - +
+
+
+
+class Slazz {
+ val s1 = 'myFirstSymbol
+ val s2 = 'mySecondSymbol
+ def s3 = 'myThirdSymbol
+ var s4: Symbol = null
+
+ s4 = 'myFourthSymbol
+}
+
+class Base {
+ val basesymbol = 'symbase
+}
+
+class Sub extends Base {
+ val subsymbol = 'symsub
+}
+
+trait Signs {
+ val ind = 'indication
+ val trace = 'trace
+}
+
+trait Lazy1 {
+ lazy val v1 = "lazy v1"
+ lazy val s1 = 'lazySymbol1
+}
+
+trait Lazy2 {
+ lazy val v2 = "lazy v2"
+ lazy val s2 = 'lazySymbol2
+}
+
+trait Lazy3 {
+ lazy val v3 = "lazy v3"
+ lazy val s3 = 'lazySymbol3
+}
+
+object SingletonOfLazyness {
+ lazy val lazysym = 'lazySymbol
+ lazy val another = 'another
+ lazy val lastone = 'lastone
+}
+
+/*
+ * Tests symbols to see if they work correct.
+ */
+object Test {
+ class Inner {
+ val simba = 'smba
+ var mfs: Symbol = null
+ mfs = Symbol("mfsa")
+ }
+
+ object InnerObject {
+ val o1 = 'aaa
+ val o2 = 'ddd
+ }
+
+ def aSymbol = 'myFirstSymbol
+ val anotherSymbol = 'mySecondSymbol
+
+ def main(args: Array[String]) {
+ testLiterals
+ testForLoop
+ testInnerClasses
+ testInnerObjects
+ testWithHashMaps
+ testLists
+ testAnonymous
+ testNestedObject
+ testInheritance
+ testTraits
+ testLazyTraits
+ testLazyObjects
+ }
+
+ def testLiterals {
+ val scl = new Slazz
+ assert(scl.s1 == aSymbol)
+ assert(scl.s2 == anotherSymbol)
+ assert(scl.s3 == 'myThirdSymbol)
+ assert(scl.s4 == Symbol.apply("myFourthSymbol"))
+ assert(scl.s1 == Symbol("myFirstSymbol"))
+ }
+
+ def testForLoop {
+ for (i <- 0 until 100) List("Val" + i)
+ }
+
+ def testInnerClasses {
+ val innerPower = new Inner
+ assert(innerPower.simba == 'smba)
+ assert(innerPower.mfs == 'mfsa)
+ }
+
+ def testInnerObjects {
+ assert(InnerObject.o1 == 'aaa)
+ assert(InnerObject.o2 == 'ddd)
+ }
+
+ def testWithHashMaps {
+ val map = new collection.mutable.HashMap[Symbol, Symbol]
+ map.put(InnerObject.o1, 'smba)
+ map.put(InnerObject.o2, 'mfsa)
+ map.put(Symbol("WeirdKey" + 1), Symbol("Weird" + "Val" + 1))
+ assert(map('aaa) == 'smba)
+ assert(map('ddd) == 'mfsa)
+ assert(map('WeirdKey1) == Symbol("WeirdVal1"))
+
+ map.clear
+ for (i <- 0 until 100) map.put(Symbol("symKey" + i), Symbol("symVal" + i))
+ assert(map(Symbol("symKey15")) == Symbol("symVal15"))
+ assert(map('symKey22) == 'symVal22)
+ assert(map('symKey73) == 'symVal73)
+ assert(map('symKey56) == 'symVal56)
+ assert(map('symKey91) == 'symVal91)
+ }
+
+ def testLists {
+ var lst: List[Symbol] = Nil
+ for (i <- 0 until 100) lst ::= Symbol("lsym" + (99 - i))
+ assert(lst(0) == 'lsym0)
+ assert(lst(10) == 'lsym10)
+ assert(lst(30) == 'lsym30)
+ assert(lst(40) == 'lsym40)
+ assert(lst(65) == 'lsym65)
+ assert(lst(90) == 'lsym90)
+ }
+
+ def testAnonymous { // TODO complaints classdef can't be found for some reason, runs fine in my case
+ // val anon = () => {
+ // val simba = 'smba
+ // simba
+ // }
+ // val an2 = () => {
+ // object nested {
+ // val m = 'mfsa
+ // }
+ // nested.m
+ // }
+ // val an3 = () => {
+ // object nested {
+ // val f = () => {
+ // 'layered
+ // }
+ // def gets = f()
+ // }
+ // nested.gets
+ // }
+ // val inner = new Inner
+ // assert(anon() == inner.simba)
+ // assert(anon().toString == "'smba")
+ // assert(an2() == 'mfsa)
+ // assert(an3() == Symbol("layered" + ""))
+ }
+
+ def testNestedObject {
+ object nested {
+ def sign = 'sign
+ def insignia = 'insignia
+ }
+ assert(nested.sign == 'sign)
+ assert(nested.insignia == 'insignia)
+ assert(('insignia).toString == "'insignia")
+ }
+
+ def testInheritance {
+ val base = new Base
+ val sub = new Sub
+ assert(base.basesymbol == 'symbase)
+ assert(sub.subsymbol == 'symsub)
+ assert(sub.basesymbol == 'symbase)
+
+ val anon = new Sub {
+ def subsubsymbol = 'symsubsub
+ }
+ assert(anon.subsubsymbol == 'symsubsub)
+ assert(anon.subsymbol == 'symsub)
+ assert(anon.basesymbol == 'symbase)
+
+ object nested extends Sub {
+ def objsymbol = 'symobj
+ }
+ assert(nested.objsymbol == 'symobj)
+ assert(nested.subsymbol == 'symsub)
+ assert(nested.basesymbol == 'symbase)
+ assert(('symbase).toString == "'symbase")
+ }
+
+ def testTraits {
+ val fromTrait = new AnyRef with Signs {
+ def traitsymbol = 'traitSymbol
+ }
+
+ assert(fromTrait.traitsymbol == 'traitSymbol)
+ assert(fromTrait.ind == 'indication)
+ assert(fromTrait.trace == 'trace)
+ assert(('trace).toString == "'trace")
+
+ trait Compl {
+ val s1 = 's1
+ def s2 = 's2
+ object inner {
+ val s3 = 's3
+ val s4 = 's4
+ }
+ }
+
+ val compl = new Sub with Signs with Compl
+ assert(compl.s1 == 's1)
+ assert(compl.s2 == 's2)
+ assert(compl.inner.s3 == 's3)
+ assert(compl.inner.s4 == 's4)
+ assert(compl.ind == 'indication)
+ assert(compl.trace == 'trace)
+ assert(compl.subsymbol == 'symsub)
+ assert(compl.basesymbol == 'symbase)
+
+ object Local extends Signs with Compl {
+ val s5 = 's5
+ def s6 = 's6
+ object inner2 {
+ val s7 = 's7
+ def s8 = 's8
+ }
+ }
+ assert(Local.s5 == 's5)
+ assert(Local.s6 == 's6)
+ assert(Local.inner2.s7 == 's7)
+ assert(Local.inner2.s8 == 's8)
+ assert(Local.inner.s3 == 's3)
+ assert(Local.inner.s4 == 's4)
+ assert(Local.s1 == 's1)
+ assert(Local.s2 == 's2)
+ assert(Local.trace == 'trace)
+ assert(Local.ind == 'indication)
+ assert(('s8).toString == "'s8")
+ }
+
+ def testLazyTraits {
+ val l1 = new AnyRef with Lazy1
+ val l2 = new AnyRef with Lazy2
+ val l3 = new AnyRef with Lazy3
+
+ l1.v1
+ l2.v2
+ l3.v3
+ assert((l1.s1).toString == "'lazySymbol1")
+ assert(l2.s2 == Symbol("lazySymbol" + 2))
+ assert(l3.s3 == 'lazySymbol3)
+ }
+
+ def testLazyObjects {
+ assert(SingletonOfLazyness.lazysym == 'lazySymbol)
+ assert(SingletonOfLazyness.another == Symbol("ano" + "ther"))
+ assert((SingletonOfLazyness.lastone).toString == "'lastone")
+
+ object nested {
+ lazy val sym1 = 'snested1
+ lazy val sym2 = 'snested2
+ }
+
+ assert(nested.sym1 == 'snested1)
+ assert(nested.sym2 == Symbol("snested" + "2"))
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/files/run/absoverride.scala b/test/files/run/absoverride.scala index a3c03df0d7..8c6de09d2a 100644 --- a/test/files/run/absoverride.scala +++ b/test/files/run/absoverride.scala @@ -26,16 +26,16 @@ trait SyncIterator extends AbsIterator { } } trait LoggedIterator extends AbsIterator { - abstract override def next: T = { - val x = super.next; println("log: " + x); x + abstract override def next: T = { + val x = super.next; println("log: " + x); x } } -class Iter2(s: String) extends StringIterator(s) - with SyncIterator with LoggedIterator; +class Iter2(s: String) extends StringIterator(s) + with SyncIterator with LoggedIterator; object Test { def main(args: Array[String]) { class Iter extends StringIterator(args(0)) with RichIterator with SyncIterator with LoggedIterator val iter = new Iter - iter foreach Console.println + iter foreach Console.println } } diff --git a/test/files/run/arrayclone.scala b/test/files/run/arrayclone.scala index 2b56c53469..55d8fc395d 100644 --- a/test/files/run/arrayclone.scala +++ b/test/files/run/arrayclone.scala @@ -16,7 +16,7 @@ object BooleanArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = false; - assert(it(0) == true) + assert(it(0) == true) } object ByteArrayClone{ @@ -24,7 +24,7 @@ object ByteArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object ShortArrayClone{ @@ -32,7 +32,7 @@ object ShortArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object CharArrayClone{ @@ -40,7 +40,7 @@ object CharArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object IntArrayClone{ @@ -48,7 +48,7 @@ object IntArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object LongArrayClone{ @@ -56,7 +56,7 @@ object LongArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object FloatArrayClone{ @@ -64,7 +64,7 @@ object FloatArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object DoubleArrayClone{ @@ -72,7 +72,7 @@ object DoubleArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object ObjectArrayClone{ @@ -80,7 +80,7 @@ object ObjectArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = "0"; - assert(it(0) == "1") + assert(it(0) == "1") } object PolymorphicArrayClone{ @@ -88,14 +88,14 @@ object PolymorphicArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = zero; - assert(it(0) == one) - } + assert(it(0) == one) + } testIt(Array("one", "two"), "one", "two"); class Mangler[T: Manifest](ts : T*){ // this will always be a BoxedAnyArray even after we've unboxed its contents. - val it = ts.toArray[T]; + val it = ts.toArray[T]; } val mangled = new Mangler[Int](0, 1); diff --git a/test/files/run/arraycopy.scala b/test/files/run/arraycopy.scala index bb06200dc7..82c34c23e7 100644 --- a/test/files/run/arraycopy.scala +++ b/test/files/run/arraycopy.scala @@ -5,7 +5,7 @@ object Test { val a = new Array[Int](10) val b = new Array[Any](10) for (i <- 0 until 10) b(i) = i - + Array.copy(b, 3, a, 3, 7) assert(a.toSeq == List(0, 0, 0, 3, 4, 5, 6, 7, 8, 9)) } diff --git a/test/files/run/bigDecimalCache.scala b/test/files/run/bigDecimalCache.scala index c0c709a50f..e8ebefee78 100644 --- a/test/files/run/bigDecimalCache.scala +++ b/test/files/run/bigDecimalCache.scala @@ -1,9 +1,9 @@ -object Test { +object Test { def main(args: Array[String]): Unit = { val bd5a = BigDecimal(5) val mc = java.math.MathContext.DECIMAL32 val bd5b = BigDecimal(5,mc) - + assert(bd5b.mc == mc) } } diff --git a/test/files/run/boolexprs.scala b/test/files/run/boolexprs.scala index b9b4faea9c..4f1c4b161a 100644 --- a/test/files/run/boolexprs.scala +++ b/test/files/run/boolexprs.scala @@ -10,7 +10,7 @@ class Counter { object Test1 { var flag = false; - def flip: Boolean = { val tmp = flag; flag = !flag; tmp } + def flip: Boolean = { val tmp = flag; flag = !flag; tmp } def run: Int = { val c = new Counter; c.incrThen(flip || flip); diff --git a/test/files/run/bug0325.scala b/test/files/run/bug0325.scala index 236f1b101f..92331ab05f 100644 --- a/test/files/run/bug0325.scala +++ b/test/files/run/bug0325.scala @@ -7,7 +7,7 @@ case class RS(self: String) { } def split(separator: Char): Array[String] = self.split(escape(separator)) - + def split(separators: Array[Char]): Array[String] = { val re = separators.foldLeft("[")(_+escape(_)) + "]" self.split(re) @@ -27,7 +27,7 @@ object Test { case e@_ => println(which + " failed with " + e.getClass) } } - + def main(args: Array[String]) { val badChars = "?*{+([\\^.$" @@ -46,8 +46,8 @@ object Test { for ((c,str) <- badCases) test(("a"+c+"b").split(str.toArray),"RichString split(\""+ str + "\")") println - + for ((c,str) <- badCases) - test(RS("a"+c+"b").split(str.toArray),"RS split(\""+ str + "\")") + test(RS("a"+c+"b").split(str.toArray),"RS split(\""+ str + "\")") } } diff --git a/test/files/run/bug1005.scala b/test/files/run/bug1005.scala index 5ccd89dd85..60129bcc51 100644 --- a/test/files/run/bug1005.scala +++ b/test/files/run/bug1005.scala @@ -10,7 +10,7 @@ object Test object FromPoly{ def main(args : Array[String]) = (new Bar[AnyRef](Array[AnyRef]("Halp!"))).bar } - + def main(args: Array[String]): Unit = { println(FromMono main null mkString) println(FromPoly main null mkString) diff --git a/test/files/run/bug1141.scala b/test/files/run/bug1141.scala index a98e3cf204..7de031366c 100644 --- a/test/files/run/bug1141.scala +++ b/test/files/run/bug1141.scala @@ -2,6 +2,6 @@ object Test extends Application { val foo = new { def apply(args : String*) = args foreach println } - + foo("var", "args") } diff --git a/test/files/run/bug1220.scala b/test/files/run/bug1220.scala index 88baa980f5..165a1c0eca 100644 --- a/test/files/run/bug1220.scala +++ b/test/files/run/bug1220.scala @@ -1,7 +1,7 @@ object Test extends Application { class QSRichIterable[A](self: Iterable[A]) { - def filterMap[R](f: PartialFunction[A,R]) = + def filterMap[R](f: PartialFunction[A,R]) = self filter (f.isDefinedAt) map f } diff --git a/test/files/run/bug1300.scala b/test/files/run/bug1300.scala index 1a759f4e1e..7b2fd79cec 100644 --- a/test/files/run/bug1300.scala +++ b/test/files/run/bug1300.scala @@ -4,10 +4,10 @@ object Test extends Application // val a1 = x1.toArray[Any] val a2 = Array('a','b','c','d').toArray[Any] val a3 = Array("e","f","g","h").toArray[Any] - + Array.copy(a3, 0, a1, 0, 4) Array.copy(a2, 0, a3, 0, 4) Array.copy(a2, 0, a1, 0, 4) - + println(a1.mkString + a2.mkString + a3.mkString) } diff --git a/test/files/run/bug1309.scala b/test/files/run/bug1309.scala index d753f4d96c..6b5167eb56 100644 --- a/test/files/run/bug1309.scala +++ b/test/files/run/bug1309.scala @@ -1,6 +1,6 @@ object Test { def f(ras: => RandomAccessSeq[Byte]): RandomAccessSeq[Byte] = ras - + def main(args: Array[String]): Unit = { f(new Array[Byte](0)) } diff --git a/test/files/run/bug1766.scala b/test/files/run/bug1766.scala index 901f9ae664..94f69356e1 100644 --- a/test/files/run/bug1766.scala +++ b/test/files/run/bug1766.scala @@ -1,16 +1,16 @@ object Test extends Application { - + class C(s: String) { - + def this(i: Int) = this("bar") - + def f = { val v: { def n: Int } = new { val n = 3 } v.n } - + } - + new C("foo").f - + } diff --git a/test/files/run/bug2029.scala b/test/files/run/bug2029.scala index 32b04f0b47..1cbe97a350 100644 --- a/test/files/run/bug2029.scala +++ b/test/files/run/bug2029.scala @@ -3,10 +3,10 @@ object Test{ import scala.collection.immutable.TreeSet; val mainSet = TreeSet(1 to 5 :_*) - + var compareCalled = false; val smallerSet = TreeSet(2 to 4 :_*)(Ordering[Int].reverse) - + println(mainSet.mkString(",")) println(smallerSet.mkString(",")) println(smallerSet.subsetOf(mainSet)); diff --git a/test/files/run/bug2124.scala b/test/files/run/bug2124.scala index e72deb09bc..a4fd654d76 100644 --- a/test/files/run/bug2124.scala +++ b/test/files/run/bug2124.scala @@ -9,7 +9,7 @@ object Test { println(new RuleTransformer(new RewriteRule { - override def transform(n: Node): NodeSeq = { + override def transform(n: Node): NodeSeq = { val result = n match { case <t>{_*}</t> => <q/> diff --git a/test/files/run/bug2125.scala b/test/files/run/bug2125.scala index 8314e4f019..a10ed9827b 100644 --- a/test/files/run/bug2125.scala +++ b/test/files/run/bug2125.scala @@ -5,11 +5,11 @@ import scala.xml.transform._ object Test { val sampleXml = <xml:group><p><lost/><t><s><r></r></s></t></p></xml:group> - + def main(args: scala.Array[String]) { println(new RuleTransformer(new RewriteRule { - override def transform(n: Node): NodeSeq = { + override def transform(n: Node): NodeSeq = { val result = n match { diff --git a/test/files/run/bug2276.scala b/test/files/run/bug2276.scala index 25c30d9e96..68b9976355 100644 --- a/test/files/run/bug2276.scala +++ b/test/files/run/bug2276.scala @@ -2,7 +2,7 @@ import scala.xml._ import scala.xml.transform._ object Test extends Application { - val inputXml : Node = + val inputXml : Node = <root> <subnode> <version>1</version> diff --git a/test/files/run/bug2354.scala b/test/files/run/bug2354.scala index f46db13a95..5419911ac3 100644 --- a/test/files/run/bug2354.scala +++ b/test/files/run/bug2354.scala @@ -8,7 +8,7 @@ object Test val parser1 = ConstructingParser.fromSource(Source.fromString(xml_good),false) val parser2 = ConstructingParser.fromSource(Source.fromString(xml_bad),false) - + def main(args: Array[String]): Unit = { parser1.document parser2.document diff --git a/test/files/run/bug2512.scala b/test/files/run/bug2512.scala index 514b26650f..c2dfda6c1f 100644 --- a/test/files/run/bug2512.scala +++ b/test/files/run/bug2512.scala @@ -4,11 +4,11 @@ object Test { val runs = 10000 class Bop - + def main(args: Array[String]): Unit = { val set: HashSet[Bop] = new HashSet("Bop", 16) (1 to runs).toList foreach (_ => set addEntry new Bop) - + assert(runs == set.size && set.size == set.iterator.length) } } diff --git a/test/files/run/bug2514.scala b/test/files/run/bug2514.scala index e23b441ecf..21c4afb472 100644 --- a/test/files/run/bug2514.scala +++ b/test/files/run/bug2514.scala @@ -1,7 +1,7 @@ object Test { implicit def x[A](a: A) = new { def xx = a } - + def main(args: Array[String]): Unit = { val r1 = 12 xx; val r2 = 12.xx @@ -9,7 +9,7 @@ object Test val r4 = 12.xx + 12.xx val r5 = 12.`xx` + 12.xx val r6 = 12.3.`xx` + 12.xx - + assert(r5 == 24) } }
\ No newline at end of file diff --git a/test/files/run/bug2552.scala b/test/files/run/bug2552.scala index 911d98decc..34fe25084e 100644 --- a/test/files/run/bug2552.scala +++ b/test/files/run/bug2552.scala @@ -2,11 +2,11 @@ object Test extends Application { def testTakeWhile = { val numbers = Iterator.range(0, 50) val zeroTo9 = numbers.takeWhile(x => { println("p(" + x + ")"); x < 10 } ) - + zeroTo9.foreach(println _) - + val zeroTo1 = Iterator.range(0, 20).takeWhile(x => { println("p(" + x + ")"); x < 2 } ) - + println(zeroTo1.hasNext) println(zeroTo1.hasNext) println(zeroTo1.next) @@ -15,16 +15,16 @@ object Test extends Application { println(zeroTo1.hasNext) println(zeroTo1.hasNext) } - + def testFilter = { val predicate = (x: Int) => { println("p(" + x + ")"); x % 2 == 0 } - + val evens = Iterator.range(0, 10).filter(predicate) - + println(evens.hasNext) println(evens.hasNext) println(evens.next) - + evens.foreach(println _) } diff --git a/test/files/run/bug2636.scala b/test/files/run/bug2636.scala index 8c49a733fd..3271f79ffc 100644 --- a/test/files/run/bug2636.scala +++ b/test/files/run/bug2636.scala @@ -3,28 +3,28 @@ object Test type Foo = { def update(x: Int, value: String): Unit } type Foo2 = { def update(x: Int, value: String): Int } type Foo3 = { def update(x: Int, value: String): Array[Int] } - + def alen() = { type L1 = { def length: Int } def len(p: L1) = p.length val x: L1 = Array(1,2,3) len(x) } - + type A1 = { def apply(x: Int): String } def arrApply(a: A1, x: Int) = a(x) - + def main(args: Array[String]): Unit = { val arr = new Array[String](3) val p1: Foo = arr def a1 = p1(0) = "b" val p2: Foo2 = new { def update(x: Int, value: String) = { p1(1) = "o" ; 1 } } - def a2 = p2(0) = "c" - + def a2 = p2(0) = "c" + val p3: Foo3 = new { def update(x: Int, value: String) = { p1(2) = "b" ; Array(1) } } def a3 = p3(10) = "hi mom" - + a1 ; a2 ; a3 ; assert(arr.mkString == "bob") diff --git a/test/files/run/bug2721.scala b/test/files/run/bug2721.scala index 8bd03bc838..93af884a60 100644 --- a/test/files/run/bug2721.scala +++ b/test/files/run/bug2721.scala @@ -2,9 +2,9 @@ object Test { val xml1 = <root xmlns:ns="nsUri" ns:at="rootVal"><sub ns:at="subVal"/></root> val xml2= scala.xml.XML.loadString("""<root xmlns:ns="nsUri" ns:at="rootVal"><sub ns:at="subVal"/></root>""") - + def backslashSearch(x: xml.Elem) = "root:-"+(x \ "@{nsUri}at") +"-sub:-"+(x \ "sub" \ "@{nsUri}at") +"-" - + def main(args: Array[String]): Unit = { println(backslashSearch(xml1)) println(backslashSearch(xml2)) diff --git a/test/files/run/bug2958.scala b/test/files/run/bug2958.scala index dcd24ecc36..b9563a1b77 100644 --- a/test/files/run/bug2958.scala +++ b/test/files/run/bug2958.scala @@ -2,14 +2,14 @@ object Test { def f(args: Array[String]) = args match { case Array("-p", prefix, from, to) => prefix + from + to - + case Array(from, to) => from + to case _ => "default" } - + def main(args: Array[String]) { assert(f(Array("1", "2")) == "12") } diff --git a/test/files/run/bug3175.scala b/test/files/run/bug3175.scala index 78660d4085..aff2e67d0d 100644 --- a/test/files/run/bug3175.scala +++ b/test/files/run/bug3175.scala @@ -6,46 +6,46 @@ object Test { def f1(x:{ def apply(x: Int): Long }) = x(0) def f2(x:{ def apply(x: Int): Byte }) = x(0) def f3(x:{ def apply(x: Int): String }) = x(0).length - + def f4(x:{ def update(x: Int, y: Long): Unit }, y: Long) = x(0) = y def f5(x:{ def update(x: Int, y: Byte): Unit }, y: Byte) = x(0) = y def f6(x:{ def update(x: Int, y: String): Unit }, y: String) = x(0) = y - + def f7(x: { def length: Any }) = x.length - + def f8(x: { def apply(x: Int): Any }) = x(0) def f9(x: { def apply(x: Int): Int }) = x(0) def f10(x: { def apply(x: Int): Long }) = x(0) - + // update has some interesting special cases def f11(x:{ def update(x: Int, y: Long): Any }, y: Long) = x(0) = y - def f12(x:{ def update(x: Int, y: String): AnyVal }, y: String) = x(0) = y + def f12(x:{ def update(x: Int, y: String): AnyVal }, y: String) = x(0) = y def f13(x:{ def update(x: Int, y: String): AnyRef }, y: String) = x(0) = y - + // doesn't work yet, see #3197 // def fclone(x:{ def clone(): AnyRef }) = x.clone() - + def main(args: Array[String]): Unit = { val longs = Array(5L) val bytes = Array(5: Byte) val strs = Array("abcde", "fghjij") - + println(len(Array(1,2,3)) + len(Array(4.0,5.0f)) + len(Array("abc", 5)) + len("bop")) println(f1(longs) + f2(bytes) + f3(strs)) - + f4(longs, 1) f5(bytes, 1) f6(strs, "a") - + println(f1(longs) + f2(bytes) + f3(strs)) - + println(f7(Array(1,2,3))) println(f7("def")) - + println(f8(Array(5))) println(f9(Array(5))) println(f10(Array(5))) - + f11(longs, 100L) f12(strs, "jabooboo") println(longs(0)) diff --git a/test/files/run/bug3269.scala b/test/files/run/bug3269.scala index 17e42cdb0e..6fe727111c 100644 --- a/test/files/run/bug3269.scala +++ b/test/files/run/bug3269.scala @@ -4,6 +4,6 @@ object Test { println(it.next) it.hasNext it.hasNext - it.hasNext + it.hasNext } } diff --git a/test/files/run/bug3395.scala b/test/files/run/bug3395.scala index b4990a1716..01cc431871 100644 --- a/test/files/run/bug3395.scala +++ b/test/files/run/bug3395.scala @@ -1,11 +1,11 @@ object Test { def main(args: Array[String]): Unit = { - Seq("") match { + Seq("") match { case Seq("") => println("abc") case Seq(_, _, x) => println(x) } - - Seq(1, 2, "def") match { + + Seq(1, 2, "def") match { case Seq("") => println("abc") case Seq(_, _, x) => println(x) } diff --git a/test/files/run/bug3397.scala b/test/files/run/bug3397.scala index 2c8cbed3ab..243fe766de 100644 --- a/test/files/run/bug3397.scala +++ b/test/files/run/bug3397.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { val x = Seq(Set(1,2,3),Set(4,5,6),Set(7,8,9)).transpose - + () } } diff --git a/test/files/run/bug3516.scala b/test/files/run/bug3516.scala index aa302ce85a..82a97f27de 100644 --- a/test/files/run/bug3516.scala +++ b/test/files/run/bug3516.scala @@ -1,7 +1,7 @@ object Test { def mkIterator = (1 to 5).iterator map (x => { println(x) ; x }) def mkInfinite = Iterator continually { println(1) ; 1 } - + def main(args: Array[String]): Unit = { // Stream is strict in its head so we should see 1 from each of them. val s1 = mkIterator.toStream diff --git a/test/files/run/bug3540.scala b/test/files/run/bug3540.scala index 5ffacb5dff..4eb3de780b 100644 --- a/test/files/run/bug3540.scala +++ b/test/files/run/bug3540.scala @@ -2,6 +2,6 @@ object Test { def main(args: Array[String]): Unit = { assert(List.iterate(List(1,2,3), 4)(_.tail).last.isEmpty) assert(Stream.iterate(Stream(1,2,3), 4)(_.tail).last.isEmpty) - assert(Array.iterate(Array(1,2,3), 4)(_.tail).last.isEmpty) + assert(Array.iterate(Array(1,2,3), 4)(_.tail).last.isEmpty) } } diff --git a/test/files/run/bug3563.scala b/test/files/run/bug3563.scala index 8abbb60803..2a80ef412a 100644 --- a/test/files/run/bug3563.scala +++ b/test/files/run/bug3563.scala @@ -5,17 +5,17 @@ // ticket #3563 object Test { - + def main(args: Array[String]) { var sum = 0 val setseq = Set(1, 2, 3, 4).toSeq setseq.map( n => { sum += n; n * n }).head assert(sum == 10) - + sum = 0 val mapseq = Map(1 -> 1, 2 -> 2, 3 -> 3, 4 -> 4).toSeq mapseq.map( n => { sum += n._1; (n._1 + n._1, n._2 * n._2) }).head assert(sum == 10) } - + } diff --git a/test/files/run/bug363.scala b/test/files/run/bug363.scala index c747be2ec9..5f3f30a098 100644 --- a/test/files/run/bug363.scala +++ b/test/files/run/bug363.scala @@ -3,7 +3,7 @@ object Test { println("I love the smell of (Array[String])Unit in the morning.") } } - + class Test { def kurtz() = "We must kill them. We must incinerate them." } diff --git a/test/files/run/bug408.scala b/test/files/run/bug408.scala index 9e51e881ed..4d3dcbcb84 100644 --- a/test/files/run/bug408.scala +++ b/test/files/run/bug408.scala @@ -2,7 +2,7 @@ object Test { val a = scala.collection.immutable.Set.empty ++ (0 to 100000) val b = scala.collection.immutable.Set.empty ++ (0 to 100000) - + def main(args: Array[String]): Unit = { a -- b a -- b diff --git a/test/files/run/bug603.scala b/test/files/run/bug603.scala index 361cef1f41..b8825c933b 100644 --- a/test/files/run/bug603.scala +++ b/test/files/run/bug603.scala @@ -22,7 +22,7 @@ object forceDelay { object Test { import forceDelay._ - + def main(args: Array[String]) = { val s: Susp[Int] = delay { Console.println("evaluating..."); 3 } Console.println("s = " + s) diff --git a/test/files/run/bug744.scala b/test/files/run/bug744.scala index 4895e9baa0..d5e9f6df34 100644 --- a/test/files/run/bug744.scala +++ b/test/files/run/bug744.scala @@ -5,7 +5,7 @@ trait Linked { } } object Test { - class Test extends Linked { + class Test extends Linked { trait FileImpl extends super.FileImpl { // val x: int = 1 } diff --git a/test/files/run/bug920.scala b/test/files/run/bug920.scala index 6a7f122d55..1e12e6ba87 100644 --- a/test/files/run/bug920.scala +++ b/test/files/run/bug920.scala @@ -7,7 +7,7 @@ object Test { trait Foo extends Test.Foo0 { def foo : B.this.type = B.this; } - class baz extends Baz with Foo { + class baz extends Baz with Foo { override def toString = "baz" } Console.println(new baz); diff --git a/test/files/run/bugs.scala b/test/files/run/bugs.scala index bbf2a0fb39..d5905af76c 100644 --- a/test/files/run/bugs.scala +++ b/test/files/run/bugs.scala @@ -304,7 +304,7 @@ object Bug250Test { // Bug 257 object Bug257Test { - def sayhello(): Unit = { Console.println("I should come 1st and 2nd"); }; + def sayhello(): Unit = { Console.println("I should come 1st and 2nd"); }; def sayhi(): Unit = { Console.println("I should come last"); }; def f1(x: Unit): Unit = (); diff --git a/test/files/run/bugs2087-and-2400.scala b/test/files/run/bugs2087-and-2400.scala index 19a5df26e3..93cd633ffb 100644 --- a/test/files/run/bugs2087-and-2400.scala +++ b/test/files/run/bugs2087-and-2400.scala @@ -3,14 +3,14 @@ object Test def negativeCharMaker = new (Short => Char) { def apply(x: Short) = x.toChar } def main(args: Array[String]): Unit = { // throws exception if -100 gets to Character.valueOf - val x = negativeCharMaker(-100) - + val x = negativeCharMaker(-100) + // chars are unsigned, they should never be equal to negative values assert((-100).toShort != (-100).toChar) assert((-100).toChar != (-100).toShort) assert((-100).toChar != (-100).toByte) assert((-100).toByte != (-100).toChar) - + // BoxesRunTime must agree as well assert(((-100).toShort: Any) != (-100).toChar) assert(((-100).toChar: Any) != (-100).toShort) diff --git a/test/files/run/caseClassEquality.scala b/test/files/run/caseClassEquality.scala index c11d7ad0d1..4940d80951 100644 --- a/test/files/run/caseClassEquality.scala +++ b/test/files/run/caseClassEquality.scala @@ -11,25 +11,25 @@ object Test { case _ => false } } - + case class CS1(xs: Any*) class CS2(xs: Seq[_]*) extends CS1(xs: _*) class CS3(xs: IndexedSeq[Int]*) extends CS2(xs: _*) - + case class H1(x: Int, y: Double) class H2(x: Double, y: Int) extends H1(y, x) - + def main(args: Array[String]): Unit = { assert(C1(5) == new C2(5)) assert(new C2(5) == C1(5)) assert(C1(5).hashCode == new C2(5).hashCode) assert(new C2(5).hashCode == C1(5).hashCode) - + assert(C1(5) != new C3(5)) assert(new C3(5) != C1(5)) - + assert(CS1(List(1d,2d), Seq[Float](3f, 4f)) == new CS3(IndexedSeq(1,2), IndexedSeq(3, 4))) - + assert(H1(5, 10d) == new H2(10d, 5)) assert(H1(5, 10d).hashCode == new H2(10d, 5).hashCode) } diff --git a/test/files/run/castsingleton.scala b/test/files/run/castsingleton.scala index f907467741..3921696efa 100644 --- a/test/files/run/castsingleton.scala +++ b/test/files/run/castsingleton.scala @@ -8,4 +8,4 @@ object Test extends Application { } empty(L()) -} +} diff --git a/test/files/run/checked.scala b/test/files/run/checked.scala index adb0c509a5..4a79aa2b9c 100644 --- a/test/files/run/checked.scala +++ b/test/files/run/checked.scala @@ -23,9 +23,9 @@ trait T { // Should not throw class D extends B with T { val sum = x + y + z + b1 + b2 + t1 + t2 - override def toString = + override def toString = "sum = " + sum - + } abstract class NeedsXEarly { @@ -91,7 +91,7 @@ class TestInterference extends { object Test extends Application { - + def shouldThrow(t: => Unit) = try { t println("[FAIL]: No UFE thrown") diff --git a/test/files/run/classof.scala b/test/files/run/classof.scala index b50facc1e9..10c07d2e51 100644 --- a/test/files/run/classof.scala +++ b/test/files/run/classof.scala @@ -13,14 +13,14 @@ object Test { println(classOf[Long]) println(classOf[Float]) println(classOf[Double]) - + println("Class types") println(classOf[SomeClass]) println(classOf[List[Array[Float]]]) println(classOf[(String, Map[Int, String])]) println("Arrays:") - println(classOf[Array[Unit]]) + println(classOf[Array[Unit]]) println(classOf[Array[Int]]) println(classOf[Array[Double]]) println(classOf[Array[List[String]]]) diff --git a/test/files/run/collections.scala b/test/files/run/collections.scala index f286123322..2bbeed00d1 100644 --- a/test/files/run/collections.scala +++ b/test/files/run/collections.scala @@ -61,7 +61,7 @@ object Test extends Application { } time { var x = 0 - for (i <- 0 to 10000) + for (i <- 0 to 10000) s get i match { case Some(i) => x += i case None => @@ -96,7 +96,7 @@ object Test extends Application { } time { var x = 0 - for (i <- 0 to 10000) + for (i <- 0 to 10000) s get i match { case Some(i) => x += i case None => diff --git a/test/files/run/colltest1.scala b/test/files/run/colltest1.scala index dd9ecdbd5e..a505847058 100644 --- a/test/files/run/colltest1.scala +++ b/test/files/run/colltest1.scala @@ -61,7 +61,7 @@ object Test extends Application { assert(ten.toStream == ten) assert(ten.toString endsWith "(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)") assert(ten.mkString("[", "; ", "]") endsWith "[1; 2; 3; 4; 5; 6; 7; 8; 9; 10]") - } + } def orderedIterableTest(empty: Iterable[Int]) { orderedTraversableTest(empty) @@ -84,7 +84,7 @@ object Test extends Application { assert(ten(0) == 1 && ten(9) == 10) assert((ten lengthCompare 10) == 0 && (ten lengthCompare 1) > 0 && (ten lengthCompare 11) < 0) assert((ten isDefinedAt 0) && (ten isDefinedAt 9)) - assert(!(ten isDefinedAt -1)); + assert(!(ten isDefinedAt -1)); assert(!(ten isDefinedAt 10)) val tenten = ten zip ten assert((tenten map (_._1)) == ten) @@ -174,8 +174,8 @@ object Test extends Application { m ++= ('J' to 'Z') map (x => (x.toString -> x.toString)) println(m.toList.sorted) assert(!m.isEmpty) - assert(m.keySet forall (k => (m get k) == Some(k))) - assert(m.keySet forall (k => (m apply k) == k)) + assert(m.keySet forall (k => (m get k) == Some(k))) + assert(m.keySet forall (k => (m apply k) == k)) assert(m.keySet forall (m contains)) assert(m.getOrElse("7", "@") == "@") assert(m.keySet.size == 26) diff --git a/test/files/run/constrained-types.scala b/test/files/run/constrained-types.scala index c03c144ad1..b3d5254f69 100644 --- a/test/files/run/constrained-types.scala +++ b/test/files/run/constrained-types.scala @@ -21,7 +21,7 @@ object Test { "val a = new A", - + """val y = a.y // should rewrite "this.x" to "a.x" """, @@ -77,7 +77,7 @@ object Test { """object A { val x = "hello" : String @ rep }""", "val y = a.x // should drop the annotation", - "val x = 3 : Int @Annot(e+f+g+h) //should have a graceful error message", + "val x = 3 : Int @Annot(e+f+g+h) //should have a graceful error message", "class Where(condition: Boolean) extends Annotation", "val x : Int @Where(self > 0 && self < 100) = 3" diff --git a/test/files/run/ctor-order.scala b/test/files/run/ctor-order.scala index 44e981e413..b32f005d70 100644 --- a/test/files/run/ctor-order.scala +++ b/test/files/run/ctor-order.scala @@ -8,7 +8,7 @@ class Outer { class X extends { /* The constructor of X should set this.$outer to the outer instance - * *before* calling the super constructors. This is tested by + * *before* calling the super constructors. This is tested by * mixin M1, which tries to access global from the enclosing class. */ val outer = Outer.this diff --git a/test/files/run/distinct.scala b/test/files/run/distinct.scala index 698d31f1e9..09e5a0734a 100644 --- a/test/files/run/distinct.scala +++ b/test/files/run/distinct.scala @@ -5,7 +5,7 @@ object Test { val alphabet = 'a' to 'z' mkString "" val alphaList = 'a' to 'z' toList def shuffled = util.Random.shuffle(alphaList) - + def main(args: Array[String]): Unit = { val longList = alphaList ++ (1 to 9 flatMap (_ => shuffled)) val result = longList.distinct mkString "" diff --git a/test/files/run/elidable.scala b/test/files/run/elidable.scala index 2a527efc4b..264efbad59 100644 --- a/test/files/run/elidable.scala +++ b/test/files/run/elidable.scala @@ -6,7 +6,7 @@ object Test { @elidable(INFO) def f2() = assert(false, "Should have been elided.") @elidable(SEVERE) def f3() = println("Good for me, I was not elided.") @elidable(INFO) def f4 = assert(false, "Should have been elided (no parens).") - + def main(args: Array[String]): Unit = { f1() f2() diff --git a/test/files/run/equality.scala b/test/files/run/equality.scala index ff59898821..68055fd012 100644 --- a/test/files/run/equality.scala +++ b/test/files/run/equality.scala @@ -2,7 +2,7 @@ object Test { import scala.runtime.ScalaRunTime.hash - + def makeFromInt(x: Int) = List( x.toByte, x.toShort, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x) ) ::: ( @@ -11,26 +11,26 @@ object Test def makeFromDouble(x: Double) = List( x.toShort, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x.toInt), BigDecimal(x) ) - + def main(args: Array[String]): Unit = { var xs = makeFromInt(5) for (x <- xs ; y <- xs) { assert(x == y, x + " == " + y) assert(hash(x) == hash(y), "hash(%s) == hash(%s)".format(x, y)) } - + xs = makeFromInt(-5) for (x <- xs ; y <- xs) { assert(x == y, x + " == " + y) assert(hash(x) == hash(y), "hash(%s) == hash(%s)".format(x, y)) } - + xs = makeFromDouble(500.0) for (x <- xs ; y <- xs) { assert(x == y, x + " == " + y) assert(hash(x) == hash(y), "hash(%s) == hash(%s)".format(x, y)) } - + // negatives val bigLong = new java.util.concurrent.atomic.AtomicLong(Long.MaxValue) assert(-1 != bigLong && bigLong != -1) // bigLong.intValue() == -1 diff --git a/test/files/run/exceptions-2.scala b/test/files/run/exceptions-2.scala index 05aab66dd0..d0312a49b2 100644 --- a/test/files/run/exceptions-2.scala +++ b/test/files/run/exceptions-2.scala @@ -68,7 +68,7 @@ object Test { Console.println("Outermost finally"); } - def mixed = + def mixed = try { if (10 > 0) throw Leaf(10); @@ -107,7 +107,7 @@ object Test { case Leaf(a) => Console.println(a); } } catch { - case npe: NullPointerException => + case npe: NullPointerException => Console.println("Caught an NPE"); } @@ -141,14 +141,14 @@ object Test { } } - def valInFinally: Unit = - try { + def valInFinally: Unit = + try { } finally { val fin = "Abc"; Console.println(fin); }; - def tryAndValInFinally: Unit = + def tryAndValInFinally: Unit = try { } finally { val fin = "Abc"; @@ -157,51 +157,51 @@ object Test { } catch { case _ => () } }; - def returnInBody: Unit = try { + def returnInBody: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); } - } finally { + } finally { Console.println("Outer finally"); } - def returnInBodySynch: Unit = try { + def returnInBodySynch: Unit = try { synchronized { try { Console.println("Synchronized normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); } } - } finally { + } finally { Console.println("Outer finally"); } - def returnInBodyAndInFinally: Unit = try { + def returnInBodyAndInFinally: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); return } - } finally { + } finally { Console.println("Outer finally"); return } - def returnInBodyAndInFinally2: Unit = try { + def returnInBodyAndInFinally2: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { try { @@ -211,7 +211,7 @@ object Test { Console.println("finally inside finally"); } } - } finally { + } finally { Console.println("Outer finally"); return } @@ -253,7 +253,7 @@ object Test { } - def returnWithFinallyClean: Int = try { + def returnWithFinallyClean: Int = try { try { Console.println("Normal execution..."); return 10 @@ -262,7 +262,7 @@ object Test { } finally { Console.println("inner finally"); } - } finally { + } finally { Console.println("Outer finally"); try { 1 } catch { case e: java.io.IOException => () } } @@ -294,7 +294,7 @@ object Test { Console.println("mixed: "); execute(mixed); - + Console.println("withValue1:"); execute(withValue1); @@ -322,7 +322,7 @@ object Test { Console.println("NoExcep.method3:"); execute(NoExcep.method3); - + Console.println("NoExcep.method4:"); execute(NoExcep.method4); diff --git a/test/files/run/existentials.scala b/test/files/run/existentials.scala index 471f8fe779..78980df1b0 100644 --- a/test/files/run/existentials.scala +++ b/test/files/run/existentials.scala @@ -2,7 +2,7 @@ class Foo { class Line { case class Cell[T](var x: T) def f[T](x: Any): Cell[t1] forSome { type t1 } = x match { case y: Cell[t] => y } - + var x: Cell[T] forSome { type T } = new Cell(1) println({ x = new Cell("abc"); x }) } @@ -12,7 +12,7 @@ class FooW { class Line { case class Cell[T](var x: T) def f[T](x: Any): Cell[ _ ] = x match { case y: Cell[t] => y } - + var x: Cell[_] = new Cell(1) println({ x = new Cell("abc"); x }) } diff --git a/test/files/run/forvaleq.scala b/test/files/run/forvaleq.scala index 8c1824a769..2a958802b6 100644 --- a/test/files/run/forvaleq.scala +++ b/test/files/run/forvaleq.scala @@ -2,7 +2,7 @@ import scala.collection.immutable.Queue import scala.{List=>L} - + object Test { // redefine some symbols to make it extra hard class List @@ -16,11 +16,11 @@ object Test { case _ if (x<10) => x case _ => firstDigit(x / 10) } - - + + { - // a basic test case - + // a basic test case + val input = L.range(0,20) val oddFirstTimesTwo = for {x <- input @@ -32,7 +32,7 @@ object Test { { // a test case with patterns - + val input = L.range(0, 20) val oddFirstTimesTwo = for {x <- input @@ -43,10 +43,10 @@ object Test { yield a + b println(oddFirstTimesTwo) } - + { // make sure it works on non-Ls - + // val input: Queue = Queue.Empty[int].incl(L.range(0,20)) val input = L.range(0, 20).iterator val oddFirstTimesTwo = @@ -54,36 +54,36 @@ object Test { xf = firstDigit(x) if xf % 2 == 1} yield x*2 - println(oddFirstTimesTwo.toList) + println(oddFirstTimesTwo.toList) } - + { // yield the computed value - + val input = L.range(0,20) val oddFirstTimesTwo = for {x <- input xf = firstDigit(x) if xf % 2 == 1} yield xf*2 - println(oddFirstTimesTwo) + println(oddFirstTimesTwo) } { // make sure the function is only called once var count: Int = 0 - + def fdct(x: Int) = { count += 1 firstDigit(x) } - + val input = L.range(0,20) for {x <- input xf = fdct(x) if xf % 2 == 1} yield xf - + println("called " + count + " times") } diff --git a/test/files/run/gadts.scala b/test/files/run/gadts.scala index 11b094d99a..697df4c1b4 100644 --- a/test/files/run/gadts.scala +++ b/test/files/run/gadts.scala @@ -2,8 +2,8 @@ abstract class Term[T] case class Lit(x: Int) extends Term[Int] case class Succ(t: Term[Int]) extends Term[Int] case class IsZero(t: Term[Int]) extends Term[Boolean] -case class If[T](c: Term[Boolean], - t1: Term[T], +case class If[T](c: Term[Boolean], + t1: Term[T], t2: Term[T]) extends Term[T] object Test extends Application { diff --git a/test/files/run/groupby.scala b/test/files/run/groupby.scala index a751e65e80..fe08f52812 100644 --- a/test/files/run/groupby.scala +++ b/test/files/run/groupby.scala @@ -3,8 +3,8 @@ // Fixes #3422 object Test { - - def main(args: Array[String]) { + + def main(args: Array[String]) { val arr = Array.range(0,10) val map = arr groupBy (_%2) val v1 = map(0) @@ -14,5 +14,5 @@ object Test { // hash map by default. assert(v1 eq v2) } - + } diff --git a/test/files/run/hashCodeBoxesRunTime.scala b/test/files/run/hashCodeBoxesRunTime.scala index ba1a30f5fb..081a73376e 100644 --- a/test/files/run/hashCodeBoxesRunTime.scala +++ b/test/files/run/hashCodeBoxesRunTime.scala @@ -4,16 +4,16 @@ object Test { import java.{ lang => jl } import scala.runtime.BoxesRunTime.{ hashFromNumber, hashFromObject } - + def allSame[T](xs: List[T]) = assert(xs.distinct.size == 1, "failed: " + xs) - + def mkNumbers(x: Int): List[Number] = List(x.toByte, x.toShort, x, x.toLong, x.toFloat, x.toDouble) - + def testLDF(x: Long) = allSame(List[Number](x, x.toDouble, x.toFloat) map hashFromNumber) - + def main(args: Array[String]): Unit = { - List(Byte.MinValue, -1, 0, 1, Byte.MaxValue) foreach { n => + List(Byte.MinValue, -1, 0, 1, Byte.MaxValue) foreach { n => val hashes = mkNumbers(n) map hashFromNumber allSame(hashes) if (n >= 0) { @@ -21,7 +21,7 @@ object Test assert(charCode == hashes.head) } } - + testLDF(Short.MaxValue.toLong) testLDF(Short.MinValue.toLong) } diff --git a/test/files/run/hashhash.scala b/test/files/run/hashhash.scala index 4a34ab12e0..5a7859357f 100644 --- a/test/files/run/hashhash.scala +++ b/test/files/run/hashhash.scala @@ -3,10 +3,10 @@ object Test class A { val x1 = this.## ; val x2 = super.## } val myA = new A assert(myA.x1 == myA.x2) - + def confirmSame(x: Any) = assert(x.## == x.hashCode, "%s.## != %s.hashCode".format(x, x)) def confirmDifferent(x: Any) = assert(x.## != x.hashCode, "%s.## == %s.hashCode (but should not)".format(x, x)) - + def main(args: Array[String]): Unit = { /** Just a little sanity check, not to be confused with a unit test. */ List(5, 5.5f, "abc", new AnyRef, new A, ()) foreach confirmSame diff --git a/test/files/run/infix.scala b/test/files/run/infix.scala index 60a844acad..66a41f66f1 100644 --- a/test/files/run/infix.scala +++ b/test/files/run/infix.scala @@ -9,4 +9,4 @@ object Test extends Application { case null op (0, 0) op (1, 1) op (2, 2) => Console.println("OK") } } - + diff --git a/test/files/run/inliner-infer.scala b/test/files/run/inliner-infer.scala index 107b9508ee..2c818c4a43 100644 --- a/test/files/run/inliner-infer.scala +++ b/test/files/run/inliner-infer.scala @@ -7,8 +7,8 @@ object Test extends Application { @annotation.tailrec def walk(xs: MyList): Unit = { - if (xs.isEmpty) - println("empty") + if (xs.isEmpty) + println("empty") else { println("non-empty") walk(MyNil) @@ -26,4 +26,4 @@ object MyNil extends MyList { override def isEmpty = true } - + diff --git a/test/files/run/iq.scala b/test/files/run/iq.scala index 88a2884fcc..59baee1270 100644 --- a/test/files/run/iq.scala +++ b/test/files/run/iq.scala @@ -9,8 +9,8 @@ object iq { /* Create an empty queue. */ val q: Queue[Int] = Queue.Empty - /* Test isEmpty. - * Expected: Empty + /* Test isEmpty. + * Expected: Empty */ if (q.isEmpty) { Console.println("Empty") @@ -20,14 +20,14 @@ object iq { //val q2 = q + 42 + 0 // deprecated val q2 = q.enqueue(42).enqueue(0) - /* Test is empty and dequeue. + /* Test is empty and dequeue. * Expected: Head: 42 */ val q4 = if (q2.isEmpty) { Console.println("Empty") q2 - } + } else { val (head, q3) = q2.dequeue Console.println("Head: " + head) @@ -36,8 +36,8 @@ object iq { /* Test sequence enqueing. */ val q5: Queue[Any] = q4.enqueue(List(1,2,3,4,5,6,7,8,9)) - /* Test toString. - * Expected: Head: q5: Queue(0,1,2,3,4,5,6,7,8,9) + /* Test toString. + * Expected: Head: q5: Queue(0,1,2,3,4,5,6,7,8,9) */ Console.println("q5: " + q5) /* Test apply @@ -59,7 +59,7 @@ object iq { //val q8 = q7 + 10 + 11 //deprecated val q8 = q7.enqueue(10).enqueue(11) /* Test dequeu - * Expected: q8: Queue(2,3,4,5,6,7,8,9,10,11) + * Expected: q8: Queue(2,3,4,5,6,7,8,9,10,11) */ Console.println("q8: " + q8) val q9 = Queue(2,3,4,5,6,7,8,9,10,11) @@ -70,14 +70,14 @@ object iq { Console.println("q8 == q9: " + (q8 == q9)) /* Testing elements - * Expected: Elements: 1 2 3 4 5 6 7 8 9 + * Expected: Elements: 1 2 3 4 5 6 7 8 9 */ - Console.print("Elements: "); + Console.print("Elements: "); q6.iterator.foreach(e => Console.print(" "+ e + " ")) - Console.println; + Console.println; /* Testing mkString - * Expected: String: <1-2-3-4-5-6-7-8-9> + * Expected: String: <1-2-3-4-5-6-7-8-9> */ Console.println("String: " + q6.mkString("<","-",">")) @@ -89,7 +89,7 @@ object iq { /* Testing front * Expected: Front: 1 */ - Console.println("Front: " + q6.front); + Console.println("Front: " + q6.front); } } diff --git a/test/files/run/issue192.scala b/test/files/run/issue192.scala index 55130072b7..32e203a4e1 100644 --- a/test/files/run/issue192.scala +++ b/test/files/run/issue192.scala @@ -1,16 +1,16 @@ object Test extends Application { - + def f1(p: Any{def unary_+ : Int}) = +p def f2(p: Any{def unary_- : Int}) = -p def f3(p: Any{def unary_~ : Int}) = ~p def f4(p: Any{def unary_! : Boolean}) = !p - + def f5(p: Any{def +(q: Int): Int}) = p + 7 def f6(p: Any{def -(q: Int): Int}) = p - 7 def f7(p: Any{def *(q: Int): Int}) = p * 7 def f8(p: Any{def /(q: Int): Int}) = p / 7 def f9(p: Any{def %(q: Int): Int}) = p % 7 - + def f10(p: Any{def |(q: Int): Int}) = p | 7 def f11(p: Any{def |(q: Boolean): Boolean}) = p | true def f12(p: Any{def ^(q: Int): Int}) = p ^ 7 @@ -19,11 +19,11 @@ object Test extends Application { def f15(p: Any{def &(q: Boolean): Boolean}) = p & true def f16(p: Any{def ||(q: Boolean): Boolean}) = p || true def f17(p: Any{def &&(q: Boolean): Boolean}) = p && true - + def f18(p: Any{def <<(q: Int): Int}) = p << 7 def f19(p: Any{def >>(q: Int): Int}) = p >> 7 def f20(p: Any{def >>>(q: Int): Int}) = p >>> 7 - + def f21(p: Any{def toByte: Byte}) = p.toByte def f22(p: Any{def toShort: Short}) = p.toShort def f23(p: Any{def toChar: Char}) = p.toChar @@ -31,28 +31,28 @@ object Test extends Application { def f25(p: Any{def toLong: Long}) = p.toLong def f26(p: Any{def toFloat: Float}) = p.toFloat def f27(p: Any{def toDouble: Double}) = p.toDouble - + def f28(p: Any{def ==(q: Int): Boolean}) = p == 7 def f29(p: Any{def !=(q: Int): Boolean}) = p != 7 def f30(p: Any{def ==(q: Boolean): Boolean}) = p == true def f31(p: Any{def !=(q: Boolean): Boolean}) = p != true - + def f32(p: Any{def <(q: Int): Boolean}) = p < 7 def f33(p: Any{def <=(q: Int): Boolean}) = p <= 7 def f34(p: Any{def >=(q: Int): Boolean}) = p >= 7 def f35(p: Any{def >(q: Int): Boolean}) = p > 7 - + print("f1 = "); println(f1(1) == +1) print("f2 = "); println(f2(1) == -1) print("f3 = "); println(f3(1) == ~1) print("f4 = "); println(f4(true) == !true) - + print("f5 = "); println(f5(4) == (4 + 7)) print("f6 = "); println(f6(4) == (4 - 7)) print("f7 = "); println(f7(4) == (4 * 7)) print("f8 = "); println(f8(4) == (4 / 7)) print("f9 = "); println(f9(4) == (4 % 7)) - + print("f10 = "); println(f10(4) == (4 | 7)) print("f11 = "); println(f11(false) == (false | true)) print("f12 = "); println(f12(4) == (4 ^ 7)) @@ -61,11 +61,11 @@ object Test extends Application { print("f15 = "); println(f15(false) == (false & true)) print("f16 = "); println(f16(false) == (false || true)) print("f17 = "); println(f17(false) == (false && true)) - + print("f18 = "); println(f18(4) == (4 << 7)) print("f19 = "); println(f19(-4) == (-4 >> 7)) print("f20 = "); println(f20(-4) == (-4 >>> 7)) - + print("f21 = "); println(f21(4.2) == (4.2.toByte)) print("f22 = "); println(f22(4.2) == (4.2.toShort)) print("f23 = "); println(f23(4.2) == (4.2.toChar)) @@ -73,17 +73,17 @@ object Test extends Application { print("f25 = "); println(f25(4.2) == (4.2.toLong)) print("f26 = "); println(f26(4.2) == (4.2.toFloat)) print("f27 = "); println(f27(4.2) == (4.2.toDouble)) - + print("f28 = "); println(f28(4) == (4 == 7)) print("f29 = "); println(f29(4) == (4 != 7)) print("f30 = "); println(f30(false) == (false == true)) print("f31 = "); println(f31(false) == (false != true)) - + print("f32 = "); println(f32(4) == (4 < 7)) print("f33 = "); println(f33(4) == (4 <= 7)) print("f34 = "); println(f34(4) == (4 >= 7)) print("f35 = "); println(f35(4) == (4 > 7)) - + println("ok") - + } diff --git a/test/files/run/iterator3444.scala b/test/files/run/iterator3444.scala index 1d0713addc..2d0643bd56 100644 --- a/test/files/run/iterator3444.scala +++ b/test/files/run/iterator3444.scala @@ -2,22 +2,22 @@ // ticked #3444 object Test { - + def main(args: Array[String]) { val it = (1 to 12).toSeq.iterator - + assert(it.next == 1) assert(it.take(2).toList == List(2, 3)) - + val jt = (4 to 12).toSeq.iterator assert(jt.next == 4) assert(jt.drop(5).toList == List(10, 11, 12)) - + val kt = (1 until 10).toSeq.iterator assert(kt.drop(50).toList == Nil) - + val mt = (1 until 5).toSeq.iterator assert(mt.take(50).toList == List(1, 2, 3, 4)) } - + } diff --git a/test/files/run/iterators.scala b/test/files/run/iterators.scala index 5f77289343..f0f93f0683 100644 --- a/test/files/run/iterators.scala +++ b/test/files/run/iterators.scala @@ -82,16 +82,16 @@ object Test { var xs4 = Iterator.fromArray(a, 0, 4).toList; xs0.length + xs1.length + xs2.length + xs3.length + xs4.length } - + def check_toSeq: String = List(1, 2, 3, 4, 5).iterator.toSeq.mkString("x") - + def check_indexOf: String = { val i = List(1, 2, 3, 4, 5).indexOf(4) val j = List(1, 2, 3, 4, 5).indexOf(16) "" + i + "x" + j } - + def check_findIndexOf: String = { val i = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 4 } val j = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 16 } diff --git a/test/files/run/json.scala b/test/files/run/json.scala index 0a141dc38c..6d25999e9c 100644 --- a/test/files/run/json.scala +++ b/test/files/run/json.scala @@ -28,7 +28,7 @@ object Test extends Application { case Some(parsed) => println("Passed: " + sortJSON(parsed)) } } - + def printJSON(given : String, expected : Any) { JSON parseFull given match { case None => println("Parse failed for \"%s\"".format(given)) @@ -63,11 +63,11 @@ object Test extends Application { // The library should recurse into arrays to find objects (ticket #2207) printJSON("""[{"a": "team"},{"b": 52}]""", List(Map("a" -> "team"), Map("b" -> 52.0))) - + // The library should differentiate between empty maps and lists (ticket #3284) - printJSON("{}", Map()) + printJSON("{}", Map()) printJSON("[]", List()) - + // Lists should be returned in the same order as specified printJSON("[4,1,3,2,6,5,8,7]", List[Double](4,1,3,2,6,5,8,7)) @@ -110,7 +110,7 @@ object Test extends Application { ) ) - + printJSON(sample1, sample1Obj) println @@ -146,7 +146,7 @@ object Test extends Application { // from http://json.org/example.html val sample3 = """ {"web-app": { - "servlet": [ + "servlet": [ { "servlet-name": "cofaxCDS", "servlet-class": "org.cofax.cds.CDSServlet", @@ -202,7 +202,7 @@ object Test extends Application { { "servlet-name": "cofaxAdmin", "servlet-class": "org.cofax.cds.AdminServlet"}, - + { "servlet-name": "fileServlet", "servlet-class": "org.cofax.cds.FileServlet"}, @@ -229,7 +229,7 @@ object Test extends Application { "cofaxAdmin": "/admin/*", "fileServlet": "/static/*", "cofaxTools": "/tools/*"}, - + "taglib": { "taglib-uri": "cofax.tld", "taglib-location": "/WEB-INF/tlds/cofax.tld"} diff --git a/test/files/run/lazy-exprs.scala b/test/files/run/lazy-exprs.scala index 8a80423646..d4913c78d5 100644 --- a/test/files/run/lazy-exprs.scala +++ b/test/files/run/lazy-exprs.scala @@ -2,7 +2,7 @@ object TestExpressions { def patmatchScrut { lazy val z1: Option[String] = { println("forced <z1>"); Some("lazy z1") } - + val res = z1 match { case Some(msg) => msg case None => "failed" @@ -17,10 +17,10 @@ object TestExpressions { def patmatchCase { val t: Option[String] = Some("test") val res = t match { - case Some(msg) => + case Some(msg) => lazy val z1 = { println("forced <z1>"); "lazy z1" } z1 - + case None => "failed" } print("lazy val in case: ") @@ -36,9 +36,9 @@ object TestExpressions { print("lazy val in case: ") val t: Option[String] = Some("lazy Z1") t match { - case Some(Z1) => + case Some(Z1) => println("ok") - + case None => println("failed") } @@ -60,13 +60,13 @@ object TestExpressions { print("lazy val in pattern: ") val t: Option[String] = Some("LazyField") t match { - case Some(LazyField) => + case Some(LazyField) => println("ok") - + case None => println("failed") } - } + } lazy val (x, y) = ({print("x"); "x"}, {print("y"); "y"}) def testPatLazyVal { diff --git a/test/files/run/lazy-locals.scala b/test/files/run/lazy-locals.scala index be738a0f70..5755007c55 100644 --- a/test/files/run/lazy-locals.scala +++ b/test/files/run/lazy-locals.scala @@ -163,18 +163,18 @@ object Test extends Application { // see #1589 object NestedLazyVals extends Application { - lazy val x = { + lazy val x = { lazy val y = { println("forcing y"); 42; } println("forcing x") - y + y } - + val x1 = 5 + { lazy val y = 10 ; y } - + println(x) println(x1) } - + trait TNestedLazyVals { lazy val x = { lazy val y = 42; y } } diff --git a/test/files/run/lazy-override.scala b/test/files/run/lazy-override.scala index e5884257a8..fe2c85bda4 100644 --- a/test/files/run/lazy-override.scala +++ b/test/files/run/lazy-override.scala @@ -20,7 +20,7 @@ object Test extends Application { val b = new B print("b.x=") - println(b.x) + println(b.x) print("b.z=") - println(b.z) + println(b.z) } diff --git a/test/files/run/lazy-traits.scala b/test/files/run/lazy-traits.scala index 5a8d3f3db7..e3fb37af84 100644 --- a/test/files/run/lazy-traits.scala +++ b/test/files/run/lazy-traits.scala @@ -1,5 +1,5 @@ trait A { - lazy val z1 = { + lazy val z1 = { println("<forced z1>") "lazy z1" } @@ -7,7 +7,7 @@ trait A { /** Simple class which mixes in one lazy val. */ class Cls extends AnyRef with A { - override def toString = + override def toString = "z1 = " + z1 } @@ -18,7 +18,7 @@ class Cls2 extends AnyRef with A { "lazy z2" } - override def toString = + override def toString = "z1 = " + z1 + " z2 = " + z2 } @@ -34,7 +34,7 @@ class ClsB extends Object with B { println("<forced zc1>") "lazy zc1" } - override def toString = + override def toString = "z1 = " + z1 + " zb1 = " + zb1 + " zc1 = " + zc1 } @@ -73,39 +73,39 @@ class OverflownLazyFields extends Object with A { lazy val zc30 = { println("<forced zc30>"); "lazy zc30" } lazy val zc31 = { println("<forced zc31>"); "lazy zc31" } - override def toString = - "\nzc00 = " + zc00 + - "\nzc01 = " + zc01 + - "\nzc02 = " + zc02 + - "\nzc03 = " + zc03 + - "\nzc04 = " + zc04 + - "\nzc05 = " + zc05 + - "\nzc06 = " + zc06 + - "\nzc07 = " + zc07 + - "\nzc08 = " + zc08 + - "\nzc09 = " + zc09 + - "\nzc10 = " + zc10 + - "\nzc11 = " + zc11 + - "\nzc12 = " + zc12 + - "\nzc13 = " + zc13 + - "\nzc14 = " + zc14 + - "\nzc15 = " + zc15 + - "\nzc16 = " + zc16 + - "\nzc17 = " + zc17 + - "\nzc18 = " + zc18 + - "\nzc19 = " + zc19 + - "\nzc20 = " + zc20 + - "\nzc21 = " + zc21 + - "\nzc22 = " + zc22 + - "\nzc23 = " + zc23 + - "\nzc24 = " + zc24 + - "\nzc25 = " + zc25 + - "\nzc26 = " + zc26 + - "\nzc27 = " + zc27 + - "\nzc28 = " + zc28 + - "\nzc29 = " + zc29 + - "\nzc30 = " + zc30 + - "\nzc31 = " + zc31 + + override def toString = + "\nzc00 = " + zc00 + + "\nzc01 = " + zc01 + + "\nzc02 = " + zc02 + + "\nzc03 = " + zc03 + + "\nzc04 = " + zc04 + + "\nzc05 = " + zc05 + + "\nzc06 = " + zc06 + + "\nzc07 = " + zc07 + + "\nzc08 = " + zc08 + + "\nzc09 = " + zc09 + + "\nzc10 = " + zc10 + + "\nzc11 = " + zc11 + + "\nzc12 = " + zc12 + + "\nzc13 = " + zc13 + + "\nzc14 = " + zc14 + + "\nzc15 = " + zc15 + + "\nzc16 = " + zc16 + + "\nzc17 = " + zc17 + + "\nzc18 = " + zc18 + + "\nzc19 = " + zc19 + + "\nzc20 = " + zc20 + + "\nzc21 = " + zc21 + + "\nzc22 = " + zc22 + + "\nzc23 = " + zc23 + + "\nzc24 = " + zc24 + + "\nzc25 = " + zc25 + + "\nzc26 = " + zc26 + + "\nzc27 = " + zc27 + + "\nzc28 = " + zc28 + + "\nzc29 = " + zc29 + + "\nzc30 = " + zc30 + + "\nzc31 = " + zc31 + "\nz1 = " + z1 } diff --git a/test/files/run/lisp.scala b/test/files/run/lisp.scala index fe3941d0db..63b615804b 100644 --- a/test/files/run/lisp.scala +++ b/test/files/run/lisp.scala @@ -12,11 +12,11 @@ class LispTokenizer(s: String) extends Iterator[String] { while (i < s.length() && s.charAt(i) <= ' ') i += 1 i < s.length() } - def next: String = + def next: String = if (hasNext) { val start = i if (isDelimiter(s charAt i)) i += 1 - else + else do i = i + 1 while (!isDelimiter(s charAt i)) s.substring(start, i) diff --git a/test/files/run/lists.scala b/test/files/run/lists.scala index 6c9b55961e..8a319c2fed 100644 --- a/test/files/run/lists.scala +++ b/test/files/run/lists.scala @@ -12,7 +12,7 @@ import testing.SUnit._ */ object Test extends TestConsoleMain { def suite = new TestSuite( - Test_multiset, // multiset operations: union, intersect, diff + Test_multiset, // multiset operations: union, intersect, diff Test1, //count, exists, filter, .. Test2, //#468 Test3, //#1691 @@ -63,7 +63,7 @@ object Test_multiset extends TestCase("multiset") with Assert { assertEquals("vs_diff_xs", List(3, 2), vs diff xs) assertTrue("xs_subset_vs", isSubListOf(xs -- vs, xs diff vs)) - // tests adapted from Thomas Jung + // tests adapted from Thomas Jung assertTrue( "be symmetric after sorting", { def sort(zs: List[Int]) = zs sort ( _ > _ ) @@ -73,7 +73,7 @@ object Test_multiset extends TestCase("multiset") with Assert { "obey min cardinality", { def cardinality[A](zs: List[A], e: A): Int = zs count (e == _) val intersection = xs intersect ys - xs forall (e => cardinality(intersection, e) == (cardinality(xs, e) + xs forall (e => cardinality(intersection, e) == (cardinality(xs, e) min cardinality(ys, e))) }) assertTrue( @@ -149,7 +149,7 @@ object Test2 extends TestCase("t0468") with Assert { override def runTest { val xs1 = List(1, 2, 3) val xs2 = List(0) - + val ys1 = xs1 ::: List(4) assertEquals("check_:::", List(1, 2, 3, 4), ys1) diff --git a/test/files/run/manifests.scala b/test/files/run/manifests.scala index ed6efab70d..1da06b8aee 100644 --- a/test/files/run/manifests.scala +++ b/test/files/run/manifests.scala @@ -4,15 +4,15 @@ object Test val CO, IN, CONTRA = Value } import Variances.{ CO, IN, CONTRA } - + object SubtypeRelationship extends Enumeration { val NONE, SAME, SUB, SUPER = Value } import SubtypeRelationship.{ NONE, SAME, SUB, SUPER } - + class VarianceTester[T, U, CC[_]](expected: Variances.Value)( implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) { - + def elements = List(ev1 <:< ev2, ev2 <:< ev1) def containers = List(ev3 <:< ev4, ev4 <:< ev3) @@ -20,13 +20,13 @@ object Test def isSame = typeCompare[T, U] == SAME def isSub = typeCompare[T, U] == SUB def isSuper = typeCompare[T, U] == SUPER - + def showsCovariance = (elements == containers) def showsContravariance = (elements == containers.reverse) def showsInvariance = containers forall (_ == isSame) def allContainerVariances = List(showsCovariance, showsInvariance, showsContravariance) - + def showsExpectedVariance = if (isUnrelated) allContainerVariances forall (_ == false) else if (isSame) allContainerVariances forall (_ == true) @@ -36,55 +36,55 @@ object Test case CONTRA => showsContravariance && !showsCovariance && !showsInvariance } } - + def showsCovariance[T, U, CC[_]](implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) = new VarianceTester[T, U, CC](CO) showsExpectedVariance def showsInvariance[T, U, CC[_]](implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) = new VarianceTester[T, U, CC](IN) showsExpectedVariance - + def showsContravariance[T, U, CC[_]](implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) = new VarianceTester[T, U, CC](CONTRA) showsExpectedVariance - + def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = (ev1 <:< ev2, ev2 <:< ev1) match { case (true, true) => SAME case (true, false) => SUB case (false, true) => SUPER case (false, false) => NONE } - + def assertAnyRef[T: Manifest] = List( manifest[T] <:< manifest[Any], manifest[T] <:< manifest[AnyRef], !(manifest[T] <:< manifest[AnyVal]) ) foreach (assert(_, "assertAnyRef")) - + def assertAnyVal[T: Manifest] = List( manifest[T] <:< manifest[Any], !(manifest[T] <:< manifest[AnyRef]), manifest[T] <:< manifest[AnyVal] ) foreach (assert(_, "assertAnyVal")) - + def assertSameType[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == SAME, "assertSameType") def assertSuperType[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == SUPER, "assertSuperType") def assertSubType[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == SUB, "assertSubType") def assertNoRelationship[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == NONE, "assertNoRelationship") - + def testVariancesVia[T: Manifest, U: Manifest] = assert( - typeCompare[T, U] == SUB && + typeCompare[T, U] == SUB && showsCovariance[T, U, List] && showsInvariance[T, U, Set], "testVariancesVia" ) - + def runAllTests = { assertAnyVal[AnyVal] assertAnyVal[Unit] - assertAnyVal[Int] - assertAnyVal[Double] + assertAnyVal[Int] + assertAnyVal[Double] assertAnyVal[Boolean] assertAnyVal[Char] - + assertAnyRef[AnyRef] assertAnyRef[java.lang.Object] assertAnyRef[java.lang.Integer] @@ -94,7 +94,7 @@ object Test assertAnyRef[String] assertAnyRef[scala.List[String]] assertAnyRef[scala.List[_]] - + // variance doesn't work yet // testVariancesVia[String, Any] // testVariancesVia[String, AnyRef] @@ -102,11 +102,11 @@ object Test assertSubType[List[String], List[Any]] assertSubType[List[String], List[AnyRef]] assertNoRelationship[List[String], List[AnyVal]] - + assertSubType[List[Int], List[Any]] assertSubType[List[Int], List[AnyVal]] assertNoRelationship[List[Int], List[AnyRef]] - + // Nothing assertSubType[Nothing, Any] assertSubType[Nothing, AnyVal] @@ -115,7 +115,7 @@ object Test assertSubType[Nothing, List[String]] assertSubType[Nothing, Null] assertSameType[Nothing, Nothing] - + // Null assertSubType[Null, Any] assertNoRelationship[Null, AnyVal] @@ -124,7 +124,7 @@ object Test assertSubType[Null, List[String]] assertSameType[Null, Null] assertSuperType[Null, Nothing] - + // Any assertSameType[Any, Any] assertSuperType[Any, AnyVal] @@ -133,7 +133,7 @@ object Test assertSuperType[Any, List[String]] assertSuperType[Any, Null] assertSuperType[Any, Nothing] - + // Misc unrelated types assertNoRelationship[Unit, AnyRef] assertNoRelationship[Unit, Int] diff --git a/test/files/run/mapValues.scala b/test/files/run/mapValues.scala index d3266bd18f..bd1794bc51 100644 --- a/test/files/run/mapValues.scala +++ b/test/files/run/mapValues.scala @@ -1,7 +1,7 @@ object Test { val m = Map(1 -> 1, 2 -> 2) val mv = (m mapValues identity) - 1 - + def main(args: Array[String]): Unit = { assert(mv.size == 1) } diff --git a/test/files/run/map_java_conversions.scala b/test/files/run/map_java_conversions.scala index 4f9f8a915a..58ff471190 100644 --- a/test/files/run/map_java_conversions.scala +++ b/test/files/run/map_java_conversions.scala @@ -4,20 +4,20 @@ object Test { - + def main(args: Array[String]) { import collection.JavaConversions._ - + test(new java.util.HashMap[String, String]) test(new java.util.Properties) testConcMap } - + def testConcMap { import collection.JavaConversions._ - + val concMap = new java.util.concurrent.ConcurrentHashMap[String, String] - + test(concMap) val cmap = asConcurrentMap(concMap) cmap.putIfAbsent("absentKey", "absentValue") @@ -26,31 +26,31 @@ object Test { assert(cmap.replace("absentKey", "newAbsentValue") == Some("absentValue")) assert(cmap.replace("absentKey", "newAbsentValue", ".......") == true) } - + def test(m: collection.mutable.Map[String, String]) { m.clear assert(m.size == 0) - + m.put("key", "value") assert(m.size == 1) - + assert(m.put("key", "anotherValue") == Some("value")) assert(m.put("key2", "value2") == None) assert(m.size == 2) - + m += (("key3", "value3")) assert(m.size == 3) - + m -= "key2" assert(m.size == 2) assert(m.nonEmpty) assert(m.remove("key") == Some("anotherValue")) - + m.clear for (i <- 0 until 10) m += (("key" + i, "value" + i)) for ((k, v) <- m) assert(k.startsWith("key")) } - + } diff --git a/test/files/run/matchbytes.scala b/test/files/run/matchbytes.scala index 73e55d47cb..e776f0bf84 100644 --- a/test/files/run/matchbytes.scala +++ b/test/files/run/matchbytes.scala @@ -4,4 +4,4 @@ object Test extends Application{ case 1 => println(1); case _ => println("????"); } -} +} diff --git a/test/files/run/matchintasany.scala b/test/files/run/matchintasany.scala index 2c732b98b5..e21dce9562 100644 --- a/test/files/run/matchintasany.scala +++ b/test/files/run/matchintasany.scala @@ -5,4 +5,4 @@ object Test extends Application{ case 1L => println(1); case _ => println("????"); } -} +} diff --git a/test/files/run/matchnull.scala b/test/files/run/matchnull.scala index 2cc8550d47..cfb3049239 100644 --- a/test/files/run/matchnull.scala +++ b/test/files/run/matchnull.scala @@ -3,7 +3,7 @@ object Test def f1 = null match { case x: AnyRef => 1 case _ => -1 } def f2(x: Any) = x match { case 52 => 1 ; case null => -1 ; case _ => 0 } def f3(x: AnyRef) = x match { case x: String => 1 ; case List(_) => 0 ; case null => -1 ; case _ => -2 } - + def main(args: Array[String]): Unit = { println(f1) println(f2(null)) diff --git a/test/files/run/misc.scala b/test/files/run/misc.scala index 2ae76bd968..139d2d70f7 100644 --- a/test/files/run/misc.scala +++ b/test/files/run/misc.scala @@ -60,7 +60,7 @@ object Test { Console.println; val x = 13; x; - // !!! why are DefDef replaced by Block(Tree[0])? we should use Empty! + // !!! why are DefDef replaced by Block(Tree[0])? we should use Empty! def f = 19; f; def f0() = 11; diff --git a/test/files/run/missingparams.scala b/test/files/run/missingparams.scala index 3672fdf76f..0b79fa15d0 100644 --- a/test/files/run/missingparams.scala +++ b/test/files/run/missingparams.scala @@ -6,8 +6,8 @@ final class Foo(val x: Int) { // test that the closure elimination is not wrongly replacing // 'that' by 'this' - def intersect(that: Foo) = - filter { dummy => + def intersect(that: Foo) = + filter { dummy => // x // dummy that.x > 0 } diff --git a/test/files/run/nodebuffer-array.scala b/test/files/run/nodebuffer-array.scala index f9cfbc50df..4e1ffe1e5e 100644 --- a/test/files/run/nodebuffer-array.scala +++ b/test/files/run/nodebuffer-array.scala @@ -1,5 +1,5 @@ object Test { - + def f(s: String) = { <entry> { @@ -8,7 +8,7 @@ object Test { } </entry> } - + def main(args: Array[String]): Unit = { println(f("a,b,c")) } diff --git a/test/files/run/numbereq.scala b/test/files/run/numbereq.scala index b07c83dc3e..77a217df36 100644 --- a/test/files/run/numbereq.scala +++ b/test/files/run/numbereq.scala @@ -13,25 +13,25 @@ object Test { if (x >= Byte.MinValue && x <= Byte.MaxValue) List(new java.lang.Byte(x.toByte)) else Nil, if (x >= Char.MinValue && x <= Char.MaxValue) List(new java.lang.Character(x.toChar)) else Nil ).flatten - + base ::: extras } - - + + def main(args: Array[String]): Unit = { val ints = (0 to 15).toList map (Short.MinValue >> _) val ints2 = ints map (x => -x) val ints3 = ints map (_ + 1) val ints4 = ints2 map (_ - 1) - + val setneg1 = ints map mkNumbers val setneg2 = ints3 map mkNumbers val setpos1 = ints2 map mkNumbers val setpos2 = ints4 map mkNumbers val zero = mkNumbers(0) - - val sets = setneg1 ++ setneg2 ++ List(zero) ++ setpos1 ++ setpos2 - + + val sets = setneg1 ++ setneg2 ++ List(zero) ++ setpos1 ++ setpos2 + for (set <- sets ; x <- set ; y <- set) { // println("'%s' == '%s' (%s == %s) (%s == %s)".format(x, y, x.hashCode, y.hashCode, x.##, y.##)) assert(x == y, "%s/%s != %s/%s".format(x, x.getClass, y, y.getClass)) diff --git a/test/files/run/packrat1.scala b/test/files/run/packrat1.scala index 26fa8e76f2..71b593d421 100644 --- a/test/files/run/packrat1.scala +++ b/test/files/run/packrat1.scala @@ -21,15 +21,15 @@ object Test extends Application{ } object grammars extends StandardTokenParsers with PackratParsers{ - + def extractResult(r : ParseResult[_]) = r match { case Success(a,_) => a case NoSuccess(a,_) => a } - + lexical.delimiters ++= List("+","-","*","/","(",")") lexical.reserved ++= List("Hello","World") - + /**** * term = term + fact | term - fact | fact * fact = fact * num | fact / num | num @@ -39,7 +39,7 @@ object grammars extends StandardTokenParsers with PackratParsers{ val term: PackratParser[Int] = (term~("+"~>fact) ^^ {case x~y => x+y} |term~("-"~>fact) ^^ {case x~y => x-y} |fact) - + val fact: PackratParser[Int] = (fact~("*"~>numericLit) ^^ {case x~y => x*y.toInt} |fact~("/"~>numericLit) ^^ {case x~y => x/y.toInt} |"("~>term<~")" diff --git a/test/files/run/packrat2.scala b/test/files/run/packrat2.scala index e5c8db0f50..45558e86cc 100644 --- a/test/files/run/packrat2.scala +++ b/test/files/run/packrat2.scala @@ -22,15 +22,15 @@ object Test extends Application{ } object grammars2 extends StandardTokenParsers with PackratParsers{ - + def extractResult(r : ParseResult[_]) = r match{ case Success(a,_) => a case NoSuccess(a,_) => a } - + lexical.delimiters ++= List("+","-","*","/","(",")") lexical.reserved ++= List("Hello","World") - + /* * exp = sum | prod | num * sum = exp ~ "+" ~ num @@ -40,18 +40,18 @@ object grammars2 extends StandardTokenParsers with PackratParsers{ val exp : PackratParser[Int] = sum | prod | numericLit ^^{_.toInt} | "("~>exp<~")" val sum : PackratParser[Int] = exp~("+"~>exp) ^^ {case x~y => x+y} val prod: PackratParser[Int] = exp~("*"~>(numericLit ^^{_.toInt} | exp)) ^^ {case x~y => x*y} - - + + /* lexical.reserved ++= List("a","b", "c") val a : PackratParser[Any] = numericLit^^{x => primeFactors(x.toInt)} val b : PackratParser[Any] = memo("b") val c : PackratParser[Any] = memo("c") - val AnBnCn : PackratParser[Any] = + val AnBnCn : PackratParser[Any] = parseButDontEat(repMany1(a,b))~not(b)~>rep1(a)~repMany1(b,c)// ^^{case x~y => x:::y} //val c : PackratParser[Any] = parseButDontEat(a)~a~a //println(c((new PackratReader(new lexical.Scanner("45 24"))))) val r = new PackratReader(new lexical.Scanner("45 b c")) println(AnBnCn(r)) println(r.getCache.size) -*/ +*/ } diff --git a/test/files/run/packrat3.scala b/test/files/run/packrat3.scala index 3820f05158..e58d16a1fb 100644 --- a/test/files/run/packrat3.scala +++ b/test/files/run/packrat3.scala @@ -24,28 +24,28 @@ object Test { } object grammars3 extends StandardTokenParsers with PackratParsers { - + def extractResult(r: ParseResult[_]) = r match { case Success(a,_) => a case NoSuccess(a,_) => a } - + lexical.reserved ++= List("a","b", "c") val a: PackratParser[Any] = memo("a") val b: PackratParser[Any] = memo("b") val c: PackratParser[Any] = memo("c") - val AnBnCn: PackratParser[Any] = + val AnBnCn: PackratParser[Any] = guard(repMany1(a,b) ~ not(b)) ~ rep1(a) ~ repMany1(b,c)// ^^{case x~y => x:::y} - private def repMany[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = + private def repMany[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = ( p~repMany(p,q)~q ^^ {case x~xs~y => x::xs:::(y::Nil)} | success(Nil) ) - def repMany1[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = + def repMany1[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = p~opt(repMany(p,q))~q ^^ {case x~Some(xs)~y => x::xs:::(y::Nil)} -} +} diff --git a/test/files/run/patmat-seqs.scala b/test/files/run/patmat-seqs.scala index b5c47b4b4b..e23711697c 100644 --- a/test/files/run/patmat-seqs.scala +++ b/test/files/run/patmat-seqs.scala @@ -7,14 +7,14 @@ object Test { case Seq(_, _, _, _, _, x: String) => "ss6" case _ => "d" } - + def f2(x: Any) = x match { case Seq("a", "b", _*) => "s2" case Seq(1, _*) => "s1" case Seq(5, 6, 7, _*) => "s3" case _ => "d" } - + def main(args: Array[String]): Unit = { val xs1 = List( List(1,2,3), @@ -24,9 +24,9 @@ object Test { Seq(1, 2, 3, 4, 5, "abcd"), "abc" ) map f1 - + xs1 foreach println - + val xs2 = List( Seq(5, 6, 7), Seq(5, 6, 7, 8, 9), @@ -36,7 +36,7 @@ object Test { Nil, 5 ) map f2 - + xs2 foreach println } } diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index 025d6bf2ef..e2c95e3c81 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -72,7 +72,7 @@ object Test extends TestConsoleMain { object SeqUnapply extends TestCase("seqUnapply") { case class SFB(i: Int, xs: List[Int]) - override def runTest() { + override def runTest() { List(1,2) match { case List(1) => assert(false, "wrong case") case List(1,2,xs @ _*) => assert(xs.isEmpty, "not empty") @@ -104,11 +104,11 @@ object Test extends TestConsoleMain { case 0 => 0 }) assertEquals("s2", 1, 1 match { - case 1 => 1 + case 1 => 1 case _ => 0 }) assertEquals("s2boxed", 1, (1:Any) match { - case 1 => 1 + case 1 => 1 case _ => 0 }) assertEquals("s3", 1, ("hello") match { @@ -235,7 +235,7 @@ object Test extends TestConsoleMain { case class Foo() extends Con case class Bar(xs:Con*) extends Con - + override def runTest() { val res = (Bar(Foo()):Con) match { case Bar(xs@_*) => xs // this should be optimized away to a pattern Bar(xs) @@ -246,9 +246,9 @@ object Test extends TestConsoleMain { } object TestSequence06 extends TestCase("sei (not regular) fancy guards / bug#644 ") { - + case class A(i: Any) - + def doMatch(x: Any, bla: Int) = x match { case x:A if (bla==1) => 0 case A(1) => 1 @@ -273,7 +273,7 @@ object Test extends TestConsoleMain { //def doMatch3(xs:List[char]) = xs match { // case List(_*, z, w) => w::Nil //} - // + // // Since the second case should have been unreachable all along, // let's just comment this one out. // @@ -299,8 +299,8 @@ object Test extends TestConsoleMain { assertEquals(List('c','d'), doMatch6(List('a','b','c','d'))) } } - - object TestSequence08 extends TestCase("backquoted identifiers in pattern") { + + object TestSequence08 extends TestCase("backquoted identifiers in pattern") { override def runTest() { val xs = List(2, 3) val ys = List(1, 2, 3) match { @@ -318,17 +318,17 @@ object Test extends TestConsoleMain { case Stream.Empty => 0 case Stream.cons(hd, tl) => hd + sum(tl) } - + val str: Stream[Int] = List(1,2,3).iterator.toStream def runTest() = assertEquals(sum(str), 6) } - + class Test1163_Order extends TestCase("bug#1163 order of temps must be preserved") { abstract class Function case class Var(n: String) extends Function case class Const(v: Double) extends Function - + def f(): (Function, Function) = { (Var("x"): Function, Var("y"): Function) match { case (Const(v), Const(w)) => throw new Error @@ -336,13 +336,13 @@ object Test extends TestConsoleMain { case (leftTwo, rightTwo) => (leftTwo, rightTwo) // was giving "y","x" } } - - def flips(l: List[Int]): Int = (l: @unchecked) match { + + def flips(l: List[Int]): Int = (l: @unchecked) match { case 1 :: ls => 0 case n :: ls => flips((l take n reverse) ::: (l drop n)) + 1 } - def runTest() = assertEquals("both", (Var("x"),Var("y")), f) + def runTest() = assertEquals("both", (Var("x"),Var("y")), f) } class TestUnbox extends TestCase("unbox") { @@ -366,8 +366,8 @@ object Test extends TestConsoleMain { case dq : DoubleQuoteImpl => dq } } - - trait IfElseMatcher { + + trait IfElseMatcher { type Node <: NodeImpl trait NodeImpl trait IfImpl @@ -375,7 +375,7 @@ object Test extends TestConsoleMain { case node : IfImpl => node // var node is of type Node with IfImpl! case _ => null } - } + } } @@ -385,7 +385,7 @@ object Test extends TestConsoleMain { } object PersonFather { - def unapply(p : Person) : Option[Person] = + def unapply(p : Person) : Option[Person] = if (p.father == null) None else @@ -425,11 +425,11 @@ object Test extends TestConsoleMain { object Foo1 { class Bar1(val x : String) def p(b : Bar1) = Console.println(b.x) - + def unapply(s : String) : Option[Bar1] = Some(new Bar1(s)) } - + object bug881 extends TestCase("881") { override def runTest = { "baz" match { @@ -448,19 +448,19 @@ object Test extends TestConsoleMain { case Pair(Some(x),Some(y)) => 3 case _ => 4 } - + def g1[A](z:Option[List[A]]) = z match { - case Some(Nil) => true - case Some(x::Nil) => true + case Some(Nil) => true + case Some(x::Nil) => true case _ => true } - + def g2[A](z:Option[List[A]]) = z match { - case Some(x::Nil) => true + case Some(x::Nil) => true case Some(_) => false case _ => true } - + def h[A](x: (Option[A],Option[A])) = x match { case Pair(None,_:Some[_]) => 1 case Pair(_:Some[_],None ) => 2 @@ -485,20 +485,20 @@ object Test extends TestConsoleMain { } object Bug1270 { // unapply13 - + class Sync { def apply(x: Int): Int = 42 def unapply(scrut: Any): Option[Int] = None } - + class Buffer { object Get extends Sync - + var ps: PartialFunction[Any, Any] = { - case Get(y) if y > 4 => // y gets a wildcard type for some reason?! hack + case Get(y) if y > 4 => // y gets a wildcard type for some reason?! hack } } - + println((new Buffer).ps.isDefinedAt(42)) } @@ -509,7 +509,7 @@ object Test extends TestConsoleMain { trait Row extends Elem object Row { def unapply(r: Row) = true - + def f(elem: Elem) { elem match { case Bar() => ; @@ -520,9 +520,9 @@ object Test extends TestConsoleMain { /* object Feature1196 { def f(l: List[Int]) { } - + val l: Seq[Int] = List(1, 2, 3) - + l match { case x @ List(1, _) => f(x) // x needs to get better type List[int] here } @@ -546,9 +546,9 @@ object Test extends TestConsoleMain { trait Core { def next : Position = null } trait Dir val NEXT = new Dir{} - + trait Position extends Core - + (null:Core, null:Dir) match { case (_, NEXT) if true => false // no matter whether NEXT test succeed, cannot throw column because of guard case (at2:Position,dir) => true @@ -573,15 +573,15 @@ object Test extends TestConsoleMain { else None } } - + class Buffer { val Get = new Sync - + val jp: PartialFunction[Any, Any] = { case Get(xs) => println(xs) // the argDummy <unapply-selector> should have proper arg.tpe (Int in this case) } } - + println((new Buffer).jp.isDefinedAt(40)) println((new Buffer).jp.isDefinedAt(42)) } @@ -595,7 +595,7 @@ object Test extends TestConsoleMain { val s:PartialFunction[Any,Any] = { case List(4::xs) => 1 case List(5::xs) => 1 - case _ if false => + case _ if false => case List(3::xs) if List(3:Any).forall { g => g.hashCode() > 0 } => 1 } z.isDefinedAt(42) @@ -644,10 +644,10 @@ object Test extends TestConsoleMain { // bug#508 - object Bug508 extends TestCase("aladdin #508") { + object Bug508 extends TestCase("aladdin #508") { case class Operator(x: Int); val EQ = new Operator(2); - + def analyze(x: Pair[Operator, Int]) = x match { case Pair(EQ, 0) => "0" case Pair(EQ, 1) => "1" @@ -660,35 +660,35 @@ object Test extends TestConsoleMain { assertEquals("1", analyze(y)); // should print "1" val z = Pair(EQ, 2); assertEquals("2", analyze(z)); // should print "2" - } + } } // bug#789 - + object Bug789 extends TestCase("aladdin #789") { // don't do this at home trait Impl - + trait SizeImpl extends Impl { def size = 42 } - + trait ColorImpl extends Impl { def color = "red" } - + type Both = SizeImpl with ColorImpl - + def info(x:Impl) = x match { case x:Both => "size "+x.size+" color "+x.color // you wish case x:SizeImpl => "!size "+x.size case x:ColorImpl => "color "+x.color case _ => "n.a." } - + def info2(x:Impl) = x match { case x:SizeImpl with ColorImpl => "size "+x.size+" color "+x.color // you wish case x:SizeImpl => "!size "+x.size case x:ColorImpl => "color "+x.color case _ => "n.a." } - + override def runTest { // make up some class that has a size class MyNode extends SizeImpl @@ -705,7 +705,7 @@ object Test extends TestConsoleMain { case a: AnyRef if runtime.ScalaRunTime.isArray(a) => "Array" case _ => v.toString } - override def runTest { assertEquals("Array", foo(Array(0))) } + override def runTest { assertEquals("Array", foo(Array(0))) } } // bug#1093 (contribution #460) @@ -739,7 +739,7 @@ object Test extends TestConsoleMain { } } } - + object Ticket2 extends TestCase("#2") { override def runTest { val o1 = new Outer_2; val o2 = new Outer_2; val x: Any = o1.Foo(1, 2); val y: Any = o2.Foo(1, 2) assertFalse("equals test returns true (but should not)", x equals y) @@ -758,9 +758,9 @@ object Test extends TestConsoleMain { // will cause the test to succeed. trait SpecialException extends MyException1 // trait SpecialException - + class MyException2 extends MyException1 with SpecialException - + object Ticket11 extends TestCase("#11") { override def runTest { Array[Throwable](new Exception("abc"), @@ -781,7 +781,7 @@ object Test extends TestConsoleMain { } // #37 - + object Ticket37 extends TestCase("#37") { def foo() {} val (a,b) = { foo(); (2,3) } @@ -799,7 +799,7 @@ object Test extends TestConsoleMain { object Y extends _X { val foo = _Foo() foo match { - case _Bar() => + case _Bar() => case _ => assert(false) } } @@ -819,7 +819,7 @@ object Test extends TestConsoleMain { sealed abstract class Tree case class Node(l: Tree, v: Int, r: Tree) extends Tree case object EmptyTree extends Tree - + object Ticket335 extends TestCase("#335") { // compile-only override def runTest { (EmptyTree: Tree @unchecked) match { @@ -849,7 +849,7 @@ class L(val content: List[Int]) { } object N extends L(Nil) { - + override def equals(that: Any): Boolean = { val result = (that.isInstanceOf[L] && that.asInstanceOf[L].isEmpty) //println("N.equals("+that+") returning "+result) @@ -887,13 +887,13 @@ override def runTest() { } // end Ticket346 object Ticket495bis { // compile-only - def signum(x: Int): Int = - x match { + def signum(x: Int): Int = + x match { case 0 => 0 case _ if x < 0 => -1 case _ if x > 0 => 1 } - def pair_m(x: Int, y: Int) = + def pair_m(x: Int, y: Int) = (x,y) match { case (_, 0) => 0 case (-1, _) => -1 @@ -903,14 +903,14 @@ override def runTest() { object Ticket522 { // compile-only class Term[X] - object App { + object App { // i'm hidden case class InternalApply[Y,Z](fun:Y=>Z, arg:Y) extends Term[Z] - def apply[Y,Z](fun:Y=>Z, arg:Y): Term[Z] = + def apply[Y,Z](fun:Y=>Z, arg:Y): Term[Z] = new InternalApply[Y,Z](fun,arg) - def unapply[X](arg: Term[X]): Option[(Y=>Z,Y)] forSome {type Y; type Z} = + def unapply[X](arg: Term[X]): Option[(Y=>Z,Y)] forSome {type Y; type Z} = arg match { case i:InternalApply[y,z] => Some(i.fun, i.arg) case _ => None @@ -918,7 +918,7 @@ override def runTest() { } App({x: Int => x}, 5) match { - case App(arg, a) => + case App(arg, a) => } } // end Ticket522 diff --git a/test/files/run/priorityQueue.scala b/test/files/run/priorityQueue.scala index 20f7a3cb44..a3460cd8d6 100644 --- a/test/files/run/priorityQueue.scala +++ b/test/files/run/priorityQueue.scala @@ -31,21 +31,21 @@ object Test { val pq2 = new PriorityQueue[String] val pq3 = new PriorityQueue[String] val pq4 = new PriorityQueue[String] - + val strings = (1 to 20).toList map (i => List.fill((Math.abs(nextInt % 20)) + 1)("x").mkString) - + pq1 ++= strings pq2 ++= strings.reverse for (s <- strings) pq3 += s for (s <- strings.reverse) pq4 += s - + val pqs = List(pq1, pq2, pq3, pq4, pq1.clone, pq2.clone) - + for (queue1 <- pqs ; queue2 <- pqs) { assert(queue1 == queue2) assert(queue1.max == queue2.max) } - + assertPriority(pq1) } @@ -80,7 +80,7 @@ object Test { } for (i <- 0 until 100) assert(intpq(i) == (99 - i)) } - + def testTails { val pq = new PriorityQueue[Int] for (i <- 0 until 10) pq += i * 4321 % 200 @@ -120,9 +120,9 @@ object Test { def testInits { val pq = new PriorityQueue[Long] for (i <- 0 until 20) pq += (i + 313) * 111 % 300 - + assert(pq.size == 20) - + val initpq = pq.init assert(initpq.size == 19) assertPriorityDestructive(initpq) @@ -131,19 +131,19 @@ object Test { def testFilters { val pq = new PriorityQueue[String] for (i <- 0 until 100) pq += "Some " + (i * 312 % 200) - + val filpq = pq.filter(_.indexOf('0') != -1) assertPriorityDestructive(filpq) } def testIntensiveEnqueueDequeue { val pq = new PriorityQueue[Int] - + testIntensive(1000, pq) pq.clear testIntensive(200, pq) } - + def testIntensive(sz: Int, pq: PriorityQueue[Int]) { val lst = new collection.mutable.ArrayBuffer[Int] ++ (0 until sz) val rand = new util.Random(7) @@ -161,7 +161,7 @@ object Test { pq ++= (0 until 100) val droppq = pq.drop(50) assertPriority(droppq) - + pq.clear pq ++= droppq assertPriorityDestructive(droppq) @@ -180,7 +180,7 @@ object Test { assertPriority(pq) pq.clear - + pq ++= (1 to 100) pq(5) = 200 assert(pq(0) == 200) @@ -211,7 +211,7 @@ object Test { def testEquality { val pq1 = new PriorityQueue[Int] val pq2 = new PriorityQueue[Int] - + pq1 ++= (0 until 50) var i = 49 while (i >= 0) { @@ -220,7 +220,7 @@ object Test { } assert(pq1 == pq2) assertPriority(pq2) - + pq1 += 100 assert(pq1 != pq2) pq2 += 100 @@ -237,7 +237,7 @@ object Test { val pq = new PriorityQueue[Int] pq ++= (0 until 100) assert(pq.size == 100) - + val (p1, p2) = pq.partition(_ < 50) assertPriorityDestructive(p1) assertPriorityDestructive(p2) @@ -259,13 +259,13 @@ object Test { assert(pq.lastIndexWhere(_ == 9) == 0) assert(pq.lastIndexOf(8) == 1) assert(pq.lastIndexOf(7) == 2) - + pq += 5 pq += 9 assert(pq.lastIndexOf(9) == 1) assert(pq.lastIndexWhere(_ % 2 == 1) == 10) assert(pq.lastIndexOf(5) == 6) - + val lst = pq.reverseIterator.toList for (i <- 0 until 5) assert(lst(i) == i) assert(lst(5) == 5) @@ -275,13 +275,13 @@ object Test { assert(lst(9) == 8) assert(lst(10) == 9) assert(lst(11) == 9) - + pq.clear assert(pq.reverseIterator.toList.isEmpty) - + pq ++= (50 to 75) assert(pq.lastIndexOf(70) == 5) - + pq += 55 pq += 70 assert(pq.lastIndexOf(70) == 6) @@ -291,11 +291,11 @@ object Test { assert(pq.lastIndexWhere(_ > 54, 21) == 21) assert(pq.lastIndexWhere(_ > 69, 5) == 5) } - + def testReverse { val pq = new PriorityQueue[(Int, Int)] pq ++= (for (i <- 0 until 10) yield (i, i * i % 10)) - + assert(pq.reverse.size == pq.reverseIterator.toList.size) assert((pq.reverse zip pq.reverseIterator.toList).forall(p => p._1 == p._2)) assert(pq.reverse.sameElements(pq.reverseIterator.toSeq)) @@ -303,19 +303,19 @@ object Test { assert(pq.reverse(1)._1 == pq(8)._1) assert(pq.reverse(4)._1 == pq(5)._1) assert(pq.reverse(9)._1 == pq(0)._1) - + pq += ((7, 7)) pq += ((7, 9)) pq += ((7, 8)) assert(pq.reverse.reverse == pq) assert(pq.reverse.lastIndexWhere(_._2 == 6) == 6) assertPriorityDestructive(pq.reverse.reverse) - + val iq = new PriorityQueue[Int] iq ++= (0 until 50) assert(iq.reverse == iq.reverseIterator.toSeq) assert(iq.reverse.reverse == iq) - + iq += 25 iq += 40 iq += 10 @@ -324,7 +324,7 @@ object Test { assert(iq.reverse.lastIndexWhere(_ == 10) == 11) assertPriorityDestructive(iq.reverse.reverse) } - + } diff --git a/test/files/run/programmatic-main.scala b/test/files/run/programmatic-main.scala index 9c7d0b7095..b44b1a9a55 100644 --- a/test/files/run/programmatic-main.scala +++ b/test/files/run/programmatic-main.scala @@ -5,7 +5,7 @@ object Test { val cwd = Option(System.getProperty("partest.cwd")) getOrElse "." val basedir = Path(cwd).parent / "lib" path val baseargs = Array("-usejavacp", "-bootclasspath", basedir + "/scala-library.jar", "-cp", basedir + "/scala-compiler.jar") - + def main(args: Array[String]): Unit = { Main process (baseargs ++ Array("-Xshow-phases")) } diff --git a/test/files/run/proxy.scala b/test/files/run/proxy.scala index 48192a7a79..869cbf87df 100644 --- a/test/files/run/proxy.scala +++ b/test/files/run/proxy.scala @@ -1,6 +1,6 @@ object Test extends Application { val p = new Proxy { - def self = 2 + def self = 2 } println(p equals 1) println(p equals 2) diff --git a/test/files/run/randomAccessSeq-apply.scala b/test/files/run/randomAccessSeq-apply.scala index 1f74050bb7..f398ea1536 100644 --- a/test/files/run/randomAccessSeq-apply.scala +++ b/test/files/run/randomAccessSeq-apply.scala @@ -1,14 +1,14 @@ object Test extends Application { val empty = RandomAccessSeq() assert(empty.isEmpty) - + val single = RandomAccessSeq(1) assert(List(1) == single.toList) - + val two = RandomAccessSeq("a", "b") assert("a" == two.head) assert("b" == two.apply(1)) - + println("OK") } diff --git a/test/files/run/range.scala b/test/files/run/range.scala index 02b48fad7c..387b2d0d5b 100644 --- a/test/files/run/range.scala +++ b/test/files/run/range.scala @@ -6,30 +6,30 @@ object Test { range.foreach(buffer += _); assert(buffer.toList == range.iterator.toList, buffer.toList+"/"+range.iterator.toList) } - + case class GR[T](val x: T)(implicit val num: Integral[T]) { import num._ - + def negated = GR[T](-x) - + def gr1 = NumericRange(x, x, x) def gr2 = NumericRange.inclusive(x, x, x) def gr3 = NumericRange(x, x * fromInt(10), x) def gr4 = NumericRange.inclusive(x, x * fromInt(10), x) - + def check = assert( gr1.isEmpty && !gr2.isEmpty && - gr3.size == 9 && gr4.size == 10 && - (gr3.toList ::: negated.gr3.toList).sum == num.zero && + gr3.size == 9 && gr4.size == 10 && + (gr3.toList ::: negated.gr3.toList).sum == num.zero && !(gr3 contains (x * fromInt(10))) && (gr4 contains (x * fromInt(10))) ) - } - + } + def main(args: Array[String]): Unit = { implicit val imp1 = Numeric.BigDecimalAsIfIntegral implicit val imp2 = Numeric.DoubleAsIfIntegral - + val _grs = List[GR[_]]( GR(BigDecimal(5.0)), GR(BigInt(5)), @@ -39,19 +39,19 @@ object Test { ) val grs = _grs ::: (_grs map (_.negated)) grs foreach (_.check) - + assert(NumericRange(1, 10, 1) sameElements (1 until 10)) assert(NumericRange.inclusive(1, 10, 1) sameElements (1 to 10)) assert(NumericRange.inclusive(1, 100, 3) sameElements (1 to 100 by 3)) - + // #2518 assert((3L to 7 by 2) sameElements List(3L, 5L, 7L)) - + rangeForeach(1 to 10); rangeForeach(1 until 10); rangeForeach(10 to 1 by -1); rangeForeach(10 until 1 by -1); rangeForeach(10 to 1 by -3); - rangeForeach(10 until 1 by -3); + rangeForeach(10 until 1 by -3); } } diff --git a/test/files/run/runtime-richChar.scala b/test/files/run/runtime-richChar.scala index b2c488983d..f5ddc95f04 100644 --- a/test/files/run/runtime-richChar.scala +++ b/test/files/run/runtime-richChar.scala @@ -5,19 +5,19 @@ object Test extends Application { else println(name + " failed: " + expected + " differs from " + got) } - + testSeq("'a' to 'c'", List('a', 'b', 'c'), 'a' to 'c') testSeq("'a' until 'c'", List('a', 'b'), 'a' until 'c') - + testSeq("'a' to 'b'", List('a', 'b'), 'a' to 'b') testSeq("'a' until 'b'", List('a'), 'a' until 'b') - + testSeq("'a' to 'a'", List('a'), 'a' to 'a') testSeq("'a' until 'a'", List(), 'a' until 'a') - + testSeq("'b' to 'a'", List(), 'b' to 'a') testSeq("'b' until 'a'", List(), 'b' until 'a') - + testSeq("'c' to 'a'", List(), 'c' to 'a') testSeq("'c' until 'a'", List(), 'c' until 'a') } diff --git a/test/files/run/sequenceComparisons.scala b/test/files/run/sequenceComparisons.scala index 2b5833aacc..c8e14e452c 100644 --- a/test/files/run/sequenceComparisons.scala +++ b/test/files/run/sequenceComparisons.scala @@ -2,12 +2,12 @@ import scala.collection.{ mutable, immutable } import collection.{ Seq, Traversable } object Test { - // TODO: + // TODO: // // SeqProxy // SeqForwarder // the commented out ones in seqMakers - + val seqMakers = List[List[Int] => Seq[Int]]( // scala.Array(_: _*), mutable.ArrayBuffer(_: _*), @@ -23,13 +23,13 @@ object Test { immutable.Seq(_: _*), mutable.Seq(_: _*), immutable.Stack(_: _*), - // mutable.Stack(_: _*), + // mutable.Stack(_: _*), immutable.IndexedSeq(_: _*), // was Vector //mutable.Vector(_: _*), immutable.List(_: _*), immutable.Stream(_: _*) ) - + abstract class Data[T] { val seq: Seq[T] private def seqList = seq.toList @@ -45,50 +45,50 @@ object Test { } lazy val eqeq = Method(_ == _, (List(seqList), List(Nil, seqList drop 1, seqList ::: seqList)), "%s == %s") - + val startsWithInputs: Inputs lazy val startsWith = Method(_ startsWith _, startsWithInputs, "%s startsWith %s") - + val endsWithInputs: Inputs lazy val endsWith = Method(_ endsWith _, endsWithInputs, "%s endsWith %s") val indexOfSliceInputs: Inputs private def subseqTest(s1: Seq[T], s2: Seq[T]) = (s1 indexOfSlice s2) != -1 lazy val indexOfSlice = Method(subseqTest _, indexOfSliceInputs, "(%s indexOfSlice %s) != -1") - + val sameElementsInputs: Inputs lazy val sameElements = Method(_ sameElements _, sameElementsInputs, "%s sameElements %s") - + def methodList = List(eqeq, startsWith, endsWith, indexOfSlice, sameElements) } - + object test1 extends Data[Int] { val seq = List(1,2,3,4,5) - + val startsWithInputs = ( List(Nil, List(1), List(1,2), seq), List(List(1,2,3,4,6), seq ::: List(5), List(0)) ) - + val endsWithInputs = ( List(Nil, List(5), List(4,5), seq), List(0 :: seq, List(5,2,3,4,5), List(3,4), List(5,6)) ) - + val indexOfSliceInputs = ( List(Nil, List(1), List(3), List(5), List(1,2), List(2,3,4), List(4,5), seq), List(List(1,2,3,5), List(6), List(5,4,3,2,1), List(2,1)) ) - + val sameElementsInputs = ( List(List(1,2,3,4,5)), List(Nil, List(1), List(1,2), List(2,3,4), List(2,3,4,5), List(2,3,4,5,1), List(1,2,3,5,4), seq reverse) ) } - + val failures = new mutable.ListBuffer[String] var testCount = 0 - + def assertOne(op1: Any, op2: Any, res: Boolean, str: String) { testCount += 1 val resStr = str.format(op1, op2) @@ -97,25 +97,25 @@ object Test { failures += ("FAIL: " + resStr) // assert(res, resStr) } - + def runSeqs() = { for (s1f <- seqMakers ; s2f <- seqMakers ; testData <- List(test1)) { import testData._ val scrut = s1f(seq) - + for (Method(f, (trueList, falseList), descr) <- methodList) { for (s <- trueList; val rhs = s2f(s)) assertOne(scrut, rhs, f(scrut, rhs), descr) - + for (s <- falseList; val rhs = s2f(s)) assertOne(scrut, rhs, !f(scrut, rhs), "!(" + descr + ")") } } } - + def main(args: Array[String]) { runSeqs() - + assert(failures.isEmpty, failures mkString "\n") } } diff --git a/test/files/run/slice-strings.scala b/test/files/run/slice-strings.scala index 129314387a..23085866f5 100644 --- a/test/files/run/slice-strings.scala +++ b/test/files/run/slice-strings.scala @@ -1,7 +1,7 @@ -object Test { +object Test { def cmp(x1: String) = { val x2 = x1.toList - + -10 to 10 foreach { i => assert(x1.take(i) == x2.take(i).mkString) assert(x1.drop(i) == x2.drop(i).mkString) @@ -12,7 +12,7 @@ object Test { assert(x1.slice(idx1, idx2) == x2.slice(idx1, idx2).mkString) } } - + def main(args: Array[String]): Unit = { cmp("abcde") } diff --git a/test/files/run/spec-ame.scala b/test/files/run/spec-ame.scala index 86c47077f0..5898170ff2 100644 --- a/test/files/run/spec-ame.scala +++ b/test/files/run/spec-ame.scala @@ -1,13 +1,13 @@ // ticket #3432 object Test { trait B[@specialized(Int) T] { - def value: T + def value: T } - class A[@specialized(Int) T](x: T) { - def foo: B[T] = new B[T] { - def value = x - } + class A[@specialized(Int) T](x: T) { + def foo: B[T] = new B[T] { + def value = x + } } def main(args: Array[String]) { diff --git a/test/files/run/spec-matrix.scala b/test/files/run/spec-matrix.scala index 81e3eaf212..2acf6204ff 100644 --- a/test/files/run/spec-matrix.scala +++ b/test/files/run/spec-matrix.scala @@ -3,7 +3,7 @@ class Matrix[@specialized A: ClassManifest](val rows: Int, val cols: Int) { private val arr: Array[Array[A]] = new Array[Array[A]](rows, cols) - + def apply(i: Int, j: Int): A = { if (i < 0 || i >= rows || j < 0 || j >= cols) throw new NoSuchElementException("Indexes out of bounds: " + (i, j)) @@ -36,7 +36,7 @@ object Test { def randomMatrix(n: Int, m: Int) = { val r = new util.Random(10) - val x = new Matrix[Int](n, m) + val x = new Matrix[Int](n, m) for (i <- 0 until n; j <- 0 until m) x(i, j) = r.nextInt x @@ -47,7 +47,7 @@ object Test { val p = new Matrix[T](m.rows, n.cols) import num._ - for (i <- 0 until m.rows) + for (i <- 0 until m.rows) for (j <- 0 until n.cols) { var sum = num.zero for (k <- 0 until n.rows) @@ -59,7 +59,7 @@ object Test { def mult(m: Matrix[Int], n: Matrix[Int]) { val p = new Matrix[Int](m.rows, n.cols) - for (i <- 0 until m.rows) + for (i <- 0 until m.rows) for (j <- 0 until n.cols) { var sum = 0 for (k <- 0 until n.rows) diff --git a/test/files/run/streamWithFilter.scala b/test/files/run/streamWithFilter.scala index cb919d4f55..7f8f9a09d2 100644 --- a/test/files/run/streamWithFilter.scala +++ b/test/files/run/streamWithFilter.scala @@ -4,7 +4,7 @@ object Test { def isBuzz(x: Int) = x % 5 == 0 // next line will run forever if withFilter isn't doing its thing. val fizzbuzzes = for (n <- nums ; if isFizz(n) ; if isBuzz(n)) yield n - + def main(args: Array[String]): Unit = { fizzbuzzes take 5 foreach println } diff --git a/test/files/run/streams.scala b/test/files/run/streams.scala index 83b7772886..e3c871c693 100644 --- a/test/files/run/streams.scala +++ b/test/files/run/streams.scala @@ -29,7 +29,7 @@ object Test extends Application { def powers(x: Int) = if ((x&(x-1)) == 0) Some(x) else None println(s3.flatMap(powers).reverse.head) - // large enough to generate StackOverflows (on most systems) + // large enough to generate StackOverflows (on most systems) // unless the following methods are tail call optimized. val size = 100000 diff --git a/test/files/run/stringbuilder.scala b/test/files/run/stringbuilder.scala index 28ddc653a5..8ee8435e37 100644 --- a/test/files/run/stringbuilder.scala +++ b/test/files/run/stringbuilder.scala @@ -1,21 +1,21 @@ object Test extends Application { val str = "ABCDEFGHIJKLMABCDEFGHIJKLM" val surrogateStr = "an old Turkic letter: \uD803\uDC22" - - type SB = { + + type SB = { def indexOf(str: String): Int def indexOf(str: String, fromIndex: Int): Int def lastIndexOf(str: String): Int def lastIndexOf(str: String, fromIndex: Int): Int } - + import scala.collection.mutable.{ StringBuilder => ScalaStringBuilder } import java.lang.{ StringBuilder => JavaStringBuilder } - + val sbScala = new ScalaStringBuilder() append str val sbJava = new JavaStringBuilder() append str val sbs: List[SB] = List[SB](sbScala, sbJava) - + def sameAnswers(f: (SB) => Int) = assert(f(sbScala) == f(sbJava)) sameAnswers(_.indexOf("")) @@ -31,10 +31,10 @@ object Test extends Application { sameAnswers(_.lastIndexOf("QZV")) sameAnswers(_.lastIndexOf("GHI", 22)) sameAnswers(_.lastIndexOf("KLM", 22)) - + // testing that the "reverse" implementation avoids reversing surrogate pairs val jsb = new JavaStringBuilder(surrogateStr) reverse val ssb = new ScalaStringBuilder(surrogateStr) reverseContents ; - + assert(jsb.toString == ssb.toString) } diff --git a/test/files/run/structural.scala b/test/files/run/structural.scala index 5fc2292b42..c9a13b8469 100644 --- a/test/files/run/structural.scala +++ b/test/files/run/structural.scala @@ -1,18 +1,18 @@ object test1 { - + val o1 = new Object { override def toString = "ohone" } val o2 = new Object { override def toString = "ohtwo" } - + val t1 = new Tata("tieone") val t2 = new Tata("tietwo") - + class Tata(name: String) { override def toString = name def tatMe = "oy" } - + class Titi extends Tata("titi") - + object Rec { val a = 1 val b = 2 @@ -41,7 +41,7 @@ object test1 { val y: Tata = null def z(t: Tata) = () } - + type rt = Object { val a: Int; val c: String; @@ -65,7 +65,7 @@ object test1 { var v: Int val y: Tata } - + def l (r: rt) { println(" 1. " + r.c) println(" 2. " + r.a + 1) @@ -94,33 +94,33 @@ object test1 { println("25. " + r.y) println("26. " + r.e(null)) } - + /*def ma[T](r: Object{def e(x: T): T; val x: T}) { println("30. " + r.e(r.x)) // static error }*/ - + def mb(r: Object { def e[T](x: T): T }) { println("31. " + r.e[Int](4)) // while this is ok } - + def m1(r: Object { def z(x: Tata): Unit }) { println("32. " + r.z(new Titi)) // while this is ok } - + def m2[T](r: Object { def e(x: Tata): T; val x: Tata }) { println("33. " + r.e(r.x)) // and this too } - + class Rec3[T] { def e(x: T): T = x } - + def m3[T](r: Rec3[T], x: T) { println("33. " + r.e(x)) // and this too } - + Rec.g(11) - + this.l(Rec) this.mb(new Object{def e[T](x: T): T = x}) this.m1(Rec) @@ -132,7 +132,7 @@ object test2 { class C extends { def f() { println("1") } } val x1 = new C x1.f() - + abstract class D extends { def f() } val x2 = new D { def f() { println("2") } } x2.f() @@ -153,11 +153,11 @@ object test2 { object test3 { case class Exc extends Exception - + object Rec { def f = throw Exc() } - + def m(r: { def f: Nothing }) = try { r.f @@ -166,31 +166,31 @@ object test3 { case e: Exc => println("caught") case e => println(e) } - + m(Rec) - + } object test4 { class A - + val aar = Array(new A, new A, new A) val nar = Array(1, 2) - + def f(p: {def size: Int}) = println(p.size) //def g[T <: {def size: Int}](p: T) = println(p.size) // open issue //def h[T <% {def size: Int}](p: T) = println(p.size) // open issue - + f(aar) f(nar) - + //g(aar) //g(nar) - + //h(aar) //h(nar) - + } object Test extends Application { diff --git a/test/files/run/t0017.scala b/test/files/run/t0017.scala index f43481f39b..5f02606b74 100644 --- a/test/files/run/t0017.scala +++ b/test/files/run/t0017.scala @@ -7,7 +7,7 @@ def transpose[A](arr: Array[Array[A]]) = { var my_arr = Array(Array(1,2),Array(3,4)) -for (i <- Array.range(0, my_arr(0).length)) yield +for (i <- Array.range(0, my_arr(0).length)) yield for (row <- my_arr) yield row(i) val transposed = transpose(my_arr) diff --git a/test/files/run/t0421.scala b/test/files/run/t0421.scala index b69373f341..121fc4f2f0 100644 --- a/test/files/run/t0421.scala +++ b/test/files/run/t0421.scala @@ -7,17 +7,17 @@ object Test extends Application { } def scalprod(xs: Array[Double], ys: Array[Double]) = { - var acc = 0.0 - for ((x, y) <- xs zip ys) acc = acc + x * y + var acc = 0.0 + for ((x, y) <- xs zip ys) acc = acc + x * y acc } def matmul(xss: Array[Array[Double]], yss: Array[Array[Double]]) = { - val ysst = transpose(yss) + val ysst = transpose(yss) val ysst1: Array[Array[Double]] = yss.transpose assert(ysst.deep == ysst1.deep) for (xs <- xss) yield - for (yst <- ysst) yield + for (yst <- ysst) yield scalprod(xs, yst) } @@ -25,6 +25,6 @@ object Test extends Application { println(transpose(a1).deepMkString("[", ",", "]")) println(matmul(Array(Array(2, 3)), Array(Array(5), Array(7))).deepMkString("[", ",", "]")) - + println(matmul(Array(Array(4)), Array(Array(6, 8))).deepMkString("[", ",", "]")) } diff --git a/test/files/run/t0508.scala b/test/files/run/t0508.scala index 7ef6f8197f..8dc34dd417 100644 --- a/test/files/run/t0508.scala +++ b/test/files/run/t0508.scala @@ -9,5 +9,5 @@ object Test extends Application { } } - foo(Foo.unapply, Foo("this might be fun", 10)) + foo(Foo.unapply, Foo("this might be fun", 10)) } diff --git a/test/files/run/t0631.scala b/test/files/run/t0631.scala index e64301e514..48bb3c986c 100644 --- a/test/files/run/t0631.scala +++ b/test/files/run/t0631.scala @@ -1,5 +1,5 @@ object Test extends Application { - class Foo { + class Foo { override def equals(that: Any) = { println("Foo.equals called") super.equals(that) diff --git a/test/files/run/t0677.scala b/test/files/run/t0677.scala index eb01a85fcb..94f30815b2 100644 --- a/test/files/run/t0677.scala +++ b/test/files/run/t0677.scala @@ -1,7 +1,7 @@ object Test extends Application { - class X[T: ClassManifest] { + class X[T: ClassManifest] { val a = new Array[Array[T]](3,4) - val b = Array.ofDim[T](3, 4) + val b = Array.ofDim[T](3, 4) } val x = new X[String] x.a(1)(2) = "hello" diff --git a/test/files/run/t0807.scala b/test/files/run/t0807.scala index e69aa1c71c..b4aa0b14a4 100644 --- a/test/files/run/t0807.scala +++ b/test/files/run/t0807.scala @@ -1,5 +1,5 @@ trait A -trait B extends A { val x = println("early") } +trait B extends A { val x = println("early") } object Test extends Application { new B {} } diff --git a/test/files/run/t0883.scala b/test/files/run/t0883.scala index b9d71702d8..c55992642d 100644 --- a/test/files/run/t0883.scala +++ b/test/files/run/t0883.scala @@ -1,14 +1,14 @@ object Foo { def apply(x: String) = new Foo(x) } class Foo(name: String) case object Bar extends Foo("Bar") -case class Baz extends Foo("Baz") +case class Baz extends Foo("Baz") object Test extends Application { - Foo("Bar") match { - case Bar => println("What?") + Foo("Bar") match { + case Bar => println("What?") case _ => println("OK") } - Foo("Baz") match { - case Baz() => println("What?") + Foo("Baz") match { + case Baz() => println("What?") case _ => println("OK") - } + } } diff --git a/test/files/run/t1167.scala b/test/files/run/t1167.scala index 25e42ffd4d..ac9626227b 100644 --- a/test/files/run/t1167.scala +++ b/test/files/run/t1167.scala @@ -7,13 +7,13 @@ trait Test1 { (i:Int) => i + 5 } } - + abstract class Foo { override def toString = getClass.getSimpleName - + abstract class Bar { override def toString = getClass.getSimpleName - } + } } object Test extends Application { diff --git a/test/files/run/t1323.scala b/test/files/run/t1323.scala index 89676c888b..831f8c72f0 100644 --- a/test/files/run/t1323.scala +++ b/test/files/run/t1323.scala @@ -3,9 +3,9 @@ object Test extends Application { println(" 2:" + List(1,2,3,4).indexOfSlice(List(1,2))) // 0 println(" 3:" + List(1,2,3,4).indexOfSlice(List(2,3))) // 1 println(" 4:" + List(1,2,3,4).indexOfSlice(List(3,4))) // 2 - println(" 5:" + List(1,2,3,4).indexOfSlice(List(4,5))) // -1 + println(" 5:" + List(1,2,3,4).indexOfSlice(List(4,5))) // -1 println(" 6:" + List(1,2,3,4).indexOfSlice(List(2,4))) // -1 - println(" 7:" + List(1,2,3,4).indexOfSlice(List(4,3))) // -1 + println(" 7:" + List(1,2,3,4).indexOfSlice(List(4,3))) // -1 println(" 8:" + List(1,2,3,4).indexOfSlice(List(1,3))) // -1 println(" 9:" + List(1,2,3,4).indexOfSlice(List(1,3))) // -1 println("10:" + List(1,2,3,4).indexOfSlice(List(1,2,3,4))) // 0 diff --git a/test/files/run/t1423.scala b/test/files/run/t1423.scala index 83c35a46bd..4f2c911530 100644 --- a/test/files/run/t1423.scala +++ b/test/files/run/t1423.scala @@ -5,4 +5,4 @@ object Test extends Application{ case 1L => println(1); case _ => println("????"); } -} +} diff --git a/test/files/run/t1500.scala b/test/files/run/t1500.scala index ce6278cd05..c312a9a883 100644 --- a/test/files/run/t1500.scala +++ b/test/files/run/t1500.scala @@ -1,23 +1,23 @@ -import scala.tools.nsc._ +import scala.tools.nsc._ object Test { - + /** * Type inference overlooks constraints posed by type parameters in annotations on types. */ - + val testCode = <code> - + class posingAs[A] extends TypeConstraint - + def resolve[A,B](x: A @posingAs[B]): B = x.asInstanceOf[B] - + val x = resolve(7: @posingAs[Any]) - + </code>.text - + def main(args: Array[String]) = { - + val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") val tool = new Interpreter(settings) @@ -35,11 +35,11 @@ object Test { } } - + global.addAnnotationChecker(checker) - + tool.interpret(testCode) - + } } diff --git a/test/files/run/t1501.scala b/test/files/run/t1501.scala index f1eb8f287d..05e4da8c7a 100644 --- a/test/files/run/t1501.scala +++ b/test/files/run/t1501.scala @@ -1,15 +1,15 @@ -import scala.tools.nsc._ +import scala.tools.nsc._ object Test { - + /** * ... */ - + val testCode = <code> - + class xyz[A] extends TypeConstraint - + def loopWhile[T](cond: =>Boolean)(body: =>(Unit @xyz[T])): Unit @ xyz[T] = {{ if (cond) {{ body @@ -24,9 +24,9 @@ object Test { (): @xyz[Int] }} }} - + </code>.text - + def main(args: Array[String]) = { val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") @@ -45,11 +45,11 @@ object Test { } } - + global.addAnnotationChecker(checker) - + tool.interpret(testCode) - + } } diff --git a/test/files/run/t1591.scala b/test/files/run/t1591.scala index 434064a5dd..28e77775ff 100644 --- a/test/files/run/t1591.scala +++ b/test/files/run/t1591.scala @@ -1,8 +1,8 @@ abstract class A { - + lazy val lazyBar = bar - - object bar { + + object bar { val foo = 12 } diff --git a/test/files/run/t1718.scala b/test/files/run/t1718.scala index 61a17b2906..431e237327 100644 --- a/test/files/run/t1718.scala +++ b/test/files/run/t1718.scala @@ -1,10 +1,10 @@ object Test extends Application{ - def matchesNull[T](mightBeNull: Array[T]): Boolean = mightBeNull match { + def matchesNull[T](mightBeNull: Array[T]): Boolean = mightBeNull match { case null => true case x => false } val nullArray: Array[String] = null - println(matchesNull(nullArray)) + println(matchesNull(nullArray)) } diff --git a/test/files/run/t1773.scala b/test/files/run/t1773.scala index 4a4aaba1f0..04729df7e7 100644 --- a/test/files/run/t1773.scala +++ b/test/files/run/t1773.scala @@ -7,6 +7,6 @@ object Test extends Application <a>{""}</a>, <a>{ if (true) "" else "I like turtles" }</a> ) - + for (x1 <- xs; x2 <- xs) assert (x1 xml_== x2) } diff --git a/test/files/run/t1829.scala b/test/files/run/t1829.scala index 8240527424..7c39d33ae9 100644 --- a/test/files/run/t1829.scala +++ b/test/files/run/t1829.scala @@ -1,6 +1,6 @@ object Test{ def main(args : Array[String]){ - import scala.collection.immutable._ + import scala.collection.immutable._ assert(IntMap.empty == HashMap.empty); assert(HashMap.empty == IntMap.empty); assert(LongMap.empty == HashMap.empty); diff --git a/test/files/run/t2074_2.scala b/test/files/run/t2074_2.scala index 4624170f89..1f59e0b8a1 100644 --- a/test/files/run/t2074_2.scala +++ b/test/files/run/t2074_2.scala @@ -12,7 +12,7 @@ object Test { def iterator = underlying.iterator } val w = IndexedSeq(1, 2, 3).view - + def main(args: Array[String]): Unit = { println(v) println(w) diff --git a/test/files/run/t2417.scala b/test/files/run/t2417.scala index 31d4c143fa..aeb61a7d1d 100644 --- a/test/files/run/t2417.scala +++ b/test/files/run/t2417.scala @@ -1,6 +1,6 @@ // #2417 object Test { - + def parallel(numThreads: Int)(block: => Unit) { var failure: Throwable = null val threads = Array.fromFunction(i => new Thread { @@ -16,7 +16,7 @@ object Test { for (t <- threads) t.join if (failure != null) println("FAILURE: " + failure) } - + def testSet(initialSize: Int, numThreads: Int, passes: Int) { val orig = Set.empty ++ (1 to initialSize) parallel(numThreads) { @@ -32,7 +32,7 @@ object Test { } } } - + def testMap(initialSize: Int, numThreads: Int, passes: Int) { val orig = Map.empty ++ ((1 to initialSize) map ((_,"v"))) parallel(numThreads) { @@ -48,28 +48,28 @@ object Test { } } } - + def main(args: Array[String]) { println("testing small Map that doesn't promote to HashMap...") testMap(4, 2, 1000000) println() - + println("testing single-threaded HashMap use...") testMap(5, 1, 1000000) println() - + println("testing HashMap.size from multiple threads...") testMap(5, 2, 1000000) println() - + println("testing small Set that doesn't promote to HashSet...") testSet(4, 2, 1000000) println() - + println("testing single-threaded HashSet use...") testSet(5, 1, 1000000) println() - + println("testing HashSet.size from multiple threads...") testSet(5, 2, 1000000) println() diff --git a/test/files/run/t2526.scala b/test/files/run/t2526.scala index 53f3059135..d37185535f 100644 --- a/test/files/run/t2526.scala +++ b/test/files/run/t2526.scala @@ -4,18 +4,18 @@ */ object Test { import collection._ - + def main(args: Array[String]) { val m = new mutable.HashMap[String, String] - + /* Use non hash-based structure for verification */ val keys = List("a", "b", "c", "d", "e") val valueSuffix = "value" val values = keys.map(_ + valueSuffix) val entries = keys.zip(values) - + for (k <- keys) m(k) = k + valueSuffix - + assertForeach(keys, m.keySet.iterator) assertForeach(keys, m.keysIterator) assertForeach(keys, m.keySet) @@ -25,7 +25,7 @@ object Test { assertForeach(entries, m) } - + /* Checks foreach of `actual` goes over all the elements in `expected` */ private def assertForeach[E](expected: Traversable[E], actual: Iterator[E]): Unit = { val notYetFound = new mutable.ArrayBuffer[E]() ++= expected @@ -35,12 +35,12 @@ object Test { } assert(notYetFound.size == 0, "mutable.HashMap.foreach should have iterated over: " + notYetFound) } - - /* + + /* * Checks foreach of `actual` goes over all the elements in `expected` * We duplicate the method above because there is no common inteface between Traversable and * Iterator and we want to avoid converting between collections to ensure that we test what - * we mean to test. + * we mean to test. */ private def assertForeach[E](expected: Traversable[E], actual: Traversable[E]): Unit = { val notYetFound = new mutable.ArrayBuffer[E]() ++= expected diff --git a/test/files/run/t2849.scala b/test/files/run/t2849.scala index 68094de736..0588e5ed92 100644 --- a/test/files/run/t2849.scala +++ b/test/files/run/t2849.scala @@ -7,17 +7,17 @@ import scala.collection.immutable.TreeSet object Test { - + def main(args: Array[String]) { ticketExample similarExample } - + def ticketExample { var big = 100000 - + var aSortedSet: SortedSet[Int] = TreeSet(big) - + for (i <- 1 until 10000) { aSortedSet = (aSortedSet - big) ++ (TreeSet(i, big - 1)) big = big - 1 @@ -26,7 +26,7 @@ object Test { } } } - + def similarExample { var big = 100 @@ -40,7 +40,7 @@ object Test { } } } - + } diff --git a/test/files/run/t2867.scala b/test/files/run/t2867.scala index 25e55eaecd..0d30f95f8d 100644 --- a/test/files/run/t2867.scala +++ b/test/files/run/t2867.scala @@ -1,6 +1,6 @@ object Test { - case class A(l: List[_]*) - + case class A(l: List[_]*) + def main(args: Array[String]): Unit = { /** Kind of sneaking a slightly different test in here as well as * testing 2867. How subversive. @@ -9,7 +9,7 @@ object Test { val xs2 = List(1.0, 2.0, 3.0) val xs3 = List[Any](1.0f, 2.0f, 3.0f) val xs4 = List[Byte](1, 2, 3) - + assert(A(List(xs1, xs2)) == A(List(xs3, xs4))) } } diff --git a/test/files/run/t3026.scala b/test/files/run/t3026.scala index 22dde9cc03..0231c7bcd1 100755 --- a/test/files/run/t3026.scala +++ b/test/files/run/t3026.scala @@ -3,6 +3,6 @@ object Test { case object RED extends Colour case object YELLOW extends Colour val items = Array(RED, YELLOW) - + def main(args: Array[String]): Unit = items foreach println } diff --git a/test/files/run/t3112.scala b/test/files/run/t3112.scala index eb8eec6327..88677fa09e 100644 --- a/test/files/run/t3112.scala +++ b/test/files/run/t3112.scala @@ -7,5 +7,5 @@ object Test { println((Vector() ++ (0 until 32)) takeRight 0) // works println((Vector() ++ (0 until 33)) takeRight 0) // error } - + }
\ No newline at end of file diff --git a/test/files/run/t3158.scala b/test/files/run/t3158.scala index c824b62e96..2261b5cd81 100644 --- a/test/files/run/t3158.scala +++ b/test/files/run/t3158.scala @@ -1,6 +1,6 @@ object Test { def main(args: Array[String]) { - println(args.map(_ => foo _).deep) + println(args.map(_ => foo _).deep) } def foo(xs: String*) { diff --git a/test/files/run/t3493.scala b/test/files/run/t3493.scala index aafe7a3a4a..b0b7589cfd 100644 --- a/test/files/run/t3493.scala +++ b/test/files/run/t3493.scala @@ -3,7 +3,7 @@ object Test { - + def main(args: Array[String]) { import scala.collection.immutable._ val x = TreeSet("a", "b", "c", "d") @@ -11,5 +11,5 @@ object Test { assert(x2.toString == "TreeSet(a, b, c, d, e)") assert(x2.toString == runtime.ScalaRunTime.stringOf(x2).trim) } - + } diff --git a/test/files/run/t3496.scala b/test/files/run/t3496.scala index e1aa032ab1..80a4e6bd86 100644 --- a/test/files/run/t3496.scala +++ b/test/files/run/t3496.scala @@ -4,12 +4,12 @@ // ticket #3496 object Test { - + def main(args: Array[String]) { val s = Stream.from(1) s.take(5) s.drop(5) s.splitAt(5) } - + } diff --git a/test/files/run/t3502.scala b/test/files/run/t3502.scala index cc78e54c86..9492b2d4d4 100644 --- a/test/files/run/t3502.scala +++ b/test/files/run/t3502.scala @@ -5,7 +5,7 @@ // ticket #3502 object Test { - + object GeneratePrimeFactorsLazy extends (Int => List[Int]) { override def apply(n:Int) = { val s = Stream.range(2, n / 2).filter(n % _ == 0) @@ -13,12 +13,12 @@ object Test { s.headOption.map(x => x :: apply(n / x)).getOrElse(List(n)) } } - + def main(args:Array[String]) { // a prime number //val num = 623456789 val num = 2796203 assert(GeneratePrimeFactorsLazy(num) == List(num)) } - + } diff --git a/test/files/run/t3580.scala b/test/files/run/t3580.scala index 50ff6c4551..ac9f81ab9e 100644 --- a/test/files/run/t3580.scala +++ b/test/files/run/t3580.scala @@ -4,14 +4,14 @@ object Test { - + class Empty extends Traversable[Nothing] { def foreach[U](f: Nothing => U) {} } - + def main(args: Array[String]) { val t = new Empty t.toStream } - + } diff --git a/test/files/run/t3603.scala b/test/files/run/t3603.scala index a89cb7080a..a0821a2a45 100644 --- a/test/files/run/t3603.scala +++ b/test/files/run/t3603.scala @@ -2,17 +2,17 @@ object Test { - + def main(args: Array[String]) { import collection.immutable._ - + val intmap = IntMap(1 -> 1, 2 -> 2) val intres = intmap.map { case (a, b) => (a, b.toString) } assert(intres.isInstanceOf[IntMap[_]]) - + val longmap = LongMap(1L -> 1, 2L -> 2) val longres = longmap.map { case (a, b) => (a, b.toString) } assert(longres.isInstanceOf[LongMap[_]]) } - + } diff --git a/test/files/run/t3719.scala b/test/files/run/t3719.scala index 2436e0cdf6..0dd3fc2af9 100644 --- a/test/files/run/t3719.scala +++ b/test/files/run/t3719.scala @@ -1,7 +1,7 @@ object Days extends Enumeration { type Day = DayValue val Mon, Tue, Wed, Thu, Fri, Sat, Sun = new DayValue // DayValue - + protected class DayValue extends Val { def isWeekday: Boolean = this match { @@ -21,7 +21,7 @@ object Test extends Application { val d: Day = Mon d.toString } - + def nameOfTue(): String = { import Days._ val d: Day = Tue diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala index 2d136b5708..33382405e1 100644 --- a/test/files/run/tailcalls.scala +++ b/test/files/run/tailcalls.scala @@ -194,10 +194,10 @@ object FancyTailCalls { } object PolyObject extends Application { - def tramp[A](x: Int): Int = + def tramp[A](x: Int): Int = if (x > 0) tramp[A](x - 1) - else + else 0 } @@ -233,7 +233,7 @@ class NonTailCall { if (n == 0) 0 else f2(n - 1) } - + } //############################################################################ @@ -273,7 +273,7 @@ object Test { } println } - + def check_overflow(name: String, closure: => Int) { print("test " + name) try { @@ -367,7 +367,7 @@ object Test { check_success("TailCall.g3", TailCall.g3(max, max, Nil), 0) check_success("TailCall.h1", TailCall.h1(max, max ), 0) println - + val NonTailCall = new NonTailCall check_success("NonTailCall.f1", NonTailCall.f1(2), 0) check_overflow("NonTailCall.f2", NonTailCall.f2(max)) @@ -382,17 +382,17 @@ object Test { } // testing explicit tailcalls. - + import scala.util.control.TailCalls._ def isEven(xs: List[Int]): TailRec[Boolean] = if (xs.isEmpty) done(true) else tailcall(isOdd(xs.tail)) def isOdd(xs: List[Int]): TailRec[Boolean] = - if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail)) + if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail)) assert(isEven((1 to 100000).toList).result) - + } //############################################################################ diff --git a/test/files/run/takeAndDrop.scala b/test/files/run/takeAndDrop.scala index 8d2dff0bfa..6e87838e11 100644 --- a/test/files/run/takeAndDrop.scala +++ b/test/files/run/takeAndDrop.scala @@ -1,9 +1,9 @@ -object Test { +object Test { def main(args: Array[String]): Unit = { val range = 1 to 10 val target = (3 to 8).toList val confirm = (xs: Seq[Int]) => assert(xs.toList == target, xs) - + confirm(range drop 2 dropRight 2) confirm(range drop 1 dropRight 1 drop 1 dropRight 1) confirm(range take 8 drop 2) diff --git a/test/files/run/tcpoly_monads.scala b/test/files/run/tcpoly_monads.scala index bcfe6d2363..a549caa51a 100644 --- a/test/files/run/tcpoly_monads.scala +++ b/test/files/run/tcpoly_monads.scala @@ -4,15 +4,15 @@ trait Monads { * (>>=) :: m a -> (a -> m b) -> m b * return :: a -> m a * - * MonadTC encodes the above Haskell type class, + * MonadTC encodes the above Haskell type class, * an instance of MonadTC corresponds to a method dictionary. * (see http://lampwww.epfl.ch/~odersky/talks/wg2.8-boston06.pdf) * * Note that the identity (`this') of the method dictionary does not really correspond - * to the instance of m[x] (`self') that is `wrapped': e.g., unit does not use `self' (which + * to the instance of m[x] (`self') that is `wrapped': e.g., unit does not use `self' (which * corresponds to the argument of the implicit conversion that encodes an instance of this type class) */ - trait MonadTC[m[x], a] { + trait MonadTC[m[x], a] { def unit[a](orig: a): m[a] // >>='s first argument comes from the implicit definition constructing this "method dictionary" @@ -27,7 +27,7 @@ trait Monads { */ trait OptionMonad extends Monads { // this implicit method encodes the Monad type class instance for Option - implicit def OptionInstOfMonad[a](self: Option[a]): MonadTC[Option, a] + implicit def OptionInstOfMonad[a](self: Option[a]): MonadTC[Option, a] = new MonadTC[Option, a] { def unit[a](orig: a) = Some(orig) def >>=[b](fun: a => Option[b]): Option[b] = self match { diff --git a/test/files/run/tcpoly_parseridioms.scala b/test/files/run/tcpoly_parseridioms.scala index edc5d5cad8..2747e1bc8d 100644 --- a/test/files/run/tcpoly_parseridioms.scala +++ b/test/files/run/tcpoly_parseridioms.scala @@ -1,10 +1,10 @@ trait Parsers { type Input = List[Char] - + sealed class ParseResult[+t](val next: Input) - case class Success[+t](override val next: Input, result: t) extends ParseResult[t](next) + case class Success[+t](override val next: Input, result: t) extends ParseResult[t](next) case class Failure(override val next: Input, msg: String) extends ParseResult[Nothing](next) - + abstract class Parser[+t] { def apply(in: Input): ParseResult[t] } @@ -16,7 +16,7 @@ trait Parsers { case Success(next2, y) => Success(next2, Pair(x,y)) case Failure(_, msg) => Failure(in, msg) } - case Failure(_, msg) => Failure(in, msg) + case Failure(_, msg) => Failure(in, msg) } } @@ -38,20 +38,20 @@ trait Parsers { case Failure(n, msg) => Failure(n, msg) } } - + def accept[T](c: Char, r: T): Parser[T] = new Parser[T] { def apply(in: Input) = in match { case c2 :: n if c2 == c => Success(n, r) case n => Failure(n, "expected "+c+" at the head of "+n) } } - - def apply_++[s, tt](fun: Parser[s => tt], arg: Parser[s]): Parser[tt] = lift[Pair[s=>tt, s], tt]({case Pair(f, a) => f(a)})(sq(fun, arg)) - + + def apply_++[s, tt](fun: Parser[s => tt], arg: Parser[s]): Parser[tt] = lift[Pair[s=>tt, s], tt]({case Pair(f, a) => f(a)})(sq(fun, arg)) + def success[u](v: u): Parser[u] = new Parser[u] { def apply(in: Input) = Success(in, v) } - + } trait Idioms { @@ -61,21 +61,21 @@ trait Idioms { def pureMethod[a](name: String, x: a): idi[a] = pure(x) // hack for Mirrors: allow passing of method names } - class IdiomaticTarget[idi[x], idiom <: Idiom[idi], s](i: idiom, tgt: s) { + class IdiomaticTarget[idi[x], idiom <: Idiom[idi], s](i: idiom, tgt: s) { def dot [t](fun: s => t, name: String) = new IdiomaticApp2[idi, idiom, t](i, i.liftedApply(i.pureMethod(name, fun))(i.pure(tgt))) } // TODO: `.` --> java.lang.ClassFormatError: Illegal method name "." in class Idioms$Id$ - class IdiomaticFunction[idi[x], idiom <: Idiom[idi], s, t](i: idiom, fun: s => t) { + class IdiomaticFunction[idi[x], idiom <: Idiom[idi], s, t](i: idiom, fun: s => t) { def <| (a: idi[s]) = new IdiomaticApp[idi, idiom, t](i, i.liftedApply(i.pure(fun))(a)) } class IdiomaticApp[idi[x], idiom <: Idiom[idi], x](i: idiom, a: idi[x]) { // where x <: s=>t -- TODO can this be expressed without generalised constraints? def <> [s, t](b: idi[s]) = new IdiomaticApp[idi, idiom, t](i, i.liftedApply(a.asInstanceOf[idi[s=>t]])(b)) - + def |> : idi[x] = a } - + class IdiomaticApp2[idi[x], idiom <: Idiom[idi], x](i: idiom, a: idi[x]) extends IdiomaticApp[idi, idiom, x](i, a) { def <| [s, t](b: idi[s]) = <>[s,t](b) } @@ -86,22 +86,22 @@ trait ParserIdioms extends Parsers with Idioms { def liftedApply[s, t](fun: Parser[s => t])(arg: Parser[s]): Parser[t] = apply_++(fun, arg) def pure[a](x: a): Parser[a] = success(x) } - - implicit def parserIdiomFun[s, t](fun: s=>t): IdiomaticFunction[Parser, ParserIdiom.type, s, t] = + + implicit def parserIdiomFun[s, t](fun: s=>t): IdiomaticFunction[Parser, ParserIdiom.type, s, t] = new IdiomaticFunction[Parser, ParserIdiom.type, s, t](ParserIdiom, fun) - implicit def parserIdiomTgt[s](tgt: s): IdiomaticTarget[Parser, ParserIdiom.type, s] = + implicit def parserIdiomTgt[s](tgt: s): IdiomaticTarget[Parser, ParserIdiom.type, s] = new IdiomaticTarget[Parser, ParserIdiom.type, s](ParserIdiom, tgt) - + trait Expr case class Plus(a: Int, b: Int) extends Expr - + def num = or(accept('0', 0), or(accept('1', 1),accept('2', 2))) - - // TODO: how can parserIdiom(curry2(_)) be omitted? + + // TODO: how can parserIdiom(curry2(_)) be omitted? def expr: Parser[Expr] = parserIdiomFun(curry2(Plus)) <| num <> num |> - + implicit def curry2[s,t,u](fun: (s, t)=>u)(a: s)(b: t) = fun(a, b) - implicit def curry3[r,s,t,u](fun: (r,s, t)=>u)(a: r)(b: s)(c: t) = fun(a, b, c) + implicit def curry3[r,s,t,u](fun: (r,s, t)=>u)(a: r)(b: s)(c: t) = fun(a, b, c) } object Test extends ParserIdioms with Application { diff --git a/test/files/run/treePrint.scala b/test/files/run/treePrint.scala index 1fd1394e25..075ceb5234 100644 --- a/test/files/run/treePrint.scala +++ b/test/files/run/treePrint.scala @@ -3,7 +3,7 @@ object Test { import scala.tools.nsc._ import java.io.{ OutputStream, BufferedReader, StringReader, PrintWriter, Writer, OutputStreamWriter} - + val code = """ def foo = { var q: Boolean = false @@ -21,11 +21,11 @@ object Test { else 20 } else 30 - + (x == 5) || !q || true } - """ - + """ + class NullOutputStream extends OutputStream { def write(b: Int) { } } def main(args: Array[String]) { diff --git a/test/files/run/try-2.scala b/test/files/run/try-2.scala index 909a68bbd2..677f0b48eb 100644 --- a/test/files/run/try-2.scala +++ b/test/files/run/try-2.scala @@ -7,7 +7,7 @@ object Test { - def tryAllUnit: Unit = + def tryAllUnit: Unit = try { throw new Error(); } @@ -15,28 +15,28 @@ object Test { case _ => Console.println("exception happened\n"); } - def tryUnitAll: Unit = + def tryUnitAll: Unit = try { Console.println("Nothin"); } catch { case _ => error("Bad, bad, lama!"); } - def tryAllAll: Unit = + def tryAllAll: Unit = try { throw new Error(); } catch { case _ => error("Bad, bad, lama!"); } - def tryUnitUnit: Unit = + def tryUnitUnit: Unit = try { Console.println("Nothin"); } catch { case _ => Console.println("Nothin"); } - def tryIntUnit: Unit = + def tryIntUnit: Unit = try { 10; } catch { @@ -55,7 +55,7 @@ object Test { execute(tryAllUnit); execute(tryUnitAll); execute(tryAllAll); - execute(tryUnitUnit); + execute(tryUnitUnit); execute(tryIntUnit); } } diff --git a/test/files/run/try.scala b/test/files/run/try.scala index 594c630cc8..7e615ec1a4 100644 --- a/test/files/run/try.scala +++ b/test/files/run/try.scala @@ -17,8 +17,8 @@ object Test extends AnyRef with Application { Console.println( (try { x } catch { case _: Error => 1; - }) - + + }) + + (try { x } catch { case _: Error => 1; }) @@ -116,7 +116,7 @@ object Test extends AnyRef with Application { } */ - + try1; try2; try3; diff --git a/test/files/run/typealias_overriding.scala b/test/files/run/typealias_overriding.scala index 60e783791d..a102b66b79 100644 --- a/test/files/run/typealias_overriding.scala +++ b/test/files/run/typealias_overriding.scala @@ -1,21 +1,21 @@ // this bug (http://scala-webapps.epfl.ch/bugtracking/bugs/displayItem.do?id=1065) -// was caused by Uncurry not normalizing all the types +// was caused by Uncurry not normalizing all the types // (more specifically the argument/return types of an anonymous Function) object Test extends Application { trait AddRemove { type TNode <: NodeImpl; trait NodeImpl; - + object removing { type TNode = AddRemove.this.TNode; def printNode(node: TNode, f: TNode => String) = Console.println(f(node)) } } - + class Linked extends AddRemove { type TNode = Node // can also directly write `class Node extends super.NodeImpl' -- doesn't change the bug class Node extends super.NodeImpl { override def toString = "LinkedNode" } - + removing.printNode(new Node, (x: removing.TNode) => x.toString) // make inference explicit, doesn't affect the bug } diff --git a/test/files/run/unapply.scala b/test/files/run/unapply.scala index acbce58d35..7b746af997 100644 --- a/test/files/run/unapply.scala +++ b/test/files/run/unapply.scala @@ -23,7 +23,7 @@ object Faa { def unapply(x: Any): Option[String] = if(x.isInstanceOf[Bar]) Some(x.asInstanceOf[Bar].name) else None } object FaaPrecise { - def unapply(x: Bar): Option[String] = Some(x.name) + def unapply(x: Bar): Option[String] = Some(x.name) } object FaaPreciseSome { def unapply(x: Bar) = Some(x.name) // return type Some[String] @@ -94,7 +94,7 @@ object LisSeqArr extends TestCase("LisSeqArr") with Assert { //assertEquals((Array(1,2,3): Any) match { case Array(x,y,_*) => {x,y}}, {1,2}) // just compile, feature request #1196 -// (List(1,2,3): Any) match { +// (List(1,2,3): Any) match { // case a @ List(x,y,_*) => foo(a) // } @@ -120,14 +120,14 @@ object Test1256 extends TestCase("1256") { class Sync { def unapply(scrut: Any): Boolean = false } - + class Buffer { val Get = new Sync - + val jp: PartialFunction[Any, Any] = { case Get() => } } - + override def runTest { assertFalse((new Buffer).jp.isDefinedAt(42)) } } diff --git a/test/files/run/unittest_collection.scala b/test/files/run/unittest_collection.scala index d45c23d4b5..dd95540359 100644 --- a/test/files/run/unittest_collection.scala +++ b/test/files/run/unittest_collection.scala @@ -6,7 +6,7 @@ object Test { trait BufferTest extends Assert { def doTest(x:Buffer[String]) = { - // testing method += + // testing method += x += "one" assertEquals("retrieving 'one'", x(0), "one") assertEquals("length A ", x.length, 1) @@ -19,12 +19,12 @@ object Test { assertEquals("length C ", x.length, 1) - try { x(1); fail("no exception for removed element") } + try { x(1); fail("no exception for removed element") } catch { case i:IndexOutOfBoundsException => } - try { x.remove(1); fail("no exception for removed element") } + try { x.remove(1); fail("no exception for removed element") } catch { case i:IndexOutOfBoundsException => } - + x += "two2" assertEquals("length D ", x.length, 2) @@ -38,7 +38,7 @@ object Test { // clear x.clear assertEquals("length F ", x.length, 0) - + // copyToBuffer x += "a" x += "b" @@ -54,7 +54,7 @@ object Test { var x: ArrayBuffer[String] = _ override def runTest = { setUp; doTest(x); tearDown } - + override def setUp = { x = new scala.collection.mutable.ArrayBuffer } override def tearDown = { x.clear; x = null } @@ -90,8 +90,8 @@ object Test { def main(args:Array[String]) = { val ts = new TestSuite( - //new TArrayBuffer, - new TListBuffer//, + //new TArrayBuffer, + new TListBuffer//, //new TBufferProxy ) val tr = new TestResult() diff --git a/test/files/run/unittest_io.scala b/test/files/run/unittest_io.scala index 974dcff5b3..c2d95a3a7e 100644 --- a/test/files/run/unittest_io.scala +++ b/test/files/run/unittest_io.scala @@ -5,7 +5,7 @@ object Test extends TestConsoleMain { class UTF8Tests extends TestCase("UTF8Codec") { import io.UTF8Codec.encode - + def runTest { assertEquals(new String( encode(0x004D), "utf8"), new String(Array(0x004D.asInstanceOf[Char]))) assertEquals(new String( encode(0x0430), "utf8"), new String(Array(0x0430.asInstanceOf[Char]))) @@ -31,7 +31,7 @@ object Test extends TestConsoleMain { f.copyToBuffer(b) assertEquals(s, new String(b.toArray)) - /* todo: same factories for BufferedSource and Source + /* todo: same factories for BufferedSource and Source val g = io.BufferedSource.fromBytes(s.getBytes("utf-8")) val c = new collection.mutable.ArrayBuffer[Char]() g.copyToBuffer(c) diff --git a/test/files/run/unittest_iterator.scala b/test/files/run/unittest_iterator.scala index 21dc64c3c5..89ccdb9d58 100644 --- a/test/files/run/unittest_iterator.scala +++ b/test/files/run/unittest_iterator.scala @@ -1,5 +1,5 @@ // Some iterator grouped/sliding unit tests -object Test { +object Test { def it = (1 to 10).iterator def assertThat[T](expectedLength: Int, expectedLast: Seq[T])(it: Iterator[Seq[T]]) { val xs = it.toList @@ -7,15 +7,15 @@ object Test { assert(xs.size == expectedLength, fail("expected length " + expectedLength)) assert(xs.last == expectedLast, fail("expected last " + expectedLast)) } - + def main(args: Array[String]): Unit = { val itSum = it.toStream.sum for (i <- it) { // sum of the groups == sum of the original val thisSum = ((it grouped i) map (_.sum)).toStream.sum - assert(thisSum == itSum, thisSum + " != " + itSum) + assert(thisSum == itSum, thisSum + " != " + itSum) } - + // grouped assertThat(4, List(10)) { it grouped 3 } assertThat(3, List(7, 8, 9)) { it grouped 3 withPartial false } @@ -32,11 +32,11 @@ object Test { assertThat(1, (1 to 8).toList) { it.sliding(8, 8) withPartial false } assertThat(2, List(9, 10, -1, -1, -1)) { it.sliding(5, 8) withPadding -1 } assertThat(1, (1 to 5).toList) { it.sliding(5, 8) withPartial false } - + // larger step than window assertThat(5, List(9)) { it.sliding(1, 2) } assertThat(3, List(9, 10)) { it.sliding(2, 4) } - + // make sure it throws past the end val thrown = try { val it = List(1,2,3).sliding(2) diff --git a/test/files/run/vector1.scala b/test/files/run/vector1.scala index e8785e2b16..b37cfe82e8 100644 --- a/test/files/run/vector1.scala +++ b/test/files/run/vector1.scala @@ -9,7 +9,7 @@ import scala.collection.mutable.Builder object Test { - + def vector(label: String, n: Int): Vector[String] = { val a = new VectorBuilder[String] for (i <- 0 until n) @@ -67,7 +67,7 @@ object Test { def test1() = { println("===== test1 =====") - + val N = 150000 val a = vector("a", N) val b = vectorForward("b", N) @@ -81,22 +81,22 @@ object Test { println("===== test2 =====") var a: Vector[String] = Vector.empty - + val rand = new java.util.Random - + val N = 150000 var min = N/2//rand.nextInt(N) var max = min - + val chunkLimit = 11 - + def nextChunkSize = 3 //rand.nextInt(chunkLimit) - + def seqBack() = for (i <- 0 until Math.min(nextChunkSize, N-max)) { a = a :+ ("a"+max); max += 1 } def seqFront() = for (i <- 0 until Math.min(nextChunkSize, min)) { min -= 1; a = ("a"+min) +: a } - + try { - + while (min > 0 || max < N) { seqFront() seqBack() @@ -107,7 +107,7 @@ object Test { //a.debug throw ex } - + assertVector(a, "a", 0, N) } @@ -122,14 +122,14 @@ object Test { val pos = scala.util.Random.shuffle(scala.collection.mutable.WrappedArray.make[Int](Array.tabulate[Int](N)(i => i))) var b = a - + { var i = 0 while (i < N) { b = b.updated(pos(i), "b"+(pos(i))) i += 1 } - + assertVector(b, "b", 0, N) } diff --git a/test/files/run/viewtest.scala b/test/files/run/viewtest.scala index 833c0101e3..c5dffa5dbd 100755 --- a/test/files/run/viewtest.scala +++ b/test/files/run/viewtest.scala @@ -26,8 +26,8 @@ object Test extends Application { 2.8 regression: CCE when zipping list projection with stream Reported by: szeiger Owned by: odersky Priority: normal Component: Standard Library -Keywords: collections, zip Cc: -Fixed in version: +Keywords: collections, zip Cc: +Fixed in version: Description Welcome to Scala version 2.8.0.r18784-b20090925021043 (Java HotSpot(TM) Client VM, Java 1.6.0_11). diff --git a/test/files/run/xml-loop-bug.scala b/test/files/run/xml-loop-bug.scala index 3894779f7c..378ae9bc2b 100644 --- a/test/files/run/xml-loop-bug.scala +++ b/test/files/run/xml-loop-bug.scala @@ -1,6 +1,6 @@ object Test { def main(args: Array[String]): Unit = { scala.tools.nsc.io.NullPrintStream.setOutAndErr() - scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString("<!DOCTYPE xmeml SYSTEM> <xmeml> <sequence> </sequence> </xmeml> "), true).document.docElem + scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString("<!DOCTYPE xmeml SYSTEM> <xmeml> <sequence> </sequence> </xmeml> "), true).document.docElem } } diff --git a/test/files/scalap/caseClass/A.scala b/test/files/scalap/caseClass/A.scala index be86714898..95f9984519 100644 --- a/test/files/scalap/caseClass/A.scala +++ b/test/files/scalap/caseClass/A.scala @@ -1,3 +1,3 @@ case class CaseClass[A <: Seq[Int]](i: A, s: String) { - def foo = 239 + def foo = 239 } diff --git a/test/files/scalap/caseObject/A.scala b/test/files/scalap/caseObject/A.scala index 809341ade9..6a3ff10d75 100644 --- a/test/files/scalap/caseObject/A.scala +++ b/test/files/scalap/caseObject/A.scala @@ -1,3 +1,3 @@ case object CaseObject { - def bar = 239 + def bar = 239 } diff --git a/test/files/scalap/cbnParam/A.scala b/test/files/scalap/cbnParam/A.scala index 978a718032..2f366df64a 100644 --- a/test/files/scalap/cbnParam/A.scala +++ b/test/files/scalap/cbnParam/A.scala @@ -1 +1 @@ -class CbnParam(s: => String) +class CbnParam(s: => String) diff --git a/test/files/script/t1017.scala b/test/files/script/t1017.scala index d1b43ea923..2600f4f553 100755 --- a/test/files/script/t1017.scala +++ b/test/files/script/t1017.scala @@ -23,7 +23,7 @@ exec scala -nocompdaemon "$SOURCE" "$@" def foo = { bar } - + var x = 1 - + def bar = 1 diff --git a/test/partest-tests/run/streamWithFilter.scala b/test/partest-tests/run/streamWithFilter.scala index cb919d4f55..7f8f9a09d2 100644 --- a/test/partest-tests/run/streamWithFilter.scala +++ b/test/partest-tests/run/streamWithFilter.scala @@ -4,7 +4,7 @@ object Test { def isBuzz(x: Int) = x % 5 == 0 // next line will run forever if withFilter isn't doing its thing. val fizzbuzzes = for (n <- nums ; if isFizz(n) ; if isBuzz(n)) yield n - + def main(args: Array[String]): Unit = { fizzbuzzes take 5 foreach println } diff --git a/test/pending/continuations-run/example0.scala b/test/pending/continuations-run/example0.scala index 44b1331339..de5ea54e9d 100644 --- a/test/pending/continuations-run/example0.scala +++ b/test/pending/continuations-run/example0.scala @@ -1,9 +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 index 195a98e59f..e31d6af88c 100644 --- a/test/pending/continuations-run/example1.scala +++ b/test/pending/continuations-run/example1.scala @@ -1,9 +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 index 5eb64046ed..561f0ab0eb 100644 --- a/test/pending/continuations-run/example16.scala +++ b/test/pending/continuations-run/example16.scala @@ -1,9 +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 index 0d96257c40..730f7cc63e 100644 --- a/test/pending/continuations-run/example2.scala +++ b/test/pending/continuations-run/example2.scala @@ -1,9 +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 index 3f5052a4ad..41cf1cce0c 100644 --- a/test/pending/continuations-run/example3.scala +++ b/test/pending/continuations-run/example3.scala @@ -1,9 +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 index 66c6774791..adcc7aa90e 100644 --- a/test/pending/continuations-run/example4.scala +++ b/test/pending/continuations-run/example4.scala @@ -1,9 +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 index 0994bdee8a..241e8cd069 100644 --- a/test/pending/continuations-run/example5.scala +++ b/test/pending/continuations-run/example5.scala @@ -1,9 +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 index 5207e3fc68..00f84fcd6c 100644 --- a/test/pending/continuations-run/example6.scala +++ b/test/pending/continuations-run/example6.scala @@ -1,9 +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 index fb22387dac..64abc6d9a6 100644 --- a/test/pending/continuations-run/example7.scala +++ b/test/pending/continuations-run/example7.scala @@ -1,9 +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 index 8e21e6c674..a5f953d3fc 100644 --- a/test/pending/continuations-run/example8.scala +++ b/test/pending/continuations-run/example8.scala @@ -1,9 +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 index 0f27c686f7..09d792c427 100644 --- a/test/pending/continuations-run/example9.scala +++ b/test/pending/continuations-run/example9.scala @@ -1,9 +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.scala b/test/pending/continuations-run/foreach.scala index 4daade452c..76823e7604 100644 --- a/test/pending/continuations-run/foreach.scala +++ b/test/pending/continuations-run/foreach.scala @@ -5,16 +5,16 @@ 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) @@ -22,12 +22,12 @@ object Test { else println("enough is enough") } - + } - + } - - + + } - + }
\ No newline at end of file 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/natives.scala b/test/pending/jvm/natives.scala index 14ee4e1c1b..ba868dc85e 100644 --- a/test/pending/jvm/natives.scala +++ b/test/pending/jvm/natives.scala @@ -1,16 +1,16 @@ object Test { //println("java.library.path=" + System.getProperty("java.library.path")) - + val sysWordSize = System.getProperty("sun.arch.data.model", "32") val sysType = System.getProperty("os.name") - + val libName = if (sysType == "Mac OS X") "natives" else "natives-" + sysWordSize - + System.loadLibrary(libName) @native 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 index 5dffb5ebe6..e1ecab2a15 100644 --- a/test/pending/neg/bug112506A.scala +++ b/test/pending/neg/bug112506A.scala @@ -7,7 +7,7 @@ trait TypeManagerXXX { } trait ScalaTyperXXX extends TypeManagerXXX { private var typed : Node = null; - private val dependMap = new HashMap[String,ListSet[TypedNode]]; + private val dependMap = new HashMap[String,ListSet[TypedNode]]; override def lookupEntry(name: String): String = { val set = dependMap.get(name) match { case Some(set) => set; diff --git a/test/pending/neg/bug1210.scala b/test/pending/neg/bug1210.scala index fc2c954ff2..58ef50b497 100644 --- a/test/pending/neg/bug1210.scala +++ b/test/pending/neg/bug1210.scala @@ -1,6 +1,6 @@ object Test { def id[T](f: T => T): T = error("bla") - + abstract class M { self => type Settings type selfType = M {type Settings = self.Settings} diff --git a/test/pending/neg/plugin-after-terminal/src/ThePlugin.scala b/test/pending/neg/plugin-after-terminal/src/ThePlugin.scala index f3c913086e..2a4607392f 100644 --- a/test/pending/neg/plugin-after-terminal/src/ThePlugin.scala +++ b/test/pending/neg/plugin-after-terminal/src/ThePlugin.scala @@ -12,7 +12,7 @@ class ThePlugin(val global: Global) extends Plugin { 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 @@ -20,9 +20,9 @@ class ThePlugin(val global: Global) extends Plugin { val phaseName = ThePlugin.this.name - def newPhase(prev: Phase) = new ThePhase(prev) + 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/src/ThePlugin.scala b/test/pending/neg/plugin-before-parser/src/ThePlugin.scala index 8714a55dc4..7ca896650d 100644 --- a/test/pending/neg/plugin-before-parser/src/ThePlugin.scala +++ b/test/pending/neg/plugin-before-parser/src/ThePlugin.scala @@ -12,7 +12,7 @@ class ThePlugin(val global: Global) extends Plugin { 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 @@ -21,9 +21,9 @@ class ThePlugin(val global: Global) extends Plugin { val phaseName = ThePlugin.this.name - def newPhase(prev: Phase) = new ThePhase(prev) + 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/src/ThePlugin.scala b/test/pending/neg/plugin-cyclic-dependency/src/ThePlugin.scala index 1dfc15cb28..bd94ce60d7 100644 --- a/test/pending/neg/plugin-cyclic-dependency/src/ThePlugin.scala +++ b/test/pending/neg/plugin-cyclic-dependency/src/ThePlugin.scala @@ -12,7 +12,7 @@ class ThePlugin(val global: Global) extends Plugin { 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 @@ -20,9 +20,9 @@ class ThePlugin(val global: Global) extends Plugin { val phaseName = ThePlugin.this.name + "1" - def newPhase(prev: Phase) = new ThePhase(prev) + def newPhase(prev: Phase) = new ThePhase(prev) } - + private object thePhase2 extends PluginComponent { val global = ThePlugin.this.global @@ -30,9 +30,9 @@ class ThePlugin(val global: Global) extends Plugin { val phaseName = ThePlugin.this.name + "2" - def newPhase(prev: Phase) = new ThePhase(prev) + 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/src/ThePlugin.scala b/test/pending/neg/plugin-multiple-rafter/src/ThePlugin.scala index 4c761517c1..819176fa88 100644 --- a/test/pending/neg/plugin-multiple-rafter/src/ThePlugin.scala +++ b/test/pending/neg/plugin-multiple-rafter/src/ThePlugin.scala @@ -12,7 +12,7 @@ class ThePlugin(val global: Global) extends Plugin { val name = "multi-rafter" val description = "" val components = List[PluginComponent](thePhase) - + private object thePhase extends PluginComponent { val global = ThePlugin.this.global @@ -20,9 +20,9 @@ class ThePlugin(val global: Global) extends Plugin { override val runsRightAfter = Some("explicitouter") val phaseName = ThePlugin.this.name - def newPhase(prev: Phase) = new ThePhase(prev) + 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/src/ThePlugin.scala b/test/pending/neg/plugin-rafter-before-1/src/ThePlugin.scala index c42a914066..81ba85ae80 100644 --- a/test/pending/neg/plugin-rafter-before-1/src/ThePlugin.scala +++ b/test/pending/neg/plugin-rafter-before-1/src/ThePlugin.scala @@ -12,7 +12,7 @@ class ThePlugin(val global: Global) extends Plugin { val name = "rafter-before-1" val description = "" val components = List[PluginComponent](thePhase1) - + private object thePhase1 extends PluginComponent { val global = ThePlugin.this.global @@ -20,9 +20,9 @@ class ThePlugin(val global: Global) extends Plugin { override val runsBefore = List[String]("erasure") val phaseName = ThePlugin.this.name - def newPhase(prev: Phase) = new ThePhase(prev) + 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/src/ThePlugin.scala b/test/pending/neg/plugin-rightafter-terminal/src/ThePlugin.scala index 47dd06ec8a..9d6d30b327 100644 --- a/test/pending/neg/plugin-rightafter-terminal/src/ThePlugin.scala +++ b/test/pending/neg/plugin-rightafter-terminal/src/ThePlugin.scala @@ -12,18 +12,18 @@ class ThePlugin(val global: Global) extends Plugin { 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) + 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/t1477.scala b/test/pending/neg/t1477.scala index 0cc0cd5f7a..3ecd275a55 100644 --- a/test/pending/neg/t1477.scala +++ b/test/pending/neg/t1477.scala @@ -8,7 +8,7 @@ object Test extends Application { type V <: D val y: V#T = new B { } } - + trait Middle extends C { type V <: (D with U) } diff --git a/test/pending/neg/t2079.scala b/test/pending/neg/t2079.scala index a86674c7e0..d60910321b 100644 --- a/test/pending/neg/t2079.scala +++ b/test/pending/neg/t2079.scala @@ -4,8 +4,8 @@ trait A { } 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/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/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/pos/bug0305.scala b/test/pending/pos/bug0305.scala index 433f0e72c3..1fc66788b1 100644 --- a/test/pending/pos/bug0305.scala +++ b/test/pending/pos/bug0305.scala @@ -1,5 +1,5 @@ object Test extends Application { - + def foo(is:int*) = 1; def foo(i:int) = 2; diff --git a/test/pending/pos/bug112606B.scala b/test/pending/pos/bug112606B.scala index 6dfaf4bf01..3e50949ef2 100644 --- a/test/pending/pos/bug112606B.scala +++ b/test/pending/pos/bug112606B.scala @@ -5,7 +5,7 @@ trait Test2 { 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; + // required: Test2.this.KeywordToken + case Token("final") => true; } } diff --git a/test/pending/pos/bug1357.scala b/test/pending/pos/bug1357.scala index fcdecb3ad3..7bc6d45034 100644 --- a/test/pending/pos/bug1357.scala +++ b/test/pending/pos/bug1357.scala @@ -6,7 +6,7 @@ object NonEmptyCons { 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]] }] diff --git a/test/pending/pos/bug563.scala b/test/pending/pos/bug563.scala index d559226bdb..927773d1e5 100644 --- a/test/pending/pos/bug563.scala +++ b/test/pending/pos/bug563.scala @@ -1,6 +1,6 @@ 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 index 3a69cde4a6..31eac9370c 100644 --- a/test/pending/pos/bug572.scala +++ b/test/pending/pos/bug572.scala @@ -14,15 +14,15 @@ object DirX { 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) = + 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); diff --git a/test/pending/pos/bug573.scala b/test/pending/pos/bug573.scala index b1b4f75098..c3d68107ff 100644 --- a/test/pending/pos/bug573.scala +++ b/test/pending/pos/bug573.scala @@ -16,15 +16,15 @@ 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) = + private def set(dir : Dir, node : Node) = if (dir == BEFORE) prev = node; else next = node; def link(dir : Dir, node : Node) = { @@ -34,7 +34,7 @@ abstract class Linked { 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/bug579.scala b/test/pending/pos/bug579.scala index a0806919e0..c42ac172fa 100644 --- a/test/pending/pos/bug579.scala +++ b/test/pending/pos/bug579.scala @@ -8,7 +8,7 @@ class MyBean { } object Test extends Application { - + val x = new MyBean; x.frombulizer = "hello" diff --git a/test/pending/pos/bug586.scala b/test/pending/pos/bug586.scala index b736e6ab43..f07d0cd2a7 100644 --- a/test/pending/pos/bug586.scala +++ b/test/pending/pos/bug586.scala @@ -2,11 +2,11 @@ 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 +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) @@ -20,13 +20,13 @@ abstract class Goal2 { type Question val question: Question - type Answer + type Answer def initialAnswer: Answer } -abstract class AbstractRespondersGoal +abstract class AbstractRespondersGoal extends Goal2 // TYPEFIX -- comment out the extends Goal2 { } @@ -68,7 +68,7 @@ class RespondersGoalSet // 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/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 index 4f7346f57f..40f0e54f63 100644 --- a/test/pending/pos/moors.scala +++ b/test/pending/pos/moors.scala @@ -7,6 +7,6 @@ object Test { 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")} + + class Bar { def baz = System.out.println("baz")} } 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/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/t0756.scala b/test/pending/pos/t0756.scala index a778bd63d0..8011a9c526 100644 --- a/test/pending/pos/t0756.scala +++ b/test/pending/pos/t0756.scala @@ -2,7 +2,7 @@ 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 index 565a2a6527..c6348f45e3 100644 --- a/test/pending/pos/t0805.scala +++ b/test/pending/pos/t0805.scala @@ -3,7 +3,7 @@ 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/t1004.scala b/test/pending/pos/t1004.scala index e86631acea..e121d13618 100644 --- a/test/pending/pos/t1004.scala +++ b/test/pending/pos/t1004.scala @@ -1,6 +1,6 @@ object A { def main(args: Array[String]) = { val x = new { def copy(a : this.type) = a }; - x.copy(x) + x.copy(x) } } diff --git a/test/pending/pos/t1380/hallo.scala b/test/pending/pos/t1380/hallo.scala index 27ecd9fb8b..bb8fff2333 100644 --- a/test/pending/pos/t1380/hallo.scala +++ b/test/pending/pos/t1380/hallo.scala @@ -1,3 +1,3 @@ object hallo { - def main(args:Array[String]) = println("hallo") + def main(args:Array[String]) = println("hallo") } 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/unappgadteval.scala b/test/pending/pos/unappgadteval.scala index 0c22c71dee..007d57d7ea 100644 --- a/test/pending/pos/unappgadteval.scala +++ b/test/pending/pos/unappgadteval.scala @@ -11,21 +11,21 @@ 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] // Environments : -abstract class Env { +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 { + 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 { +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 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/bug837/DeadCode.scala b/test/pending/res/bug837/DeadCode.scala index 2978e24d42..c63af909af 100644 --- a/test/pending/res/bug837/DeadCode.scala +++ b/test/pending/res/bug837/DeadCode.scala @@ -1,6 +1,6 @@ package test; trait DeadcodeAnalysis { - object liveness extends Liveness; + object liveness extends Liveness; val a = new liveness.LivenessAnalysis(); var live = a.out("hello"); } diff --git a/test/pending/run/array_casts.scala b/test/pending/run/array_casts.scala index 9d298bbc2b..4940f9419b 100644 --- a/test/pending/run/array_casts.scala +++ b/test/pending/run/array_casts.scala @@ -24,7 +24,7 @@ object Test { try { Console.println(a.asInstanceOf[RandomAccessSeq.Mutable[_]]) } catch { case ex : ClassCastException => Console.println("Bad, arrays should be mutable random access seqs") } - try { + try { Console.println("not expected: " + a.asInstanceOf[List[_]]) } catch { case ex : ClassCastException => Console.println("Good, arrays are not lists") } try { @@ -38,5 +38,5 @@ object Test { 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.scala b/test/pending/run/arrays-2.scala index bee22db577..5f8096deec 100644 --- a/test/pending/run/arrays-2.scala +++ b/test/pending/run/arrays-2.scala @@ -20,6 +20,6 @@ object Test extends Application { println("a2=" + _toString(a2)) util.Sorting.stableSort(a2) println("a2=" + _toString(a2)) - + println(a1 deepEquals a3) } diff --git a/test/pending/run/bug2087.scala b/test/pending/run/bug2087.scala index b3f96fa415..787e411115 100644 --- a/test/pending/run/bug2087.scala +++ b/test/pending/run/bug2087.scala @@ -2,7 +2,7 @@ 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/bug2365/Test.scala b/test/pending/run/bug2365/Test.scala index 92b58f4a25..75f0c39b2f 100644 --- a/test/pending/run/bug2365/Test.scala +++ b/test/pending/run/bug2365/Test.scala @@ -17,17 +17,17 @@ object Test 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 ivyJar = File("/local/lib/java/ivy.jar").toURL // load a class in a separate loader that will be passed to A val loader = new java.net.URLClassLoader(Array(File(".").toURL, ivyJar)) // load a real class to fill perm gen space - Class.forName("org.apache.ivy.Ivy", true, loader).newInstance + Class.forName("org.apache.ivy.Ivy", 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/run/bug3050.scala b/test/pending/run/bug3050.scala index aaec99ec14..2b85149d7c 100644 --- a/test/pending/run/bug3050.scala +++ b/test/pending/run/bug3050.scala @@ -1,9 +1,10 @@ object Test { def main(args: Array[String]): Unit = { - val x = + val x = try { ("": Any) match { case List(_*) => true } } catch { case _ => false } - + assert(x == false) } } +
\ No newline at end of file diff --git a/test/pending/run/bug3150.scala b/test/pending/run/bug3150.scala index 034703b5f7..8acdb50354 100644 --- a/test/pending/run/bug3150.scala +++ b/test/pending/run/bug3150.scala @@ -1,7 +1,7 @@ object Test { case object Bob { override def equals(other: Any) = true } def f(x: Any) = x match { case Bob => Bob } - + def main(args: Array[String]): Unit = { assert(f(Bob) eq Bob) assert(f(0) eq Bob) diff --git a/test/pending/run/bug874.scala b/test/pending/run/bug874.scala index 29dfabe0e9..f8d14eec09 100644 --- a/test/pending/run/bug874.scala +++ b/test/pending/run/bug874.scala @@ -5,7 +5,7 @@ object Test { } U("xyz")(2) } - class Mix extends Base { + class Mix extends Base { case class U[A](x1: A)(x2: int) { Console.println("U created with "+x1+" and "+x2) } diff --git a/test/pending/run/castsingleton.scala b/test/pending/run/castsingleton.scala index 171b380dc9..59c912e092 100644 --- a/test/pending/run/castsingleton.scala +++ b/test/pending/run/castsingleton.scala @@ -7,4 +7,4 @@ object Test extends Application { } empty(L()) -} +} diff --git a/test/pending/run/collections.scala b/test/pending/run/collections.scala index 6717b524bb..ea8149e16a 100644 --- a/test/pending/run/collections.scala +++ b/test/pending/run/collections.scala @@ -60,7 +60,7 @@ object Test extends Application { } time { var x = 0 - for (val i <- (0 to 10000)) + for (val i <- (0 to 10000)) s get i match { case Some(i) => x = x + i case None => @@ -81,7 +81,7 @@ object Test extends Application { } time { var x = 0 - for (val i <- (0 to 10000)) + for (val i <- (0 to 10000)) s get i match { case Some(i) => x = x + i case None => diff --git a/test/pending/run/deprecated.scala b/test/pending/run/deprecated.scala index 122e339d2f..0b3919aa76 100644 --- a/test/pending/run/deprecated.scala +++ b/test/pending/run/deprecated.scala @@ -2,16 +2,16 @@ 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" } @@ -21,15 +21,15 @@ object Test { [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 + val blue = new BlueStuff // warning: RedStuff will be abstract after deprecated methods are removed - val red = new RedStuff - + val red = new RedStuff + // warning: dostuff is deprecated - blue.dostuff - } + blue.dostuff + } } diff --git a/test/pending/run/instanceOfAndTypeMatching.scala b/test/pending/run/instanceOfAndTypeMatching.scala index 9ab2d6c3c4..5273060c25 100644 --- a/test/pending/run/instanceOfAndTypeMatching.scala +++ b/test/pending/run/instanceOfAndTypeMatching.scala @@ -6,9 +6,9 @@ object Summary { 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. // @@ -20,7 +20,7 @@ object Summary { // 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 @@ -44,13 +44,13 @@ class Outer { 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 @@ -58,16 +58,16 @@ class Outer { } } 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 comparePathWithInstanceOf(other: Any) = other.isInstanceOf[Outer.this.Inner] } - + def f() = { - class MethodInner { + 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 @@ -75,19 +75,19 @@ class Outer { 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 +object Test { val outer1 = new Outer val outer2 = new Outer @@ -95,7 +95,7 @@ object Test val inner2 = new outer2.Inner val method1 = outer1.f() val method2 = outer2.f() - + def testInnerStatic = { // these should all work inner1.passOuter(outer1) @@ -105,7 +105,7 @@ object Test inner1.passInner2(inner1) inner1.passInnerSharp(inner1) inner1.passInnerSharp(inner2) - + // these should all fail to compile, and do // // inner1.passThisType(outer2) @@ -114,30 +114,30 @@ object Test } def testInnerRuntime = { println("testInnerRuntime\n") - + List("These should be true under any scenario: ", - inner1.isInstanceOf[outer1.Inner] , + inner1.isInstanceOf[outer1.Inner] , inner1.isInstanceOf[Outer#Inner] , inner1 match { case _: Outer#Inner => true ; case _ => false } , inner1 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) + inner1.compareSimpleWithInstanceOf(inner2) ) foreach println - + List("These should be false under current proposal: ", inner1.compareSimpleWithTypeMatch(inner2) , - inner1.comparePathWithTypeMatch(inner2) + inner1.comparePathWithTypeMatch(inner2) ) foreach println - - List("These return true but I think should return false: ", + + 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 match { case _: outer2.Inner => true ; case _ => false } // should be false ) foreach println @@ -160,7 +160,7 @@ object Test // method1.passMethodInner(method1) // ^ // method1.passMethodInner(method1) - + // these should all fail to compile, and do // // method1.passThisType(outer2) @@ -168,24 +168,24 @@ object Test // 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) + 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/records.scala b/test/pending/run/records.scala index 87b15265f2..edab6b46fb 100644 --- a/test/pending/run/records.scala +++ b/test/pending/run/records.scala @@ -16,10 +16,10 @@ object Test { 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/string-reverse.scala b/test/pending/run/string-reverse.scala index 51b16bcd6a..976a970dec 100644 --- a/test/pending/run/string-reverse.scala +++ b/test/pending/run/string-reverse.scala @@ -6,13 +6,13 @@ object Test { 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) 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/t0807.scala b/test/pending/run/t0807.scala index e69aa1c71c..b4aa0b14a4 100644 --- a/test/pending/run/t0807.scala +++ b/test/pending/run/t0807.scala @@ -1,5 +1,5 @@ trait A -trait B extends A { val x = println("early") } +trait B extends A { val x = println("early") } object Test extends Application { new B {} } diff --git a/test/pending/run/t0947.scala b/test/pending/run/t0947.scala index f5daca3d30..c93ee40fda 100644 --- a/test/pending/run/t0947.scala +++ b/test/pending/run/t0947.scala @@ -1,6 +1,6 @@ import scala.tools.nsc._ -object Test extends Application { +object Test extends Application { class Foo { override def toString = "Foo" }; val int = new Interpreter(new Settings()); diff --git a/test/pending/run/t1980.scala b/test/pending/run/t1980.scala index 67cb3ada9e..9ecf5a4100 100644 --- a/test/pending/run/t1980.scala +++ b/test/pending/run/t1980.scala @@ -2,7 +2,7 @@ by-name argument incorrectly evaluated on :-ending operator Reported by: extempore Owned by: odersky Priority: normal Component: Compiler Keywords: Cc: paulp@… -Fixed in version: +Fixed in version: Description scala> def foo() = { println("foo") ; 5 } diff --git a/test/pending/scalacheck/CheckEither.scala b/test/pending/scalacheck/CheckEither.scala index a6c728451b..767ae7739e 100644 --- a/test/pending/scalacheck/CheckEither.scala +++ b/test/pending/scalacheck/CheckEither.scala @@ -16,7 +16,7 @@ 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]] = + 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) @@ -27,7 +27,7 @@ object CheckEither { 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 { @@ -50,7 +50,7 @@ object CheckEither { 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)}) @@ -159,7 +159,7 @@ object CheckEither { } 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 { @@ -172,33 +172,33 @@ object CheckEither { case Right(ee) => Either.joinRight(e) == ee }) - val prop_Either_lefts = property((es: List[Either[Int, Int]]) => + 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]]) => + + 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]]) => + + 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) => + + 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]) => + + 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]) => + 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))) + Either.iif(c, a, b) == (if(c) Right(b) else Left(a))) val tests = List( ("prop_either1", prop_either1), @@ -234,20 +234,20 @@ object CheckEither { ("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_right", prop_Either_right), ("prop_Either_joinLeft", prop_Either_joinLeft), - ("prop_Either_joinRight", prop_Either_joinRight), + ("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_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) => + + 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/array.scala b/test/pending/scalacheck/array.scala index 03c0217180..f262bc6320 100644 --- a/test/pending/scalacheck/array.scala +++ b/test/pending/scalacheck/array.scala @@ -11,7 +11,7 @@ object Test extends Properties("Array") { */ implicit def arbArray[T](implicit a: Arbitrary[T], m: Manifest[T]): Arbitrary[Array[T]] = Arbitrary(containerOf[List,T](arbitrary[T]) map (_.toArray)) - + val arrGen: Gen[Array[_]] = oneOf( arbitrary[Array[Int]], arbitrary[Array[Array[Int]]], @@ -20,7 +20,7 @@ object Test extends Properties("Array") { arbitrary[Array[Boolean]], arbitrary[Array[AnyVal]] ) - + // inspired by #1857 and #2352 property("eq/ne") = forAll(arrGen, arrGen) { (c1, c2) => (c1 eq c2) || (c1 ne c2) @@ -32,6 +32,6 @@ object Test extends Properties("Array") { val arr = Array.ofDim[String](i1, i2, i3) val flattened = arr flatMap (x => x) flatMap (x => x) flattened.length == i1 * i2 * i3 - } + } } diff --git a/test/pending/scalacheck/eqeq.scala b/test/pending/scalacheck/eqeq.scala index 60fe63c207..a783805e46 100644 --- a/test/pending/scalacheck/eqeq.scala +++ b/test/pending/scalacheck/eqeq.scala @@ -4,7 +4,7 @@ import Gen._ object Test extends Properties("==") { def equalObjectsEqualHashcodes(x: Any, y: Any) = (x != y) || (x == y && x.## == y.##) - + // ticket #2087 property("short/char") = forAll { (x: Short) => { val ch: Char = x.toChar @@ -14,15 +14,15 @@ object Test extends Properties("==") { property("symmetry") = forAll { (x: AnyVal, y: AnyVal) => (x == y) == (y == x) } property("transitivity") = forAll { (x: AnyVal, y: AnyVal, z: AnyVal) => x != y || y != z || x == z } - - property("##") = forAll { + + property("##") = forAll { (x: Short) => { val anyvals = List(x.toByte, x.toChar, x, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x)) val shortAndLarger = anyvals drop 2 val result = ( - ((anyvals, anyvals).zipped forall equalObjectsEqualHashcodes) && - ((shortAndLarger, shortAndLarger).zipped forall (_ == _)) && + ((anyvals, anyvals).zipped forall equalObjectsEqualHashcodes) && + ((shortAndLarger, shortAndLarger).zipped forall (_ == _)) && ((shortAndLarger, shortAndLarger).zipped forall ((x, y) => (x: Any) == (y: Any))) ) result diff --git a/test/pending/scalacheck/list.scala b/test/pending/scalacheck/list.scala index 1caf35e872..dfa84468d1 100644 --- a/test/pending/scalacheck/list.scala +++ b/test/pending/scalacheck/list.scala @@ -12,7 +12,7 @@ object Test extends Properties("List") { property("startsWith/take") = forAll { (xs: List[Int], count: Int) => xs startsWith (xs take count) } property("endsWith/takeRight") = forAll { (xs: List[Int], count: Int) => xs endsWith (xs takeRight count) } property("fill") = forAll(choose(1, 100)) { count => - forAll { (x: Int) => + forAll { (x: Int) => val xs = List.fill(count)(x) (xs.length == count) && (xs.distinct == List(x)) } diff --git a/test/pending/scalacheck/range.scala b/test/pending/scalacheck/range.scala index faa1f5d479..364c6947e9 100644 --- a/test/pending/scalacheck/range.scala +++ b/test/pending/scalacheck/range.scala @@ -1,205 +1,205 @@ -import org.scalacheck._ -import Prop._ -import Gen._ -import Arbitrary._ - -class Counter(r: Range) { - var cnt = 0L - var last: Option[Int] = None - val str = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")") - def apply(x: Int) = { - cnt += 1L - if (cnt % 500000000L == 0L) { - println("Working: %s %d %d" format (str, cnt, x)) - } - if (cnt > (Int.MaxValue.toLong + 1) * 2) - error("Count exceeds maximum possible for an Int Range") - if ((r.step > 0 && last.exists(_ > x)) || (r.step < 0 && last.exists(_ < x))) - error("Range wrapped: %d %s" format (x, last.toString)) - last = Some(x) - } -} - -abstract class RangeTest(kind: String) extends Properties("Range "+kind) { - def myGen: Gen[Range] - - val genRange = for { - start <- arbitrary[Int] - end <- arbitrary[Int] - step <- Gen.choose(1, (start - end).abs + 1) - } yield if (start < end) Range(start, end, step) else Range(start, end, -step) - - val genReasonableSizeRange = for { - start <- choose(-Int.MinValue, Int.MaxValue) - end <- choose(-Int.MinValue, Int.MaxValue) - step <- choose(-Int.MaxValue, Int.MaxValue) - } yield Range(start, end, if (step == 0) 100 else step) - - val genSmallRange = for { - start <- choose(-100, 100) - end <- choose(-100, 100) - step <- choose(1, 1) - } yield if (start < end) Range(start, end, step) else Range(start, end, -step) - - val genRangeByOne = for { - start <- arbitrary[Int] - end <- arbitrary[Int] - if (end.toLong - start.toLong).abs <= 10000000L - } yield if (start < end) Range(start, end) else Range(end, start) - - def str(r: Range) = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")") - - def expectedSize(r: Range): Long = if (r.isInclusive) { - (r.end.toLong - r.start.toLong < 0, r.step < 0) match { - case (true, true) | (false, false) => (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong + 1L - case _ => if (r.start == r.end) 1L else 0L - } - } else { - (r.end.toLong - r.start.toLong < 0, r.step < 0) match { - case (true, true) | (false, false) => ( - (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong - + (if ((r.end.toLong - r.start.toLong).abs % r.step.abs.toLong > 0L) 1L else 0L) - ) - case _ => 0L - } - } - - def within(r: Range, x: Int) = if (r.step > 0) - r.start <= x && (if (r.isInclusive) x <= r.end else x < r.end) - else - r.start >= x && (if (r.isInclusive) x >= r.end else x > r.end) - - def multiple(r: Range, x: Int) = (x.toLong - r.start) % r.step == 0 - - property("foreach.step") = forAll(myGen) { r => - var allValid = true - val cnt = new Counter(r) -// println("--------------------") -// println(r) - r foreach { x => cnt(x) -// println(x + ", " + (x - r.start) + ", " + (x.toLong - r.start) + ", " + ((x.toLong - r.start) % r.step)) - allValid &&= multiple(r, x) - } - allValid :| str(r) - } - - property("foreach.inside.range") = forAll(myGen) { r => - var allValid = true - var last: Option[Int] = None - val cnt = new Counter(r) - r foreach { x => cnt(x) - allValid &&= within(r, x) - } - allValid :| str(r) - } - - property("foreach.visited.size") = forAll(myGen) { r => - var visited = 0L - val cnt = new Counter(r) - r foreach { x => cnt(x) - visited += 1L - } -// println("----------") -// println(str(r)) -// println("size: " + r.size) -// println("expected: " + expectedSize(r)) -// println("visited: " + visited) - (visited == expectedSize(r)) :| str(r) - } - - property("length") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => - (r.length == expectedSize(r)) :| str(r) - } - - property("isEmpty") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => - (r.isEmpty == (expectedSize(r) == 0L)) :| str(r) - } - - property("contains") = forAll(myGen, arbInt.arbitrary) { (r, x) => -// println("----------------") -// println(str(r)) -// println(x) -// println("within: " + within(r, x)) -// println("multiple: " + multiple(r, x)) -// println("contains: " + r.contains(x)) - ((within(r, x) && multiple(r, x)) == r.contains(x)) :| str(r)+": "+x - } - - property("take") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => - val t = r take x - (t.size == (0 max x min r.size) && t.start == r.start && t.step == r.step) :| str(r)+" / "+str(t)+": "+x - } - - property("takeWhile") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => - val t = (if (r.step > 0) r takeWhile (_ <= x) else r takeWhile(_ >= x)) - if (r.size == 0) { - (t.size == 0) :| str(r)+" / "+str(t)+": "+x - } else { - val t2 = (if (r.step > 0) Range(r.start, x min r.last, r.step).inclusive else Range(r.start, x max r.last, r.step).inclusive) - (t.start == r.start && t.size == t2.size && t.step == r.step) :| str(r)+" / "+str(t)+" / "+str(t2)+": "+x - } - } - - property("reverse.toSet.equal") = forAll(myGen) { r => - val reversed = r.reverse - val aresame = r.toSet == reversed.toSet - if (!aresame) { - println(str(r)) - println(r) - println(reversed) - println(r.toSet) - println(reversed.toSet) - } - aresame - } -} - -object NormalRangeTest extends RangeTest("normal") { - override def myGen = genReasonableSizeRange - def genOne = for { - start <- arbitrary[Int] - end <- arbitrary[Int] - if (start.toLong - end.toLong).abs < Int.MaxValue.toLong - } yield Range(start, end, if (start < end) 1 else - 1) - property("by 1.size + 1 == inclusive.size") = forAll(genOne) { r => - (r.size + 1 == r.inclusive.size) :| str(r) - } -} - -object InclusiveRangeTest extends RangeTest("inclusive") { - override def myGen = for (r <- genReasonableSizeRange) yield r.inclusive -} - -object ByOneRangeTest extends RangeTest("byOne") { - override def myGen = genSmallRange -} - -object InclusiveByOneRangeTest extends RangeTest("inclusiveByOne") { - override def myGen = for (r <- genSmallRange) yield r.inclusive -} - -object SmallValuesRange extends RangeTest("smallValues") { - override def myGen = genSmallRange -} - -object Test extends Properties("Range") { - include(NormalRangeTest) - include(InclusiveRangeTest) - include(ByOneRangeTest) - include(InclusiveByOneRangeTest) -} - -/* Mini-benchmark -def testRange(i: Int, j: Int, k: Int) = { - var count = 0 - for { - vi <- 0 to i - vj <- 0 to j - vk <- 0 to k - } { count += 1 } -} - -testRange(10, 1000, 10000) -testRange(10000, 1000, 10) -*/ - +import org.scalacheck._
+import Prop._
+import Gen._
+import Arbitrary._
+
+class Counter(r: Range) {
+ var cnt = 0L
+ var last: Option[Int] = None
+ val str = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")")
+ def apply(x: Int) = {
+ cnt += 1L
+ if (cnt % 500000000L == 0L) {
+ println("Working: %s %d %d" format (str, cnt, x))
+ }
+ if (cnt > (Int.MaxValue.toLong + 1) * 2)
+ error("Count exceeds maximum possible for an Int Range")
+ if ((r.step > 0 && last.exists(_ > x)) || (r.step < 0 && last.exists(_ < x)))
+ error("Range wrapped: %d %s" format (x, last.toString))
+ last = Some(x)
+ }
+}
+
+abstract class RangeTest(kind: String) extends Properties("Range "+kind) {
+ def myGen: Gen[Range]
+
+ val genRange = for {
+ start <- arbitrary[Int]
+ end <- arbitrary[Int]
+ step <- Gen.choose(1, (start - end).abs + 1)
+ } yield if (start < end) Range(start, end, step) else Range(start, end, -step)
+
+ val genReasonableSizeRange = for {
+ start <- choose(-Int.MinValue, Int.MaxValue)
+ end <- choose(-Int.MinValue, Int.MaxValue)
+ step <- choose(-Int.MaxValue, Int.MaxValue)
+ } yield Range(start, end, if (step == 0) 100 else step)
+
+ val genSmallRange = for {
+ start <- choose(-100, 100)
+ end <- choose(-100, 100)
+ step <- choose(1, 1)
+ } yield if (start < end) Range(start, end, step) else Range(start, end, -step)
+
+ val genRangeByOne = for {
+ start <- arbitrary[Int]
+ end <- arbitrary[Int]
+ if (end.toLong - start.toLong).abs <= 10000000L
+ } yield if (start < end) Range(start, end) else Range(end, start)
+
+ def str(r: Range) = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")")
+
+ def expectedSize(r: Range): Long = if (r.isInclusive) {
+ (r.end.toLong - r.start.toLong < 0, r.step < 0) match {
+ case (true, true) | (false, false) => (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong + 1L
+ case _ => if (r.start == r.end) 1L else 0L
+ }
+ } else {
+ (r.end.toLong - r.start.toLong < 0, r.step < 0) match {
+ case (true, true) | (false, false) => (
+ (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong
+ + (if ((r.end.toLong - r.start.toLong).abs % r.step.abs.toLong > 0L) 1L else 0L)
+ )
+ case _ => 0L
+ }
+ }
+
+ def within(r: Range, x: Int) = if (r.step > 0)
+ r.start <= x && (if (r.isInclusive) x <= r.end else x < r.end)
+ else
+ r.start >= x && (if (r.isInclusive) x >= r.end else x > r.end)
+
+ def multiple(r: Range, x: Int) = (x.toLong - r.start) % r.step == 0
+
+ property("foreach.step") = forAll(myGen) { r =>
+ var allValid = true
+ val cnt = new Counter(r)
+// println("--------------------")
+// println(r)
+ r foreach { x => cnt(x)
+// println(x + ", " + (x - r.start) + ", " + (x.toLong - r.start) + ", " + ((x.toLong - r.start) % r.step))
+ allValid &&= multiple(r, x)
+ }
+ allValid :| str(r)
+ }
+
+ property("foreach.inside.range") = forAll(myGen) { r =>
+ var allValid = true
+ var last: Option[Int] = None
+ val cnt = new Counter(r)
+ r foreach { x => cnt(x)
+ allValid &&= within(r, x)
+ }
+ allValid :| str(r)
+ }
+
+ property("foreach.visited.size") = forAll(myGen) { r =>
+ var visited = 0L
+ val cnt = new Counter(r)
+ r foreach { x => cnt(x)
+ visited += 1L
+ }
+// println("----------")
+// println(str(r))
+// println("size: " + r.size)
+// println("expected: " + expectedSize(r))
+// println("visited: " + visited)
+ (visited == expectedSize(r)) :| str(r)
+ }
+
+ property("length") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r =>
+ (r.length == expectedSize(r)) :| str(r)
+ }
+
+ property("isEmpty") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r =>
+ (r.isEmpty == (expectedSize(r) == 0L)) :| str(r)
+ }
+
+ property("contains") = forAll(myGen, arbInt.arbitrary) { (r, x) =>
+// println("----------------")
+// println(str(r))
+// println(x)
+// println("within: " + within(r, x))
+// println("multiple: " + multiple(r, x))
+// println("contains: " + r.contains(x))
+ ((within(r, x) && multiple(r, x)) == r.contains(x)) :| str(r)+": "+x
+ }
+
+ property("take") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) =>
+ val t = r take x
+ (t.size == (0 max x min r.size) && t.start == r.start && t.step == r.step) :| str(r)+" / "+str(t)+": "+x
+ }
+
+ property("takeWhile") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) =>
+ val t = (if (r.step > 0) r takeWhile (_ <= x) else r takeWhile(_ >= x))
+ if (r.size == 0) {
+ (t.size == 0) :| str(r)+" / "+str(t)+": "+x
+ } else {
+ val t2 = (if (r.step > 0) Range(r.start, x min r.last, r.step).inclusive else Range(r.start, x max r.last, r.step).inclusive)
+ (t.start == r.start && t.size == t2.size && t.step == r.step) :| str(r)+" / "+str(t)+" / "+str(t2)+": "+x
+ }
+ }
+
+ property("reverse.toSet.equal") = forAll(myGen) { r =>
+ val reversed = r.reverse
+ val aresame = r.toSet == reversed.toSet
+ if (!aresame) {
+ println(str(r))
+ println(r)
+ println(reversed)
+ println(r.toSet)
+ println(reversed.toSet)
+ }
+ aresame
+ }
+}
+
+object NormalRangeTest extends RangeTest("normal") {
+ override def myGen = genReasonableSizeRange
+ def genOne = for {
+ start <- arbitrary[Int]
+ end <- arbitrary[Int]
+ if (start.toLong - end.toLong).abs < Int.MaxValue.toLong
+ } yield Range(start, end, if (start < end) 1 else - 1)
+ property("by 1.size + 1 == inclusive.size") = forAll(genOne) { r =>
+ (r.size + 1 == r.inclusive.size) :| str(r)
+ }
+}
+
+object InclusiveRangeTest extends RangeTest("inclusive") {
+ override def myGen = for (r <- genReasonableSizeRange) yield r.inclusive
+}
+
+object ByOneRangeTest extends RangeTest("byOne") {
+ override def myGen = genSmallRange
+}
+
+object InclusiveByOneRangeTest extends RangeTest("inclusiveByOne") {
+ override def myGen = for (r <- genSmallRange) yield r.inclusive
+}
+
+object SmallValuesRange extends RangeTest("smallValues") {
+ override def myGen = genSmallRange
+}
+
+object Test extends Properties("Range") {
+ include(NormalRangeTest)
+ include(InclusiveRangeTest)
+ include(ByOneRangeTest)
+ include(InclusiveByOneRangeTest)
+}
+
+/* Mini-benchmark
+def testRange(i: Int, j: Int, k: Int) = {
+ var count = 0
+ for {
+ vi <- 0 to i
+ vj <- 0 to j
+ vk <- 0 to k
+ } { count += 1 }
+}
+
+testRange(10, 1000, 10000)
+testRange(10000, 1000, 10)
+*/
+
diff --git a/test/pending/script/bug2365/Test.scala b/test/pending/script/bug2365/Test.scala index 53581d256b..110dea2ab6 100644 --- a/test/pending/script/bug2365/Test.scala +++ b/test/pending/script/bug2365/Test.scala @@ -17,17 +17,17 @@ object Test 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 + 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/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..16b6f42201 --- /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..89b43d7b6a --- /dev/null +++ b/test/pending/shootout/fasta.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..46c36a23c8 --- /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 (val 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..4b4055909d --- /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(val 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 (val 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..28d031ae46 --- /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..5cf77d077a --- /dev/null +++ b/test/pending/shootout/harmonic.scala-3.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..0097d92956 --- /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 (val 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..7030aa3f8f --- /dev/null +++ b/test/pending/shootout/heapsort.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..9d2d31408b --- /dev/null +++ b/test/pending/shootout/mandelbrot.scala-2.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..32738b030e --- /dev/null +++ b/test/pending/shootout/message.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..1154ce95cc --- /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 ++= Iterator.range(0,unplaced.capacity) } + + + def findSolutions(): Unit = { + if (countdown == 0) return + + if (unplaced.size > 0){ + val emptyCellIndex = board.firstEmptyCellIndex + + for (val k <- Iterator.range(0,pieces.length)){ + if (unplaced.contains(k)){ + unplaced -= k + + for (val i <- Iterator.range(0,Piece.orientations)){ + val piece = pieces(k).nextOrientation + + for (val 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 (val 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 (val 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 (val 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 (val c <- cells; 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 (val i <- Iterator.range(0,Cell.sides)) find(p.next(i), b.next(i)) + } + } + + + private def boardCells() = { + val a = for (val i <- Array.range(0,Board.size)) yield new BoardCell(i) + val m = (Board.size / Board.cols) - 1 + + for (val 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 (val i <- Iterator.range(0,Board.size)){ + Console.print(i + "\t") + for (val 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 (val 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 (val c <- cells) c.flip + def rotate() = for (val c <- cells) c.rotate + def unmark() = for (val 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 (val i <- Iterator.range(0,Piece.size)){ + Console.print(i + "\t") + for (val j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + for (val 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 { + 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 Cell { + type T = BoardCell + 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 (val 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..e8eb9a4e29 --- /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 ++= Iterator.range(0,unplaced.capacity) } + + + def findSolutions(): Unit = { + if (countdown == 0) return + + if (unplaced.size > 0){ + val emptyCellIndex = board.firstEmptyCellIndex + + for (val k <- Iterator.range(0,pieces.length)){ + if (unplaced.contains(k)){ + unplaced -= k + + for (val i <- Iterator.range(0,Piece.orientations)){ + val piece = pieces(k).nextOrientation + + for (val 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 (val 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 (val 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 (val 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 (val c <- cells; 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 (val i <- Iterator.range(0,Cell.sides)) find(p.next(i), b.next(i)) + } + } + + + private def boardCells() = { + val a = for (val i <- Array.range(0,Board.size)) yield new BoardCell(i) + val m = (Board.size / Board.cols) - 1 + + for (val 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 (val i <- Iterator.range(0,Board.size)){ + Console.print(i + "\t") + for (val 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 (val 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 (val c <- cells) c.flip + def rotate() = for (val c <- cells) c.rotate + def unmark() = for (val 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 (val i <- Iterator.range(0,Piece.size)){ + Console.print(i + "\t") + for (val j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + for (val 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 (val 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..9f1b95e150 --- /dev/null +++ b/test/pending/shootout/meteor.scala-2.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..7a4aca8fb8 --- /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 ++= Iterator.range(0,unplaced.capacity) } + + + 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 (val 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 (val i <- Array.range(0,Board.size)) yield new BoardCell(i) + val m = (Board.size / Board.cols) - 1 + + for (val 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 (val i <- Iterator.range(0,Board.size)){ + Console.print(i + "\t") + for (val 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 (val 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 (val i <- Iterator.range(0,Piece.size)){ + Console.print(i + "\t") + for (val j <- Iterator.range(0,Cell.sides)){ + val c = cells(i).next(j) + if (c == null) + Console.print("-- ") + else + for (val 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..9f1b95e150 --- /dev/null +++ b/test/pending/shootout/meteor.scala-3.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..eb7d04e11e --- /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 ++= Iterator.range(0,unplaced.capacity) } + + + 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 + + + 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..9f1b95e150 --- /dev/null +++ b/test/pending/shootout/meteor.scala-4.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..9f1b95e150 --- /dev/null +++ b/test/pending/shootout/meteor.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..2781da0be5 --- /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 = _; + + val toggle = new Toggle(true); + for (val i <- Iterator.range(1,n)) v = toggle.activate.value; + + Console println( toggle.activate.value ); + + val ntoggle = new NToggle(true,3); + for (val 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..1e50ac5492 --- /dev/null +++ b/test/pending/shootout/methcall.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..b5e5ccc66c --- /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 (val i <- List.range(2, m)) isPrime(i) = true + var count = 0 + + for (val 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..8c9e80bca5 --- /dev/null +++ b/test/pending/shootout/nsieve.scala-4.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..9da6ab9536 --- /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..ad83b17a73 --- /dev/null +++ b/test/pending/shootout/pidigits.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..d76c3736f7 --- /dev/null +++ b/test/pending/shootout/prodcons.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..9320b5aa95 --- /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 = _; + + 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..ffe62e5d40 --- /dev/null +++ b/test/pending/shootout/random.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val 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..a8ea650cb9 --- /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 (val 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..0f68f0da01 --- /dev/null +++ b/test/pending/shootout/revcomp.scala-2.scala.runner @@ -0,0 +1,6 @@ +object Test extends Application { + for(val 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..fa875f4b22 --- /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 += 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 (val 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..0f68f0da01 --- /dev/null +++ b/test/pending/shootout/revcomp.scala-3.scala.runner @@ -0,0 +1,6 @@ +object Test extends Application { + for(val 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..06d7214ea6 --- /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 = _; + + while (n>0) { + count = 0; + + for (val i <- Iterator.range(start,stop+1)) + isPrime(i)=true; + + for (val 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..1c53d1dd72 --- /dev/null +++ b/test/pending/shootout/sieve.scala.runner @@ -0,0 +1,3 @@ +object Test extends Application { + for(val n <- List(300,600,900,1200)) sieve.main(Array(n.toString)) +} diff --git a/test/support/annotations/NestedAnnotations.java b/test/support/annotations/NestedAnnotations.java index 8f2327dcce..c4a98a0af3 100644 --- a/test/support/annotations/NestedAnnotations.java +++ b/test/support/annotations/NestedAnnotations.java @@ -10,14 +10,14 @@ public class NestedAnnotations { @OuterAnno(inner=@InnerAnno(name="inner")) String field; - - @Target({FIELD}) + + @Target({FIELD}) @Retention(RUNTIME) public static @interface InnerAnno { String name(); } - - @Target({FIELD}) + + @Target({FIELD}) @Retention(RUNTIME) public static @interface OuterAnno { InnerAnno inner(); |