removed deprecated features

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@13607 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
michelou 2007-12-19 16:52:40 +00:00
parent 9a6a83101d
commit a24d737313
18 changed files with 126 additions and 488 deletions

View File

@ -1,6 +1,6 @@
SCALA LICENSE
Copyright (c) 2002-2007 EPFL, Lausanne, unless otherwise specified.
Copyright (c) 2002-2008 EPFL, Lausanne, unless otherwise specified.
All rights reserved.
This software was developed by the Programming Methods Laboratory of the

View File

@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
* Copyright 2005-2007 LAMP/EPFL
* Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@ -141,7 +141,6 @@ trait Types {
override def typeParams = underlying.typeParams
override def typeSymbol = underlying.typeSymbol
override def typeSymbolDirect = underlying.typeSymbolDirect
@deprecated override def symbol = underlying.symbol
override def widen = underlying.widen
override def typeOfThis = underlying.typeOfThis
override def bounds = underlying.bounds
@ -211,8 +210,6 @@ trait Types {
IsDependentTraverser.result
}
@deprecated def symbol: Symbol = NoSymbol
/** The term symbol associated with the type
* Note that the symbol of the normalized type is returned (@see normalize)
*/
@ -868,7 +865,6 @@ trait Types {
override def isTrivial: Boolean = sym.isPackageClass
override def isNotNull = true
override def typeSymbol = sym
@deprecated override def symbol = sym
override def underlying: Type = sym.typeOfThis
override def prefixString =
if (settings.debug.value) sym.nameString + ".this."
@ -930,7 +926,6 @@ trait Types {
override def narrow: Type = this
override def termSymbol = sym
@deprecated override def symbol = sym
override def prefix: Type = pre
override def prefixString: String =
if ((sym.isEmptyPackage || sym.isInterpreterWrapper || sym.isPredefModule || sym.isScalaPackage) && !settings.debug.value) ""
@ -942,7 +937,6 @@ trait Types {
override val isTrivial: Boolean = thistpe.isTrivial && supertpe.isTrivial
override def isNotNull = true;
override def typeSymbol = thistpe.typeSymbol
@deprecated override def symbol = thistpe.symbol
override def underlying = supertpe
override def prefix: Type = supertpe.prefix
override def prefixString =
@ -1154,7 +1148,6 @@ trait Types {
override val decls: Scope,
override val typeSymbol: Symbol) extends CompoundType
{
@deprecated override def symbol = typeSymbol
/** refs indices */
private final val NonExpansive = 0
@ -1369,7 +1362,6 @@ trait Types {
override def termSymbol = if (sym.isAliasType) normalize.termSymbol else super.termSymbol
override def typeSymbolDirect = sym
override def termSymbolDirect = super.termSymbol
@deprecated override def symbol = if (sym.isAliasType) normalize.symbol else sym
/* @MAT
whenever you see `tp.typeSymbol.isXXXX' and then act on tp based on that predicate, you're on thin ice,
@ -1618,7 +1610,6 @@ A type's typeSymbol should never be inspected directly.
override def decls: Scope = resultType.decls
override def termSymbol: Symbol = resultType.termSymbol
override def typeSymbol: Symbol = resultType.typeSymbol
@deprecated override def symbol: Symbol = resultType.symbol
override def prefix: Type = resultType.prefix
override def closure: Array[Type] = resultType.closure
override def closureDepth: Int = resultType.closureDepth
@ -1746,7 +1737,6 @@ A type's typeSymbol should never be inspected directly.
val level = skolemizationLevel
override def typeSymbol = origin.typeSymbol
@deprecated override def symbol = origin.symbol
override def toString: String =
if (constr.inst eq null) "<null " + origin + ">"
else if (constr.inst eq NoType)
@ -1895,7 +1885,6 @@ A type's typeSymbol should never be inspected directly.
def refinementOfClass(clazz: Symbol, parents: List[Type], decls: Scope) = {
class RefinementOfClass extends RefinedType(parents, decls) {
override def typeSymbol: Symbol = clazz
@deprecated override def symbol: Symbol = clazz
}
new RefinementOfClass
}

View File

@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
* Copyright 2005-2007 LAMP/EPFL
* Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@ -255,7 +255,6 @@ abstract class UnPickler {
new RefinedType(ps, dcls) { override def symbol = clazz }
*/
new RefinedType(until(end, readTypeRef), symScope(clazz)(newTempScope)) {
@deprecated override def symbol = clazz
override def typeSymbol = clazz
}
case CLASSINFOtpe =>

View File

@ -1,25 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id: All$.scala 9262 2006-11-14 17:29:59Z mihaylov $
package scala
/**
* Dummy class which exist only to satisfy the JVM. It corresponds
* to <code>scala.All</code>. If such type appears in method
* signatures, it is erased to this one.
*
* @deprecated <i>To be removed at some time in the future. Kept only for
* backward compatibility. Newly compiled code will refer to
* <code>scala.runtime.Nothing$</code></i>
*/
sealed abstract class All$

View File

@ -1,25 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id: AllRef$.scala 10086 2007-02-21 19:10:41Z odersky $
package scala
/**
* Dummy class which exist only to satisfy the JVM. It corresponds
* to <code>scala.AllRef</code>. If such type appears in method
* signatures, it is erased to this one.
*
* @deprecated <i>To be removed at some time in the future. Kept only for
* backward compatibility. Newly compiled code will refer to
* <code>scala.runtime.Null$</code></i>
*/
sealed abstract class AllRef$

View File

@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@ -35,10 +35,6 @@ object Predef {
type boolean = scala.Boolean
type unit = scala.Unit
/** @deprecated use <code>Nothing</code> instead */
@deprecated type All = Nothing
/** @deprecated use <code>Null</code> instead */
@deprecated type AllRef = Null
/** @deprecated use <code>Int</code> instead */
@deprecated type Integer = java.lang.Integer
/** @deprecated use <code>Char</code> instead */

View File

@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@ -28,23 +28,10 @@ trait Product extends AnyRef {
*/
def productElement(n: Int): Any
/** for a case class <code>A(x_1,...,x_k))</code>, returns <code>x_(i+1)</code>
* for <code>0 &lt;= i &lt; k</code>
*
* @param n the position of the n-th element
* @throws IndexOutOfBoundsException
* @return ...
*/
@deprecated def element(n: Int): Any = productElement(n)
/** return k for a product <code>A(x_1,...,x_k))</code>
*/
def productArity: Int
/** return k for a product <code>A(x_1,...,x_k))</code>
*/
@deprecated def arity: Int = productArity
/**
* By default the empty string. Implementations may override this
* method in order to prepend a string prefix to the result of the

View File

@ -1,54 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.compat
/**
* This class will be removed soon. Use <code>scala.Math</code> instead.
*/
@deprecated
object Math {
val MIN_BYTE = java.lang.Byte.MIN_VALUE
val MAX_BYTE = java.lang.Byte.MAX_VALUE
val MIN_SHORT = java.lang.Short.MIN_VALUE
val MAX_SHORT = java.lang.Short.MAX_VALUE
val MIN_CHAR = java.lang.Character.MIN_VALUE
val MAX_CHAR = java.lang.Character.MAX_VALUE
val MIN_INT = java.lang.Integer.MIN_VALUE
val MAX_INT = java.lang.Integer.MAX_VALUE
val MIN_LONG = java.lang.Long.MIN_VALUE
val MAX_LONG = java.lang.Long.MAX_VALUE
val MIN_FLOAT = -java.lang.Float.MAX_VALUE
val EPS_FLOAT = java.lang.Float.MIN_VALUE
val MAX_FLOAT = java.lang.Float.MAX_VALUE
val NaN_FLOAT = java.lang.Float.NaN
val NEG_INF_FLOAT = java.lang.Float.NEGATIVE_INFINITY
val POS_INF_FLOAT = java.lang.Float.POSITIVE_INFINITY
val MIN_DOUBLE = -java.lang.Double.MAX_VALUE
val EPS_DOUBLE = java.lang.Double.MIN_VALUE
val MAX_DOUBLE = java.lang.Double.MAX_VALUE
val NaN_DOUBLE = java.lang.Double.NaN
val NEG_INF_DOUBLE = java.lang.Double.NEGATIVE_INFINITY
val POS_INF_DOUBLE = java.lang.Double.POSITIVE_INFINITY
val E = java.lang.Math.E
val PI = java.lang.Math.PI
def min(x: Int, y: Int): Int = java.lang.Math.min(x, y)
def max(x: Int, y: Int): Int = java.lang.Math.max(x, y)
def ceil (x: Double): Double = java.lang.Math.ceil(x)
def floor(x: Double): Double = java.lang.Math.floor(x)
def log (x: Double): Double = java.lang.Math.log(x)
def sqrt (x: Double): Double = java.lang.Math.sqrt(x)
}

View File

@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@ -163,6 +163,12 @@ object SUnit {
def enableStackTrace: Boolean = true
/** fails if <code>! actual.sameElements(expected)</code> */
def assertSameElements[A](actual: Seq[A], expected: Seq[A]) {
if (! actual.sameElements(expected))
fail("(no message)", actual.toString, expected.toString)
}
/** fails if expected != actual */
def assertEquals[A](msg: String, expected: A, actual: A) {
if (expected != actual) fail(msg, expected, actual)
@ -192,28 +198,12 @@ object SUnit {
def assertNotNull(actual: AnyRef): Unit =
assertNotNull("(no message)", actual)
/**
* @deprecated use assertNotEq instead
*/
@deprecated
def assertNotSame(msg: String, expected: AnyRef, actual: AnyRef) {
if (expected eq actual) fail(msg)
}
/**
* @deprecated use assertNotEq instead
*/
@deprecated
def assertNotSame(expected: AnyRef, actual: AnyRef) {
assertNotEq("(no message)", expected, actual)
}
/** fail if expected eq actual */
/** fails if <code>expected eq actual</code> */
def assertNotEq(msg: String, expected: AnyRef, actual: AnyRef) {
if (expected eq actual) fail(msg)
}
/** fail if expected eq actual */
/** fails if <code>expected eq actual</code> */
def assertNotEq(expected: AnyRef, actual: AnyRef) {
assertNotEq("(no message)", expected, actual)
}
@ -228,23 +218,7 @@ object SUnit {
assertNull("(no message)", actual)
}
/**
* @deprecated use assertEq instead
*/
@deprecated
def assertSame(msg: String, expected: AnyRef, actual: AnyRef) {
if (expected ne actual) fail(msg)
}
/**
* @deprecated use assertEq instead
*/
@deprecated
def assertSame(expected: AnyRef, actual: AnyRef) {
assertEq("(no message)", expected, actual)
}
/** fails if expected ne actual */
/** fails if <code>expected ne actual</code> */
def assertEq(msg: String, expected: AnyRef, actual: AnyRef) {
if (expected ne actual) fail(msg)
}

View File

@ -1,95 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.testing
/**
* Some simple methods to support unit testing with assertions
* to contain more JUnit style assertions which use Scala's features.
*
* @author Burak Emir
*
* @deprecated use <a href="SUnit.html" target="contentFrame">SUnit</a>
* instead.
*/
@deprecated
object UnitTest {
class Report(report_ok: () => Unit, report_fail: (String,String) => Unit) {
def ok(): Unit = report_ok()
def fail(actual: String, expected: String) {
report_fail(actual, expected)
}
}
var report = new Report(
{ () => Console.println("passed ok") },
{ (actual: String, expected: String) =>
Console.print("failed! we got ")
Console.print( "\""+ actual +"\"" )
Console.println(" but expected \"" + expected + "\"") })
/**
* @param r ...
*/
def setReporter(r: Report) {
this.report = r
}
/**
* @param actual ...
* @param expected ...
*/
def assertSameElements[A](actual: Seq[A], expected: Seq[A]) {
if (actual.sameElements(expected))
report.ok
else
report.fail(actual.toString, expected.toString)
}
/**
* @param actual ...
* @param expected ...
*/
def assertEquals[A](actual: A, expected: A) {
if (actual == expected)
report.ok
else
report.fail(actual.toString(), expected.toString())
}
def assertTrue(actual: Boolean) { assertEquals(actual, true) }
def assertFalse(actual: Boolean) { assertEquals(actual, false) }
def assertNull(actual: AnyRef) {
if (actual eq null)
report.ok
else
report.fail(actual.toString, "null")
}
def assertNonNull(actual: AnyRef) {
if (actual ne null)
report.ok
else
report.fail(actual.toString, "null")
}
def assertNotEquals[A](actual: A, expected: A) {
if (actual != expected)
report.ok
else
report.fail(actual.toString(), "x != "+expected.toString())
}
//def test[a](def doit: a, expected: a): Unit = assertEquals(doit, expected)
} // unitTest

View File

@ -1,31 +1,8 @@
passed ok
equality
passed ok
passed ok
passed ok
passed ok
passed ok
xpath \
passed ok
passed ok
passed ok
passed ok
passed ok
passed ok
passed ok
passed ok
xpath \\ DESCENDANTS
passed ok
passed ok
<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book>
passed ok
-- group nodes
<f><a></a><b></b><c></c></f>
<a></a><f><a></a><b></b><c></c></f><a></a><b></b><c></c>
passed ok
passed ok
passed ok
attribute value normalization
passed ok
passed ok
passed ok

View File

@ -1,37 +1,37 @@
import java.io.StringReader;
import org.xml.sax.InputSource;
import scala.xml._;
import scala.util.logging._;
import java.io.StringReader
import org.xml.sax.InputSource
import scala.testing.UnitTest._ ;
import scala.xml._
import scala.util.logging._
object Test {
def main(args:Array[String]) = {
val e: scala.xml.MetaData = Null; //Node.NoAttributes;
val sc: scala.xml.NamespaceBinding = TopScope;
import scala.testing.SUnit._
object Test extends Application with Assert {
val e: scala.xml.MetaData = Null //Node.NoAttributes
val sc: scala.xml.NamespaceBinding = TopScope
val xmlFile1 = "<hello><world/></hello>";
val isrc1 = new InputSource( new StringReader(xmlFile1) );
val parsedxml1 = XML.load(isrc1);
val isrc11 = new InputSource( new StringReader( xmlFile1 ) );
val parsedxml11 = XML.load(isrc11);
val isrc1 = new InputSource(new StringReader(xmlFile1))
val parsedxml1 = XML.load(isrc1)
val isrc11 = new InputSource(new StringReader(xmlFile1))
val parsedxml11 = XML.load(isrc11)
val c = new Node {
def label = "hello";
def label = "hello"
override def hashCode() =
Utility.hashCode(prefix, label, attributes.hashCode(), scope.hashCode(), child);
def child = Elem(null, "world", e, sc);
//def attributes = e;
override def text = "";
};
override def text = ""
}
assertSameElements( List( 3 ), List( 3 ));
assertSameElements(List(3), List(3))
Console.println("equality");
assertEquals(c, parsedxml11);
assertEquals(parsedxml1, parsedxml11);
assertSameElements( List(parsedxml1), List(parsedxml11));
assertSameElements( Iterator.fromArray(Array(parsedxml1)).toList, List(parsedxml11));
println("equality")
assertEquals(c, parsedxml11)
assertEquals(parsedxml1, parsedxml11)
assertSameElements(List(parsedxml1), List(parsedxml11))
assertSameElements(Iterator.fromArray(Array(parsedxml1)).toList, List(parsedxml11))
val x2 = "<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book>";
@ -200,7 +200,7 @@ object Test {
assertTrue(uup == "&<<>\"\"^%@$!#")
// test unicode escapes backslash u
Console println ("attribute value normalization");
println("attribute value normalization")
val xmlAttrValueNorm = "<personne id='p0003' nom='&#x015e;ahingöz' />";
{
val isrcA = new InputSource( new StringReader(xmlAttrValueNorm) );
@ -225,9 +225,4 @@ object Test {
val p = scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString("<foo bar:attr='&amp;'/>"),true)
val n = p.element(new scala.xml.NamespaceBinding("bar","BAR",scala.xml.TopScope))(0)
assertFalse( n.attributes.get("BAR", n, "attr").isEmpty)
}
}

View File

@ -1,18 +1,9 @@
passed ok
passed ok
passed ok
<hello>world</hello>
passed ok
<hello>1.5</hello>
passed ok
<hello>5</hello>
passed ok
<hello>true</hello>
passed ok
<hello>5</hello>
passed ok
<hello>27</hello>
passed ok
<hello>1 2 3 4</hello>
1
2

View File

@ -1,21 +1,18 @@
object Test {
import scala.testing.SUnit._
import scala.xml._
import scala.testing.UnitTest._
import scala.xml._
object Test extends AnyRef with Assert {
def handle[A](x:Node): A = {
Console println x
private def handle[A](x: Node): A = {
println(x)
x.child(0).asInstanceOf[Atom[A]].data
}
def main(args:Array[String]) = {
import scala.xml.NodeSeq
import NodeSeq.view
import testing.UnitTest._
def main(args: Array[String]) {
val xNull = <hello>{null}</hello> // these used to be Atom(unit), changed to empty children
assertSameElements( xNull.child, Nil )
assertSameElements(xNull.child, Nil)
val x0 = <hello>{}</hello> // these used to be Atom(unit), changed to empty children
val x00 = <hello>{ }</hello> // dto.
@ -23,45 +20,44 @@ object Test {
val xa = <hello>{ "world" }</hello>
assertSameElements( x0.child, Nil )
assertSameElements( x00.child, Nil )
assertEquals( handle[String](xa),"world" )
assertSameElements(x0.child, Nil)
assertSameElements(x00.child, Nil)
assertEquals(handle[String](xa), "world")
val xb = <hello>{ 1.5 }</hello>
assertEquals( handle[Double](xb), 1.5 )
assertEquals(handle[Double](xb), 1.5)
val xc = <hello>{ 5 }</hello>
assertEquals( handle[Int](xc), 5 )
assertEquals(handle[Int](xc), 5)
val xd = <hello>{ true }</hello>
assertEquals( handle[Boolean](xd), true )
assertEquals(handle[Boolean](xd), true)
val xe = <hello>{ 5:short }</hello>
assertEquals( handle[Short](xe), 5:short )
assertEquals(handle[Short](xe), 5:short)
val xf = <hello>{ val x = 27; x }</hello>
assertEquals( handle[Int](xf), 27 )
assertEquals(handle[Int](xf), 27)
val xg = <hello>{ List(1,2,3,4) }</hello>
Console println xg
for(val z <- xg.child) {
Console println z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""}
println(xg)
for (z <- xg.child) {
println(z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""})
}
val xh = <hello>{ for(val x <- List(1,2,3,4); x % 2 == 0) yield x }</hello>
Console println xh
for(val z <- xh.child) {
Console println z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""}
println(xh)
for (z <- xh.child) {
println(z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""})
}
}
}
}

View File

@ -1,3 +0,0 @@
passed ok
passed ok
passed ok

View File

@ -1,17 +1,15 @@
object Test {
import scala.testing.SUnit._
import scala.testing.UnitTest._
import scala.xml._
def main(args:Array[String]) = {
object Test extends AnyRef with Assert {
def main(args: Array[String]) {
val ya = <x>{{</x>
assertEquals(ya.text, "{");
assertEquals(ya.text, "{")
val ua = <x>}}</x>
assertEquals(ua.text, "}");
assertEquals(ua.text, "}")
val za = <x>{{}}{{}}{{}}</x>
assertEquals(za.text, "{}{}{}");
assertEquals(za.text, "{}{}{}")
}
}

View File

@ -1,6 +1,4 @@
NodeSeq
passed ok
passed ok
<result>
<title>Blabla</title>
<remarks> Hallo Welt. </remarks>
@ -20,17 +18,5 @@ List(<book><title>Blabla</title></book>)
<phone where="mobile">+41 79 602 23 23</phone>
</result>
namespaces
passed ok
passed ok
passed ok
validation - elements
passed ok
passed ok
passed ok
passed ok
validation - attributes
passed ok
passed ok
passed ok
passed ok
passed ok

View File

@ -1,24 +1,25 @@
import java.io.StringReader;
import org.xml.sax.InputSource;
import scala.testing.UnitTest._ ;
import scala.xml.{Node, NodeSeq, Elem, Text, XML};
import java.io.StringReader
import org.xml.sax.InputSource
object Test {
import scala.testing.SUnit.Assert
import scala.xml.{Node, NodeSeq, Elem, Text, XML}
object Test extends AnyRef with Assert {
/** returns true if exception was thrown */
def catcher(att:Function1[Unit,scala.xml.MetaData]): Boolean = {
var ex = false;
def catcher(att: Function1[Unit, scala.xml.MetaData]): Boolean = {
var ex = false
try {
val x = att.apply({});
att.apply({})
} catch {
case scala.xml.MalformedAttributeException(msg) =>
Console.println(msg);
ex = true;
println(msg)
ex = true
}
return ex;
ex
}
def main(args:Array[String]) = {
def main(args: Array[String]) {
//val e: scala.xml.MetaData = null; //Node.NoAttributes;
//val sc: scala.xml.NamespaceBinding = null;
@ -26,7 +27,7 @@ object Test {
// ------------------------------------------ tests for class NodeSeq
/**
Console.println("checking wellformed attributes");
println("checking wellformed attributes");
{
import scala.xml.{ UnprefixedAttribute, Null }
assertTrue(catcher {x:Unit => new UnprefixedAttribute("key", "<", Null)}); // < illegal
@ -51,8 +52,7 @@ passed ok
passed ok
*/
Console.println("NodeSeq");
import scala.xml.Utility.view ;
println("NodeSeq")
val p = <foo>
<bar gt='ga' value="3"/>
@ -64,35 +64,9 @@ passed ok
Text(x.attributes("value").toString + y.attributes("bazValue").toString+ "!")
};
val pelems_2 = new NodeSeq { val theSeq = List(Text("38!"),Text("58!")) };
assertSameElements(pelems_1, pelems_2);
assertSameElements(pelems_1, pelems_2)
assertEquals(p \\ "@bazValue", Text("8"))
// the following won't work anymore because of group nodes
//assertSameElements(
// p \\ "@value", new NodeSeq { val theSeq = List(Text("3"), Text("5")) }
//);
/* // more test cases !!!
val test = <a name="bar"/>;
Console.println(test \ "@name");
val x = test.attributes.nodes;
Console.println("trying to print");
val it = x.elements;
while(it.hasNext) {
val c = it.next;
Console.println(c);
Console.println("c.label == @name? "+(c.label == "@name"));
}
*/
/*
for(val c <- x) {
Console.println(x);
}
*/
val books =
<bks>
@ -120,10 +94,10 @@ passed ok
</entry>
</reviews>;
Console.println( new scala.xml.PrettyPrinter(80, 5).formatNodes (
for( val t <- books \\ "title";
val r <- reviews \\ "entry";
r \ "title" == t) yield
println( new scala.xml.PrettyPrinter(80, 5).formatNodes (
for (t <- books \\ "title";
r <- reviews \\ "entry"
if r \ "title" == t) yield
<result>
{ t }
{ r \ "remarks" }
@ -131,8 +105,8 @@ passed ok
));
// example
Console.println(
for( val t @ <book><title>Blabla</title></book> <- new NodeSeq { val theSeq = books.child }.toList)
println(
for (t @ <book><title>Blabla</title></book> <- new NodeSeq { val theSeq = books.child }.toList)
yield t
);
val phoneBook =
@ -162,10 +136,10 @@ val addrBook =
</entry>
</addrbook>;
Console.println( new scala.xml.PrettyPrinter(80, 5).formatNodes (
for( val t <- addrBook \\ "entry";
val r <- phoneBook \\ "entry";
t \ "name" == r \ "name") yield
println( new scala.xml.PrettyPrinter(80, 5).formatNodes (
for (t <- addrBook \\ "entry";
r <- phoneBook \\ "entry"
if t \ "name" == r \ "name") yield
<result>
{ t.child }
{ r \ "phone" }
@ -175,46 +149,24 @@ val addrBook =
/* namespaces */
// begin tmp
Console.println("namespaces");
println("namespaces")
val cuckoo = <cuckoo xmlns="http://cuckoo.com">
<foo/>
<bar/>
</cuckoo>;
assertEquals( cuckoo.namespace, "http://cuckoo.com");
for( val n <- cuckoo \ "_" ) {
//Console.println("n = "+n);
//Console.println("n.prefix = "+n.prefix);
//Console.println("n.scope = "+n.scope);
assertEquals( n.namespace, "http://cuckoo.com");
assertEquals(cuckoo.namespace, "http://cuckoo.com")
for (n <- cuckoo \ "_" ) {
//println("n = "+n);
//println("n.prefix = "+n.prefix);
//.println("n.scope = "+n.scope);
assertEquals( n.namespace, "http://cuckoo.com")
}
// end tmp
/*
DEPRECATED, don't support namespaces in pattern match anymore
*/
/*
assertEquals( true, cuckoo match {
case <cuckoo xmlns="http://cuckoo.com">
<foo/>
<bar/>
</cuckoo> => true;
case _ => false; });
*/
/*
// begin tmp
assertEquals( false, cuckoo match {
case <cuckoo>
<foo/>
<bar/>
</cuckoo> => true;
case _ => false; });
// end tmp
*/
Console.println("validation - elements");
println("validation - elements")
val vtor = new scala.xml.dtd.ElementValidator();
{
import scala.xml.dtd.ELEMENTS;
import scala.xml.dtd.ContentModel._;
import scala.xml.dtd.ELEMENTS
import scala.xml.dtd.ContentModel._
vtor.setContentModel(
ELEMENTS(
Sequ(
@ -222,10 +174,10 @@ DEPRECATED, don't support namespaces in pattern match anymore
Star(Letter(ElemName("baz"))) )));
}
assertEquals( vtor( <foo><bar/><baz/><baz/></foo> ), true );
assertEquals(vtor( <foo><bar/><baz/><baz/></foo> ), true);
{
import scala.xml.dtd.MIXED;
import scala.xml.dtd.ContentModel._;
import scala.xml.dtd.MIXED
import scala.xml.dtd.ContentModel._
vtor.setContentModel(
MIXED(
@ -234,28 +186,28 @@ DEPRECATED, don't support namespaces in pattern match anymore
Letter(ElemName("bal")))));
}
assertEquals( vtor( <foo><bar/><baz/><baz/></foo> ), true );
assertEquals( vtor( <foo>ab<bar/>cd<baz/>ed<baz/>gh</foo> ), true );
assertEquals( vtor( <foo> <ugha/> <bugha/> </foo> ), false );
assertEquals(vtor(<foo><bar/><baz/><baz/></foo> ), true)
assertEquals(vtor(<foo>ab<bar/>cd<baz/>ed<baz/>gh</foo> ), true)
assertEquals(vtor(<foo> <ugha/> <bugha/> </foo> ), false)
Console.println("validation - attributes");
vtor.setContentModel(null);
vtor.setMetaData(List());
assertEquals( vtor( <foo bar="hello"/> ), false );
println("validation - attributes")
vtor.setContentModel(null)
vtor.setMetaData(List())
assertEquals(vtor( <foo bar="hello"/> ), false)
{
import scala.xml.dtd._ ;
vtor.setMetaData(List(AttrDecl("bar","CDATA",IMPLIED)));
import scala.xml.dtd._
vtor setMetaData List(AttrDecl("bar", "CDATA", IMPLIED))
}
assertEquals( vtor( <foo href="http://foo.com" bar="hello"/> ), false );
assertEquals( vtor( <foo bar="hello"/> ), true );
assertEquals(vtor(<foo href="http://foo.com" bar="hello"/>), false)
assertEquals(vtor(<foo bar="hello"/>), true)
{
import scala.xml.dtd._ ;
vtor.setMetaData(List(AttrDecl("bar","CDATA",REQUIRED)));
import scala.xml.dtd._
vtor.setMetaData(List(AttrDecl("bar","CDATA",REQUIRED)))
}
assertEquals( vtor( <foo href="http://foo.com" /> ), false );
assertEquals( vtor( <foo bar="http://foo.com" /> ), true );
assertEquals( vtor( <foo href="http://foo.com" /> ), false )
assertEquals( vtor( <foo bar="http://foo.com" /> ), true )
}
}