diff options
author | buraq <buraq@epfl.ch> | 2004-05-26 10:44:25 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-05-26 10:44:25 +0000 |
commit | 65788124d76bf20a08f12685b72fb9d14322f3e0 (patch) | |
tree | 5eb8028ba0f73246874bc463c03727f2bced1352 /test/files | |
parent | 1f7970f3c60575d1715d1c5dd022dfa0d08bb51a (diff) | |
download | scala-65788124d76bf20a08f12685b72fb9d14322f3e0.tar.gz scala-65788124d76bf20a08f12685b72fb9d14322f3e0.tar.bz2 scala-65788124d76bf20a08f12685b72fb9d14322f3e0.zip |
*** empty log message ***
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/xmlLiterals.check | 16 | ||||
-rw-r--r-- | test/files/run/xmlLiterals.scala | 156 | ||||
-rw-r--r-- | test/files/run/xmlParsing.check | 0 | ||||
-rw-r--r-- | test/files/run/xmlParsing.scala | 51 | ||||
-rw-r--r-- | test/files/run/xmlParsing_attr.check | 2 | ||||
-rw-r--r-- | test/files/run/xmlParsing_attr.scala | 17 | ||||
-rw-r--r-- | test/files/run/xmlParsing_servlet.check | 23 | ||||
-rw-r--r-- | test/files/run/xmlParsing_servlet.scala | 83 | ||||
-rw-r--r-- | test/files/run/xmlRef.check | 2 | ||||
-rw-r--r-- | test/files/run/xmlRef.scala | 23 |
10 files changed, 0 insertions, 373 deletions
diff --git a/test/files/run/xmlLiterals.check b/test/files/run/xmlLiterals.check deleted file mode 100644 index 04f0426af9..0000000000 --- a/test/files/run/xmlLiterals.check +++ /dev/null @@ -1,16 +0,0 @@ -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -ArrayBuffer(<foo></foo>, <bar>Text</bar>, <foo></foo>) -<foo></foo> -passed ok -passed ok -passed ok diff --git a/test/files/run/xmlLiterals.scala b/test/files/run/xmlLiterals.scala deleted file mode 100644 index 63600f7962..0000000000 --- a/test/files/run/xmlLiterals.scala +++ /dev/null @@ -1,156 +0,0 @@ -//############################################################################ -// XML Literals -//############################################################################ -// $Id$ - -import scala.testing.UnitTest._ ; - -import scala.xml._ ; - -object Test with Application { - - def noWS(x:String):String = { - val res = new StringBuffer(); - var i = 0; while( i < x.length() ) { - val c = x.charAt( i ); - c match { - case ' ' | '\n' | '\t' => - case _ => res.append( c ) - } - i = i + 1; - } - res.toString(); - } - - - - /* */ - /* === tags, elements === */ - /* */ - - val x = <hello></hello>.toString(); /* see neg(1) */ - - /* whitespace (ws) handling */ - - val x2 = <hello > </hello>.toString(); /* ws in tags allowed */ - - assertEquals( x, noWS( x2 ) ); - - val x3 = <hello> - <world></world> - <test/> - <mars></mars></hello>.toString(); /* ws in element content */ - - - assertEquals( noWS( x3 ), - Elem("hello", - Elem("world"), - Elem("test"), - Elem("mars")).toString() ); - - - /* */ - /* === attributes === */ - /* */ - - val z = <html> - <body background="#FFFFFF"> - <h1>Hello World</h1> - <p>Check the <a href="scala.epfl.ch">scala</a> page!</p> - </body> - </html>.toString(); - - assertEquals( noWS( z ), noWS( - Elem("html", - Elem("body", - Elem("h1",Text("Hello World")), - Elem("p",Text("Check the "), - Elem("a", Text("scala")) - % Pair("href","scala.epfl.ch"), - Text("page!")) - ) % Pair("background","#FFFFFF") - ).toString() - )); - - /* todo: better way to deal with whitespace in content */ - /* (Canonical XML or even more aggressive normlization) */ - - /* */ - /* === embedded Scala blocks === */ - /* */ - - def computeDate() = { - Elem("date", Text("now!")); - } - - - /* embedding Scala strings as text and elements */ - val sc = <hello>{ "World" }{ Text("42") }{ computeDate() }</hello>; - - assertEquals( sc.child.elements.toList, - List( Text("World"), Text("42"), Elem( "date", Text("now!") ) ) ); - - assertEquals( sc.toString(), - Elem("hello",Text("World42"),Elem("date",Text("now!"))).toString() ); - - 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.toString() + e2.toString(); - } - - 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/>.toString() + <b><c/></b>.toString() ); - - val rows = <tr> - <td>1.1</td><td>1.2</td> - </tr> - <tr> - <td>2.1</td><td>2.2</td> - </tr>; - - assertEquals( noWS( rows.toList.toString() ), - noWS( List(Elem("tr", - Elem("td",Text("1.1")),Elem("td",Text("1.2")) - ), - Elem("tr", - Elem("td",Text("2.1")),Elem("td",Text("2.2")) - ) - ).toString() ) - ); - val rows2 = <tr><!-- an XML comment --><td>1.1</td><td>1.2</td> - </tr> - <tr> - <td>2.1</td><td>2.2</td> - </tr>; - - assertEquals( noWS( rows.toList.toString() ), noWS( rows2.toList.toString() ) ); - - val sequence = <foo/> - <bar>Text</bar> - <foo/>; - - Console.println( sequence ); - - val onlyOne = <foo/>; - - Console.println( onlyOne ); - - val tryBrace = <try>Now we try escaped {{ braces } </try>; - - assertEquals( tryBrace, Elem("try",Text("Now we try escaped { braces }"))); - - val tryBrace2 = <try myAttrib={ (3+4).toString() }> cool ?</try>; - - assertEquals( tryBrace2("myAttrib").get, "7" ); - - /* Scala comments are not allowed in XML literals. see neg(2) */ - val zzz = <hello>/* no comment */</hello>; - assertEquals( zzz, Elem("hello", Text("/* no comment */"))); - -} - diff --git a/test/files/run/xmlParsing.check b/test/files/run/xmlParsing.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/xmlParsing.check +++ /dev/null diff --git a/test/files/run/xmlParsing.scala b/test/files/run/xmlParsing.scala deleted file mode 100644 index beedf44b62..0000000000 --- a/test/files/run/xmlParsing.scala +++ /dev/null @@ -1,51 +0,0 @@ -//############################################################################ -// XML Parsing -//############################################################################ -// $Id$ - -import scala.testing.UnitTest._ ; - -import scala.xml._ ; - -/** this file test just succesful run of the parser. There are no checks whether - * the encoding to Scala expressions is done correctly - */ -object Test with Application { - - val x0 = <hello/>; - val x1s = <foo></foo>.toString(); - val x2 = <foo><bar><baz/></bar><bar/></foo>.toString(); - - /* whitespace (ws) handling */ - - val x3 = <hello > </hello>.toString(); /* ws in tags allowed */ - - val x4 = <hello> - <world></world> - <test/> - <mars></mars></hello>.toString(); /* ws in element content */ - - /* attributes */ - - val z = <html> - <body background="#FFFFFF"> - <h1>Hello World</h1> - <p>Check the <a href="scala.epfl.ch">scala</a> page!</p> - </body> - </html>.toString(); - - val ent = <foo> - hello character entities! - welcome   unicode characters! - </foo>; - - - val foo = <a/><b/><c/>; - - val foo2 = foo match { - case <a/><b/> => 1 - case <a></a><b></b><c></c> => 2 - case Seq(Elem("a"),Elem("b"),Elem("c")) => 3 - }; - -} diff --git a/test/files/run/xmlParsing_attr.check b/test/files/run/xmlParsing_attr.check deleted file mode 100644 index 9c042b5de2..0000000000 --- a/test/files/run/xmlParsing_attr.check +++ /dev/null @@ -1,2 +0,0 @@ -<testTag value="This is a test." ab="bkla"></testTag> -<testTag value="42" bla="foo"></testTag> diff --git a/test/files/run/xmlParsing_attr.scala b/test/files/run/xmlParsing_attr.scala deleted file mode 100644 index ea2eb60bf6..0000000000 --- a/test/files/run/xmlParsing_attr.scala +++ /dev/null @@ -1,17 +0,0 @@ -import scala.xml._ ; - -object Test with Application { - - val testValue = "This is a test."; - - val testValue2 = 42; - - val page = <testTag value={ testValue } ab="bkla" />; - - val page2 = <testTag value={testValue2.toString()} bla="foo"></testTag>; - - Console.println( page.toString() ); - - Console.println( page2.toString() ); - -} diff --git a/test/files/run/xmlParsing_servlet.check b/test/files/run/xmlParsing_servlet.check deleted file mode 100644 index ef35a97716..0000000000 --- a/test/files/run/xmlParsing_servlet.check +++ /dev/null @@ -1,23 +0,0 @@ -<html> - <head> - <title>ModularFormatting</title> - </head> - <body> - <h2>Welcome</h2> - <p> - What follows is an example of modular formatting. - </p> - <p> - <table align="center"> - <tr> - <td color="#222255" bgcolor="#AAAAFF"><h1> message </h1></td> - </tr> - </table> - </p> - <hr></hr> - <p> - Complicated layout tasks can be encapsulated and outsourced. - </p> - <h2>Bye!</h2> - </body> - </html> diff --git a/test/files/run/xmlParsing_servlet.scala b/test/files/run/xmlParsing_servlet.scala deleted file mode 100644 index 7bd622b0a6..0000000000 --- a/test/files/run/xmlParsing_servlet.scala +++ /dev/null @@ -1,83 +0,0 @@ -import scala.xml._ ; - -object Test { - - val headerMsg = Text("What follows is an example of modular formatting."); - val footerMsg = Text("Complicated layout tasks can be encapsulated and outsourced."); - - /** helper function for the main page, provides header and a footer - */ - def page( ns:Seq[Node] ) = { - <html> - <head> - <title>ModularFormatting</title> - </head> - <body> - <h2>Welcome</h2> - <p> - { headerMsg } - </p> - <p> - { ns:_* } - </p> - <hr/> - <p> - { footerMsg } - </p> - <h2>Bye!</h2> - </body> - </html> - } - - /** applies beautify to every element in a sequence - */ - def beautify( xs:Seq[Node] ):Seq[Node] = xs.toList.map { beautify } - - /** this is a recursive procedure that adds some attributes to the tree - */ - def beautify( n:Node ):Node = n match { - case <td>{ xs @ _* }</td> => - <td bgcolor="#AAAAFF" color="#222255">{ xs:_* }</td> - - case <table>{ xs @ _* }</table> => - <table align="center">{ beautify( xs ):_* }</table> - - case Elem( label, xs @ _* ) => - Elem( label, beautify( xs ):_*) - - case _ => n - } - - /** this function will take a node and put it in a table - */ - def format( msg:Node ):Node = { - <table> - <tr> - <td>{ msg }</td> - </tr> - </table> - } - - /** returns a highlighted text node with the string given as arguemnt. if it - * is null, supplies a default string. - */ - def getMessage( x:String ) = { - if( x == null ) - <h1> This could be YOUR message ! </h1> - else - <h1> { Text( x ) } </h1> - } - - /** the entry method - */ - def doGetXML() = { - beautify( page( List( format( getMessage( "message" ) )) )); - /* page( List( format( theMessage ))); */ - - } - - def main( args:Array[String] ) = { - Console.println( doGetXML() ); - } - -} diff --git a/test/files/run/xmlRef.check b/test/files/run/xmlRef.check deleted file mode 100644 index 049f160175..0000000000 --- a/test/files/run/xmlRef.check +++ /dev/null @@ -1,2 +0,0 @@ -<foo>{</foo> -<foo> {<bar><baz></baz></bar><bar></bar></foo> diff --git a/test/files/run/xmlRef.scala b/test/files/run/xmlRef.scala deleted file mode 100644 index 47bc5dd6dd..0000000000 --- a/test/files/run/xmlRef.scala +++ /dev/null @@ -1,23 +0,0 @@ -//############################################################################ -// XML Parsing -//############################################################################ -// $Id$ - -import scala.testing.UnitTest._ ; - -import scala.xml._ ; - -/** this file test just succesful run of the parser. There are no checks whether - * the encoding to Scala expressions is done correctly - */ -object Test with Application { - - val x1s = <foo>{</foo>.toString(); - - Console.println( x1s ); - - val x2 = <foo> {<bar><baz/></bar><bar/></foo>.toString(); - - Console.println( x2 ); - -} |