summaryrefslogtreecommitdiff
path: root/test/files/run/patmatnew.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-05-20 10:32:59 +0000
committermichelou <michelou@epfl.ch>2008-05-20 10:32:59 +0000
commit4686535142b380ccfad910250303e15bd41fb79d (patch)
tree210b6b24b42e837472ee03dfb98c045e2b882ec7 /test/files/run/patmatnew.scala
parent44fd5e7272f7fbcc901d1ecaf563351217a50e7d (diff)
downloadscala-4686535142b380ccfad910250303e15bd41fb79d.tar.gz
scala-4686535142b380ccfad910250303e15bd41fb79d.tar.bz2
scala-4686535142b380ccfad910250303e15bd41fb79d.zip
int -> Int, etc..
Diffstat (limited to 'test/files/run/patmatnew.scala')
-rw-r--r--test/files/run/patmatnew.scala64
1 files changed, 32 insertions, 32 deletions
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala
index 1652397ab2..615046bf14 100644
--- a/test/files/run/patmatnew.scala
+++ b/test/files/run/patmatnew.scala
@@ -20,7 +20,7 @@ object Test extends TestConsoleMain {
//just compilation
def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = (Pair(xs,ys): @unchecked) match {
// !!! case Pair(List(), _), Pair(_, List()) => List()
- case Pair(x :: xs1, y :: ys1) => Pair(x, y) :: zipFun(xs1, ys1)
+ case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1)
}
def suite = new TestSuite(
@@ -62,7 +62,7 @@ object Test extends TestConsoleMain {
}
class SimpleUnapply extends TestCase("simpleUnapply") {
override def runTest() { // from sortedmap, old version
- List((1,2)).head match {
+ List((1, 2)).head match {
case kv @ Pair(key, _) => kv.toString + " " + key.toString
}
@@ -71,7 +71,7 @@ object Test extends TestConsoleMain {
}
object SeqUnapply extends TestCase("seqUnapply") {
- case class SFB(i:int,xs:List[Int])
+ case class SFB(i: Int, xs: List[Int])
override def runTest() {
List(1,2) match {
case List(1) => assert(false, "wrong case")
@@ -79,8 +79,8 @@ object Test extends TestConsoleMain {
case Nil => assert(false, "wrong case")
}
SFB(1,List(1)) match {
- case SFB(_,List(x)) => assert(x==1)
- case SFB(_,_) => assert(false)
+ case SFB(_, List(x)) => assert(x == 1)
+ case SFB(_, _) => assert(false)
}
}
}
@@ -89,8 +89,8 @@ object Test extends TestConsoleMain {
override def runTest {
val p = (1,2)
Some(2) match {
- case Some(p._2) => ;
- case _ => assert(false) ;
+ case Some(p._2) =>
+ case _ => assert(false)
}
}
}
@@ -115,7 +115,7 @@ object Test extends TestConsoleMain {
case s:String => 1
//case _ => 0 // unreachable!
})
- val xyz: (int, String, boolean) = (1, "abc", true);
+ val xyz: (Int, String, Boolean) = (1, "abc", true);
assertEquals("s4", 1, xyz._1 match {
case 1 => 1
case _ => 0
@@ -249,7 +249,7 @@ object Test extends TestConsoleMain {
case class A(i: Any)
- def doMatch(x: Any, bla: int) = x match {
+ def doMatch(x: Any, bla: Int) = x match {
case x:A if (bla==1) => 0
case A(1) => 1
case A(A(1)) => 2
@@ -264,10 +264,10 @@ object Test extends TestConsoleMain {
}
object TestSequence07 extends TestCase("sette List of chars") {
- def doMatch1(xs: List[char]) = xs match {
+ def doMatch1(xs: List[Char]) = xs match {
case List(x, y, _*) => x::y::Nil
}
- def doMatch2(xs:List[char]) = xs match {
+ def doMatch2(xs: List[Char]) = xs match {
case List(x, y, z, w) => List(z,w)
}
//def doMatch3(xs:List[char]) = xs match {
@@ -309,7 +309,7 @@ object Test extends TestConsoleMain {
object TestStream extends TestCase("unapply for Streams") {
- def sum(stream: Stream[int]): int =
+ def sum(stream: Stream[Int]): Int =
stream match {
case Stream.empty => 0
case Stream.cons(hd, tl) => hd + sum(tl)
@@ -323,7 +323,7 @@ object Test extends TestConsoleMain {
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
+ case class Const(v: Double) extends Function
def f(): (Function, Function) = {
(Var("x"): Function, Var("y"): Function) match {
@@ -333,7 +333,7 @@ object Test extends TestConsoleMain {
}
}
- 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
}
@@ -343,7 +343,7 @@ object Test extends TestConsoleMain {
class TestUnbox extends TestCase("unbox") {
override def runTest() {
- val xyz: (int, String, boolean) = (1, "abc", true)
+ val xyz: (Int, String, Boolean) = (1, "abc", true)
xyz._1 match {
case 1 => "OK"
case 2 => assert(false); "KO"
@@ -355,21 +355,21 @@ object Test extends TestConsoleMain {
class Test806_818 { // #806, #811 compile only -- type of bind
// bug811
trait Core {
- trait NodeImpl;
- trait OtherImpl extends NodeImpl;
- trait DoubleQuoteImpl extends NodeImpl;
+ trait NodeImpl
+ trait OtherImpl extends NodeImpl
+ trait DoubleQuoteImpl extends NodeImpl
def asDQ(node : OtherImpl) = node match {
- case dq : DoubleQuoteImpl => dq;
+ case dq : DoubleQuoteImpl => dq
}
}
trait IfElseMatcher {
- type Node <: NodeImpl;
- trait NodeImpl;
- trait IfImpl;
- private def coerceIf(node : Node) = node match {
- case node : IfImpl => node; // var node is of type Node with IfImpl!
- case _ => null;
+ type Node <: NodeImpl
+ trait NodeImpl
+ trait IfImpl
+ private def coerceIf(node: Node) = node match {
+ case node : IfImpl => node // var node is of type Node with IfImpl!
+ case _ => null
}
}
}
@@ -545,7 +545,7 @@ object Test extends TestConsoleMain {
trait Position extends Core
- (null:Core,null:Dir) match {
+ (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
}
@@ -616,8 +616,8 @@ object Test extends TestConsoleMain {
def method2(): scala.Boolean = {
val x: String = "Hello, world"; val y: scala.Int = 100; {
- var temp1: scala.Int = y;
- var result: scala.Boolean = false;
+ var temp1: scala.Int = y
+ var result: scala.Boolean = false
if (
{
var result1: scala.Boolean = true;
@@ -728,7 +728,7 @@ object Test extends TestConsoleMain {
// #2
class Outer_2 {
- case class Foo(x: int, y: int) {
+ case class Foo(x: Int, y: Int) {
override def equals(other: Any) = other match {
case Outer_2.this.Foo(`x`, `y`) => true
case _ => false
@@ -740,7 +740,7 @@ object Test extends TestConsoleMain {
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)
assertTrue("match enters wrong case", x match {
- case o2.Foo(x, y) => false;
+ case o2.Foo(x, y) => false
case o1.Foo(x, y) => true
case _ => false
})
@@ -772,7 +772,7 @@ object Test extends TestConsoleMain {
assume(e.isInstanceOf[Throwable])
}
}
- }
+ }
}
}
@@ -920,7 +920,7 @@ override def runTest() {
object Ticket710 { // compile-only
- def method: Unit = {
+ def method {
sealed case class Parent
case object Child extends Parent
val x: Parent = Child