summaryrefslogtreecommitdiff
path: root/test/files/run/unapply.scala
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2007-03-22 03:28:30 +0000
committerBurak Emir <emir@epfl.ch>2007-03-22 03:28:30 +0000
commitc61121a813abaace6e739a6f02e4c85b186f95a1 (patch)
tree74e4b0b57269397e888424346f674efcd933efc4 /test/files/run/unapply.scala
parent8e890c848ff68e69342d0f340df40f926857c861 (diff)
downloadscala-c61121a813abaace6e739a6f02e4c85b186f95a1.tar.gz
scala-c61121a813abaace6e739a6f02e4c85b186f95a1.tar.bz2
scala-c61121a813abaace6e739a6f02e4c85b186f95a1.zip
new pattern matching algo
removed "removeoption" changed SUnit and some tests added useful debug msg in typer
Diffstat (limited to 'test/files/run/unapply.scala')
-rw-r--r--test/files/run/unapply.scala28
1 files changed, 14 insertions, 14 deletions
diff --git a/test/files/run/unapply.scala b/test/files/run/unapply.scala
index fb154cf192..d351468bec 100644
--- a/test/files/run/unapply.scala
+++ b/test/files/run/unapply.scala
@@ -1,12 +1,12 @@
import scala.testing.SUnit._
-object Test {
- def main(args:Array[String]) = {
- Foo.run
- Mas.run
- LisSeqArr.run
- StreamFoo.run
- }
+object Test extends TestConsoleMain {
+ def suite = new TestSuite(
+ Foo,
+ Mas,
+ LisSeqArr,
+ StreamFoo
+ )
}
// this class is used for representation
@@ -28,7 +28,7 @@ object FaaPrecise {
object FaaPreciseSome {
def unapply(x: Bar) = Some(x.name) // return type Some[String]
}
-object Foo extends Assert {
+object Foo extends TestCase("Foo") with Assert {
def unapply(x: Any): Option[Product2[Int, String]] = x match {
case y: Bar => Some(Tuple(y.size, y.name))
case _ => None
@@ -48,7 +48,7 @@ object Foo extends Assert {
def doMatch5(b:Bar) = (b:Any) match {
case FaaPreciseSome(n:String) => n
}
- def run {
+ override def runTest {
val b = new Bar
assertEquals(doMatch1(b),(50,"medium"))
assertEquals(doMatch2(b),null)
@@ -59,7 +59,7 @@ object Foo extends Assert {
}
// same, but now object is not top-level
-object Mas extends Assert {
+object Mas extends TestCase("Mas") with Assert {
object Gaz {
def unapply(x: Any): Option[Product2[Int, String]] = x match {
case y: Baz => Some(Tuple(y.size, y.name))
@@ -70,7 +70,7 @@ object Mas extends Assert {
var size: Int = 60
var name: String = "too large"
}
- def run {
+ def runTest {
val b = new Baz
assertEquals(b match {
case Gaz(s:Int, n:String) => (s,n)
@@ -78,8 +78,8 @@ object Mas extends Assert {
}
}
-object LisSeqArr extends Assert {
- def run {
+object LisSeqArr extends TestCase("LisSeqArr") with Assert {
+ def runTest {
assertEquals((List(1,2,3): Any) match { case List(x,y,_*) => (x,y)}, (1,2))
assertEquals((List(1,2,3): Any) match { case Seq(x,y,_*) => (x,y)}, (1,2))
assertEquals((Array(1,2,3): Any) match { case Seq(x,y,_*) => (x,y)}, (1,2))
@@ -96,7 +96,7 @@ object StreamFoo extends TestCase("unapply for Streams") with Assert {
case Stream.empty => 0
case Stream.cons(hd, tl) => hd + sum(tl)
}
- override def run {
+ override def runTest {
val str: Stream[int] = Stream.fromIterator(List(1,2,3).elements)
assertEquals(sum(str), 6)
}