diff options
author | buraq <buraq@epfl.ch> | 2004-06-25 17:29:50 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-06-25 17:29:50 +0000 |
commit | d4e3c78e738e37a0ba5fa5eb8b5196a8556d2c53 (patch) | |
tree | eda1c098f09aa6283333550d05a86d541a030f6a /test | |
parent | f3129f0da6487fd6a33fc40ee1d19a1c6c5de06b (diff) | |
download | scala-d4e3c78e738e37a0ba5fa5eb8b5196a8556d2c53.tar.gz scala-d4e3c78e738e37a0ba5fa5eb8b5196a8556d2c53.tar.bz2 scala-d4e3c78e738e37a0ba5fa5eb8b5196a8556d2c53.zip |
namespaces
Diffstat (limited to 'test')
-rwxr-xr-x | test/bin/scala-test | 3 | ||||
-rw-r--r-- | test/files/jvm/xmlLiterals.scala | 6 | ||||
-rw-r--r-- | test/files/jvm/xmlstuff.check | 9 | ||||
-rw-r--r-- | test/files/jvm/xmlstuff.scala | 52 | ||||
-rw-r--r-- | test/files/xml/lnk.check | 4 | ||||
-rw-r--r-- | test/files/xml/lnk.namespace | 1 | ||||
-rw-r--r-- | test/files/xml/lnk.scala | 9 | ||||
-rw-r--r-- | test/files/xml/xhtml.check | 4 | ||||
-rw-r--r-- | test/files/xml/xhtml.namespace | 1 | ||||
-rw-r--r-- | test/files/xml/xhtml.scala | 15 |
10 files changed, 88 insertions, 16 deletions
diff --git a/test/bin/scala-test b/test/bin/scala-test index c548b57438..1735b0b158 100755 --- a/test/bin/scala-test +++ b/test/bin/scala-test @@ -145,6 +145,7 @@ test_xml() { output="$OBJDIR"/`expr "$source" : "\(.*\)\\.scala"`-$KIND.obj; dtdfile="`expr "$source" : "\(.*\)\\.scala"`.dtd"; xmlfile="`expr "$source" : "\(.*\)\\.scala"`.xml"; + nsfile="`expr "$source" : "\(.*\)\\.scala"`.namespace"; objfile="$output/dtd.scala"; classpath="$output"; if $CYGWIN; then @@ -155,7 +156,7 @@ test_xml() { fi; rm -rf "$output"; mkdir -p "$output" && - $DTD2SCALA -d "$os_output" "$dtdfile" dtd && + $DTD2SCALA -d "$os_output" "$dtdfile" dtd `cat $nsfile` && $SOCOS -d "$os_output" $TEST_FLAGS $FLAGS "$objfile" "$source" && $SCALA -classpath "$classpath" Test "$xmlfile" && rm -rf "$output"; diff --git a/test/files/jvm/xmlLiterals.scala b/test/files/jvm/xmlLiterals.scala index d908a49349..65abd50094 100644 --- a/test/files/jvm/xmlLiterals.scala +++ b/test/files/jvm/xmlLiterals.scala @@ -11,7 +11,7 @@ import scala.collection.immutable ; object Test { - val e = immutable.TreeMap.Empty[String,String]; + val e = Node.NoAttributes; /* a helper function to compare up to whitespace */ @@ -77,9 +77,9 @@ object Test { Elem("","h1",e,Text("Hello World")), Elem("","p",e,Text("Check the "), Elem("","a", e,Text("scala")) - % Pair("href","scala.epfl.ch"), + % (Attribute("","href","scala.epfl.ch")), Text("page!")) - ) % Pair("background","#FFFFFF") + ) % Attribute("", "background","#FFFFFF") ).toString() )); diff --git a/test/files/jvm/xmlstuff.check b/test/files/jvm/xmlstuff.check index b348451a28..397a8970d6 100644 --- a/test/files/jvm/xmlstuff.check +++ b/test/files/jvm/xmlstuff.check @@ -38,3 +38,12 @@ List(<book><title>Blabla</title></book>) <phone where="work">+41 21 693 68 67</phone> <phone where="mobile">+41 79 602 23 23</phone> </result> +patterns +passed ok +passed ok +passed ok +namespaces +passed ok +passed ok +passed ok +passed ok diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala index 2617110372..f05548aa96 100644 --- a/test/files/jvm/xmlstuff.scala +++ b/test/files/jvm/xmlstuff.scala @@ -6,7 +6,7 @@ import scala.xml.{Node,NodeSeq,Elem,Text}; object Test with Application { - val e = scala.collection.immutable.TreeMap.Empty[String,String]; + val e = Node.NoAttributes; /* def eq( a:Seq[Node], b:Seq[Node] ):boolean = { @@ -30,7 +30,7 @@ object Test with Application { def label = "hello"; def namespace = ""; def child = List(Elem("","world",e)); - def attribute = e; + def attributes = e; }; assertSameElements( List( 3 ), List( 3 )); @@ -274,5 +274,53 @@ val addrBook = </result> )); + /* patterns */ + Console.println("patterns"); + assertEquals(<hello/> match { case <hello/> => true; case _ => false; }, + true); + + assertEquals( + <hello foo="bar"> + <world/> + </hello> match { case <hello> + <world/> + </hello> => true; + case _ => false; }, + true); + + assertEquals( + <hello foo="bar"> + crazy text world + </hello> match { case <hello> + crazy text world + </hello> => true; + case _ => false; }, + true); + + /* namespaces */ + Console.println("namespaces"); + val cuckoo = <cuckoo xmlns="http://cuckoo.com"> + <foo/> + <bar/> + </cuckoo>; + assertEquals( cuckoo.namespace, "http://cuckoo.com"); + for( val n <- cuckoo.child ) { + assertEquals( n.namespace, "http://cuckoo.com"); + } + + /* + assertEquals( true, cuckoo match { + case <cuckoo xmlns="http://cuckoo.com"> + <foo/> + <bar/> + </cuckoo> => true; + case _ => false; }); +*/ + assertEquals( false, cuckoo match { + case <cuckoo> + <foo/> + <bar/> + </cuckoo> => true; + case _ => false; }); } diff --git a/test/files/xml/lnk.check b/test/files/xml/lnk.check index f9f959fd5a..e7dca84cc8 100644 --- a/test/files/xml/lnk.check +++ b/test/files/xml/lnk.check @@ -1,5 +1,5 @@ -<link target="http://www.scala.org"><name>hello-link</name></link> -<lnkDB><linkgroup><groupname>LDAP Links</groupname><link target="http://www.openldap.org/doc/"><name>OpenLDAP Administration Guide</name><description>contains very readable section "What is LDAP"</description></link><linkgroup><groupname>LDAP RFCs</groupname><link target="ftp://ftp.isi.edu/in-notes/rfc2251.txt"><name>RFC2251 Lightweight Directory Access Protocol (v3)</name></link><link target="ftp://ftp.isi.edu/in-notes/rfc2252.txt"><name>Lightweight Directory Access Protocol (v3): +<link target="http://www.scala.org" xmlns="http://scala.epfl.ch/testSuite/links"><name>hello-link</name></link> +<lnkDB xmlns="http://scala.epfl.ch/testSuite/links"><linkgroup><groupname>LDAP Links</groupname><link target="http://www.openldap.org/doc/"><name>OpenLDAP Administration Guide</name><description>contains very readable section "What is LDAP"</description></link><linkgroup><groupname>LDAP RFCs</groupname><link target="ftp://ftp.isi.edu/in-notes/rfc2251.txt"><name>RFC2251 Lightweight Directory Access Protocol (v3)</name></link><link target="ftp://ftp.isi.edu/in-notes/rfc2252.txt"><name>Lightweight Directory Access Protocol (v3): Attribute Syntax Definitions</name></link><link target="ftp://ftp.isi.edu/in-notes/rfc2253.txt"><name>Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names </name></link><link target="ftp://ftp.isi.edu/in-notes/rfc2254.txt"><name>The String Representation of LDAP Search Filters</name></link></linkgroup><linkgroup><groupname>LDAP and Lotus Notes</groupname><link target="http://www.shmoo.com/mail/fw1/jul99/msg00040.html"><name>LDAP enabled on Notes... to change settings</name></link><link target="http://www.openldap.org/lists/openldap-general/200103/msg00004.html"><name>Replicating Notes data to OpenLDAP</name></link></linkgroup></linkgroup></lnkDB> diff --git a/test/files/xml/lnk.namespace b/test/files/xml/lnk.namespace new file mode 100644 index 0000000000..5d787d9564 --- /dev/null +++ b/test/files/xml/lnk.namespace @@ -0,0 +1 @@ +http://scala.epfl.ch/testSuite/links
\ No newline at end of file diff --git a/test/files/xml/lnk.scala b/test/files/xml/lnk.scala index 962c2f9149..8d81eae609 100644 --- a/test/files/xml/lnk.scala +++ b/test/files/xml/lnk.scala @@ -1,6 +1,6 @@ // $Id$ -import scala.xml.Node; +import scala.xml.{Attribute, AttributeSeq, Node}; import dtd._; object Test { @@ -14,7 +14,12 @@ object Test { // !!! System.out.println(b.toXML); // construct data using constructor - val c = Link(n + "target" -> "http://www.scala.org", Name(n, scala.xml.Text("hello-link"))); + val c = Link( + new AttributeSeq( + Attribute("","target","http://www.scala.org") + ), + Name(n, scala.xml.Text("hello-link")) + ); //c.getAttribs.update("target", "http://www.scala.org"); System.out.println( c ); diff --git a/test/files/xml/xhtml.check b/test/files/xml/xhtml.check index 50186a8428..1cb0cbf6b4 100644 --- a/test/files/xml/xhtml.check +++ b/test/files/xml/xhtml.check @@ -1,2 +1,2 @@ -<html version="-//W3C//DTD XHTML Basic 1.0//EN" xmlns="http://www.w3.org/1999/xhtml"><head profile="" xmlns="http://www.w3.org/1999/xhtml"><base href="http://here.edu" xmlns="http://www.w3.org/1999/xhtml"></base><title xmlns="http://www.w3.org/1999/xhtml">a basic xhtml page</title></head><body xmlns="http://www.w3.org/1999/xhtml"><h1 xmlns="http://www.w3.org/1999/xhtml">Welcome to xhtml in scala</h1><p xmlns="http://www.w3.org/1999/xhtml">a paragraph</p><p xmlns="http://www.w3.org/1999/xhtml">another one, with a <a href="http://lampwww.epfl.ch" xmlns="http://www.w3.org/1999/xhtml">link</a> to the LAMP homepage.</p></body></html> -<html version="-//W3C//DTD XHTML Basic 1.0//EN" xmlns="http://www.w3.org/1999/xhtml"><head profile="" xmlns="http://www.w3.org/1999/xhtml"><base href="here.com" xmlns="http://www.w3.org/1999/xhtml"></base><title xmlns="http://www.w3.org/1999/xhtml">a basic xhtml page</title></head><body xmlns="http://www.w3.org/1999/xhtml"><h1 xmlns="http://www.w3.org/1999/xhtml">Welcome to xhtml in scala</h1><p xmlns="http://www.w3.org/1999/xhtml">a paragraph</p><p xmlns="http://www.w3.org/1999/xhtml">another, with a <a href="http://lampwww.epfl.ch" xmlns="http://www.w3.org/1999/xhtml">example link</a> to lamp homepage</p></body></html> +<html version="-//W3C//DTD XHTML Basic 1.0//EN" xmlns="http://www.w3.org/1999/xhtml"><head profile=""><base href="http://here.edu"></base><title>a basic xhtml page</title></head><body><h1>Welcome to xhtml in scala</h1><p>a paragraph</p><p>another one, with a <a href="http://lampwww.epfl.ch">link</a> to the LAMP homepage.</p></body></html> +<html version="-//W3C//DTD XHTML Basic 1.0//EN" xmlns="http://www.w3.org/1999/xhtml"><head profile=""><base href="here.com"></base><title>a basic xhtml page</title></head><body><h1>Welcome to xhtml in scala</h1><p>a paragraph</p><p>another, with a <a href="http://lampwww.epfl.ch">example link</a> to lamp homepage</p></body></html> diff --git a/test/files/xml/xhtml.namespace b/test/files/xml/xhtml.namespace new file mode 100644 index 0000000000..4685ae94e0 --- /dev/null +++ b/test/files/xml/xhtml.namespace @@ -0,0 +1 @@ +http://www.w3.org/1999/xhtml
\ No newline at end of file diff --git a/test/files/xml/xhtml.scala b/test/files/xml/xhtml.scala index e1510456c7..07cf3a1a74 100644 --- a/test/files/xml/xhtml.scala +++ b/test/files/xml/xhtml.scala @@ -1,6 +1,6 @@ // $Id$ -import scala.xml.{Node,Text}; +import scala.xml.{Attribute, AttributeSeq, Node, Text}; import dtd._; object Test { @@ -8,8 +8,12 @@ object Test { val n = Node.NoAttributes; def main( argv:Array[String] ) = { - val link = A( n + "href" -> "http://lampwww.epfl.ch", - Text("link")); + val link = A( + new AttributeSeq( + Attribute("","href","http://lampwww.epfl.ch") + ), + Text("link") + ); //val m = new scala.collection.mutable.HashMap[String, String]; //m.put("href","http://lampwww.epfl.ch"); @@ -21,7 +25,10 @@ object Test { P(n,Text("another one, with a "),link,Text(" to the LAMP homepage."))); val page = Html(n, Head(n, - Base(n+"href" -> "http://here.edu"), + Base( + new AttributeSeq( + Attribute("","href","http://here.edu") + )), Title(n,Text("a basic xhtml page"))), body); System.out.println( page ) ; |