summaryrefslogtreecommitdiff
path: root/src/partest-extras/scala/tools/partest/ParserTest.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 /src/partest-extras/scala/tools/partest/ParserTest.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 'src/partest-extras/scala/tools/partest/ParserTest.scala')
-rw-r--r--src/partest-extras/scala/tools/partest/ParserTest.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/partest-extras/scala/tools/partest/ParserTest.scala b/src/partest-extras/scala/tools/partest/ParserTest.scala
new file mode 100644
index 0000000000..e4c92e3dc3
--- /dev/null
+++ b/src/partest-extras/scala/tools/partest/ParserTest.scala
@@ -0,0 +1,21 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2014 LAMP/EPFL
+ */
+
+package scala.tools.partest
+
+/** A class for testing parser output.
+ * Just supply the `code` and update the check file.
+ */
+abstract class ParserTest extends DirectTest {
+
+ override def extraSettings: String = "-usejavacp -Ystop-after:parser -Xprint:parser"
+
+ override def show(): Unit = {
+ // redirect err to out, for logging
+ val prevErr = System.err
+ System.setErr(System.out)
+ compile()
+ System.setErr(prevErr)
+ }
+}