From 259d87178624afccab56f5221fb4a4f0cd0239aa Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Wed, 12 Feb 2020 01:06:31 +0100 Subject: [PATCH] Improve syntax error reporting in tests --- src/test/scala/millfork/test/emu/ShouldNotCompile.scala | 6 +++++- src/test/scala/millfork/test/emu/ShouldNotParse.scala | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/test/scala/millfork/test/emu/ShouldNotCompile.scala b/src/test/scala/millfork/test/emu/ShouldNotCompile.scala index 5f140c6e..53040acd 100644 --- a/src/test/scala/millfork/test/emu/ShouldNotCompile.scala +++ b/src/test/scala/millfork/test/emu/ShouldNotCompile.scala @@ -117,7 +117,11 @@ object ShouldNotCompile extends Matchers { case f: Failure[_, _] => println(f.extra.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") } } diff --git a/src/test/scala/millfork/test/emu/ShouldNotParse.scala b/src/test/scala/millfork/test/emu/ShouldNotParse.scala index 9fb3ca18..d72156e4 100644 --- a/src/test/scala/millfork/test/emu/ShouldNotParse.scala +++ b/src/test/scala/millfork/test/emu/ShouldNotParse.scala @@ -43,7 +43,11 @@ object ShouldNotParse extends Matchers { case f: Failure[_, _] => println(f.extra.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)) + } } } }