summaryrefslogtreecommitdiff
path: root/test/files/run/t4339.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/t4339.scala')
-rw-r--r--test/files/run/t4339.scala35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/files/run/t4339.scala b/test/files/run/t4339.scala
new file mode 100644
index 0000000000..bb8b847ec3
--- /dev/null
+++ b/test/files/run/t4339.scala
@@ -0,0 +1,35 @@
+
+import scala.util.{ Try, Success, Failure }
+import xml._
+import scala.io.Source.fromString
+import java.io.PrintStream
+
+object Test extends App {
+
+ def quietSource(text: String) = new io.Source {
+ override protected val iter = io.Source fromString text
+ override def report(pos: Int, msg: String, out: PrintStream) = ()
+ }
+ def reading(text: String)(f: pull.XMLEventReader => Unit): Unit = {
+ val r = new pull.XMLEventReader(quietSource(text))
+ try f(r)
+ finally r.stop()
+ }
+ def trying(body: => Unit): Unit =
+ Try (body) match {
+ case Success(_) => Console println "Expected failure"
+ case Failure(e) => Console println s"Saw failure: $e"
+ }
+
+ val problematic = """<foo bar="baz/>"""
+
+ trying (
+ parsing.ConstructingParser.fromSource(quietSource(problematic), false).document.docElem
+ )
+
+ trying (
+ reading(problematic) { r =>
+ while (r.hasNext) println(r.next())
+ }
+ )
+}