blob: d0d97e64ebea31f5dc060a02fa96e4ff2700ee2a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
object Test {
def main(args:Array[String]) = {
import scala.xml.NodeSeq
import NodeSeq.view
import testing.UnitTest._
val ax = <hello foo="bar">
<world/>
</hello>
Console.println("attributes");
Console.println("one");
assertEquals(ax \ "@foo", "bar")
Console.println("two");
assertEquals(ax \ "@foo", xml.Text("bar"))
val bx = <hello foo="bar&x"></hello>
Console.println("three");
assertEquals(bx \ "@foo", "bar&x")
Console.println("four");
assertSameElements(bx \ "@foo", List(xml.Text("bar&x")))
//assertSameElements(bx \ "@foo", List(xml.Text("bar"),xml.EntityRef("amp"),xml.Text("x")))
Console.println("five");
assertEquals(bx.toString, "<hello foo=\"bar&x\"></hello>")
/* patterns */
Console.println("patterns");
assertEquals(<hello/> match { case <hello/> => true; case _ => false; },
true);
/*
assertEquals(ax match { case x @ <hello>
<world/>
</hello> if x \ "@foo" == "bar" => true;
case _ => false; },
true);
assertEquals(
<hello foo="bar">
crazy text world
</hello> match { case <hello>
crazy text world
</hello> => true;
case _ => false; },
true);
*/
}
}
|