summaryrefslogtreecommitdiff
path: root/test/files/run/t3368.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2014-12-20 02:28:44 -0800
committerSom Snytt <som.snytt@gmail.com>2015-04-08 09:20:24 -0700
commit4df81aab315e587d9c7e319c7a2ece0f0f6fbaf3 (patch)
treed83454b666d54549d88f52bd800cddb66bd46041 /test/files/run/t3368.scala
parent476eef82dfed90278de45739ca72819b1b4be5a4 (diff)
downloadscala-4df81aab315e587d9c7e319c7a2ece0f0f6fbaf3.tar.gz
scala-4df81aab315e587d9c7e319c7a2ece0f0f6fbaf3.tar.bz2
scala-4df81aab315e587d9c7e319c7a2ece0f0f6fbaf3.zip
SI-3368 CDATA gets a Node
XML Parser uses `scala.xml.PCData`. A compiler flag `-Yxml:coalescing`, analogous to `DocumentBuilderFactory.setCoalescing`, turns `PCData` nodes into `Text` nodes and coalesces sibling text nodes. This change also fixes parse errors such as rejecting a sequence of CDATA sections. A sequence of "top level" nodes are not coalesced. ``` scala> <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a> res0: scala.xml.Elem = <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a> scala> :replay -Yxml:coalescing Replaying: <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a> res0: scala.xml.Elem = <a><b/>starthi &amp; bye<c/>world<d/>stuffred &amp; black</a> ```
Diffstat (limited to 'test/files/run/t3368.scala')
-rw-r--r--test/files/run/t3368.scala18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/files/run/t3368.scala b/test/files/run/t3368.scala
new file mode 100644
index 0000000000..aaf34b43fb
--- /dev/null
+++ b/test/files/run/t3368.scala
@@ -0,0 +1,18 @@
+
+import scala.tools.partest.ParserTest
+
+
+object Test extends ParserTest {
+
+ override def code = """
+ trait X {
+ // error: in XML literal: name expected, but char '!' cannot start a name
+ def x = <![CDATA[hi & bye]]> <![CDATA[red & black]]>
+ }
+ trait Y {
+ def y = <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a>
+ }
+ """
+
+ override def extraSettings = s"${super.extraSettings} -Yxml:coalescing"
+}