1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-23 23:30:22 +00:00

Improve syntax error reporting in tests

This commit is contained in:
Karol Stasiak 2020-02-12 01:06:31 +01:00
parent 5380eb39c7
commit 259d871786
2 changed files with 10 additions and 2 deletions

View File

@ -117,7 +117,11 @@ object ShouldNotCompile extends Matchers {
case f: Failure[_, _] => case f: Failure[_, _] =>
println(f.extra.toString) println(f.extra.toString)
println(f.lastParser.toString) println(f.lastParser.toString)
log.error("Syntax error: " + parserF.lastLabel, Some(parserF.lastPosition)) if (parserF.lastLabel != "") {
options.log.error(s"Syntax error: ${parserF.lastLabel} expected", Some(parserF.lastPosition))
} else {
options.log.error("Syntax error", Some(parserF.lastPosition))
}
fail("syntax error") fail("syntax error")
} }
} }

View File

@ -43,7 +43,11 @@ object ShouldNotParse extends Matchers {
case f: Failure[_, _] => case f: Failure[_, _] =>
println(f.extra.toString) println(f.extra.toString)
log.warn("Last parser: " + f.lastParser, Some(parserF.indexToPosition(f.index, f.lastParser.toString))) log.warn("Last parser: " + f.lastParser, Some(parserF.indexToPosition(f.index, f.lastParser.toString)))
log.warn("Expected syntax error: " + parserF.lastLabel, Some(parserF.lastPosition)) if (parserF.lastLabel != "") {
log.warn(s"Expected syntax error: ${parserF.lastLabel} expected", Some(parserF.lastPosition))
} else {
log.warn("Expected syntax error", Some(parserF.lastPosition))
}
} }
} }
} }