diff options
author | Burak Emir <emir@epfl.ch> | 2006-12-03 00:32:39 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-12-03 00:32:39 +0000 |
commit | ccb5bd1da84a8ae09bee61e16f08ca9d726b3270 (patch) | |
tree | 5cf4586be40870b0ca9389c0b15317bf970e9737 /test | |
parent | 6cffd12cb90c8353ccd8581a712bffb52a7b4c59 (diff) | |
download | scala-ccb5bd1da84a8ae09bee61e16f08ca9d726b3270.tar.gz scala-ccb5bd1da84a8ae09bee61e16f08ca9d726b3270.tar.bz2 scala-ccb5bd1da84a8ae09bee61e16f08ca9d726b3270.zip |
more on Xkilloption, and a PM fix
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/patmatnew.scala | 26 | ||||
-rw-r--r-- | test/files/run/unittest_xml.scala | 10 | ||||
-rw-r--r-- | test/pending/run/testSome.scala | 88 |
3 files changed, 106 insertions, 18 deletions
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index d7cb9aec6f..377e89a267 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -20,7 +20,7 @@ object Test { val tr = new TestResult new TestSuite( - new Test01 + new Test717 ).run(tr) @@ -31,7 +31,7 @@ object Test { class Foo(j:Int) { case class Bar(i:Int) } - class Test01 extends TestCase("bir (#717 test path of case classes)") { + class Test717 extends TestCase("#717 test path of case classes") { val foo1 = new Foo(1) val foo2 = new Foo(2) @@ -43,4 +43,26 @@ object Test { assertTrue("ok", res); } } + + class Test806_818 { // #806, #811 compile only -- type of bind + // bug811 + trait Core { + trait NodeImpl; + trait OtherImpl extends NodeImpl; + trait DoubleQuoteImpl extends NodeImpl; + def asDQ(node : OtherImpl) = node match { + 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; + } + } + } } diff --git a/test/files/run/unittest_xml.scala b/test/files/run/unittest_xml.scala index 5f7c523996..99284f144e 100644 --- a/test/files/run/unittest_xml.scala +++ b/test/files/run/unittest_xml.scala @@ -2,9 +2,14 @@ object Test { import scala.testing.SUnit._ - import scala.xml.{MetaData, Null, PrefixedAttribute, UnprefixedAttribute } + import scala.xml.{MetaData, Null, Parsing, PrefixedAttribute, UnprefixedAttribute } - class MetaDataTest extends TestCase("collection.mutable.ArrayBuffer") with Assert { + class ParsingTest extends TestCase("scala.xml.Parsing") with Assert { + override def runTest = { + assertTrue(Parsing.isNameStart('b')) + } + } + class MetaDataTest extends TestCase("scala.xml.MetaData") with Assert { import scala.xml.{TopScope, NamespaceBinding, Atom, Text } @@ -44,6 +49,7 @@ object Test { def main(args:Array[String]) = { val ts = new TestSuite( + new ParsingTest, new MetaDataTest //, ) val tr = new TestResult() diff --git a/test/pending/run/testSome.scala b/test/pending/run/testSome.scala index 9ed3a35558..4320adb681 100644 --- a/test/pending/run/testSome.scala +++ b/test/pending/run/testSome.scala @@ -1,43 +1,103 @@ import testing.SUnit._ +//trait Foo { +// def bar:Option[Seq[xml.Node]] = Some(Nil) +//} object testSome extends Assert { + //val x: Option[String] = Some("foo") - val x: Option[String] = Some("foo") + //val x1: Option[Int] = Some(3) - val x1: Option[Int] = Some(3) + //val y: Option[String] = None - val y: Option[String] = None - - val y1: Option[Int] = None + //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) + //assertFalse("some[string].isEmpty ", x.isEmpty) // x eq null + //assertFalse("some[int].isEmpty ", x1.isEmpty) - assertTrue("none<:opt[string].isEmpty ", y.isEmpty) + // assertTrue("some[string].isInstanceOf[Some] ", x.isInstanceOf[Some[String]]) + // assertTrue("some[int].isInstanceOf[Some] ", x1.isInstanceOf[Some[Int]]) + //assertTrue("some[string].asInstanceOf[Some] ", {x.asInstanceOf[Some[String]];true}) + //assertTrue("some[int].asInstanceOf[Some] ", {x1.asInstanceOf[Some[Int]]; true}) + /* + assertTrue("none<:opt[string].isEmpty ", y.isEmpty) assertTrue("non<:opt[int].isEmpty ", y1.isEmpty) - Console.println(x.get) // x - - Console.println(x1.get) + assertEquals("Some(foo).get ", "foo", x.get) + assertEquals("Some(3).get ", 3, 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("filter: (foo) "+x.filter(g)) - // to do: - - //assertEquals("equals", len == Some(3)) +// assertEquals("equals", len == Some(3)) // matching + x match { + case Some("foo") => true + case None => false + } + // matching + x match { + case Some(z) => z + case _ => null + } + x match { + case None => "3" + case Some(z) => "4" + } +*/ + + new collection.mutable.HashMap[Int,Option[String]]().get(1) match { + case Some(Some(x)) => 1 + case _ => 2 + } // unapply } +/* + def foobar(x:Foo) = {x.bar == 42} // nonsense + val zz : Option[Int] = try { Some(1/0) } catch { case _ => None} + + trait ZyGo { + def impolite: Option[String] + } + val foo = new ZyGo { + val impolite = None + } + + class Fu { + def bar: Option[String] = Some("foo") + } + new Fu().bar + + def isNullable (metadata:java.sql.ResultSetMetaData, index:Int): Option[scala.Boolean] = + metadata.isNullable(index) match { + case java.sql.ResultSetMetaData.columnNoNulls => Some(false); + case java.sql.ResultSetMetaData.columnNullable => Some(true); + //case java.sql.ResultSetMetaData.columnNoNulls => None; // bq:unreachable code + } + + + def names_get_self : Option[scala.Symbol] = None + + def send: Tuple1[String] = { + val senderName = new collection.mutable.HashMap[String, scala.Symbol].get("foo") match { + case None => + "foo" + case Some(name) => + "bar" + } + Tuple1(senderName) + } +*/ } |