From 98e4194b2fac38fff0d4e40329b8273430f41a26 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Fri, 30 Sep 2016 15:24:48 -0400 Subject: [PATCH 01/11] Add ScalaCheck to build.sbt --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index a284f9e2d..fd5c0181e 100644 --- a/build.sbt +++ b/build.sbt @@ -107,6 +107,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform) libraryDependencies += "junit" % "junit" % "4.12" % Test, libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.9" % Test, + libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.2" % Test, libraryDependencies += ("org.scala-lang" % "scala-compiler" % scalaVersion.value % Test).exclude("org.scala-lang.modules", s"scala-xml_${scalaBinaryVersion.value}") ) .jsSettings( From aaec213433afcf67618f26bab0f56dc9e6d58c4d Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Fri, 30 Sep 2016 15:25:19 -0400 Subject: [PATCH 02/11] Add ScalaCheck specs to test suite Adds 26 specifications in ScalaCheck, with 154 properties, of 18 are proofs by example, and the rest are 136 tests using randomly-generated values. ScalaCheck requires at least 100 generated tests to pass, by default. So that gives 13,618 new tests! The suite should be a real benefit for future maintenance endeavors, rewrites, documentation, or finishing a Scala-based parser to avoid depending on the the Xerces/SAX Java library. These integrate well with the existing suite of JUnit 4 tests. If you want to run both the ScalaCheck and JUnit tests from SBT, > test ... [info] Passed: Total 145, Failed 0, Errors 0, Passed 145 [success] Total time: 43 s, completed Sep 30, 2016 2:19:56 PM If you want to run a single spec, > testOnly scala.xml.XMLSpec [info] + XML.write: OK, passed 100 tests. [info] Passed: Total 1, Failed 0, Errors 0, Passed 1 [success] Total time: 3 s, completed Sep 30, 2016 2:20:28 PM If you want to run all the ScalaCheck specs, > testOnly *Spec ... [info] Passed: Total 26, Failed 0, Errors 0, Passed 26 [success] Total time: 30 s, completed Sep 30, 2016 2:22:58 PM If you want to run the specs under a namespace, > testOnly scala.xml.dtd.*Spec ... [info] + dtd.DTD.toString: OK, passed 100 tests. [info] + dtd.DocType.new(name): OK, passed 100 tests. [info] + dtd.DocType.new(name, extId, intSubset): OK, passed 100 tests. [info] + dtd.DocType.new(name, extId, emptyInt): OK, passed 100 tests. [info] + dtd.DocType.toString: OK, passed 100 tests. [info] Passed: Total 4, Failed 0, Errors 0, Passed 4 [success] Total time: 6 s, completed Sep 30, 2016 3:14:05 PM If you want to generate 1000 tests instead of 100, > testOnly *Spec -- -s 1000 ... [info] Passed: Total 26, Failed 0, Errors 0, Passed 26 [success] Total time: 217 s, completed Sep 30, 2016 2:27:31 PM If you want to generate 10 tests, instead of 100, > testOnly *Spec -- -s 10 ... [info] Passed: Total 26, Failed 0, Errors 0, Passed 26 [success] Total time: 10 s, completed Sep 30, 2016 2:23:49 PM If you want to generate full back traces on errors and display the elapsed time for each property, > testOnly *Spec -- -verbosity 2 ... [info] + parsing.XhtmlParser.initialize: OK, passed 100 tests. [info] Elapsed time: 0.046 sec [info] + parsing.XhtmlParser.prolog: OK, passed 100 tests. [info] Elapsed time: 0.022 sec [info] + parsing.XhtmlParser.document: OK, passed 100 tests. [info] Elapsed time: 0.015 sec [info] Passed: Total 26, Failed 0, Errors 0, Passed 26 [success] Total time: 30 s, completed Sep 30, 2016 2:29:24 PM The default verbosity is 0, > testOnly *Spec -- -verbosity 0 ... [info] + parsing.XhtmlParser.initialize: OK, passed 100 tests. [info] + parsing.XhtmlParser.prolog: OK, passed 100 tests. [info] + parsing.XhtmlParser.document: OK, passed 100 tests. [info] Passed: Total 26, Failed 0, Errors 0, Passed 26 [success] Total time: 26 s, completed Sep 30, 2016 2:30:26 PM To run only the failed tests, > testQuick [info] Passed: Total 0, Failed 0, Errors 0, Passed 0 [info] No tests to run for test:testQuick [success] Total time: 1 s, completed Sep 30, 2016 2:32:50 PM Currently, these tests in ScalaCheck will cover only 25% of the source code, and 20% of branches. Not surprisingly, there are some defects in scala-xml for certain types and classes. I am forced to comment out and disable those tests and generators so that the suite passes. Those issues should be taken up separately and in subsequent pull requests. When those tests and generators are re-enabled for those types, the code coverage would most likely increase. There are no shrink heuristics defined written to help ScalaCheck identify the minimum value to falsify a property of an XML string or data structure. This will be a nice to have, but was too advanced for me to take on at this time. Right now, the generators equally weight the Node types among those that are allowed. It would probably be worthwhile to have the frequencies be more realistic. For example, have a a greater emphasis on Elem and EntityRef elements over Comment, ProcInstr, nulls, empty strings and empty lists. The frequencies should be closer in line with what a typical XML file would be, but also more broadly cover the code and sooner using fewer generated values. Similarly, there is not an appropriate sizing for lists. Presently, ScalaCheck randomly selects a number, and then the generators I wrote will try to approach termination by recursively halving and square-rooting at each level of descent. --- .../test/scala/scala/xml/NodeSeqSpec.scala | 171 +++++++++ .../scala/xml/NodeSerializationSpec.scala | 27 ++ .../test/scala/scala/xml/XmlStringGen.scala | 22 ++ .../scala/scala/xml/dtd/ExternalIDSpec.scala | 65 ++++ .../scala/xml/factory/XMLLoaderSpec.scala | 203 +++++++++++ .../xml/parsing/ConstructingParserGen.scala | 25 ++ .../xml/parsing/ConstructingParserSpec.scala | 29 ++ .../scala/xml/parsing/XhtmlParserGen.scala | 22 ++ .../scala/xml/parsing/XhtmlParserSpec.scala | 29 ++ .../test/scala/scala/xml/ArbitraryElem.scala | 11 + .../test/scala/scala/xml/ArbitraryGroup.scala | 11 + .../scala/scala/xml/ArbitraryMetaData.scala | 11 + .../test/scala/scala/xml/ArbitraryNode.scala | 11 + .../scala/scala/xml/ArbitraryNodeBuffer.scala | 11 + .../scala/scala/xml/ArbitraryTextBuffer.scala | 11 + shared/src/test/scala/scala/xml/AtomGen.scala | 16 + .../src/test/scala/scala/xml/AtomSpec.scala | 27 ++ .../test/scala/scala/xml/AttributeGen.scala | 44 +++ .../test/scala/scala/xml/AttributeSpec.scala | 131 +++++++ .../src/test/scala/scala/xml/CommentGen.scala | 17 + .../test/scala/scala/xml/CommentSpec.scala | 37 ++ .../test/scala/scala/xml/DocumentGen.scala | 63 ++++ .../test/scala/scala/xml/DocumentSpec.scala | 78 ++++ shared/src/test/scala/scala/xml/ElemGen.scala | 58 +++ .../src/test/scala/scala/xml/ElemSpec.scala | 62 ++++ .../test/scala/scala/xml/EntityRefGen.scala | 22 ++ .../src/test/scala/scala/xml/GroupGen.scala | 19 + .../src/test/scala/scala/xml/GroupSpec.scala | 72 ++++ .../test/scala/scala/xml/MetaDataGen.scala | 18 + .../test/scala/scala/xml/MetaDataSpec.scala | 98 +++++ .../scala/scala/xml/NamespaceBindingGen.scala | 28 ++ .../scala/xml/NamespaceBindingSpec.scala | 49 +++ .../test/scala/scala/xml/NodeBufferGen.scala | 15 + .../test/scala/scala/xml/NodeBufferSpec.scala | 42 +++ shared/src/test/scala/scala/xml/NodeGen.scala | 28 ++ .../src/test/scala/scala/xml/NodeSeqGen.scala | 20 ++ .../src/test/scala/scala/xml/NodeSpec.scala | 339 ++++++++++++++++++ .../src/test/scala/scala/xml/PCDataGen.scala | 17 + .../src/test/scala/scala/xml/PCDataSpec.scala | 27 ++ .../scala/scala/xml/PrettyPrinterGen.scala | 18 + .../scala/scala/xml/PrettyPrinterSpec.scala | 21 ++ .../test/scala/scala/xml/ProcInstrGen.scala | 38 ++ .../test/scala/scala/xml/ProcInstrSpec.scala | 49 +++ .../src/test/scala/scala/xml/QNodeSpec.scala | 16 + .../test/scala/scala/xml/TextBufferGen.scala | 18 + .../test/scala/scala/xml/TextBufferSpec.scala | 32 ++ shared/src/test/scala/scala/xml/TextGen.scala | 17 + .../src/test/scala/scala/xml/TextSpec.scala | 21 ++ .../test/scala/scala/xml/UnparsedGen.scala | 17 + .../test/scala/scala/xml/Utf8StringGen.scala | 51 +++ .../test/scala/scala/xml/Utf8StringSpec.scala | 49 +++ .../test/scala/scala/xml/UtilitySpec.scala | 66 ++++ shared/src/test/scala/scala/xml/XMLSpec.scala | 30 ++ .../src/test/scala/scala/xml/XmlNameGen.scala | 41 +++ .../scala/scala/xml/dtd/ArbitraryDecl.scala | 16 + .../scala/scala/xml/dtd/ContentModelGen.scala | 25 ++ .../src/test/scala/scala/xml/dtd/DTDGen.scala | 29 ++ .../test/scala/scala/xml/dtd/DTDSpec.scala | 21 ++ .../test/scala/scala/xml/dtd/DeclGen.scala | 168 +++++++++ .../test/scala/scala/xml/dtd/DeclSpec.scala | 136 +++++++ .../test/scala/scala/xml/dtd/DocTypeGen.scala | 23 ++ .../scala/scala/xml/dtd/DocTypeSpec.scala | 70 ++++ .../scala/scala/xml/dtd/ExternalIDGen.scala | 58 +++ .../scala/scala/xml/dtd/impl/RegExpGen.scala | 34 ++ 64 files changed, 3050 insertions(+) create mode 100644 jvm/src/test/scala/scala/xml/NodeSeqSpec.scala create mode 100644 jvm/src/test/scala/scala/xml/NodeSerializationSpec.scala create mode 100644 jvm/src/test/scala/scala/xml/XmlStringGen.scala create mode 100644 jvm/src/test/scala/scala/xml/dtd/ExternalIDSpec.scala create mode 100644 jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala create mode 100644 jvm/src/test/scala/scala/xml/parsing/ConstructingParserGen.scala create mode 100644 jvm/src/test/scala/scala/xml/parsing/ConstructingParserSpec.scala create mode 100644 jvm/src/test/scala/scala/xml/parsing/XhtmlParserGen.scala create mode 100644 jvm/src/test/scala/scala/xml/parsing/XhtmlParserSpec.scala create mode 100644 shared/src/test/scala/scala/xml/ArbitraryElem.scala create mode 100644 shared/src/test/scala/scala/xml/ArbitraryGroup.scala create mode 100644 shared/src/test/scala/scala/xml/ArbitraryMetaData.scala create mode 100644 shared/src/test/scala/scala/xml/ArbitraryNode.scala create mode 100644 shared/src/test/scala/scala/xml/ArbitraryNodeBuffer.scala create mode 100644 shared/src/test/scala/scala/xml/ArbitraryTextBuffer.scala create mode 100644 shared/src/test/scala/scala/xml/AtomGen.scala create mode 100644 shared/src/test/scala/scala/xml/AtomSpec.scala create mode 100644 shared/src/test/scala/scala/xml/AttributeGen.scala create mode 100644 shared/src/test/scala/scala/xml/AttributeSpec.scala create mode 100644 shared/src/test/scala/scala/xml/CommentGen.scala create mode 100644 shared/src/test/scala/scala/xml/CommentSpec.scala create mode 100644 shared/src/test/scala/scala/xml/DocumentGen.scala create mode 100644 shared/src/test/scala/scala/xml/DocumentSpec.scala create mode 100644 shared/src/test/scala/scala/xml/ElemGen.scala create mode 100644 shared/src/test/scala/scala/xml/ElemSpec.scala create mode 100644 shared/src/test/scala/scala/xml/EntityRefGen.scala create mode 100644 shared/src/test/scala/scala/xml/GroupGen.scala create mode 100644 shared/src/test/scala/scala/xml/GroupSpec.scala create mode 100644 shared/src/test/scala/scala/xml/MetaDataGen.scala create mode 100644 shared/src/test/scala/scala/xml/MetaDataSpec.scala create mode 100644 shared/src/test/scala/scala/xml/NamespaceBindingGen.scala create mode 100644 shared/src/test/scala/scala/xml/NamespaceBindingSpec.scala create mode 100644 shared/src/test/scala/scala/xml/NodeBufferGen.scala create mode 100644 shared/src/test/scala/scala/xml/NodeBufferSpec.scala create mode 100644 shared/src/test/scala/scala/xml/NodeGen.scala create mode 100644 shared/src/test/scala/scala/xml/NodeSeqGen.scala create mode 100644 shared/src/test/scala/scala/xml/NodeSpec.scala create mode 100644 shared/src/test/scala/scala/xml/PCDataGen.scala create mode 100644 shared/src/test/scala/scala/xml/PCDataSpec.scala create mode 100644 shared/src/test/scala/scala/xml/PrettyPrinterGen.scala create mode 100644 shared/src/test/scala/scala/xml/PrettyPrinterSpec.scala create mode 100644 shared/src/test/scala/scala/xml/ProcInstrGen.scala create mode 100644 shared/src/test/scala/scala/xml/ProcInstrSpec.scala create mode 100644 shared/src/test/scala/scala/xml/QNodeSpec.scala create mode 100644 shared/src/test/scala/scala/xml/TextBufferGen.scala create mode 100644 shared/src/test/scala/scala/xml/TextBufferSpec.scala create mode 100644 shared/src/test/scala/scala/xml/TextGen.scala create mode 100644 shared/src/test/scala/scala/xml/TextSpec.scala create mode 100644 shared/src/test/scala/scala/xml/UnparsedGen.scala create mode 100644 shared/src/test/scala/scala/xml/Utf8StringGen.scala create mode 100644 shared/src/test/scala/scala/xml/Utf8StringSpec.scala create mode 100644 shared/src/test/scala/scala/xml/UtilitySpec.scala create mode 100644 shared/src/test/scala/scala/xml/XMLSpec.scala create mode 100644 shared/src/test/scala/scala/xml/XmlNameGen.scala create mode 100644 shared/src/test/scala/scala/xml/dtd/ArbitraryDecl.scala create mode 100644 shared/src/test/scala/scala/xml/dtd/ContentModelGen.scala create mode 100644 shared/src/test/scala/scala/xml/dtd/DTDGen.scala create mode 100644 shared/src/test/scala/scala/xml/dtd/DTDSpec.scala create mode 100644 shared/src/test/scala/scala/xml/dtd/DeclGen.scala create mode 100644 shared/src/test/scala/scala/xml/dtd/DeclSpec.scala create mode 100644 shared/src/test/scala/scala/xml/dtd/DocTypeGen.scala create mode 100644 shared/src/test/scala/scala/xml/dtd/DocTypeSpec.scala create mode 100644 shared/src/test/scala/scala/xml/dtd/ExternalIDGen.scala create mode 100644 shared/src/test/scala/scala/xml/dtd/impl/RegExpGen.scala diff --git a/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala b/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala new file mode 100644 index 000000000..e4309a0e5 --- /dev/null +++ b/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala @@ -0,0 +1,171 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +object NodeSeqSpec extends PropertiesFor("NodeSeq") + with NodeSeqGen { + + property("theSeq") = { + Prop.forAll { n: NodeSeq => + n.theSeq ne null + } + } + + property("length") = { + Prop.forAll { n: NodeSeq => + n.length >= 0 + } + } + + property("\\ \"\".throws[Exception]") = { + Prop.forAll { n: NodeSeq => + Prop.throws(classOf[IllegalArgumentException]) { + (n \ "") + } + } + } + + property("\\ _.throws[Exception]") = { + Prop.forAll { n: NodeSeq => + Prop.iff[NodeSeq](n, { + // FIXME: Exception thrown in NodeSeq.\.makeSeq + case g @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + (g \ "_") + } + case _ => { + (n \ "_") + Prop.passed + } + }) + } + } + + property("\\ @.throws[Exception]") = { + Prop.forAll { n: NodeSeq => + Prop.iff[NodeSeq](n, { + // FIXME: Should be IllegalArgumentException, regardless of theSeq. + case n if n.length == 0 => + (n \ "@") ?= NodeSeq.Empty + case n if n.length == 1 => + Prop.throws(classOf[IllegalArgumentException]) { + (n \ "@") + } + case n: NodeSeq => + (n \ "@") + Prop.passed + }) + } + } + + property("\\") = { + Prop.forAll { (n: NodeSeq, s: String) => + Prop.iff[String](s, { + // FIXME: Should be IllegalArgumentException, regardless of theSeq. + case "" => + Prop.throws(classOf[IllegalArgumentException]) { + (n \ s) + } + case "@" => + Prop.throws(classOf[IllegalArgumentException]) { + (n \ s) + } + case s => + (n \ s) + Prop.passed + }) + } + } + + property("\\\\ \"\".throws[Exception]") = { + Prop.forAll { n: NodeSeq => + // FIXME: Should be IllegalArgumentException. + Prop.throws(classOf[StringIndexOutOfBoundsException]) { + (n \\ "") + } + } + } + + property("\\\\ @.throws[Exception]") = { + Prop.forAll { n: NodeSeq => + Prop.iff[NodeSeq](n, { + // FIXME: Should be IllegalArgumentException, regardless of theSeq + case n if n.filter(!_.isAtom).length == 0 => + (n \\ "@") ?= NodeSeq.Empty + case n => + Prop.throws(classOf[IllegalArgumentException]) { + (n \\ "@") + } + }) + } + } + + property("\\\\") = { + Prop.forAll { (n: NodeSeq, s: String) => + Prop.iff[String](s, { + // FIXME: Should be IllegalArgumentException, regardless of theSeq. + case "" => + Prop.throws(classOf[StringIndexOutOfBoundsException]) { + (n \\ s) + } + case "@" => + Prop.throws(classOf[IllegalArgumentException]) { + (n \\ s) + } + case s => + (n \\ s) + Prop.passed + }) + } + } + + property("\\@ \"\".throws[Exception]") = { + Prop.forAll { n: NodeSeq => + Prop.iff[NodeSeq](n, { + // FIXME: Should be IllegalArgumentException, regardless of theSeq. + case n if n.length == 0 => + (n \@ "") ?= "" + case n if n.length == 1 => + Prop.throws(classOf[IllegalArgumentException]) { + (n \@ "") + } + case s => + (n \@ "") + Prop.passed + }) + } + } + + property("\\@ _.throws[Exception]") = { + Prop.forAll { n: NodeSeq => + Prop.iff[NodeSeq](n, { + // FIXME: Exception thrown in NodeSeq.\.makeSeq + case g @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + (g \@ "_") + } + case _ => { + (n \@ "_") + Prop.passed + } + }) + } + } + + property("\\@") = { + Prop.forAll { (n: NodeSeq, s: String) => + // FIXME: Should be IllegalArgumentException, regardless of theSeq. + Prop.throws(classOf[IllegalArgumentException]) { + (n \@ s) + } || Prop.passed // FIXME: Error conditions are too complex. + } + } + + property("text") = { + Prop.forAll { n: NodeSeq => + n.text.length >= 0 + } + } +} diff --git a/jvm/src/test/scala/scala/xml/NodeSerializationSpec.scala b/jvm/src/test/scala/scala/xml/NodeSerializationSpec.scala new file mode 100644 index 000000000..5385a24db --- /dev/null +++ b/jvm/src/test/scala/scala/xml/NodeSerializationSpec.scala @@ -0,0 +1,27 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => CheckProperties } +import org.scalacheck.Prop.AnyOperators +import org.scalacheck.Prop.BooleanOperators + +object NodeSerializationSpec extends CheckProperties("NodeSerialization") + with NodeGen { + + property("serialization") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n => + JavaByteSerialization.roundTrip(n) ?= n + }) + } + } +} diff --git a/jvm/src/test/scala/scala/xml/XmlStringGen.scala b/jvm/src/test/scala/scala/xml/XmlStringGen.scala new file mode 100644 index 000000000..a622f408c --- /dev/null +++ b/jvm/src/test/scala/scala/xml/XmlStringGen.scala @@ -0,0 +1,22 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait XmlStringGen extends DocumentGen { + + def xmlDeclGen(version: String, encoding: String): Gen[String] = + Gen.oneOf( + Gen.const(""), + Gen.const(s"") + ) + + val genXmlString: Gen[String] = for { + document <- Arbitrary.arbitrary[Document] + encoding <- Gen.const(java.nio.charset.StandardCharsets.UTF_8.name) + xmlDecl <- xmlDeclGen("1.0", encoding) + } yield { + val str = xmlDecl + Group(document.children ++ Seq(document.docElem)).toString + str + } +} diff --git a/jvm/src/test/scala/scala/xml/dtd/ExternalIDSpec.scala b/jvm/src/test/scala/scala/xml/dtd/ExternalIDSpec.scala new file mode 100644 index 000000000..08d093da4 --- /dev/null +++ b/jvm/src/test/scala/scala/xml/dtd/ExternalIDSpec.scala @@ -0,0 +1,65 @@ +package scala.xml +package dtd + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +object ExternalIDSpec extends PropertiesFor("dtd.ExternalID") + with ExternalIDGen { + + property("PublicID.throws[Exception]") = { + Prop.forAll(genNonPubIdStr) { s: String => + Prop.throws(classOf[IllegalArgumentException]) { + PublicID(s, s) + } + } + } + + property("SystemID.throws[Exception]") = { + Prop.forAll(genNonSysIdStr) { s: String => + Prop.throws(classOf[IllegalArgumentException]) { + SystemID(s) + } + } + } + + property("SystemID(null).throws[Exception]") = { + Prop.throws(classOf[NullPointerException]) { + SystemID(null) + } + } + + property("label") = { + Prop.forAll { p: PublicID => + p.label ?= "#PI" + } + } + + property("attribute") = { + Prop.forAll { p: PublicID => + p.attribute ?= Node.NoAttributes + } + } + + property("child") = { + Prop.forAll { p: PublicID => + p.child ?= Nil + } + } + + property("toString") = Prop.forAll { e: ExternalID => + val str = e.toString + Prop.atLeastOne( + str ?= "", + str ?= s"""SYSTEM '${e.systemId}'""", + str ?= s"""SYSTEM "${e.systemId}"""", + str ?= s"""PUBLIC '${e.publicId}'""", + str ?= s"""PUBLIC "${e.publicId}"""", + str ?= s"""PUBLIC '${e.publicId}' '${e.systemId}'""", + str ?= s"""PUBLIC "${e.publicId}" "${e.systemId}"""", + str ?= s"""PUBLIC '${e.publicId}' "${e.systemId}"""", + str ?= s"""PUBLIC "${e.publicId}" '${e.systemId}'""" + ) + } +} diff --git a/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala b/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala new file mode 100644 index 000000000..e77663768 --- /dev/null +++ b/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala @@ -0,0 +1,203 @@ +package scala.xml +package factory + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +import scala.language.implicitConversions +import org.scalacheck.util.Pretty + +object XMLLoaderSpec extends PropertiesFor("factory.XMLLoader") + with DocumentGen + with NodeGen + with dtd.DocTypeGen + with XmlStringGen { + + def testParser: SAXParser = { + val parser = XML.parser + val reader = parser.getXMLReader + // Disable loading of external DTD files, to suppress + // java.io.FileNotFoundException: "dtd" (No such file or directory) + reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) + parser + } + + val loader: XMLLoader[Elem] = + new XMLLoader[Elem] { + override def parser = testParser + } + + val genXMLLoader: Gen[XMLLoader[Elem]] = + Gen.const( + loader + ) + + class StreamAndWriter( + val stream: java.io.ByteArrayOutputStream, + val writer: java.io.Writer + ) + + val genStreamAndWriter: Gen[StreamAndWriter] = for { + out <- Gen.delay(new java.io.ByteArrayOutputStream) + } yield { + new StreamAndWriter( + out, + new java.io.OutputStreamWriter( + out, + java.nio.charset.StandardCharsets.UTF_8.name + ) + ) + } + + implicit val arbStreamAndWriter = Arbitrary { + genStreamAndWriter + } + + val genInputStream: Gen[java.io.InputStream] = for { + inOut <- Arbitrary.arbitrary[StreamAndWriter] + document <- Arbitrary.arbitrary[Document] + encoding <- Gen.const(java.nio.charset.StandardCharsets.UTF_8.name) + xmlDecl <- Gen.const(true) // Gen.oneOf(true, false) + doctype <- Arbitrary.arbitrary[dtd.DocType] + minimizeTags <- Gen.oneOf( + MinimizeMode.Default, + MinimizeMode.Always, + MinimizeMode.Never + ) + } yield { + XML.write( + inOut.writer, + Group(document.children ++ Seq(document.docElem)), + encoding, + xmlDecl, + doctype.copy(name = document.docElem.nameToString(new StringBuilder).toString), + minimizeTags + ) + inOut.writer.flush() + val str = inOut.stream.toString + new java.io.StringBufferInputStream(str) + } + + implicit val arbInputStream = Arbitrary { + genInputStream + } + + val genInputSource: Gen[InputSource] = for { + is <- Arbitrary.arbitrary[java.io.InputStream] + } yield { + Source.fromInputStream(is) + } + + implicit val arbInputSource = Arbitrary { + genInputSource + } + + property("adapter") = { + XML.adapter ne XML.adapter + } + + property("parser") = { + XML.parser ne XML.parser + } + + implicit def prettyInputStream(is: java.io.InputStream) = Pretty { p => + val builder = new StringBuilder + is.reset() + var off = 0 + val chunkSize = 65536 + val arr = new Array[Byte](chunkSize) + while (is.available() > 0) { + val len = scala.math.min(is.available(), chunkSize) + is.read(arr, off, chunkSize) + builder ++= new String(arr.take(len)) + off += len + } + builder.toString + } + + implicit def prettyInputSource(is: InputSource) = + prettyInputStream(is.getByteStream) + + // FIXME: xerces.internal.impl.io.MalformedByteSequenceException: + // Invalid byte 1 of 1-byte UTF-8 sequence. + // property("load(_: java.io.InputStream)") = { + // Prop.forAll { is: java.io.InputStream => + // loader.load(is) + // Prop.passed + // } + // } + + // FIXME: xerces.internal.impl.io.MalformedByteSequenceException: + // Invalid byte 1 of 1-byte UTF-8 sequence. + // property("load(_: InputSource)") = { + // Prop.forAll { is: InputSource => + // loader.load(is) + // Prop.passed + // } + // } + + property("loadString(_: String)") = { + // Use forAllNoShrink since Scalacheck's shrinking strategy for a + // string, removing characters byte-by-byte, won't improve the + // insight of a failure. Scalacheck is getting false feedback + // while shrinking since Xerces only throws a SAXParseException, + // albeit with different message values, but Scalacheck doesn't + // listen to them. + Prop.forAllNoShrink(genXmlString) { xml: String => + loader.loadString(xml) + Prop.passed + } + } + + property("loadString(\"\").throws[Exception]") = { + Prop.throws(classOf[org.xml.sax.SAXParseException]) { + loader.loadString("") + } + } + + property("loadString().throws[Exception]") = { + Prop.throws(classOf[org.xml.sax.SAXParseException]) { + loader.loadString("") + } + } + + property("loadString().throws[Exception]") = { + Prop.throws(classOf[org.xml.sax.SAXParseException]) { + loader.loadString("").toString ?= "" + } + } + + property("loadString(<_/>)") = { + val xml = <_/> + loader.loadString(xml.toString) ?= xml + } + + property("loadString(<_:_/>)") = { + val xml = <_:_/> + loader.loadString(xml.toString) ?= xml + } + + property("loadString(<_:_>)") = { + val xml = <_:_> + loader.loadString(xml.toString) ?= xml + } + + property("loadString(<_/>)") = { + loader.loadString("<_/>") ?= <_/> + } + + // Confirm external DTD files are not loaded, see above. + property("loadString(<_/>)") = { + loader.loadString("<_/>") ?= <_/> + } + + property("loadString(<_:_/>)") = { + val xml = """ + |<_:_/>""".stripMargin + // val is = new java.io.StringBufferInputStream(xml) + loader.loadString(xml) ?= <_:_/> + } +} diff --git a/jvm/src/test/scala/scala/xml/parsing/ConstructingParserGen.scala b/jvm/src/test/scala/scala/xml/parsing/ConstructingParserGen.scala new file mode 100644 index 000000000..b78521e13 --- /dev/null +++ b/jvm/src/test/scala/scala/xml/parsing/ConstructingParserGen.scala @@ -0,0 +1,25 @@ +package scala.xml +package parsing + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ConstructingParserGen extends XmlStringGen { + + val genConstructingParser: Gen[ConstructingParser] = for { + xml <- Gen.oneOf( + genXmlString: Gen[String], + Arbitrary.arbitrary[String] + ) + preserveWS <- Arbitrary.arbitrary[Boolean] + } yield { + // ConstructingParser.fromSource(scala.io.Source.fromString(xml), preserveWS) + new ConstructingParser(scala.io.Source.fromString(xml), preserveWS) { + override def reportSyntaxError(str: String) = {} + } + } + + implicit val arbConstructingParser = Arbitrary { + genConstructingParser + } +} diff --git a/jvm/src/test/scala/scala/xml/parsing/ConstructingParserSpec.scala b/jvm/src/test/scala/scala/xml/parsing/ConstructingParserSpec.scala new file mode 100644 index 000000000..7325860e0 --- /dev/null +++ b/jvm/src/test/scala/scala/xml/parsing/ConstructingParserSpec.scala @@ -0,0 +1,29 @@ +package scala.xml +package parsing + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } + +object ConstructingParserSpec extends PropertiesFor("parsing.ConstructingParser") + with ConstructingParserGen { + + property("initialize") = { + Prop.forAll { parser: ConstructingParser => + parser.initialize eq parser + } + } + + property("prolog") = { + Prop.forAll { parser: ConstructingParser => + parser.prolog + Prop.passed + } + } + + property("document") = { + Prop.forAll { parser: ConstructingParser => + parser.document + Prop.passed + } + } +} diff --git a/jvm/src/test/scala/scala/xml/parsing/XhtmlParserGen.scala b/jvm/src/test/scala/scala/xml/parsing/XhtmlParserGen.scala new file mode 100644 index 000000000..6ad67dcba --- /dev/null +++ b/jvm/src/test/scala/scala/xml/parsing/XhtmlParserGen.scala @@ -0,0 +1,22 @@ +package scala.xml +package parsing + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait XhtmlParserGen { + + val genXhtmlParser: Gen[XhtmlParser] = for { + // FIXME: Doesn't generate valid XML strings + xml <- Arbitrary.arbitrary[String] + preserveWS <- Arbitrary.arbitrary[Boolean] + } yield { + new XhtmlParser(scala.io.Source.fromString(xml)) { + override def reportSyntaxError(str: String) = {} + } + } + + implicit val arbXhtmlParser = Arbitrary { + genXhtmlParser + } +} diff --git a/jvm/src/test/scala/scala/xml/parsing/XhtmlParserSpec.scala b/jvm/src/test/scala/scala/xml/parsing/XhtmlParserSpec.scala new file mode 100644 index 000000000..ce595ac9a --- /dev/null +++ b/jvm/src/test/scala/scala/xml/parsing/XhtmlParserSpec.scala @@ -0,0 +1,29 @@ +package scala.xml +package parsing + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } + +object XhtmlParserSpec extends PropertiesFor("parsing.XhtmlParser") + with XhtmlParserGen { + + property("initialize") = { + Prop.forAll { parser: XhtmlParser => + parser.initialize eq parser + } + } + + property("prolog") = { + Prop.forAll { parser: XhtmlParser => + parser.prolog + Prop.passed + } + } + + property("document") = { + Prop.forAll { parser: XhtmlParser => + parser.document + Prop.passed + } + } +} diff --git a/shared/src/test/scala/scala/xml/ArbitraryElem.scala b/shared/src/test/scala/scala/xml/ArbitraryElem.scala new file mode 100644 index 000000000..2b3f395ab --- /dev/null +++ b/shared/src/test/scala/scala/xml/ArbitraryElem.scala @@ -0,0 +1,11 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ArbitraryElem { + + def genElem(sz: Int): Gen[Elem] + + implicit val arbElem: Arbitrary[Elem] +} diff --git a/shared/src/test/scala/scala/xml/ArbitraryGroup.scala b/shared/src/test/scala/scala/xml/ArbitraryGroup.scala new file mode 100644 index 000000000..61fed05de --- /dev/null +++ b/shared/src/test/scala/scala/xml/ArbitraryGroup.scala @@ -0,0 +1,11 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ArbitraryGroup { + + def genGroup(sz: Int): Gen[Group] + + implicit val arbGroup: Arbitrary[Group] +} diff --git a/shared/src/test/scala/scala/xml/ArbitraryMetaData.scala b/shared/src/test/scala/scala/xml/ArbitraryMetaData.scala new file mode 100644 index 000000000..c30feb62c --- /dev/null +++ b/shared/src/test/scala/scala/xml/ArbitraryMetaData.scala @@ -0,0 +1,11 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ArbitraryMetaData { + + val genMetaData: Gen[MetaData] + + implicit val arbMetaData: Arbitrary[MetaData] +} diff --git a/shared/src/test/scala/scala/xml/ArbitraryNode.scala b/shared/src/test/scala/scala/xml/ArbitraryNode.scala new file mode 100644 index 000000000..811826cfb --- /dev/null +++ b/shared/src/test/scala/scala/xml/ArbitraryNode.scala @@ -0,0 +1,11 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ArbitraryNode { + + def genNode(sz: Int): Gen[Node] + + implicit val arbNode: Arbitrary[Node] +} diff --git a/shared/src/test/scala/scala/xml/ArbitraryNodeBuffer.scala b/shared/src/test/scala/scala/xml/ArbitraryNodeBuffer.scala new file mode 100644 index 000000000..e0e869718 --- /dev/null +++ b/shared/src/test/scala/scala/xml/ArbitraryNodeBuffer.scala @@ -0,0 +1,11 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ArbitraryNodeBuffer { + + val genNodeBuffer: Gen[NodeBuffer] + + implicit val arbNodeBuffer: Arbitrary[NodeBuffer] +} diff --git a/shared/src/test/scala/scala/xml/ArbitraryTextBuffer.scala b/shared/src/test/scala/scala/xml/ArbitraryTextBuffer.scala new file mode 100644 index 000000000..4178d5217 --- /dev/null +++ b/shared/src/test/scala/scala/xml/ArbitraryTextBuffer.scala @@ -0,0 +1,11 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ArbitraryTextBuffer { + + val genTextBuffer: Gen[TextBuffer] + + implicit val arbTextBuffer: Arbitrary[TextBuffer] +} diff --git a/shared/src/test/scala/scala/xml/AtomGen.scala b/shared/src/test/scala/scala/xml/AtomGen.scala new file mode 100644 index 000000000..f2eab8f64 --- /dev/null +++ b/shared/src/test/scala/scala/xml/AtomGen.scala @@ -0,0 +1,16 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait AtomGen extends PCDataGen + with TextGen + with UnparsedGen { + + val genAtom: Gen[Atom[String]] = + Gen.oneOf(genPCData, genText, genUnparsed) + + implicit val arbAtom = Arbitrary { + genAtom + } +} diff --git a/shared/src/test/scala/scala/xml/AtomSpec.scala b/shared/src/test/scala/scala/xml/AtomSpec.scala new file mode 100644 index 000000000..3c0173d79 --- /dev/null +++ b/shared/src/test/scala/scala/xml/AtomSpec.scala @@ -0,0 +1,27 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +object AtomSpec extends PropertiesFor("Atom") + with AtomGen { + + property("new(null).throws[Exception]") = { + Prop.throws(classOf[IllegalArgumentException]) { + new Atom(null) + } + } + + property("data") = { + Prop.forAll { a: Atom[String] => + a.data ne null + } + } + + property("text") = { + Prop.forAll { a: Atom[String] => + a.text ?= s"${a.data}" + } + } +} diff --git a/shared/src/test/scala/scala/xml/AttributeGen.scala b/shared/src/test/scala/scala/xml/AttributeGen.scala new file mode 100644 index 000000000..27b5cd8f2 --- /dev/null +++ b/shared/src/test/scala/scala/xml/AttributeGen.scala @@ -0,0 +1,44 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait AttributeGen extends TextGen + with ArbitraryMetaData + with XmlNameGen { + + def genAttribute: Gen[Attribute] = + Gen.oneOf( + Arbitrary.arbitrary[PrefixedAttribute], + Arbitrary.arbitrary[UnprefixedAttribute] + ) + + val genPrefixedAttribute: Gen[PrefixedAttribute] = for { + prefix <- genXmlName: Gen[String] + key <- genXmlName: Gen[String] + value <- Arbitrary.arbitrary[Text] + next <- Gen.delay(genMetaData) + } yield { + new PrefixedAttribute(prefix, key, value, next) + } + + val genUnprefixedAttribute: Gen[UnprefixedAttribute] = for { + key <- genXmlName: Gen[String] + value <- Arbitrary.arbitrary[Text] + next <- Gen.delay(genMetaData) + } yield { + new UnprefixedAttribute(key, value, next) + } + + implicit val arbAttribute: Arbitrary[Attribute] = Arbitrary { + genAttribute + } + + implicit val arbPrefixedAttribute: Arbitrary[PrefixedAttribute] = Arbitrary { + genPrefixedAttribute + } + + implicit val arbUnprefixedAttribute: Arbitrary[UnprefixedAttribute] = Arbitrary { + genUnprefixedAttribute + } +} diff --git a/shared/src/test/scala/scala/xml/AttributeSpec.scala b/shared/src/test/scala/scala/xml/AttributeSpec.scala new file mode 100644 index 000000000..fe851b548 --- /dev/null +++ b/shared/src/test/scala/scala/xml/AttributeSpec.scala @@ -0,0 +1,131 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators +import org.scalacheck.Prop.BooleanOperators + +object AttributeSpec extends PropertiesFor("Attribute") + with AttributeGen + with NamespaceBindingGen + with NodeGen + with MetaDataGen { + + property("canEqual(this)") = { + Prop.forAll { a: Attribute => + a.canEqual(a) + } + } + + property("apply") = { + Prop.forAll { (a: Attribute, s: String) => + (!s.isEmpty && Utility.isNameStart(s(0))) ==> + (a(s) != s) + } + } + + property("apply(key)") = { + Prop.forAll { a: Attribute => + Prop.iff[Attribute](a, { + case p: PrefixedAttribute => + Prop.passed + case u: UnprefixedAttribute if u.key ne null => + u(u.key) ?= u.value + }) + } + } + + property("apply(uri, namespace, key)") = { + Prop.forAll { a: Attribute => + Prop.iff[Attribute](a, { + case p: PrefixedAttribute => + val res = p(p.key, NamespaceBinding(p.pre, p.key, TopScope), p.key) + res ?= p.value + case u: UnprefixedAttribute => + Prop.passed + }) + } + } + + property("isPrefixed") = { + Prop.forAll { a: Attribute => + Prop.iff[Attribute](a, { + case p: PrefixedAttribute => + a.isPrefixed ?= true + case u: UnprefixedAttribute => + a.isPrefixed ?= false + }) + } + } + + property("length") = { + Prop.forAll { a: Attribute => + a.length >= 0 + } + } + + property("size") = { + Prop.forAll { a: Attribute => + a.size >= 0 + } + } + + property("toString") = { + Prop.forAll { a: Attribute => + val str = a.toString + Prop.iff[Attribute](a, { + case a: PrefixedAttribute if a.hasNext => + str ?= s""" ${a.pre}:${a.key}="${a.value}"${a.next}""" + case a: UnprefixedAttribute if a.hasNext => + str ?= s""" ${a.key}="${a.value}"${a.next}""" + case a: PrefixedAttribute => + str ?= s""" ${a.pre}:${a.key}="${a.value}"""" + case a: UnprefixedAttribute => + str ?= s""" ${a.key}="${a.value}"""" + }) + } + } + + property("unapply") = { + Prop.forAll { a: Attribute => + Attribute.unapply(a) ?= Some((a.key, a.value, a.next)) + } + } + + property("remove(key)") = { + Prop.forAll { a: Attribute => + Prop.iff[Attribute](a, { + case a: PrefixedAttribute => + a.remove(a.key) ?= a.copy(a.next.remove(a.key)) // FIXME: ??? + case a: UnprefixedAttribute => + a.remove(a.key) ?= a.next + }) + } + } + + property("remove") = { + Prop.forAll { (a: Attribute, s: String) => + s != a.key ==> + (a.remove(s) ?= a.copy(a.next.remove(s))) + } + } + + property("getNamespace") = { + Prop.forAll { (a: Attribute, n: Node) => + a.getNamespace(n) ?= n.getNamespace(a.pre) + } + } + + property("wellformed") = { + Prop.forAll { (a: Attribute, scope: NamespaceBinding) => + Prop.iff[Attribute](a, { + case a: PrefixedAttribute => + val res = a.wellformed(scope) + res ?= ((null eq a.next(scope.getURI(a.pre), scope, a.key)) && a.next.wellformed(scope)) + case a: UnprefixedAttribute => + val res = a.wellformed(scope) + res ?= ((null eq a.next(null, scope, a.key)) && a.next.wellformed(scope)) + }) + } + } +} diff --git a/shared/src/test/scala/scala/xml/CommentGen.scala b/shared/src/test/scala/scala/xml/CommentGen.scala new file mode 100644 index 000000000..23368fcc0 --- /dev/null +++ b/shared/src/test/scala/scala/xml/CommentGen.scala @@ -0,0 +1,17 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait CommentGen extends Utf8StringGen { + + val genComment: Gen[Comment] = for { + s <- genUtf8String: Gen[String] if !s.contains("--") && !s.endsWith("-") + } yield { + Comment(s) + } + + implicit val arbComment = Arbitrary { + genComment + } +} diff --git a/shared/src/test/scala/scala/xml/CommentSpec.scala b/shared/src/test/scala/scala/xml/CommentSpec.scala new file mode 100644 index 000000000..fe2a12959 --- /dev/null +++ b/shared/src/test/scala/scala/xml/CommentSpec.scala @@ -0,0 +1,37 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +object CommentSpec extends PropertiesFor("Comment") + with CommentGen { + + property("new(--).throws[Exception]") = { + Prop.throws(classOf[IllegalArgumentException]) { + new Comment("--") + } + } + + property("child") = { + Prop.forAll { n: Comment => + n.child ?= Nil + } + } + + property("text") = { + Prop.forAll { n: Comment => + n.text ?= "" + } + } + + property("toString") = { + Prop.forAll { n: Comment => + val str = n.toString + Prop.atLeastOne( + str ?= "", + str.startsWith("") + ) + } + } +} diff --git a/shared/src/test/scala/scala/xml/DocumentGen.scala b/shared/src/test/scala/scala/xml/DocumentGen.scala new file mode 100644 index 000000000..058c320ec --- /dev/null +++ b/shared/src/test/scala/scala/xml/DocumentGen.scala @@ -0,0 +1,63 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait DocumentGen extends NodeGen + with dtd.DocTypeGen + with dtd.DTDGen { + + val genDocument: Gen[Document] = for { + prolog <- genProlog + dtd_ <- Arbitrary.arbitrary[dtd.DTD] + elements <- Arbitrary.arbitrary[Elem] + n <- Gen.choose(0, 4) + misc <- Gen.listOfN(n, genMisc) + } yield { + new Document { + children = prolog + dtd = dtd_ + docElem = elements + } + } + + implicit val arbDocument = Arbitrary { + genDocument + } + + def genWhiteSpace: Gen[String] = + Gen.listOf(Gen.oneOf(' ', '\t', '\n', '\r')).map(_.mkString) + + def genMisc: Gen[Node] = + Gen.oneOf( + Arbitrary.arbitrary[Comment], + Arbitrary.arbitrary[ProcInstr], + genWhiteSpace.map(Text(_)) + ) + + // Seems the intention was to have the Document.children contain the + // XML "prologue", but it would need to contain XML declarations and + // DocType declarations, which are are not of type Node, and + // therefore wouldn't exist in a Seq[Node]. Oh, well. XML.write + // ended up avoiding the Document type, and just taking the values + // it needed as arguments rather than from class fields. + def genProlog: Gen[NodeSeq] = for { + // xmlDecl <- genXmlDecl + n <- Gen.choose(0, 4) + misc <- Gen.listOfN(n, genMisc) + // docType <- Arbitrary.arbitrary[dtd.DocType] + // misc2 <- Gen.listOf(genMisc) + // prolog2 <- Gen.const(Text(docType.toString) :: misc2) + // prolog <- Gen.oneOf( + // xmlDecl + misc + prolog2, + // Gen.const(misc ++ prolog2), + // Gen.const(misc) + // ) + } yield { + // NodeSeq.fromSeq(prolog) + NodeSeq.fromSeq(misc) + } + + val genXmlDecl: Gen[String] = + Gen.const("") +} diff --git a/shared/src/test/scala/scala/xml/DocumentSpec.scala b/shared/src/test/scala/scala/xml/DocumentSpec.scala new file mode 100644 index 000000000..3ab2fea26 --- /dev/null +++ b/shared/src/test/scala/scala/xml/DocumentSpec.scala @@ -0,0 +1,78 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +object DocumentSpec extends PropertiesFor("Document") + with DocumentGen { + + property("baseURI") = { + Prop.forAll { d: Document => + d.baseURI eq null + } + } + + property("children") = { + Prop.forAll { d: Document => + Prop.atLeastOne( + d.children eq null, + d.isInstanceOf[Seq[Node]] + ) + } + } + + property("docElem") = { + Prop.forAll { d: Document => + Prop.atLeastOne( + d.theSeq eq null, + d.theSeq.isInstanceOf[Node] + ) + } + } + + property("dtd") = { + Prop.forAll { d: Document => + Prop.atLeastOne( + d.dtd eq null, + d.dtd.isInstanceOf[dtd.DTD] + ) + } + } + + property("encoding") = { + Prop.forAll { d: Document => + d.encoding eq null + } + } + + property("standAlone") = { + Prop.forAll { d: Document => + d.standAlone eq null + } + } + + property("version") = { + Prop.forAll { d: Document => + d.version eq null + } + } + + property("allDeclarationsProcessed") = { + Prop.forAll { d: Document => + d.allDeclarationsProcessed ?= false + } + } + + property("theSeq") = { + Prop.forAll { d: Document => + d.theSeq eq d.docElem + } + } + + property("canEqual") = { + Prop.forAll { d: Document => + d.canEqual(d) + } + } +} diff --git a/shared/src/test/scala/scala/xml/ElemGen.scala b/shared/src/test/scala/scala/xml/ElemGen.scala new file mode 100644 index 000000000..7aab4ea25 --- /dev/null +++ b/shared/src/test/scala/scala/xml/ElemGen.scala @@ -0,0 +1,58 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ElemGen extends NamespaceBindingGen + with ArbitraryNode + with MetaDataGen + with XmlNameGen { + + val genStringOrNull: Gen[String] = + Gen.oneOf( + genXmlName: Gen[String], + Gen.const(null) + ) + + def genElem(sz: Int): Gen[Elem] = for { + prefix <- genStringOrNull + label <- genXmlName: Gen[String] + attribs <- Arbitrary.arbitrary[MetaData] + scope <- Arbitrary.arbitrary[NamespaceBinding] + minimizeEmpty <- Arbitrary.arbitrary[Boolean] + n <- Gen.choose(0, scala.math.sqrt(sz / 2).toInt) + children <- Gen.listOfN(n, genNode(n)) + } yield { + Elem( + prefix, + label, + attribs, + scope, + minimizeEmpty, + children: _* + ) + } + + def invalidElem(sz: Int): Gen[Elem] = for { + prefix <- Gen.const("") + label <- Arbitrary.arbitrary[String] + attribs <- Arbitrary.arbitrary[MetaData] + scope <- Arbitrary.arbitrary[NamespaceBinding] + minimizeEmpty <- Arbitrary.arbitrary[Boolean] + n <- Gen.choose(0, scala.math.sqrt(sz / 2).toInt) + children <- Gen.listOfN(n, genNode(n)) + } yield { + Elem( + prefix, + label, + attribs, + scope, + minimizeEmpty, + children: _* + ) + } + + implicit val arbElem = Arbitrary { + Gen.sized(sz => genElem(sz)) + } +} diff --git a/shared/src/test/scala/scala/xml/ElemSpec.scala b/shared/src/test/scala/scala/xml/ElemSpec.scala new file mode 100644 index 000000000..e68ee455a --- /dev/null +++ b/shared/src/test/scala/scala/xml/ElemSpec.scala @@ -0,0 +1,62 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators +import org.scalacheck.Prop.BooleanOperators + +object ElemSpec extends PropertiesFor("Elem") + with NodeSeqGen + with MetaDataGen + with NamespaceBindingGen { + + property("new") = { + Prop.forAll { (prefix: String, label: String, attribs: MetaData, + scope: NamespaceBinding, minimizeEmpty: Boolean, + children: NodeSeq) => + Prop.atLeastOne( + !prefix.isEmpty ==> { + new Elem( + prefix, + label, + attribs, + scope, + minimizeEmpty, + children.theSeq: _* + ) + Prop.passed + }, + prefix.isEmpty ==> + Prop.throws(classOf[IllegalArgumentException]) { + new Elem( + prefix, + label, + attribs, + scope, + minimizeEmpty, + children.theSeq: _* + ) + } + ) + } + } + + property("unapplySeq(Elem)") = { + Prop.forAll { e: Elem => + val opt = Elem.unapplySeq(e) + opt ?= Some((e.prefix, e.label, e.attributes, e.scope, e.child)) + } + } + + property("unapplySeq(Node)") = { + Prop.forAll { n: Node => + val opt = Elem.unapplySeq(n) + Prop.iff[Node](n, { + case _: SpecialNode | _: Group => + opt ?= None + case _ => + opt ?= Some((n.prefix, n.label, n.attributes, n.scope, n.child)) + }) + } + } +} diff --git a/shared/src/test/scala/scala/xml/EntityRefGen.scala b/shared/src/test/scala/scala/xml/EntityRefGen.scala new file mode 100644 index 000000000..fd3850c70 --- /dev/null +++ b/shared/src/test/scala/scala/xml/EntityRefGen.scala @@ -0,0 +1,22 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait EntityRefGen extends XmlNameGen { + + val genEntityRef: Gen[EntityRef] = for { + // FIXME: Throws SAXParseException: The entity "{0}" was + // referenced, but not declared. + // s <- genXmlName // Would need a corresponding + // // declaration for `s' to be well-formed. + // Instead, only generate the pre-defined ones. + s <- Gen.oneOf("quot", "amp", "apos", "lt", "gt") + } yield { + new EntityRef(s) + } + + implicit val arbEntityRef = Arbitrary { + genEntityRef + } +} diff --git a/shared/src/test/scala/scala/xml/GroupGen.scala b/shared/src/test/scala/scala/xml/GroupGen.scala new file mode 100644 index 000000000..e53bd90f1 --- /dev/null +++ b/shared/src/test/scala/scala/xml/GroupGen.scala @@ -0,0 +1,19 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait GroupGen extends ArbitraryGroup + with ArbitraryNode { + + def genGroup(sz: Int): Gen[Group] = for { + n <- Gen.choose(0, scala.math.sqrt(sz / 2).toInt) + nodes <- Gen.listOfN(n, genNode(n)) + } yield { + Group(nodes) + } + + implicit val arbGroup = Arbitrary { + Gen.sized(sz => genGroup(sz)) + } +} diff --git a/shared/src/test/scala/scala/xml/GroupSpec.scala b/shared/src/test/scala/scala/xml/GroupSpec.scala new file mode 100644 index 000000000..d8089fe5c --- /dev/null +++ b/shared/src/test/scala/scala/xml/GroupSpec.scala @@ -0,0 +1,72 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +object GroupSpec extends PropertiesFor("Group") + with NodeGen + with ElemGen + with GroupGen { + + property("attributes") = + Prop.forAll { g: Group => + Prop.throws(classOf[UnsupportedOperationException]) { + g.attributes + } + } + + property("child") = + Prop.forAll { g: Group => + Prop.throws(classOf[UnsupportedOperationException]) { + g.child + } + } + + property("label") = + Prop.forAll { g: Group => + Prop.throws(classOf[UnsupportedOperationException]) { + g.label + } + } + + property("namespace") = + Prop.forAll { g: Group => + Prop.throws(classOf[UnsupportedOperationException]) { + g.namespace + } + } + + property("descendant") = + Prop.forAll { g: Group => + Prop.throws(classOf[UnsupportedOperationException]) { + g.descendant + } + } + + property("descendant_or_self") = + Prop.forAll { g: Group => + Prop.throws(classOf[UnsupportedOperationException]) { + g.descendant_or_self + } + } + + property("empty.\\.throws[Exception]") = { + val g = Group(List()) + (g \ "a") ?= NodeSeq.Empty + } + + // FIXME: UnsupportedOperationException: class Group does not support method 'child' + // property("\\.throws[Exception]") = { + // Prop.forAll { g: Group => + // (g \ "a") + // Prop.passed // FIXME: Check that the result is actually correct. + // } + // } + + property("theSeq") = { + Prop.forAll { g: Group => + g.theSeq ?= g.nodes + } + } +} diff --git a/shared/src/test/scala/scala/xml/MetaDataGen.scala b/shared/src/test/scala/scala/xml/MetaDataGen.scala new file mode 100644 index 000000000..290e4c55c --- /dev/null +++ b/shared/src/test/scala/scala/xml/MetaDataGen.scala @@ -0,0 +1,18 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait MetaDataGen extends AttributeGen + with ArbitraryMetaData { + + val genMetaData: Gen[MetaData] = for { + metaData <- Gen.oneOf(Gen.const(Null), genAttribute) + } yield { + metaData + } + + implicit val arbMetaData = Arbitrary { + genMetaData + } +} diff --git a/shared/src/test/scala/scala/xml/MetaDataSpec.scala b/shared/src/test/scala/scala/xml/MetaDataSpec.scala new file mode 100644 index 000000000..c21697a04 --- /dev/null +++ b/shared/src/test/scala/scala/xml/MetaDataSpec.scala @@ -0,0 +1,98 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators +import org.scalacheck.Prop.BooleanOperators + +object MetaDataSpec extends PropertiesFor("MetaData") + with ElemGen + with GroupGen + with NodeGen + with MetaDataGen { + + property("canEqual(this)") = { + Prop.forAll { m: MetaData => + m.canEqual(m) + } + } + + property("apply") = { + Prop.forAll { (m: MetaData, s: String) => + ((!s.isEmpty && Utility.isNameStart(s(0))) ==> (m(s) != s)) + } + } + + property("apply(key)") = { + Prop.forAll { m: MetaData => + Prop.iff[MetaData](m, { + case p: PrefixedAttribute => Prop.passed + case u: UnprefixedAttribute if u.key ne null => u(u.key) ?= u.value + case Null => Prop.passed + }) + } + } + + property("apply(uri, namespace, key)") = { + Prop.forAll { m: MetaData => + Prop.iff[MetaData](m, { + case p: PrefixedAttribute => + p(p.key, NamespaceBinding(p.pre, p.key, TopScope), p.key) ?= p.value + case u: UnprefixedAttribute => Prop.passed + case Null => Prop.passed + }) + } + } + + property("isPrefixed") = { + Prop.forAll { m: MetaData => + Prop.atLeastOne( + m.isPrefixed ?= true, + m.isPrefixed ?= false + ) + } + } + + property("iterator") = { + Prop.forAll { m: MetaData => + Prop.iff[MetaData](m, { + case a: Attribute if a.value eq null => + a.iterator.sameElements(a.next.iterator) + case a: Attribute => + a.iterator.sameElements(Iterator.single(a) ++ a.next.iterator) + case Null => + m.iterator ?= Iterator.empty + }) + } + } + + property("length") = { + Prop.forAll { m: MetaData => + m.length >= 0 + } + } + + property("size") = { + Prop.forAll { m: MetaData => + m.size >= 0 + } + } + + property("toString") = { + Prop.forAll { m: MetaData => + val str = m.toString + Prop.iff[MetaData](m, { + case m: MetaData if m.value eq null => + str ?= "" + case a: PrefixedAttribute if a.hasNext => + str ?= s""" ${a.pre}:${a.key}="${a.value}"${a.next}""" + case a: UnprefixedAttribute if a.hasNext => + str ?= s""" ${a.key}="${a.value}"${a.next}""" + case a: PrefixedAttribute => + str ?= s""" ${a.pre}:${a.key}="${a.value}"""" + case a: UnprefixedAttribute => + str ?= s""" ${a.key}="${a.value}"""" + }) + } + } +} diff --git a/shared/src/test/scala/scala/xml/NamespaceBindingGen.scala b/shared/src/test/scala/scala/xml/NamespaceBindingGen.scala new file mode 100644 index 000000000..432b59c90 --- /dev/null +++ b/shared/src/test/scala/scala/xml/NamespaceBindingGen.scala @@ -0,0 +1,28 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait NamespaceBindingGen { + + val genDepth: Gen[NamespaceBinding] = for { + prefix <- Arbitrary.arbitrary[String] if !prefix.isEmpty + uri <- Arbitrary.arbitrary[String] + parent <- genNamespaceBinding + } yield { + NamespaceBinding(prefix, uri, parent) + } + + val genNamespaceBinding: Gen[NamespaceBinding] = for { + // FIXME: Throws SAXParseException: prefix "{0}" was not declared. + // Need to writer generator that can write namespace declaration + // namespace <- Gen.oneOf(Gen.const(TopScope), genDepth) + namespace <- Gen.const(TopScope) + } yield { + namespace + } + + implicit val arbNamespaceBinding = Arbitrary { + genNamespaceBinding + } +} diff --git a/shared/src/test/scala/scala/xml/NamespaceBindingSpec.scala b/shared/src/test/scala/scala/xml/NamespaceBindingSpec.scala new file mode 100644 index 000000000..b1b8ee877 --- /dev/null +++ b/shared/src/test/scala/scala/xml/NamespaceBindingSpec.scala @@ -0,0 +1,49 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +object NamespaceBindingSpec extends PropertiesFor("NamespaceBinding") + with NamespaceBindingGen { + + property("canEqual(this)") = { + Prop.forAll { n: NamespaceBinding => + n.canEqual(n) + } + } + + property("getPrefix") = { + Prop.forAll { (n: NamespaceBinding, s: String) => + n.getPrefix(s) != s + } + } + + property("getPrefix(uri)") = { + Prop.forAll { n: NamespaceBinding => + n.getPrefix(n.uri) == n.prefix + } + } + + property("getURI") = { + Prop.forAll { (n: NamespaceBinding, s: String) => + n.getURI(s) != s + } + } + + property("getURI(prefix)") = { + Prop.forAll { n: NamespaceBinding => + n.getURI(n.prefix) == n.uri + } + } + + property("toString") = { + Prop.forAll { n: NamespaceBinding => + val str = n.toString + Prop.atLeastOne( + str ?= "", + n.toString.startsWith(" xmlns:") + ) + } + } +} diff --git a/shared/src/test/scala/scala/xml/NodeBufferGen.scala b/shared/src/test/scala/scala/xml/NodeBufferGen.scala new file mode 100644 index 000000000..609ea52cd --- /dev/null +++ b/shared/src/test/scala/scala/xml/NodeBufferGen.scala @@ -0,0 +1,15 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait NodeBufferGen extends ArbitraryNodeBuffer + with NodeGen { + + implicit val arbNodeBuffer = Arbitrary { + genNodeBuffer + } + + val genNodeBuffer: Gen[NodeBuffer] = + Gen.delay(new NodeBuffer) +} diff --git a/shared/src/test/scala/scala/xml/NodeBufferSpec.scala b/shared/src/test/scala/scala/xml/NodeBufferSpec.scala new file mode 100644 index 000000000..6349e4959 --- /dev/null +++ b/shared/src/test/scala/scala/xml/NodeBufferSpec.scala @@ -0,0 +1,42 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +object NodeBufferSpec extends PropertiesFor("NodeBuffer") + with NodeBufferGen + with NodeGen { + + implicit val arbAny = Arbitrary { + genAny + } + + val genAny: Gen[Any] = + Gen.oneOf( + Gen.const(null), + Gen.const((): Unit), + Arbitrary.arbitrary[Node], + Arbitrary.arbitrary[List[Node]].map(_.toIterator), + Arbitrary.arbitrary[List[Node]].map(_.toIterable), + Arbitrary.arbitrary[Array[Node]] + ) + + property("&+") = { + Prop.forAll { (nb: NodeBuffer, a: Any) => + nb&+(a) + Prop.passed + } + } + + property("toString") = { + Prop.forAll { n: NodeBuffer => + Prop.all( + n.toString ?= "NodeBuffer()", + (n &+ "").toString.startsWith("NodeBuffer") + ) + } + } +} diff --git a/shared/src/test/scala/scala/xml/NodeGen.scala b/shared/src/test/scala/scala/xml/NodeGen.scala new file mode 100644 index 000000000..5635e2d2a --- /dev/null +++ b/shared/src/test/scala/scala/xml/NodeGen.scala @@ -0,0 +1,28 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait NodeGen extends ArbitraryNode + with ElemGen + // FIXME: UnsupportedOperationException: class Group does not support method + // with GroupGen + with AtomGen + with CommentGen + with EntityRefGen + with ProcInstrGen { + + def genNode(sz: Int): Gen[Node] = + Gen.oneOf( + genAtom, + genComment, + Gen.delay(genElem(scala.math.sqrt(sz / 2).toInt)), + genEntityRef, + // Gen.delay(genGroup(scala.math.sqrt(sz / 2).toInt)), // FIXME: See above. + genProcInstr + ) + + implicit val arbNode = Arbitrary { + Gen.sized(sz => genNode(sz)) + } +} diff --git a/shared/src/test/scala/scala/xml/NodeSeqGen.scala b/shared/src/test/scala/scala/xml/NodeSeqGen.scala new file mode 100644 index 000000000..e12e68b52 --- /dev/null +++ b/shared/src/test/scala/scala/xml/NodeSeqGen.scala @@ -0,0 +1,20 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait NodeSeqGen extends NodeGen { + + implicit val arbNodeSeq = Arbitrary { + Gen.sized(sz => genNodeSeq(sz)) + } + + def genNodeSeq(sz: Int): Gen[NodeSeq] = for { + n <- Gen.choose(0, scala.math.sqrt(sz / 2).toInt) + empty <- Gen.const(NodeSeq.Empty) + s <- Gen.listOfN(n, genNode(n)) + nodeSeq <- Gen.oneOf(empty, NodeSeq.fromSeq(s.toSeq)) + } yield { + nodeSeq + } +} diff --git a/shared/src/test/scala/scala/xml/NodeSpec.scala b/shared/src/test/scala/scala/xml/NodeSpec.scala new file mode 100644 index 000000000..839a2b93d --- /dev/null +++ b/shared/src/test/scala/scala/xml/NodeSpec.scala @@ -0,0 +1,339 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => CheckProperties } +import org.scalacheck.Prop.AnyOperators +import org.scalacheck.Prop.BooleanOperators + +object NodeSpec extends CheckProperties("Node") + with NodeGen { + + property("canEqual(this)") = { + Prop.forAll { n: Node => + n.canEqual(n) + } + } + + property("canEqual") = { + Prop.forAll { (n1: Node, n2: Node) => + val b = n1.canEqual(n2) + Prop.atLeastOne( + b ?= true, + b ?= false + ) + } + } + + property("prefix") = { + Prop.forAll { n: Text => + Prop.iff[Node](n, { + case n @ Comment(_) => n.prefix eq null + case n @ EntityRef(_) => n.prefix eq null + case n: PCData => n.prefix eq null + case n @ ProcInstr(_, _) => n.prefix eq null + case n: Text => n.prefix eq null + case n: Unparsed => n.prefix eq null + case e: Elem => + Prop.atLeastOne( + // e.prefix eq null, // FIXME: NullPointerException: null + e.prefix eq null, + e.prefix != "" + ) + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + n.label + } + case a: Atom[_] => n.prefix eq null + }) + } + } + + property("label") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Comment(_) => n.label ?= "#REM" + case n @ EntityRef(_) => n.label ?= "#ENTITY" + case n: PCData => n.label ?= "#PCDATA" + case n @ ProcInstr(_, _) => n.label ?= "#PI" + case n: Text => n.label ?= "#PCDATA" + case n: Unparsed => n.label ?= "#PCDATA" + case n: Elem => n.label.length >= 0 + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + n.label + } + case n: Atom[_] => n.label ?= "#PCDATA" + }) + } + } + + property("isAtom") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n: Atom[_] => n.isAtom ?= true + case _ => n.isAtom ?= false + }) + } + } + + property("doCollectNamespaces") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Comment(_) => n.doCollectNamespaces ?= false + case n @ EntityRef(_) => n.doCollectNamespaces ?= false + case n @ ProcInstr(_, _) => n.doCollectNamespaces ?= false + case n: PCData => n.doCollectNamespaces ?= false + case n: Unparsed => n.doCollectNamespaces ?= false + case n: Text => n.doCollectNamespaces ?= false + case n: Atom[_] => n.doCollectNamespaces ?= false + case n: Elem => n.doCollectNamespaces ?= true + case n @ Group(_) => n.doCollectNamespaces ?= true + }) + } + } + + property("doTransform") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Comment(_) => n.doTransform ?= false + case n @ EntityRef(_) => n.doTransform ?= false + case n @ ProcInstr(_, _) => n.doTransform ?= false + case n: PCData => n.doTransform ?= false + case n: Unparsed => n.doTransform ?= false + case n: Text => n.doTransform ?= false + case n: Atom[_] => n.doTransform ?= false + case n: Elem => n.doTransform ?= true + case n @ Group(_) => n.doTransform ?= true + }) + } + } + + property("scope") = { + Prop.forAll { n: Node => + n.scope ne null + } + } + + property("namespace") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + n.namespace + } + case _ => + n.namespace ?= n.getNamespace(n.prefix) + }) + } + } + + // FIXME: NoSuchElementException thrown by Null.apply + // property("attribute(\"\")") = { + // Prop.forAll { n: Node => + // Prop.throws(classOf[IllegalArgumentException]) { + // n.attribute("") + // } + // } + // } + + property("attribute") = { + Prop.forAll { (n: Node, s: String) => + Prop.iff[Node](n, { + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + n.attribute(s) + } + case _ => + Prop.atLeastOne( + s.isEmpty ==> + Prop.throws(classOf[NoSuchElementException]) { + n.attribute(s) + } , + ((!s.isEmpty) && Utility.isNameStart(s.head)) ==> + Prop.throws(classOf[NoSuchElementException]) { + n.attribute(s) + }, + ((!s.isEmpty) && !Utility.isNameStart(s.head)) ==> + Prop.throws(classOf[IllegalArgumentException]) { + n.attribute(s) + } + ) + }) + } + } + + property("attributes") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Comment(_) => n.attributes ?= Null + case n @ EntityRef(_) => n.attributes ?= Null + case n: PCData => n.attributes ?= Null + case n @ ProcInstr(_, _) => n.attributes ?= Null + case n: Text => n.attributes ?= Null + case n: Unparsed => n.attributes ?= Null + case n: Elem => n.attributes.length >= 0 + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + n.attributes + } + }) + } + } + + property("child") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Comment(_) => n.child ?= Nil + case n @ EntityRef(_) => n.child ?= Nil + case n: PCData => n.child ?= Nil + case n @ ProcInstr(_, _) => n.child ?= Nil + case n: Text => n.child ?= Nil + case n: Unparsed => n.child ?= Nil + case n: Elem => n.child.length >= 0 + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + n.child + } + }) + } + } + + property("nonEmptyChildren") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Comment(_) => n.nonEmptyChildren ?= Nil + case n @ EntityRef(_) => n.nonEmptyChildren ?= Nil + case n: PCData => n.nonEmptyChildren ?= Nil + case n @ ProcInstr(_, _) => n.nonEmptyChildren ?= Nil + case n: Text => n.nonEmptyChildren ?= Nil + case n: Unparsed => n.nonEmptyChildren ?= Nil + case n: Elem => n.nonEmptyChildren.length >= 0 + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + n.nonEmptyChildren + } + }) + } + } + + property("descendant") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Comment(_) => n.descendant ?= Nil + case n @ EntityRef(_) => n.descendant ?= Nil + case n: PCData => n.descendant ?= Nil + case n @ ProcInstr(_, _) => n.descendant ?= Nil + case n: Text => n.descendant ?= Nil + case n: Unparsed => n.descendant ?= Nil + case n: Elem => n.descendant.length >= 0 + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + n.descendant + } + }) + } + } + + property("descendant_or_self") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Comment(_) => n.descendant_or_self ?= List(n) + case n @ EntityRef(_) => n.descendant_or_self ?= List(n) + case n: PCData => n.descendant_or_self ?= List(n) + case n @ ProcInstr(_, _) => n.descendant_or_self ?= List(n) + case n: Text => n.descendant_or_self ?= List(n) + case n: Unparsed => n.descendant_or_self ?= List(n) + case n: Elem => n.descendant_or_self ?= n :: n.descendant + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + n.descendant_or_self + } + }) + } + } + + property("theSeq") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Group(nodes) => + n.theSeq ?= nodes + case _ => + n.theSeq ?= n :: Nil + }) + } + } + + property("xmlType") = { + Prop.forAll { n: Node => + n.xmlType eq null + } + } + + property("nameToString") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + n.namespace + } + case _ => { + val str = n.nameToString(new StringBuilder).toString + Prop.atLeastOne( + str ?= s"${n.prefix}:${n.label}", + str ?= s"${n.label}" + ) + } + }) + } + } + + property("text") = { + Prop.forAll { n: Node => + n.text.length >= 0 + } + } + + property("toString") = { + Prop.forAll { n: Node => + n.toString.length >= 0 + } + } + + property("match") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Comment(commentText: String) => + commentText ?= n.commentText + case Elem(null, _: String, _: MetaData, _: NamespaceBinding, _ @ _*) => + Prop.passed + case Elem(_: String, _: String, _: MetaData, _: NamespaceBinding, _ @ _*) => + Prop.passed + case n @ EntityRef(entityName) => + entityName ?= n.entityName + case n @ Group(nodes) => + Prop.passed + case n @ PCData(data) => + PCData.unapply(n) ?= Some(data) + case n @ ProcInstr(_: String, _: String) => + Prop.passed + case n @ Text(_: String) => + Prop.passed + case n @ Unparsed(_: String) => + Prop.passed + }) + } + } + + property("unapplySeq") = { + Prop.forAll { n: Node => + Prop.iff[Node](n, { + case n @ Group(_) => + Prop.throws(classOf[UnsupportedOperationException]) { + Node.unapplySeq(n) + } + case _ => + Node.unapplySeq(n) ?= Some((n.label, n.attributes, n.child)) + }) + } + } +} diff --git a/shared/src/test/scala/scala/xml/PCDataGen.scala b/shared/src/test/scala/scala/xml/PCDataGen.scala new file mode 100644 index 000000000..22b412a01 --- /dev/null +++ b/shared/src/test/scala/scala/xml/PCDataGen.scala @@ -0,0 +1,17 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait PCDataGen extends Utf8StringGen { + + val genPCData: Gen[PCData] = for { + s <- genUtf8String: Gen[String] + } yield { + PCData(s) + } + + implicit val arbPCData = Arbitrary { + genPCData + } +} diff --git a/shared/src/test/scala/scala/xml/PCDataSpec.scala b/shared/src/test/scala/scala/xml/PCDataSpec.scala new file mode 100644 index 000000000..480b15f0f --- /dev/null +++ b/shared/src/test/scala/scala/xml/PCDataSpec.scala @@ -0,0 +1,27 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => CheckProperties } +import org.scalacheck.Prop.AnyOperators + +object PCDataSpec extends CheckProperties("PCData") + with PCDataGen { + + property("text") = { + Prop.forAll { d: PCData => + d.text ?= d.data + } + } + + property("toString") = { + Prop.forAll { d: PCData => + d.toString ?= s"" + } + } + + property("unapply") = { + Prop.forAll { d: PCData => + PCData.unapply(d) ?= Some(d.data) + } + } +} diff --git a/shared/src/test/scala/scala/xml/PrettyPrinterGen.scala b/shared/src/test/scala/scala/xml/PrettyPrinterGen.scala new file mode 100644 index 000000000..821e4e99b --- /dev/null +++ b/shared/src/test/scala/scala/xml/PrettyPrinterGen.scala @@ -0,0 +1,18 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait PrettyPrinterGen { + + implicit val arbPrettyPrinter = Arbitrary { + genPrettyPrinter + } + + val genPrettyPrinter: Gen[PrettyPrinter] = for { + width <- Gen.posNum[Int] + step <- Gen.posNum[Int] + } yield { + new PrettyPrinter(width, step) + } +} diff --git a/shared/src/test/scala/scala/xml/PrettyPrinterSpec.scala b/shared/src/test/scala/scala/xml/PrettyPrinterSpec.scala new file mode 100644 index 000000000..e1a64c793 --- /dev/null +++ b/shared/src/test/scala/scala/xml/PrettyPrinterSpec.scala @@ -0,0 +1,21 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => CheckProperties } + +object PrettyPrinterSpec extends CheckProperties("PrettyPrinter") + with PrettyPrinterGen + with NodeGen { + + property("format") = { + Prop.forAll { (pp: PrettyPrinter, n: Node) => + pp.format(n).length >= 0 + } + } + + property("formatNodes") = { + Prop.forAll { (pp: PrettyPrinter, ns: Seq[Node]) => + pp.formatNodes(ns).length >= 0 + } + } +} diff --git a/shared/src/test/scala/scala/xml/ProcInstrGen.scala b/shared/src/test/scala/scala/xml/ProcInstrGen.scala new file mode 100644 index 000000000..33717ef5c --- /dev/null +++ b/shared/src/test/scala/scala/xml/ProcInstrGen.scala @@ -0,0 +1,38 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ProcInstrGen extends XmlNameGen { + + val validTarget: Gen[String] = + genXmlName.suchThat(_.toLowerCase != "xml") + + val validProcText: Gen[String] = + genXmlName.suchThat(!_.contains("?>")): Gen[String] + + val genProcInstr: Gen[ProcInstr] = for { + target <- validTarget + proctext <- validProcText + } yield { + new ProcInstr(target, proctext) + } + + def invalidProcInstr: Gen[ProcInstr] = for { + badTarget <- Gen.oneOf(invalidXmlName, Gen.oneOf("XML", "xml", "Xml")) + badProcText <- Gen.const("?>") + goodTarget <- validTarget + goodProcText <- validProcText + procinstr <- Gen.oneOf( + Gen.delay(new ProcInstr(goodTarget, badProcText)), + Gen.delay(new ProcInstr(badTarget, goodProcText)), + Gen.delay(new ProcInstr(badTarget, badProcText)) + ) + } yield { + procinstr + } + + implicit val arbProcInstr = Arbitrary { + genProcInstr + } +} diff --git a/shared/src/test/scala/scala/xml/ProcInstrSpec.scala b/shared/src/test/scala/scala/xml/ProcInstrSpec.scala new file mode 100644 index 000000000..b56cc99d2 --- /dev/null +++ b/shared/src/test/scala/scala/xml/ProcInstrSpec.scala @@ -0,0 +1,49 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => CheckProperties } +import org.scalacheck.Prop.AnyOperators + +object ProcInstrSpec extends CheckProperties("ProcInstr") + with ProcInstrGen { + + property("label") = { + Prop.forAll { p: ProcInstr => + p.label == "#PI" + } + } + + property("text") = { + Prop.forAll { p: ProcInstr => + p.text ?= "" + } + } + + property("toString") = { + Prop.forAll { (p: ProcInstr) => + val str = p.toString + Prop.atLeastOne( + str ?= s"", + str ?= s"" + ) + } + } + + property("new(name, \"?>\").throws[Exception]") = { + Prop.throws(classOf[IllegalArgumentException]) { + new ProcInstr("name", "?>") + } + } + + property("new(<>, text).throws[Exception]") = { + Prop.throws(classOf[IllegalArgumentException]) { + new ProcInstr("<>", "text") + } + } + + property("new(xml, text).throws[Exception]") = { + Prop.throws(classOf[IllegalArgumentException]) { + new ProcInstr("xml", "text") + } + } +} diff --git a/shared/src/test/scala/scala/xml/QNodeSpec.scala b/shared/src/test/scala/scala/xml/QNodeSpec.scala new file mode 100644 index 000000000..085123fd9 --- /dev/null +++ b/shared/src/test/scala/scala/xml/QNodeSpec.scala @@ -0,0 +1,16 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => CheckProperties } +import org.scalacheck.Prop.AnyOperators + +object QNodeSpec extends CheckProperties("QNode") + with NodeGen { + + property("unapplySeq") = { + Prop.forAll { n: Node => + val res = QNode.unapplySeq(n) + res ?= Some((n.scope.getURI(n.prefix), n.label, n.attributes, n.child)) + } + } +} diff --git a/shared/src/test/scala/scala/xml/TextBufferGen.scala b/shared/src/test/scala/scala/xml/TextBufferGen.scala new file mode 100644 index 000000000..c6361f761 --- /dev/null +++ b/shared/src/test/scala/scala/xml/TextBufferGen.scala @@ -0,0 +1,18 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait TextBufferGen extends ArbitraryTextBuffer + with TextGen { + + implicit val arbTextBuffer = Arbitrary { + genTextBuffer + } + + val genTextBuffer: Gen[TextBuffer] = for { + str <- Arbitrary.arbitrary[String] + } yield { + TextBuffer.fromString(str) + } +} diff --git a/shared/src/test/scala/scala/xml/TextBufferSpec.scala b/shared/src/test/scala/scala/xml/TextBufferSpec.scala new file mode 100644 index 000000000..8d67f0f1b --- /dev/null +++ b/shared/src/test/scala/scala/xml/TextBufferSpec.scala @@ -0,0 +1,32 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => CheckProperties } + +object TextBufferSpec extends CheckProperties("TextBuffer") + with TextBufferGen { + + // FIXME: Verify result value. + property("fromString") = { + Prop.forAll { str: String => + TextBuffer.fromString(str) + Prop.passed + } + } + + // FIXME: Verify result value. + property("append") = { + Prop.forAll { (tb: TextBuffer, cs: Seq[Char]) => + tb.append(cs) + Prop.passed + } + } + + // FIXME: Verify result value. + property("toText") = { + Prop.forAll { tb: TextBuffer => + tb.toText + Prop.passed + } + } +} diff --git a/shared/src/test/scala/scala/xml/TextGen.scala b/shared/src/test/scala/scala/xml/TextGen.scala new file mode 100644 index 000000000..bafaba147 --- /dev/null +++ b/shared/src/test/scala/scala/xml/TextGen.scala @@ -0,0 +1,17 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait TextGen extends Utf8StringGen { + + val genText: Gen[Text] = for { + s <- genUtf8String: Gen[String] + } yield { + new Text(s) + } + + implicit val arbText = Arbitrary { + genText + } +} diff --git a/shared/src/test/scala/scala/xml/TextSpec.scala b/shared/src/test/scala/scala/xml/TextSpec.scala new file mode 100644 index 000000000..0df6c9061 --- /dev/null +++ b/shared/src/test/scala/scala/xml/TextSpec.scala @@ -0,0 +1,21 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => CheckProperties } +import org.scalacheck.Prop.AnyOperators + +object TextSpec extends CheckProperties("Text") + with TextGen { + + property("text") = { + Prop.forAll { t: Text => + t.text ?= s"${t.data}" + } + } + + property("unapply") = { + Prop.forAll { t: Text => + Text.unapply(t) ?= Some(t.data) + } + } +} diff --git a/shared/src/test/scala/scala/xml/UnparsedGen.scala b/shared/src/test/scala/scala/xml/UnparsedGen.scala new file mode 100644 index 000000000..113c44ae2 --- /dev/null +++ b/shared/src/test/scala/scala/xml/UnparsedGen.scala @@ -0,0 +1,17 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait UnparsedGen extends Utf8StringGen { + + val genUnparsed: Gen[Unparsed] = for { + s <- genUtf8String: Gen[String] + } yield { + new Unparsed(s) + } + + implicit val arbUnparsed = Arbitrary { + genUnparsed + } +} diff --git a/shared/src/test/scala/scala/xml/Utf8StringGen.scala b/shared/src/test/scala/scala/xml/Utf8StringGen.scala new file mode 100644 index 000000000..ef73e9d63 --- /dev/null +++ b/shared/src/test/scala/scala/xml/Utf8StringGen.scala @@ -0,0 +1,51 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait Utf8StringGen { + val genUtf8String: Gen[String] = + Arbitrary.arbitrary[String].map { + _.filter { c => + // 1. SAXParseException: The entity name must immediately follow + // the '&' in the entity reference + // 2. SAXParseException: The content of elements must consist of + // well-formed character data or markup. + "<&".contains(c) == false + }.filter { c => + Character.getType(c) match { + case Character.COMBINING_SPACING_MARK | + Character.CONNECTOR_PUNCTUATION | + // Character.CONTROL | + Character.CURRENCY_SYMBOL | + Character.DASH_PUNCTUATION | + Character.DECIMAL_DIGIT_NUMBER | + Character.ENCLOSING_MARK | + Character.END_PUNCTUATION | + Character.FINAL_QUOTE_PUNCTUATION | + // Character.FORMAT | + Character.INITIAL_QUOTE_PUNCTUATION | + Character.LETTER_NUMBER | + // Character.LINE_SEPARATOR | + Character.LOWERCASE_LETTER | + Character.MATH_SYMBOL | + Character.MODIFIER_LETTER | + Character.MODIFIER_SYMBOL | + Character.NON_SPACING_MARK | + Character.OTHER_LETTER | + Character.OTHER_NUMBER | + Character.OTHER_PUNCTUATION | + Character.OTHER_SYMBOL | + // Character.PARAGRAPH_SEPARATOR | + // Character.PRIVATE_USE | + Character.SPACE_SEPARATOR | + Character.START_PUNCTUATION | + // Character.SURROGATE | + Character.TITLECASE_LETTER | + // Character.UNASSIGNED | + Character.UPPERCASE_LETTER => true + case _ => false + } + } + } +} diff --git a/shared/src/test/scala/scala/xml/Utf8StringSpec.scala b/shared/src/test/scala/scala/xml/Utf8StringSpec.scala new file mode 100644 index 000000000..51899dcb6 --- /dev/null +++ b/shared/src/test/scala/scala/xml/Utf8StringSpec.scala @@ -0,0 +1,49 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => CheckProperties } + +object Utf8StringSpec extends CheckProperties("Utf8String") + with Utf8StringGen { + + // If character classes change, this will let you know. + property("getType") = { + Prop.forAll { c: Char => + val typ: String = Character.getType(c) match { + case Character.COMBINING_SPACING_MARK => "COMBINING_SPACING_MARK" + case Character.CONNECTOR_PUNCTUATION => "CONNECTOR_PUNCTUATION" + case Character.CONTROL => "CONTROL" + case Character.CURRENCY_SYMBOL => "CURRENCY_SYMBOL" + case Character.DASH_PUNCTUATION => "DASH_PUNCTUATION" + case Character.DECIMAL_DIGIT_NUMBER => "DECIMAL_DIGIT_NUMBER" + case Character.ENCLOSING_MARK => "ENCLOSING_MARK" + case Character.END_PUNCTUATION => "END_PUNCTUATION" + case Character.FINAL_QUOTE_PUNCTUATION => "FINAL_QUOTE_PUNCTUATION" + case Character.FORMAT => "FORMAT" + case Character.INITIAL_QUOTE_PUNCTUATION => "INITIAL_QUOTE_PUNCTUATION" + case Character.LETTER_NUMBER => "LETTER_NUMBER" + case Character.LINE_SEPARATOR => "LINE_SEPARATOR" + case Character.LOWERCASE_LETTER => "LOWERCASE_LETTER" + case Character.MATH_SYMBOL => "MATH_SYMBOL" + case Character.MODIFIER_LETTER => "MODIFIER_LETTER" + case Character.MODIFIER_SYMBOL => "MODIFIER_SYMBOL" + case Character.NON_SPACING_MARK => "NON_SPACING_MARK" + case Character.OTHER_LETTER => "OTHER_LETTER" + case Character.OTHER_NUMBER => "OTHER_NUMBER" + case Character.OTHER_PUNCTUATION => "OTHER_PUNCTUATION" + case Character.OTHER_SYMBOL => "OTHER_SYMBOL" + case Character.PARAGRAPH_SEPARATOR => "PARAGRAPH_SEPARATOR" + case Character.PRIVATE_USE => "PRIVATE_USE" + case Character.SPACE_SEPARATOR => "SPACE_SEPARATOR" + case Character.START_PUNCTUATION => "START_PUNCTUATION" + case Character.SURROGATE => "SURROGATE" + case Character.TITLECASE_LETTER => "TITLECASE_LETTER" + case Character.UNASSIGNED => "UNASSIGNED" + case Character.UPPERCASE_LETTER => "UPPERCASE_LETTER" + } + Prop.collect(s"Character.$typ") { + Prop.passed + } + } + } +} diff --git a/shared/src/test/scala/scala/xml/UtilitySpec.scala b/shared/src/test/scala/scala/xml/UtilitySpec.scala new file mode 100644 index 000000000..eb4a2f3d1 --- /dev/null +++ b/shared/src/test/scala/scala/xml/UtilitySpec.scala @@ -0,0 +1,66 @@ +package scala.xml + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators +import org.scalacheck.Prop.BooleanOperators + +object UtilitySpec extends PropertiesFor("Utility") + with NodeGen { + + val escape = Map( + '<' -> "lt", + '>' -> "gt", + '&' -> "amp", + '"' -> "quot" // , + // '\'' -> "apos" + ) + + property("escape") = { + Prop.forAll { (text: String) => + val sb = new StringBuilder + val res = Utility.escape(text) + val exp = text.iterator.filter { c => + (c >= ' ' || "\n\r\t".contains(c)) + }.foldLeft(sb) { (sb, c) => + escape.get(c).map { str => + sb ++= s"&$str;" + }.getOrElse { + sb += c + } + } + res ?= exp.toString + } + } + + property("escape(\"\\u0000\")") = { + Utility.escape("\u0000") ?= "" + } + + val unescape = escape.map { + case (c, str) => str -> c.toString + } + + property("unescape") = { + Prop.forAll { (text: String) => + val sb = new StringBuilder + val res = Utility.unescape(text, sb) + Prop.atLeastOne( + unescape.contains(text) ==> { + val exp = unescape.get(text).getOrElse { + text + } + res.toString ?= exp + }, + !unescape.contains(text) ==> + (res eq null) + ) + } + } + + property("serialize") = { + Prop.forAll { x: Node => + Utility.serialize(x).toString ?= x.toString + } + } +} diff --git a/shared/src/test/scala/scala/xml/XMLSpec.scala b/shared/src/test/scala/scala/xml/XMLSpec.scala new file mode 100644 index 000000000..eee5eabfc --- /dev/null +++ b/shared/src/test/scala/scala/xml/XMLSpec.scala @@ -0,0 +1,30 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen +import org.scalacheck.Prop +import org.scalacheck.{ Properties => CheckProperties } + +object XMLSpec extends CheckProperties("XML") + with NodeGen + with dtd.DocTypeGen { + + def genWriter: Gen[java.io.Writer] = + Gen.const( + new java.io.OutputStreamWriter( + new java.io.ByteArrayOutputStream, + "UTF-8" + ) + ) + + implicit val arbWriter = Arbitrary { + genWriter + } + + property("write") = { + Prop.forAll { (w: java.io.Writer, node: Node, xmlDecl: Boolean, doctype: dtd.DocType) => + XML.write(w, node, "UTF-8", xmlDecl, doctype) + Prop.passed + } + } +} diff --git a/shared/src/test/scala/scala/xml/XmlNameGen.scala b/shared/src/test/scala/scala/xml/XmlNameGen.scala new file mode 100644 index 000000000..df051e41c --- /dev/null +++ b/shared/src/test/scala/scala/xml/XmlNameGen.scala @@ -0,0 +1,41 @@ +package scala.xml + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait XmlNameGen { + + def isLetter = Utility.isAlpha _ + def isLetterOrDigit = Utility.isAlphaDigit _ + + def validPrefix: Gen[Char] = Gen.oneOf(Gen.alphaChar, Gen.oneOf("_".toSeq)) + def validChar: Gen[Char] = + Gen.oneOf(Gen.alphaNumChar, Gen.oneOf(".-_:".toSeq)) + + val genXmlName: Gen[String] = for { + arbPrefix <- validPrefix + arbName <- Gen.listOf(validChar) + } yield { + arbPrefix.toString + arbName.mkString + } + + def invalidPrefix: Gen[Char] = + Arbitrary.arbitrary[Char].suchThat(!Utility.isNameStart(_)) + + def invalidChar: Gen[Char] = + Arbitrary.arbitrary[Char].suchThat(!Utility.isNameChar(_)) + + def invalidXmlName: Gen[String] = for { + goodPrefix <- validPrefix + goodName <- Gen.listOf(validChar) + badPrefix <- invalidPrefix + badName <- Gen.listOf(invalidChar) + name <- Gen.oneOf( + goodPrefix.toString + badName.mkString, + badPrefix.toString + goodName.mkString, + badPrefix.toString + badName.mkString + ) + } yield { + name + } +} diff --git a/shared/src/test/scala/scala/xml/dtd/ArbitraryDecl.scala b/shared/src/test/scala/scala/xml/dtd/ArbitraryDecl.scala new file mode 100644 index 000000000..070c0e8cb --- /dev/null +++ b/shared/src/test/scala/scala/xml/dtd/ArbitraryDecl.scala @@ -0,0 +1,16 @@ +package scala.xml +package dtd + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ArbitraryDecl { + + val genDecl: Gen[Decl] + + implicit val arbDecl: Arbitrary[Decl] + + val genNotationDecl: Gen[NotationDecl] + + implicit val arbNotationDecl: Arbitrary[NotationDecl] +} diff --git a/shared/src/test/scala/scala/xml/dtd/ContentModelGen.scala b/shared/src/test/scala/scala/xml/dtd/ContentModelGen.scala new file mode 100644 index 000000000..5c054d9dc --- /dev/null +++ b/shared/src/test/scala/scala/xml/dtd/ContentModelGen.scala @@ -0,0 +1,25 @@ +package scala.xml +package dtd + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ContentModelGen extends impl.RegExpGen { + + // val genDFAContentModel: Gen[ContentModel] = for { + // r <- Arbitrary.arbitrary[_regexpT] + // d <- Gen.oneOf(MIXED(r), ELEMENTS(r)) + // } yield { + // d + // } + + val genContentModel: Gen[ContentModel] = + Gen.oneOf( + Gen.const(PCDATA), Gen.const(EMPTY), Gen.const(ANY) + // genDFAContentModel + ) + + implicit val arbContentModel = Arbitrary { + genContentModel + } +} diff --git a/shared/src/test/scala/scala/xml/dtd/DTDGen.scala b/shared/src/test/scala/scala/xml/dtd/DTDGen.scala new file mode 100644 index 000000000..5562e3eb1 --- /dev/null +++ b/shared/src/test/scala/scala/xml/dtd/DTDGen.scala @@ -0,0 +1,29 @@ +package scala.xml +package dtd + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait DTDGen extends DeclGen + with ExternalIDGen { + + def genDTD(sz: Int): Gen[DTD] = for { + extID <- Gen.oneOf( + Gen.const(null), + Arbitrary.arbitrary[ExternalID] + ) + n <- Gen.choose(0, scala.math.sqrt(sz / 2).toInt) + intSubset <- Gen.listOfN(n, Arbitrary.arbitrary[dtd.Decl]) + notationDecls <- Gen.listOfN(n, Arbitrary.arbitrary[NotationDecl]) + } yield { + new DTD { + externalID = extID + decls = intSubset + override def notations = notationDecls + } + } + + implicit def arbDTD = Arbitrary { + Gen.sized(sz => genDTD(sz)) + } +} diff --git a/shared/src/test/scala/scala/xml/dtd/DTDSpec.scala b/shared/src/test/scala/scala/xml/dtd/DTDSpec.scala new file mode 100644 index 000000000..5173432dd --- /dev/null +++ b/shared/src/test/scala/scala/xml/dtd/DTDSpec.scala @@ -0,0 +1,21 @@ +package scala.xml +package dtd + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +object DTDSpec extends PropertiesFor("dtd.DTD") + with DTDGen { + + property("toString") = { + Prop.forAll { d: DTD => + val str = d.toString + val decls = d.decls.mkString("\n") + Prop.atLeastOne( + str ?= s"DTD [\n${d.externalID}${decls}\n]", + str ?= s"DTD [\n${decls}\n]" + ) + } + } +} diff --git a/shared/src/test/scala/scala/xml/dtd/DeclGen.scala b/shared/src/test/scala/scala/xml/dtd/DeclGen.scala new file mode 100644 index 000000000..63c0f9de2 --- /dev/null +++ b/shared/src/test/scala/scala/xml/dtd/DeclGen.scala @@ -0,0 +1,168 @@ +package scala.xml +package dtd + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait DeclGen extends ArbitraryDecl + with ContentModelGen + with ExternalIDGen + with XmlNameGen + with Utf8StringGen { + + val genDefault: Gen[DefaultDecl] = for { + fixed <- Arbitrary.arbitrary[Boolean] + attValue <- genUtf8String: Gen[String] + } yield { + DEFAULT(fixed, attValue) + } + + val genDefaultDecl: Gen[DefaultDecl] = + Gen.oneOf(Gen.const(REQUIRED), Gen.const(IMPLIED), genDefault) + + val genElemDecl: Gen[ElemDecl] = for { + name <- genXmlName: Gen[String] + contentModel <- Arbitrary.arbitrary[ContentModel] + } yield { + ElemDecl(name, contentModel) + } + + val genAttrDecl: Gen[AttrDecl] = for { + name <- genXmlName: Gen[String] + tpe <- genUtf8String: Gen[String] + default <- Arbitrary.arbitrary[DefaultDecl] + } yield { + AttrDecl(name, s"'$tpe'", default) + } + + val genAttListDecl: Gen[AttListDecl] = for { + name <- genXmlName: Gen[String] + attrs <- Arbitrary.arbitrary[List[AttrDecl]].suchThat(_.nonEmpty) + } yield { + AttListDecl(name, attrs) + } + + val genParsedEntityDecl: Gen[ParsedEntityDecl] = for { + name <- genXmlName: Gen[String] + entdef <- Arbitrary.arbitrary[EntityDef] + } yield { + ParsedEntityDecl(name, entdef) + } + + def genParameterEntityDecl: Gen[ParameterEntityDecl] = for { + name <- genXmlName: Gen[String] + entdef <- Arbitrary.arbitrary[EntityDef] + } yield { + ParameterEntityDecl(name, entdef) + } + + val genUnparsedEntityDecl: Gen[UnparsedEntityDecl] = for { + name <- genXmlName: Gen[String] + entdef <- Arbitrary.arbitrary[EntityDef] + extdef <- Arbitrary.arbitrary[ExternalID] + notation <- genUtf8String: Gen[String] if notation.nonEmpty + } yield { + UnparsedEntityDecl(name, extdef, notation) + } + + def genEntityDecl: Gen[EntityDecl] = + Gen.oneOf( + Arbitrary.arbitrary[ParsedEntityDecl], + Arbitrary.arbitrary[ParameterEntityDecl], + Arbitrary.arbitrary[UnparsedEntityDecl] + ) + + val genNotationDecl: Gen[NotationDecl] = for { + name <- genXmlName: Gen[String] + extdef <- Arbitrary.arbitrary[ExternalID] + } yield { + NotationDecl(name, extdef) + } + + val genIntDef: Gen[IntDef] = for { + value <- genXmlName: Gen[String] + } yield { + IntDef(value) + } + + val genExtDef: Gen[ExtDef] = for { + extID <- Arbitrary.arbitrary[ExternalID] + } yield { + ExtDef(extID) + } + + val genEntityDef: Gen[EntityDef] = + Gen.oneOf(genIntDef, genExtDef) + + val genPEReference: Gen[PEReference] = for { + name <- genXmlName: Gen[String] + } yield { + PEReference(name) + } + + // FIXME: SAXParseException: The markup declarations contained or + // pointed to by the document type declaration must be well-formed. + val genDecl: Gen[Decl] = + genElemDecl + // Gen.oneOf( + // genElemDecl, + // genAttListDecl, + // genEntityDecl + // ) + + implicit val arbDecl = Arbitrary { + genDecl + } + + implicit val arbAttListDecl = Arbitrary { + genAttListDecl + } + + implicit val arbParsedEntityDecl = Arbitrary { + genParsedEntityDecl + } + + implicit val arbParameterEntityDecl = Arbitrary { + genParameterEntityDecl + } + + implicit val arbUnparsedEntityDecl = Arbitrary { + genUnparsedEntityDecl + } + + implicit val arbAttrDecl = Arbitrary { + genAttrDecl + } + + implicit val arbElemDecl = Arbitrary { + genElemDecl + } + + implicit val arbEntityDecl = Arbitrary { + genEntityDecl + } + + implicit val arbNotationDecl = Arbitrary { + genNotationDecl + } + + implicit val arbDefaultDecl = Arbitrary { + genDefaultDecl + } + + implicit val arbEntityDef = Arbitrary { + genEntityDef + } + + implicit val arbIntDef = Arbitrary { + genIntDef + } + + implicit val arbExtDef = Arbitrary { + genExtDef + } + + implicit val arbPEReference = Arbitrary { + genPEReference + } +} diff --git a/shared/src/test/scala/scala/xml/dtd/DeclSpec.scala b/shared/src/test/scala/scala/xml/dtd/DeclSpec.scala new file mode 100644 index 000000000..625b749bb --- /dev/null +++ b/shared/src/test/scala/scala/xml/dtd/DeclSpec.scala @@ -0,0 +1,136 @@ +package scala.xml +package dtd + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators + +object DeclSpec extends PropertiesFor("dtd.Decl") + with DeclGen { + + implicit val arbStringBuilder: Arbitrary[StringBuilder] = Arbitrary { + Gen.delay(new StringBuilder) + } + + // FIXME: Expected " + // val str = d.toString + // val attrs = d.attrs.mkString("\n") + // str ?= s"" + // } + // } + + // FIXME: Fix toString above, and delete this buildString test. + property("AttListDecl.buildString") = { + Prop.forAll { (d: AttListDecl, sb: StringBuilder) => + val str = d.buildString(sb).toString + val attrs = d.attrs.mkString("\n") + str ?= s"" + } + } + + property("AttrDecl.toString") = { + Prop.forAll { d: AttrDecl => + d.toString ?= s" ${d.name} ${d.tpe} ${d.default}" + } + } + + property("DefaultDecl.toString") = { + Prop.forAll { d: DefaultDecl => + val str = d.toString + Prop.atLeastOne( + str ?= "#REQUIRED", + str ?= "#IMPLIED", + str.startsWith("#FIXED"), + str.length >= 2 + ) + } + } + + property("ElemDecl.buildString") = { + Prop.forAll { (d: ElemDecl, sb: StringBuilder) => + val str = d.buildString(sb).toString + str.startsWith(s"") + } + } + + property("EntityDecl.buildString") = { + Prop.forAll { (d: EntityDecl, sb: StringBuilder) => + val str = d.buildString(sb).toString + str.startsWith("") + } + } + + property("ParsedEntityDecl.buildString") = { + Prop.forAll { (d: ParsedEntityDecl, sb1: StringBuilder, sb2: StringBuilder) => + val str = d.buildString(sb1).toString + val entdef = d.entdef.buildString(sb2).toString + str ?= s"" + } + } + + property("ParameterEntityDecl.buildString") = { + Prop.forAll { (d: ParameterEntityDecl, sb1: StringBuilder, sb2: StringBuilder) => + val str = d.buildString(sb1).toString + val entdef = d.entdef.buildString(sb2).toString + str ?= s"" + } + } + + property("UnparsedEntityDecl.buildString") = { + Prop.forAll { (d: UnparsedEntityDecl, sb1: StringBuilder, sb2: StringBuilder) => + val str = d.buildString(sb1).toString + val extID = d.extID.buildString(sb2).toString + str ?= s"" + } + } + + property("NotationDecl.buildString") = { + Prop.forAll { (d: NotationDecl, sb: StringBuilder) => + val str = d.buildString(sb).toString + str.startsWith(" + val str = d.buildString(sb).toString + str ?= s"%${d.ent};" + } + } + + property("EntityDef.buildString") = { + Prop.forAll { (d: EntityDef, sb: StringBuilder) => + val str = d.buildString(sb).toString + str.length >= 0 + } + } + + property("IntDef.buildString") = { + Prop.forAll { (d: IntDef, sb: StringBuilder) => + val str = d.buildString(sb).toString + Prop.atLeastOne( + // str ?= "", + str ?= s"'${d.value}'", + str ?= s""""${d.value}"""" + ) + } + } + + property("ExtDef.buildString") = { + Prop.forAll { (d: ExtDef, sb1: StringBuilder, sb2: StringBuilder) => + val str = d.buildString(sb1).toString + val extID = d.extID.buildString(sb2).toString + str ?= extID + } + } + + property("toString") = { + Prop.forAll { d: Decl => + d.toString.length >= 0 + } + } +} diff --git a/shared/src/test/scala/scala/xml/dtd/DocTypeGen.scala b/shared/src/test/scala/scala/xml/dtd/DocTypeGen.scala new file mode 100644 index 000000000..97975a3e8 --- /dev/null +++ b/shared/src/test/scala/scala/xml/dtd/DocTypeGen.scala @@ -0,0 +1,23 @@ +package scala.xml +package dtd + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait DocTypeGen extends DeclGen + with ExternalIDGen + with XmlNameGen { + + def genDocType(sz: Int): Gen[DocType] = for { + name <- genXmlName: Gen[String] + extID <- Arbitrary.arbitrary[ExternalID] + n <- Gen.choose(0, scala.math.sqrt(sz / 2).toInt) + intSubset <- Gen.listOfN(n, Arbitrary.arbitrary[dtd.Decl]) + } yield { + new DocType(name, extID, intSubset) + } + + implicit val arbDocType = Arbitrary { + Gen.sized(sz => genDocType(sz)) + } +} diff --git a/shared/src/test/scala/scala/xml/dtd/DocTypeSpec.scala b/shared/src/test/scala/scala/xml/dtd/DocTypeSpec.scala new file mode 100644 index 000000000..5d69a448e --- /dev/null +++ b/shared/src/test/scala/scala/xml/dtd/DocTypeSpec.scala @@ -0,0 +1,70 @@ +package scala.xml +package dtd + +import org.scalacheck.Prop +import org.scalacheck.{ Properties => PropertiesFor } +import org.scalacheck.Prop.AnyOperators +import org.scalacheck.Prop.BooleanOperators + +object DocTypeSpec extends PropertiesFor("dtd.DocType") + with DocTypeGen + with ExternalIDGen + with DeclGen { + + property("new(name)") = { + Prop.forAll { (name: String) => + Prop.atLeastOne( + Utility.isName(name) ==> { + DocType(name) + Prop.passed + }, + !Utility.isName(name) ==> + Prop.throws(classOf[IllegalArgumentException]) { + DocType(name) + } + ) + } + } + + property("new(name, extId, intSubset)") = { + Prop.forAll { (name: String, extID: ExternalID, intSubset: dtd.Decl) => + Prop.atLeastOne( + Utility.isName(name) ==> { + new DocType(name, extID, Seq(intSubset)) + Prop.passed + }, + !Utility.isName(name) ==> + Prop.throws(classOf[IllegalArgumentException]) { + new DocType(name, extID, Seq(intSubset)) + } + ) + } + } + + property("new(name, extId, emptyInt)") = { + Prop.forAll { (name: String, extID: ExternalID) => + Prop.atLeastOne( + Utility.isName(name) ==> { + new DocType(name, extID, Seq.empty[dtd.Decl]) + Prop.passed + }, + !Utility.isName(name) ==> + Prop.throws(classOf[IllegalArgumentException]) { + new DocType(name, extID, Seq.empty[dtd.Decl]) + } + ) + } + } + + property("toString") = { + Prop.forAll { d: DocType => + val str = d.toString + val intSubset = d.intSubset.mkString + Prop.atLeastOne( + str ?= s"", + str ?= s"", + str ?= s"" + ) + } + } +} diff --git a/shared/src/test/scala/scala/xml/dtd/ExternalIDGen.scala b/shared/src/test/scala/scala/xml/dtd/ExternalIDGen.scala new file mode 100644 index 000000000..fee438404 --- /dev/null +++ b/shared/src/test/scala/scala/xml/dtd/ExternalIDGen.scala @@ -0,0 +1,58 @@ +package scala.xml +package dtd + +import org.scalacheck.Arbitrary +import org.scalacheck.Gen + +trait ExternalIDGen extends Utf8StringGen { + + // FIXME: Generate any string of chars, not just alphas. Alphas + // avoid "Gave up after only 0 passed tests. 501 tests were + // discarded." + val genPubIdStr = Gen.alphaStr + .suchThat(_.nonEmpty).suchThat(Utility.checkPubID(_)) + + // FIXME: Generate any string of chars, not just alphas, Alphas + // avoid "Gave up after only 0 passed tests. 501 tests were + // discarded." + val genSysIdStr = Gen.alphaStr + .suchThat(_.nonEmpty).suchThat(Utility.checkSysID(_)) + + val genNonPubIdStr = Arbitrary.arbitrary[String] + .suchThat(!Utility.checkPubID(_)) + + val genNonSysIdStr = Gen.listOf(Gen.oneOf("'", "\"")) + .map(_.mkString).suchThat(!Utility.checkSysID(_)) + + def genExternalID: Gen[ExternalID] = + Gen.oneOf( + Gen.const(NoExternalID), + Arbitrary.arbitrary[PublicID], + Arbitrary.arbitrary[SystemID] + ) + + val genSystemID: Gen[SystemID] = for { + systemId <- genSysIdStr + } yield { + new SystemID(systemId) + } + + val genPublicID: Gen[PublicID] = for { + pubId <- genPubIdStr + systemId <- genSysIdStr + } yield { + new PublicID(pubId, systemId) + } + + implicit val arbSystemID = Arbitrary { + genSystemID + } + + implicit val arbPublicID = Arbitrary { + genPublicID + } + + implicit val arbExternalID = Arbitrary { + genExternalID + } +} diff --git a/shared/src/test/scala/scala/xml/dtd/impl/RegExpGen.scala b/shared/src/test/scala/scala/xml/dtd/impl/RegExpGen.scala new file mode 100644 index 000000000..1d938ce8a --- /dev/null +++ b/shared/src/test/scala/scala/xml/dtd/impl/RegExpGen.scala @@ -0,0 +1,34 @@ +package scala.xml +package dtd.impl + +// import org.scalacheck.Arbitrary +// import org.scalacheck.Gen + +trait RegExpGen { // extends WordExp { + + // type _labelT = dtd.ContentModel.ElemName + // type _regexpT = RegExp + + // val genLabel: Gen[_labelT] = for { + // name <- Arbitrary.arbitrary[String] + // } yield { + // dtd.ContentModel.ElemName(name) + // } + + // implicit val arbLabel = Arbitrary { + // genLabel + // } + + // val genLetter: Gen[_regexpT] = for { + // label <- Arbitrary.arbitrary[_labelT] + // } yield { + // Letter(label) + // } + + // val genRegExp: Gen[_regexpT] = + // Gen.oneOf(genLetter, Gen.const(Wildcard())) + + // implicit val arbRegExp = Arbitrary { + // genRegExp + // } +} From c9a02a0aa3a18a4a4667abd38d153d62818198d8 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Fri, 30 Sep 2016 15:36:43 -0400 Subject: [PATCH 03/11] Comment out java.nio.charset.StandardCharsets to avoid Java 6 compiler error --- jvm/src/test/scala/scala/xml/XmlStringGen.scala | 2 +- jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jvm/src/test/scala/scala/xml/XmlStringGen.scala b/jvm/src/test/scala/scala/xml/XmlStringGen.scala index a622f408c..8f98b6f29 100644 --- a/jvm/src/test/scala/scala/xml/XmlStringGen.scala +++ b/jvm/src/test/scala/scala/xml/XmlStringGen.scala @@ -13,7 +13,7 @@ trait XmlStringGen extends DocumentGen { val genXmlString: Gen[String] = for { document <- Arbitrary.arbitrary[Document] - encoding <- Gen.const(java.nio.charset.StandardCharsets.UTF_8.name) + encoding <- Gen.const("UTF-8") // java.nio.charset.StandardCharsets.UTF_8.name xmlDecl <- xmlDeclGen("1.0", encoding) } yield { val str = xmlDecl + Group(document.children ++ Seq(document.docElem)).toString diff --git a/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala b/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala index e77663768..cc85fe24d 100644 --- a/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala +++ b/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala @@ -47,7 +47,7 @@ object XMLLoaderSpec extends PropertiesFor("factory.XMLLoader") out, new java.io.OutputStreamWriter( out, - java.nio.charset.StandardCharsets.UTF_8.name + "UTF-8" // java.nio.charset.StandardCharsets.UTF_8.name ) ) } @@ -59,7 +59,7 @@ object XMLLoaderSpec extends PropertiesFor("factory.XMLLoader") val genInputStream: Gen[java.io.InputStream] = for { inOut <- Arbitrary.arbitrary[StreamAndWriter] document <- Arbitrary.arbitrary[Document] - encoding <- Gen.const(java.nio.charset.StandardCharsets.UTF_8.name) + encoding <- Gen.const("UTF-8") // java.nio.charset.StandardCharsets.UTF_8.name xmlDecl <- Gen.const(true) // Gen.oneOf(true, false) doctype <- Arbitrary.arbitrary[dtd.DocType] minimizeTags <- Gen.oneOf( From aa74f56d47a6212e36604e0b0a2159b65b735c4c Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Sat, 4 Feb 2017 15:08:27 -0500 Subject: [PATCH 04/11] Increment scalacheck to 1.13.4 to fix 2.12 build --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index fd5c0181e..e636f595a 100644 --- a/build.sbt +++ b/build.sbt @@ -107,7 +107,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform) libraryDependencies += "junit" % "junit" % "4.12" % Test, libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.9" % Test, - libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.2" % Test, + libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.4" % Test, libraryDependencies += ("org.scala-lang" % "scala-compiler" % scalaVersion.value % Test).exclude("org.scala-lang.modules", s"scala-xml_${scalaBinaryVersion.value}") ) .jsSettings( From 8d56c4ed4db03ed726ecddbc76d5d95f486e874e Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Mon, 9 Oct 2017 14:34:46 -0400 Subject: [PATCH 05/11] Increment scalacheck to 1.13.5 to fix scalajs build --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e636f595a..95ed2cf77 100644 --- a/build.sbt +++ b/build.sbt @@ -107,7 +107,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform) libraryDependencies += "junit" % "junit" % "4.12" % Test, libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.9" % Test, - libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.4" % Test, + libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.5" % Test, libraryDependencies += ("org.scala-lang" % "scala-compiler" % scalaVersion.value % Test).exclude("org.scala-lang.modules", s"scala-xml_${scalaBinaryVersion.value}") ) .jsSettings( From 585c20ab9cfd65f23b7ef7f3c2f18acc3c3ecb7d Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Tue, 10 Oct 2017 10:53:45 -0400 Subject: [PATCH 06/11] Add Scala file header --- jvm/src/test/scala/scala/xml/NodeSeqSpec.scala | 8 ++++++++ jvm/src/test/scala/scala/xml/XmlStringGen.scala | 8 ++++++++ jvm/src/test/scala/scala/xml/dtd/ExternalIDSpec.scala | 8 ++++++++ jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala | 8 ++++++++ .../scala/scala/xml/parsing/ConstructingParserGen.scala | 8 ++++++++ .../scala/scala/xml/parsing/ConstructingParserSpec.scala | 8 ++++++++ jvm/src/test/scala/scala/xml/parsing/XhtmlParserGen.scala | 8 ++++++++ .../test/scala/scala/xml/parsing/XhtmlParserSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/ArbitraryElem.scala | 8 ++++++++ shared/src/test/scala/scala/xml/ArbitraryGroup.scala | 8 ++++++++ shared/src/test/scala/scala/xml/ArbitraryMetaData.scala | 8 ++++++++ shared/src/test/scala/scala/xml/ArbitraryNode.scala | 8 ++++++++ shared/src/test/scala/scala/xml/ArbitraryNodeBuffer.scala | 8 ++++++++ shared/src/test/scala/scala/xml/ArbitraryTextBuffer.scala | 8 ++++++++ shared/src/test/scala/scala/xml/AtomGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/AtomSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/AttributeGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/AttributeSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/CommentGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/CommentSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/DocumentGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/DocumentSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/ElemGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/ElemSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/EntityRefGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/GroupGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/GroupSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/MetaDataGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/MetaDataSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/NamespaceBindingGen.scala | 8 ++++++++ .../src/test/scala/scala/xml/NamespaceBindingSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/NodeBufferGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/NodeBufferSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/NodeGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/NodeSeqGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/NodeSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/PCDataGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/PCDataSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/PrettyPrinterGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/PrettyPrinterSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/ProcInstrGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/ProcInstrSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/QNodeSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/TextBufferGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/TextBufferSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/TextGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/TextSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/UnparsedGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/Utf8StringGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/Utf8StringSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/UtilitySpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/XMLSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/XmlNameGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/dtd/ArbitraryDecl.scala | 8 ++++++++ shared/src/test/scala/scala/xml/dtd/ContentModelGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/dtd/DTDGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/dtd/DTDSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/dtd/DeclGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/dtd/DeclSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/dtd/DocTypeGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/dtd/DocTypeSpec.scala | 8 ++++++++ shared/src/test/scala/scala/xml/dtd/ExternalIDGen.scala | 8 ++++++++ shared/src/test/scala/scala/xml/dtd/impl/RegExpGen.scala | 8 ++++++++ 63 files changed, 504 insertions(+) diff --git a/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala b/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala index e4309a0e5..a26f001e8 100644 --- a/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala +++ b/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/jvm/src/test/scala/scala/xml/XmlStringGen.scala b/jvm/src/test/scala/scala/xml/XmlStringGen.scala index 8f98b6f29..a9e26a6c6 100644 --- a/jvm/src/test/scala/scala/xml/XmlStringGen.scala +++ b/jvm/src/test/scala/scala/xml/XmlStringGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/jvm/src/test/scala/scala/xml/dtd/ExternalIDSpec.scala b/jvm/src/test/scala/scala/xml/dtd/ExternalIDSpec.scala index 08d093da4..c183fc82d 100644 --- a/jvm/src/test/scala/scala/xml/dtd/ExternalIDSpec.scala +++ b/jvm/src/test/scala/scala/xml/dtd/ExternalIDSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd diff --git a/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala b/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala index cc85fe24d..15f7a16c8 100644 --- a/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala +++ b/jvm/src/test/scala/scala/xml/factory/XMLLoaderSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package factory diff --git a/jvm/src/test/scala/scala/xml/parsing/ConstructingParserGen.scala b/jvm/src/test/scala/scala/xml/parsing/ConstructingParserGen.scala index b78521e13..cbaf9fedc 100644 --- a/jvm/src/test/scala/scala/xml/parsing/ConstructingParserGen.scala +++ b/jvm/src/test/scala/scala/xml/parsing/ConstructingParserGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package parsing diff --git a/jvm/src/test/scala/scala/xml/parsing/ConstructingParserSpec.scala b/jvm/src/test/scala/scala/xml/parsing/ConstructingParserSpec.scala index 7325860e0..f0f21c6e7 100644 --- a/jvm/src/test/scala/scala/xml/parsing/ConstructingParserSpec.scala +++ b/jvm/src/test/scala/scala/xml/parsing/ConstructingParserSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package parsing diff --git a/jvm/src/test/scala/scala/xml/parsing/XhtmlParserGen.scala b/jvm/src/test/scala/scala/xml/parsing/XhtmlParserGen.scala index 6ad67dcba..c9256b8d4 100644 --- a/jvm/src/test/scala/scala/xml/parsing/XhtmlParserGen.scala +++ b/jvm/src/test/scala/scala/xml/parsing/XhtmlParserGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package parsing diff --git a/jvm/src/test/scala/scala/xml/parsing/XhtmlParserSpec.scala b/jvm/src/test/scala/scala/xml/parsing/XhtmlParserSpec.scala index ce595ac9a..0ea7b6bcb 100644 --- a/jvm/src/test/scala/scala/xml/parsing/XhtmlParserSpec.scala +++ b/jvm/src/test/scala/scala/xml/parsing/XhtmlParserSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package parsing diff --git a/shared/src/test/scala/scala/xml/ArbitraryElem.scala b/shared/src/test/scala/scala/xml/ArbitraryElem.scala index 2b3f395ab..a9487e57a 100644 --- a/shared/src/test/scala/scala/xml/ArbitraryElem.scala +++ b/shared/src/test/scala/scala/xml/ArbitraryElem.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/ArbitraryGroup.scala b/shared/src/test/scala/scala/xml/ArbitraryGroup.scala index 61fed05de..9bc0cfcf2 100644 --- a/shared/src/test/scala/scala/xml/ArbitraryGroup.scala +++ b/shared/src/test/scala/scala/xml/ArbitraryGroup.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/ArbitraryMetaData.scala b/shared/src/test/scala/scala/xml/ArbitraryMetaData.scala index c30feb62c..abdc9cc6e 100644 --- a/shared/src/test/scala/scala/xml/ArbitraryMetaData.scala +++ b/shared/src/test/scala/scala/xml/ArbitraryMetaData.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/ArbitraryNode.scala b/shared/src/test/scala/scala/xml/ArbitraryNode.scala index 811826cfb..dbf3663a8 100644 --- a/shared/src/test/scala/scala/xml/ArbitraryNode.scala +++ b/shared/src/test/scala/scala/xml/ArbitraryNode.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/ArbitraryNodeBuffer.scala b/shared/src/test/scala/scala/xml/ArbitraryNodeBuffer.scala index e0e869718..5bf6ecf43 100644 --- a/shared/src/test/scala/scala/xml/ArbitraryNodeBuffer.scala +++ b/shared/src/test/scala/scala/xml/ArbitraryNodeBuffer.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/ArbitraryTextBuffer.scala b/shared/src/test/scala/scala/xml/ArbitraryTextBuffer.scala index 4178d5217..7097150b9 100644 --- a/shared/src/test/scala/scala/xml/ArbitraryTextBuffer.scala +++ b/shared/src/test/scala/scala/xml/ArbitraryTextBuffer.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/AtomGen.scala b/shared/src/test/scala/scala/xml/AtomGen.scala index f2eab8f64..9a649ec68 100644 --- a/shared/src/test/scala/scala/xml/AtomGen.scala +++ b/shared/src/test/scala/scala/xml/AtomGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/AtomSpec.scala b/shared/src/test/scala/scala/xml/AtomSpec.scala index 3c0173d79..ea1847b5f 100644 --- a/shared/src/test/scala/scala/xml/AtomSpec.scala +++ b/shared/src/test/scala/scala/xml/AtomSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/AttributeGen.scala b/shared/src/test/scala/scala/xml/AttributeGen.scala index 27b5cd8f2..ad29b7994 100644 --- a/shared/src/test/scala/scala/xml/AttributeGen.scala +++ b/shared/src/test/scala/scala/xml/AttributeGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/AttributeSpec.scala b/shared/src/test/scala/scala/xml/AttributeSpec.scala index fe851b548..8009ae176 100644 --- a/shared/src/test/scala/scala/xml/AttributeSpec.scala +++ b/shared/src/test/scala/scala/xml/AttributeSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/CommentGen.scala b/shared/src/test/scala/scala/xml/CommentGen.scala index 23368fcc0..9dfd3e62b 100644 --- a/shared/src/test/scala/scala/xml/CommentGen.scala +++ b/shared/src/test/scala/scala/xml/CommentGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/CommentSpec.scala b/shared/src/test/scala/scala/xml/CommentSpec.scala index fe2a12959..50bfed0a9 100644 --- a/shared/src/test/scala/scala/xml/CommentSpec.scala +++ b/shared/src/test/scala/scala/xml/CommentSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/DocumentGen.scala b/shared/src/test/scala/scala/xml/DocumentGen.scala index 058c320ec..db24f8618 100644 --- a/shared/src/test/scala/scala/xml/DocumentGen.scala +++ b/shared/src/test/scala/scala/xml/DocumentGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/DocumentSpec.scala b/shared/src/test/scala/scala/xml/DocumentSpec.scala index 3ab2fea26..7c7c963d9 100644 --- a/shared/src/test/scala/scala/xml/DocumentSpec.scala +++ b/shared/src/test/scala/scala/xml/DocumentSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/ElemGen.scala b/shared/src/test/scala/scala/xml/ElemGen.scala index 7aab4ea25..33a4b90a0 100644 --- a/shared/src/test/scala/scala/xml/ElemGen.scala +++ b/shared/src/test/scala/scala/xml/ElemGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/ElemSpec.scala b/shared/src/test/scala/scala/xml/ElemSpec.scala index e68ee455a..1224e6734 100644 --- a/shared/src/test/scala/scala/xml/ElemSpec.scala +++ b/shared/src/test/scala/scala/xml/ElemSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/EntityRefGen.scala b/shared/src/test/scala/scala/xml/EntityRefGen.scala index fd3850c70..9e5be4944 100644 --- a/shared/src/test/scala/scala/xml/EntityRefGen.scala +++ b/shared/src/test/scala/scala/xml/EntityRefGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/GroupGen.scala b/shared/src/test/scala/scala/xml/GroupGen.scala index e53bd90f1..2ec85db36 100644 --- a/shared/src/test/scala/scala/xml/GroupGen.scala +++ b/shared/src/test/scala/scala/xml/GroupGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/GroupSpec.scala b/shared/src/test/scala/scala/xml/GroupSpec.scala index d8089fe5c..e603fd0c8 100644 --- a/shared/src/test/scala/scala/xml/GroupSpec.scala +++ b/shared/src/test/scala/scala/xml/GroupSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/MetaDataGen.scala b/shared/src/test/scala/scala/xml/MetaDataGen.scala index 290e4c55c..603e57ce0 100644 --- a/shared/src/test/scala/scala/xml/MetaDataGen.scala +++ b/shared/src/test/scala/scala/xml/MetaDataGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/MetaDataSpec.scala b/shared/src/test/scala/scala/xml/MetaDataSpec.scala index c21697a04..42d37242b 100644 --- a/shared/src/test/scala/scala/xml/MetaDataSpec.scala +++ b/shared/src/test/scala/scala/xml/MetaDataSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/NamespaceBindingGen.scala b/shared/src/test/scala/scala/xml/NamespaceBindingGen.scala index 432b59c90..0fae8eeb4 100644 --- a/shared/src/test/scala/scala/xml/NamespaceBindingGen.scala +++ b/shared/src/test/scala/scala/xml/NamespaceBindingGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/NamespaceBindingSpec.scala b/shared/src/test/scala/scala/xml/NamespaceBindingSpec.scala index b1b8ee877..7f436cbe9 100644 --- a/shared/src/test/scala/scala/xml/NamespaceBindingSpec.scala +++ b/shared/src/test/scala/scala/xml/NamespaceBindingSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/NodeBufferGen.scala b/shared/src/test/scala/scala/xml/NodeBufferGen.scala index 609ea52cd..dd05af938 100644 --- a/shared/src/test/scala/scala/xml/NodeBufferGen.scala +++ b/shared/src/test/scala/scala/xml/NodeBufferGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/NodeBufferSpec.scala b/shared/src/test/scala/scala/xml/NodeBufferSpec.scala index 6349e4959..e97b21ccf 100644 --- a/shared/src/test/scala/scala/xml/NodeBufferSpec.scala +++ b/shared/src/test/scala/scala/xml/NodeBufferSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/NodeGen.scala b/shared/src/test/scala/scala/xml/NodeGen.scala index 5635e2d2a..628caf17c 100644 --- a/shared/src/test/scala/scala/xml/NodeGen.scala +++ b/shared/src/test/scala/scala/xml/NodeGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/NodeSeqGen.scala b/shared/src/test/scala/scala/xml/NodeSeqGen.scala index e12e68b52..d18dd38e2 100644 --- a/shared/src/test/scala/scala/xml/NodeSeqGen.scala +++ b/shared/src/test/scala/scala/xml/NodeSeqGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/NodeSpec.scala b/shared/src/test/scala/scala/xml/NodeSpec.scala index 839a2b93d..019a7f7e3 100644 --- a/shared/src/test/scala/scala/xml/NodeSpec.scala +++ b/shared/src/test/scala/scala/xml/NodeSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/PCDataGen.scala b/shared/src/test/scala/scala/xml/PCDataGen.scala index 22b412a01..5b141aee7 100644 --- a/shared/src/test/scala/scala/xml/PCDataGen.scala +++ b/shared/src/test/scala/scala/xml/PCDataGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/PCDataSpec.scala b/shared/src/test/scala/scala/xml/PCDataSpec.scala index 480b15f0f..86e65a026 100644 --- a/shared/src/test/scala/scala/xml/PCDataSpec.scala +++ b/shared/src/test/scala/scala/xml/PCDataSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/PrettyPrinterGen.scala b/shared/src/test/scala/scala/xml/PrettyPrinterGen.scala index 821e4e99b..441db67bd 100644 --- a/shared/src/test/scala/scala/xml/PrettyPrinterGen.scala +++ b/shared/src/test/scala/scala/xml/PrettyPrinterGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/PrettyPrinterSpec.scala b/shared/src/test/scala/scala/xml/PrettyPrinterSpec.scala index e1a64c793..67e88a236 100644 --- a/shared/src/test/scala/scala/xml/PrettyPrinterSpec.scala +++ b/shared/src/test/scala/scala/xml/PrettyPrinterSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/ProcInstrGen.scala b/shared/src/test/scala/scala/xml/ProcInstrGen.scala index 33717ef5c..f73b9f659 100644 --- a/shared/src/test/scala/scala/xml/ProcInstrGen.scala +++ b/shared/src/test/scala/scala/xml/ProcInstrGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/ProcInstrSpec.scala b/shared/src/test/scala/scala/xml/ProcInstrSpec.scala index b56cc99d2..cffb83894 100644 --- a/shared/src/test/scala/scala/xml/ProcInstrSpec.scala +++ b/shared/src/test/scala/scala/xml/ProcInstrSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/QNodeSpec.scala b/shared/src/test/scala/scala/xml/QNodeSpec.scala index 085123fd9..baf9a5bae 100644 --- a/shared/src/test/scala/scala/xml/QNodeSpec.scala +++ b/shared/src/test/scala/scala/xml/QNodeSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/TextBufferGen.scala b/shared/src/test/scala/scala/xml/TextBufferGen.scala index c6361f761..45aea1787 100644 --- a/shared/src/test/scala/scala/xml/TextBufferGen.scala +++ b/shared/src/test/scala/scala/xml/TextBufferGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/TextBufferSpec.scala b/shared/src/test/scala/scala/xml/TextBufferSpec.scala index 8d67f0f1b..91a53f5a2 100644 --- a/shared/src/test/scala/scala/xml/TextBufferSpec.scala +++ b/shared/src/test/scala/scala/xml/TextBufferSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/TextGen.scala b/shared/src/test/scala/scala/xml/TextGen.scala index bafaba147..141254644 100644 --- a/shared/src/test/scala/scala/xml/TextGen.scala +++ b/shared/src/test/scala/scala/xml/TextGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/TextSpec.scala b/shared/src/test/scala/scala/xml/TextSpec.scala index 0df6c9061..5adeb9f89 100644 --- a/shared/src/test/scala/scala/xml/TextSpec.scala +++ b/shared/src/test/scala/scala/xml/TextSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/UnparsedGen.scala b/shared/src/test/scala/scala/xml/UnparsedGen.scala index 113c44ae2..d9fb57013 100644 --- a/shared/src/test/scala/scala/xml/UnparsedGen.scala +++ b/shared/src/test/scala/scala/xml/UnparsedGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/Utf8StringGen.scala b/shared/src/test/scala/scala/xml/Utf8StringGen.scala index ef73e9d63..1e2fa3c9b 100644 --- a/shared/src/test/scala/scala/xml/Utf8StringGen.scala +++ b/shared/src/test/scala/scala/xml/Utf8StringGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +!** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/Utf8StringSpec.scala b/shared/src/test/scala/scala/xml/Utf8StringSpec.scala index 51899dcb6..c873734b9 100644 --- a/shared/src/test/scala/scala/xml/Utf8StringSpec.scala +++ b/shared/src/test/scala/scala/xml/Utf8StringSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/UtilitySpec.scala b/shared/src/test/scala/scala/xml/UtilitySpec.scala index eb4a2f3d1..5087e68ae 100644 --- a/shared/src/test/scala/scala/xml/UtilitySpec.scala +++ b/shared/src/test/scala/scala/xml/UtilitySpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Prop diff --git a/shared/src/test/scala/scala/xml/XMLSpec.scala b/shared/src/test/scala/scala/xml/XMLSpec.scala index eee5eabfc..3b8338327 100644 --- a/shared/src/test/scala/scala/xml/XMLSpec.scala +++ b/shared/src/test/scala/scala/xml/XMLSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/XmlNameGen.scala b/shared/src/test/scala/scala/xml/XmlNameGen.scala index df051e41c..7433812ac 100644 --- a/shared/src/test/scala/scala/xml/XmlNameGen.scala +++ b/shared/src/test/scala/scala/xml/XmlNameGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml import org.scalacheck.Arbitrary diff --git a/shared/src/test/scala/scala/xml/dtd/ArbitraryDecl.scala b/shared/src/test/scala/scala/xml/dtd/ArbitraryDecl.scala index 070c0e8cb..8453d4d7f 100644 --- a/shared/src/test/scala/scala/xml/dtd/ArbitraryDecl.scala +++ b/shared/src/test/scala/scala/xml/dtd/ArbitraryDecl.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd diff --git a/shared/src/test/scala/scala/xml/dtd/ContentModelGen.scala b/shared/src/test/scala/scala/xml/dtd/ContentModelGen.scala index 5c054d9dc..1950b3efe 100644 --- a/shared/src/test/scala/scala/xml/dtd/ContentModelGen.scala +++ b/shared/src/test/scala/scala/xml/dtd/ContentModelGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd diff --git a/shared/src/test/scala/scala/xml/dtd/DTDGen.scala b/shared/src/test/scala/scala/xml/dtd/DTDGen.scala index 5562e3eb1..4ec7b3d7a 100644 --- a/shared/src/test/scala/scala/xml/dtd/DTDGen.scala +++ b/shared/src/test/scala/scala/xml/dtd/DTDGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd diff --git a/shared/src/test/scala/scala/xml/dtd/DTDSpec.scala b/shared/src/test/scala/scala/xml/dtd/DTDSpec.scala index 5173432dd..ad5994e9a 100644 --- a/shared/src/test/scala/scala/xml/dtd/DTDSpec.scala +++ b/shared/src/test/scala/scala/xml/dtd/DTDSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd diff --git a/shared/src/test/scala/scala/xml/dtd/DeclGen.scala b/shared/src/test/scala/scala/xml/dtd/DeclGen.scala index 63c0f9de2..71833c616 100644 --- a/shared/src/test/scala/scala/xml/dtd/DeclGen.scala +++ b/shared/src/test/scala/scala/xml/dtd/DeclGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd diff --git a/shared/src/test/scala/scala/xml/dtd/DeclSpec.scala b/shared/src/test/scala/scala/xml/dtd/DeclSpec.scala index 625b749bb..2b5de6379 100644 --- a/shared/src/test/scala/scala/xml/dtd/DeclSpec.scala +++ b/shared/src/test/scala/scala/xml/dtd/DeclSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd diff --git a/shared/src/test/scala/scala/xml/dtd/DocTypeGen.scala b/shared/src/test/scala/scala/xml/dtd/DocTypeGen.scala index 97975a3e8..e14d117f2 100644 --- a/shared/src/test/scala/scala/xml/dtd/DocTypeGen.scala +++ b/shared/src/test/scala/scala/xml/dtd/DocTypeGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd diff --git a/shared/src/test/scala/scala/xml/dtd/DocTypeSpec.scala b/shared/src/test/scala/scala/xml/dtd/DocTypeSpec.scala index 5d69a448e..76e30e831 100644 --- a/shared/src/test/scala/scala/xml/dtd/DocTypeSpec.scala +++ b/shared/src/test/scala/scala/xml/dtd/DocTypeSpec.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd diff --git a/shared/src/test/scala/scala/xml/dtd/ExternalIDGen.scala b/shared/src/test/scala/scala/xml/dtd/ExternalIDGen.scala index fee438404..5b3354ea1 100644 --- a/shared/src/test/scala/scala/xml/dtd/ExternalIDGen.scala +++ b/shared/src/test/scala/scala/xml/dtd/ExternalIDGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd diff --git a/shared/src/test/scala/scala/xml/dtd/impl/RegExpGen.scala b/shared/src/test/scala/scala/xml/dtd/impl/RegExpGen.scala index 1d938ce8a..7b4024f94 100644 --- a/shared/src/test/scala/scala/xml/dtd/impl/RegExpGen.scala +++ b/shared/src/test/scala/scala/xml/dtd/impl/RegExpGen.scala @@ -1,3 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2018, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.xml package dtd.impl From 96fd0835e95545a64da3ba0a86481cd182d837b9 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Fri, 16 Feb 2018 15:36:24 -0500 Subject: [PATCH 07/11] Add ScalaCheck js dependency --- build.sbt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 95ed2cf77..2a0f9a380 100644 --- a/build.sbt +++ b/build.sbt @@ -112,7 +112,9 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform) ) .jsSettings( // Scala.js cannot run forked tests - fork in Test := false + fork in Test := false, + + libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.13.5" % "test" ) .jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)) From 20a50a9d9a5c7b0af61d3dd081b082eb2e5c26b9 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Sun, 10 Jun 2018 21:17:48 -0400 Subject: [PATCH 08/11] Increment scalacheck to 1.14.0 to fix sjs 1.0 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 2a0f9a380..c04dc05d8 100644 --- a/build.sbt +++ b/build.sbt @@ -107,14 +107,14 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform) libraryDependencies += "junit" % "junit" % "4.12" % Test, libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.9" % Test, - libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.5" % Test, + libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.14.0" % Test, libraryDependencies += ("org.scala-lang" % "scala-compiler" % scalaVersion.value % Test).exclude("org.scala-lang.modules", s"scala-xml_${scalaBinaryVersion.value}") ) .jsSettings( // Scala.js cannot run forked tests fork in Test := false, - libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.13.5" % "test" + libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.14.0" % Test ) .jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)) From d5ee20f18eef70c1d034a09374ba7604c7aa909f Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Fri, 24 Aug 2018 06:32:11 -0400 Subject: [PATCH 09/11] Fix property test of NodeSeq.\\ Exception thrown was made more consistent in 389cdce --- jvm/src/test/scala/scala/xml/NodeSeqSpec.scala | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala b/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala index a26f001e8..18a77e5da 100644 --- a/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala +++ b/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala @@ -89,8 +89,7 @@ object NodeSeqSpec extends PropertiesFor("NodeSeq") property("\\\\ \"\".throws[Exception]") = { Prop.forAll { n: NodeSeq => - // FIXME: Should be IllegalArgumentException. - Prop.throws(classOf[StringIndexOutOfBoundsException]) { + Prop.throws(classOf[IllegalArgumentException]) { (n \\ "") } } @@ -113,12 +112,7 @@ object NodeSeqSpec extends PropertiesFor("NodeSeq") property("\\\\") = { Prop.forAll { (n: NodeSeq, s: String) => Prop.iff[String](s, { - // FIXME: Should be IllegalArgumentException, regardless of theSeq. - case "" => - Prop.throws(classOf[StringIndexOutOfBoundsException]) { - (n \\ s) - } - case "@" => + case "" | "@" => Prop.throws(classOf[IllegalArgumentException]) { (n \\ s) } From 223271bda735e2441b5e88f996591a3cd450ffcf Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Sat, 1 Dec 2018 17:50:07 -0500 Subject: [PATCH 10/11] Fix unapplySeq property test for 2.13 Name-based pattern matching dropped in 2.13.0-M5 --- shared/src/test/scala/scala/xml/ElemSpec.scala | 2 +- shared/src/test/scala/scala/xml/NodeSpec.scala | 2 +- shared/src/test/scala/scala/xml/QNodeSpec.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/src/test/scala/scala/xml/ElemSpec.scala b/shared/src/test/scala/scala/xml/ElemSpec.scala index 1224e6734..864188fda 100644 --- a/shared/src/test/scala/scala/xml/ElemSpec.scala +++ b/shared/src/test/scala/scala/xml/ElemSpec.scala @@ -63,7 +63,7 @@ object ElemSpec extends PropertiesFor("Elem") case _: SpecialNode | _: Group => opt ?= None case _ => - opt ?= Some((n.prefix, n.label, n.attributes, n.scope, n.child)) + opt ?= Some((n.prefix, n.label, n.attributes, n.scope, n.child.toSeq)) }) } } diff --git a/shared/src/test/scala/scala/xml/NodeSpec.scala b/shared/src/test/scala/scala/xml/NodeSpec.scala index 019a7f7e3..de8274445 100644 --- a/shared/src/test/scala/scala/xml/NodeSpec.scala +++ b/shared/src/test/scala/scala/xml/NodeSpec.scala @@ -340,7 +340,7 @@ object NodeSpec extends CheckProperties("Node") Node.unapplySeq(n) } case _ => - Node.unapplySeq(n) ?= Some((n.label, n.attributes, n.child)) + Node.unapplySeq(n) ?= Some((n.label, n.attributes, n.child.toSeq)) }) } } diff --git a/shared/src/test/scala/scala/xml/QNodeSpec.scala b/shared/src/test/scala/scala/xml/QNodeSpec.scala index baf9a5bae..2ac7e4c16 100644 --- a/shared/src/test/scala/scala/xml/QNodeSpec.scala +++ b/shared/src/test/scala/scala/xml/QNodeSpec.scala @@ -18,7 +18,7 @@ object QNodeSpec extends CheckProperties("QNode") property("unapplySeq") = { Prop.forAll { n: Node => val res = QNode.unapplySeq(n) - res ?= Some((n.scope.getURI(n.prefix), n.label, n.attributes, n.child)) + res ?= Some((n.scope.getURI(n.prefix), n.label, n.attributes, n.child.toSeq)) } } } From b06a9353ab210ecf756502695366a3bf4cd6d647 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Fri, 5 Apr 2019 10:31:46 -0400 Subject: [PATCH 11/11] Fix property test of NodeSeq.\@ Exception thrown was made more consistent in 9a0db27 --- jvm/src/test/scala/scala/xml/NodeSeqSpec.scala | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala b/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala index 18a77e5da..069230aa4 100644 --- a/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala +++ b/jvm/src/test/scala/scala/xml/NodeSeqSpec.scala @@ -54,16 +54,10 @@ object NodeSeqSpec extends PropertiesFor("NodeSeq") property("\\ @.throws[Exception]") = { Prop.forAll { n: NodeSeq => Prop.iff[NodeSeq](n, { - // FIXME: Should be IllegalArgumentException, regardless of theSeq. - case n if n.length == 0 => - (n \ "@") ?= NodeSeq.Empty - case n if n.length == 1 => + case n: NodeSeq => Prop.throws(classOf[IllegalArgumentException]) { (n \ "@") } - case n: NodeSeq => - (n \ "@") - Prop.passed }) } } @@ -126,16 +120,10 @@ object NodeSeqSpec extends PropertiesFor("NodeSeq") property("\\@ \"\".throws[Exception]") = { Prop.forAll { n: NodeSeq => Prop.iff[NodeSeq](n, { - // FIXME: Should be IllegalArgumentException, regardless of theSeq. - case n if n.length == 0 => - (n \@ "") ?= "" - case n if n.length == 1 => + case s => Prop.throws(classOf[IllegalArgumentException]) { (n \@ "") } - case s => - (n \@ "") - Prop.passed }) } }