From b35bbf7b04719d48788b165dfb409fce59ba0f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Tue, 3 Oct 2023 04:00:33 +0200 Subject: [PATCH] Add parity test for scanner --- .../playground/smithyql/parser/ParserSuite.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/parser/src/test/scala/playground/smithyql/parser/ParserSuite.scala b/modules/parser/src/test/scala/playground/smithyql/parser/ParserSuite.scala index f0faa515..aa1aebf0 100644 --- a/modules/parser/src/test/scala/playground/smithyql/parser/ParserSuite.scala +++ b/modules/parser/src/test/scala/playground/smithyql/parser/ParserSuite.scala @@ -10,6 +10,8 @@ import io.circe.Decoder import io.circe.syntax._ import playground.Assertions._ import playground.smithyql._ +import playground.smithyql.parser.v2.scanner.Scanner +import playground.smithyql.parser.v2.scanner.TokenKind import weaver._ import java.nio.file @@ -52,6 +54,17 @@ trait ParserSuite extends SimpleIOSuite { } } } + + test(testCase.name + " (v2 scanner)") { + testCase.readInput(trimWhitespace).map { input => + val scanned = Scanner.scan(input) + + val errors = scanned.filter(_.kind == TokenKind.Error) + // non-empty inputs should parse to non-empty outputs + assert(input.isEmpty || scanned.nonEmpty) && + assert(errors.isEmpty) + } + } } def loadNegativeParserTests[Alg[_[_]]: SourceParser](