-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move scala-xml related code to separate module #610
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1c278ef
Move scala-xml related code to separate module
howyp 5c02a23
Add exclusions for binary compatibility failures
howyp 9363d8f
Try scalaxml module in scala 2.13 build
howyp 6c01d8d
Fix scalafmt errors
howyp d1eb212
Lowercase module's directory
howyp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
modules/scalaxml/jvm/src/main/scala/eu/timepit/refined/scalaxml/string.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package eu.timepit.refined.scalaxml | ||
|
||
import eu.timepit.refined.api.Validate | ||
|
||
object string { | ||
|
||
/** Predicate that checks if a `String` is well-formed XML. */ | ||
final case class Xml() | ||
|
||
object Xml { | ||
implicit def xmlValidate: Validate.Plain[String, Xml] = | ||
Validate.fromPartial(scala.xml.XML.loadString, "Xml", Xml()) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
modules/scalaxml/jvm/src/main/scala/eu/timepit/refined/scalaxml/util.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package eu.timepit.refined.scalaxml | ||
|
||
import eu.timepit.refined.api.Refined | ||
import eu.timepit.refined.scalaxml.string.Xml | ||
|
||
object util { | ||
|
||
/** Creates a `scala.xml.Elem` from a validated string. */ | ||
def xml(s: String Refined Xml): scala.xml.Elem = | ||
scala.xml.XML.loadString(s.value) | ||
} |
19 changes: 19 additions & 0 deletions
19
modules/scalaxml/jvm/src/test/scala/eu/timepit/refined/scalaxml/XmlUtilSpecJvm.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package eu.timepit.refined.scalaxml | ||
|
||
import eu.timepit.refined.auto._ | ||
import eu.timepit.refined.scalaxml.util._ | ||
import org.scalacheck.Prop._ | ||
import org.scalacheck.Properties | ||
import shapeless.test.illTyped | ||
|
||
class XmlUtilSpecJvm extends Properties("scalaxml.util.string") { | ||
|
||
property("xml success") = secure { | ||
xml("<root></root>") == scala.xml.XML.loadString("<root></root>") | ||
} | ||
|
||
property("xml failure") = secure { | ||
illTyped("""xml("<root>")""", "Xml predicate failed.*") | ||
true | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
modules/scalaxml/jvm/src/test/scala/eu/timepit/refined/scalaxml/XmlValidateSpecJvm.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package eu.timepit.refined.scalaxml | ||
|
||
import eu.timepit.refined.TestUtils._ | ||
import eu.timepit.refined.scalaxml.string._ | ||
import org.scalacheck.Prop._ | ||
import org.scalacheck.Properties | ||
|
||
class XmlValidateSpecJvm extends Properties("XmlValidate") { | ||
property("Xml.isValid") = secure { | ||
isValid[Xml]("<root></root>") | ||
} | ||
|
||
property("Xml.showResult") = secure { | ||
showResult[Xml]("<root>") ?= | ||
"Xml predicate failed: XML document structures must start and end within the same entity." | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If scala-xml is available for Scala.js and Scala Native, shouldn't this use
%%%
?