diff options
author | buraq <buraq@epfl.ch> | 2004-02-16 10:13:21 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-02-16 10:13:21 +0000 |
commit | b549b7bc7bd426db4a0fe18c20727e8b80057107 (patch) | |
tree | 7b934902b2d6b6eb3b768c2fa53ce0b8deccc11a /test | |
parent | 9c50901f939c6487516d38eeef0afe04523560c6 (diff) | |
download | scala-b549b7bc7bd426db4a0fe18c20727e8b80057107.tar.gz scala-b549b7bc7bd426db4a0fe18c20727e8b80057107.tar.bz2 scala-b549b7bc7bd426db4a0fe18c20727e8b80057107.zip |
added test case for xml patterns
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/xmlLiterals.check | 5 | ||||
-rw-r--r-- | test/files/jvm/xmlLiterals.scala | 25 |
2 files changed, 29 insertions, 1 deletions
diff --git a/test/files/jvm/xmlLiterals.check b/test/files/jvm/xmlLiterals.check index bd0b0c1bc5..6efcf8a200 100644 --- a/test/files/jvm/xmlLiterals.check +++ b/test/files/jvm/xmlLiterals.check @@ -3,3 +3,8 @@ passed ok passed ok passed ok passed ok +passed ok +passed ok +passed ok +passed ok +passed ok diff --git a/test/files/jvm/xmlLiterals.scala b/test/files/jvm/xmlLiterals.scala index 320fc995c0..d28e5f21d1 100644 --- a/test/files/jvm/xmlLiterals.scala +++ b/test/files/jvm/xmlLiterals.scala @@ -59,6 +59,30 @@ object Test with Application { assertEquals( sc.children.toList, List(Text("World"),Text("42"), 'date("now!")) ); assertEquals( sc.toXML, 'hello("World42",'date("now!")).toXML ); + import scala.xml.Node ; + + def foo( m:Node ):String = m match { + case <hello/> => "hello node" + case <hallo ></hallo > => "hallo node" + case <test>{ z }</test> => "test node:"+z + case <list>{ e1:Node }{ e2:Node }{ _* }</list> => e1.toXML + e2.toXML; + } + + assertEquals( foo(<hello/>), "hello node" ); + assertEquals( foo(<hallo/>), "hallo node" ); + assertEquals( foo(<test>42</test>), "test node:42" ); + assertEquals( foo(<list><a/><b><c/></b><d/><d/></list>), + <a/>.toXML + <b><c/></b>.toXML ); + + val rows = <tr> + <td>1.1</td><td>1.2</td> + </tr> + <tr> + <td>2.1</td><td>2.2</td> + </tr>; + + assertEquals( rows, List('tr('td("1.1"),'td("1.2")), + 'tr('td("2.1"),'td("2.2")))); /* examples that MUST fail neg(1) @@ -70,6 +94,5 @@ object Test with Application { */ - } |