1
+ package scala .xml
2
+
3
+ // these tests depend on xml, so they ended up here,
4
+ // though really they are compiler tests
5
+
6
+ import scala .collection ._
7
+ import scala .collection .mutable .ArrayBuffer
8
+
9
+ // t1626
10
+ object o {
11
+ val n = <a xmlns =" " />
12
+ n.namespace == null
13
+ }
14
+
15
+ // t1761
16
+ class Foo {
17
+ val elements : Seq [Node ] = Nil
18
+ val innerTransform : PartialFunction [Elem , String ] = {
19
+ case Elem (_, l : String , _, _, _@ _* ) if elements.exists(_.label == l) =>
20
+ l
21
+ }
22
+ }
23
+
24
+ // t2281
25
+ class A {
26
+ def f (x : Boolean ) = if (x) <br /><br /> else <br />
27
+ }
28
+
29
+ class B {
30
+ def splitSentences (text : String ): ArrayBuffer [String ] = {
31
+ val outarr = new ArrayBuffer [String ]
32
+ var outstr = new StringBuffer
33
+ var prevspace = false
34
+ val ctext = text.replaceAll(" \n +" , " \n " )
35
+ ctext foreach { c =>
36
+ outstr append c
37
+ if (c == '.' || c == '!' || c == '?' || c == '\n ' || c == ':' || c == ';' || (prevspace && c == '-' )) {
38
+ outarr += outstr.toString
39
+ outstr = new StringBuffer
40
+ }
41
+ if (c == '\n ' ) {
42
+ outarr += " \n\n "
43
+ }
44
+ prevspace = c == ' '
45
+ }
46
+ if (outstr.length > 0 ) {
47
+ outarr += outstr.toString
48
+ }
49
+ outarr
50
+ }
51
+
52
+ def spanForSentence (x : String , picktext : String ) =
53
+ if (x == " \n\n " ) {
54
+ <br /><br />
55
+ } else {
56
+ <span class =' clicksentence' style ={ if (x == picktext) " background-color: yellow" else " " }>{ x }</span >
57
+ }
58
+
59
+ def selectableSentences (text : String , picktext : String ) = {
60
+ val sentences = splitSentences(text)
61
+ sentences.map(x => spanForSentence(x, picktext))
62
+ }
63
+ }
64
+
65
+ // SI-5858
66
+ object Test {
67
+ new Elem (null , null , Null , TopScope , Nil : _* ) // was ambiguous
68
+ }
69
+
70
+ class Floozy {
71
+ def fooz (x : Node => String ) = {}
72
+ def foo (m : Node ): Unit = fooz {
73
+ case Elem (_, _, _, _, n, _* ) if (n == m) => " gaga"
74
+ }
75
+ }
76
+
77
+ object guardedMatch { // SI-3705
78
+ // guard caused verifyerror in oldpatmat -- TODO: move this to compiler test suite
79
+ def updateNodes (ns : Seq [Node ]): Seq [Node ] =
80
+ for (subnode <- ns) yield subnode match {
81
+ case <d >{ _ }</d > if true => <d >abc</d >
82
+ case Elem (prefix, label, attribs, scope, children @ _* ) =>
83
+ Elem (prefix, label, attribs, scope, minimizeEmpty = true , updateNodes(children): _* )
84
+ case other => other
85
+ }
86
+ updateNodes(<b />)
87
+ }
88
+
89
+ // SI-6897
90
+ object shouldCompile {
91
+ val html = (null : Any ) match {
92
+ case 1 => <xml : group ></xml : group >
93
+ case 2 => <p ></p >
94
+ }
95
+ }
0 commit comments