diff options
-rw-r--r-- | test/pending/run/testSome.scala | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/test/pending/run/testSome.scala b/test/pending/run/testSome.scala index ee5e807151..9ed3a35558 100644 --- a/test/pending/run/testSome.scala +++ b/test/pending/run/testSome.scala @@ -1,4 +1,6 @@ -object testSome { +import testing.SUnit._ + +object testSome extends Assert { val x: Option[String] = Some("foo") @@ -8,15 +10,34 @@ object testSome { val y1: Option[Int] = None + def main(args:Array[String]) = { + assertFalse("some[string].isEmpty ", x.isEmpty) // x eq null + + assertFalse("some[int].isEmpty ", x1.isEmpty) + + assertTrue("none<:opt[string].isEmpty ", y.isEmpty) + + assertTrue("non<:opt[int].isEmpty ", y1.isEmpty) + + Console.println(x.get) // x + + Console.println(x1.get) + + val f = {x:String => Some(x.length)} + + val len:Option[Int] = x.flatMap(f) + Console.println("len: (3) "+len) + + val g = {x:String => x.charAt(0) == 'f'} - Console.println(x.isEmpty) // x ne null + Console.println("filter: (foo) "+x.filter(g)) - Console.println(x1.isEmpty) + // to do: - Console.println(x.get) // x + //assertEquals("equals", len == Some(3)) - Console.println(x1.get) + // matching - def f(x:String) = Some(x) - x.flatMap(&f) + // unapply + } } |