From 81bb87f4cd545ec001817b1aaaef62eaf3b18df2 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 18 Jun 2018 15:56:47 -0400 Subject: [PATCH] test: Add a test to ensure the parser doesn't have any conflicts Our grammar shouldn't be ambiguous, and it makes sense to test this. --- test/test-vet.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test-vet.sh b/test/test-vet.sh index ed446aa6..0d963f91 100755 --- a/test/test-vet.sh +++ b/test/test-vet.sh @@ -29,9 +29,19 @@ function parser-indentation() { return 0 } +function parser-conflicts() { + # in the test, run goyacc, but don't leave any output files around + if goyacc -o /dev/null -v /dev/null "$1" | grep 'conflict'; then # grammar is ambiguous + return 1 + fi + + return 0 +} + # loop through individual *.y files for file in `find . -maxdepth 3 -type f -name '*.y' -not -path './old/*' -not -path './tmp/*'`; do run-test parser-indentation "$file" + run-test parser-conflicts "$file" done if [[ -n "$failures" ]]; then