With cabal (as CI does):
cabal build
cabal testIn the TokTok monorepo, with Bazel:
bazel build //hs-happy-arbitrary/...
bazel test //hs-happy-arbitrary/...To run some of the tests, pass hspec's --match, for example
--test_arg=--match=Mini with Bazel or --test-options=--match=Mini with
cabal.
test/Language/: tests for each module.test/Examples/Mini/: a small language with its own Happy parser and Alex lexer.Examples.MiniSpecchecks that every generated program is one its parser accepts.test/examples/Cimple/: a copy of Cimple's lexer and grammar, a real language with many start codes. Keep it in sync with hs-cimple.
tools/generate.hs (Bazel only) prints random programs and which rules they
used:
bazel run //hs-happy-arbitrary/tools:generate -- \
--alex Lexer.x --happy Parser.y --start TranslationUnit --size 50 --iterations 10Without --happy, it prints sample text for each token class of the lexer.
It joins tokens with spaces without asking a lexer, so a program can lex
differently from the tokens it was made of.