Skip to content

Commit

Permalink
Refactor Artem Stasiuk's OOE parser tests
Browse files Browse the repository at this point in the history
Shorten test names and minimize string literals.
  • Loading branch information
ashawley committed Apr 16, 2018
1 parent 9cee0d6 commit 4b6dcf5
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions jvm/src/test/scala/scala/xml/XMLTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -639,48 +639,47 @@ class XMLTestJVM {
assertEquals("<node>\n <leaf/>\n</node>", pp.format(x))
}

@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXToken {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
def xTokenFailure {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("a"), false)

x.xToken('b')
assertEquals(Seq.empty[Char], x.xToken('b'))
}

@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXCharData {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
def xCharDataFailure {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString(""), false)

x.xCharData
}

@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXComment {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
def xCommentFailure {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString(""), false)

x.xComment
}

@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXmlProcInstr {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
def xmlProcInstrFailure {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("aa"), false)

x.xmlProcInstr()
x.xmlProcInstr
}

@Ignore("Ignored for future fix, currently throw OOE because of infinity MarkupParserCommon:66")
@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXAttributeValue {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
def xAttributeValueFailure {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString(""), false)

x.xAttributeValue()
x.xAttributeValue
}

@Ignore("Ignored for future fix, currently return unexpected result")
@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXEntityValue {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
def xEntityValueFailure {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString(""), false)

assertEquals("a/>", x.xEntityValue())
x.xEntityValue
}

}

0 comments on commit 4b6dcf5

Please sign in to comment.