1
0
forked from GitHub/gf-rgl
Files
gf-rgl/unittest
odanoburu 9ca6dc8cb2 * unittest.py: more forgiving parser
- accepts whitespace before comment starts
- accepts blank lines after last test case, or more than one of them
  between test cases
2020-06-03 22:19:19 -03:00
..
2019-08-22 11:35:51 +02:00

Python script for unit testing RGL grammars

Usage

python path/to/unittest.py [-h] [-v] [--no-pmcfg] path/to/testfile.gftest (...)

The script must be located in a sibling directory to the RGL src directory to work properly.

Test format

The test file should look something like this:

LangSwe: jag sover i huset
LangEng: I sleep in the house

LangSwe: huset verkar stort
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP ...

This contains two tests: Every test should be separated by empty lines. Every line starts with a language, followed by ":" and the sentence (or the abstract syntax tree if the abstract grammar is specified).

You can also see an example in the file unittest-example.gftest.

No PMCFG

If your grammar is complex and takes long time to compile, you can try the option --no-pmcfg, which tells GF to not build the parsing grammar.

Note however that in this case, every test case needs to contain a parse tree.