shnewto / bnf

Parse BNF grammar definitions
MIT License
256 stars 22 forks source link

fix arbitrary grammar test seed #123

Closed CrockAgile closed 1 year ago

CrockAgile commented 1 year ago

While I was fiddling with some other exploratory improvements, it came up that the generated grammar test was using the same seed for every case. The intention seems to be that the test generates truly arbitrary grammars, so this PR uses the property testing generator to seed the grammar.

TLDR: this property test was using the same grammar for every run. now it doesn't

// before
Ok(" <F>::= ''  <E> <E>\n")
Ok(" <F>::= ''  <E> <E>\n")
Ok(" <F>::= ''  <E> <E>\n")
Ok(" <F>::= ''  <E> <E>\n")
test test_generated_grammars ... ok

// after
Ok("<NJW> ::=<G> '' <toKJ>     <X> \n")
Ok("<d6> ::= \"''u\" '1|3' \n<G>::=<Mq>  \"\" <a5>   'E' \n <w> ::= <t> |  \"\" \n")
Ok(" <J>::= <t> |   <t>|  <Lu>    |  <t>\"0t\"|<V-A2l><c5><F>'\"' <e>|\"\" \n")
Ok("  <d60> ::=  <d>\n <sw--T>::=<Qu><D> '6d'    |  '='\n<L> ::=  <g> <Q>\"\"'3' \"\"  '\"'\n")
test test_generated_grammars ... ok
coveralls commented 1 year ago

Coverage Status

Coverage: 91.063%. Remained the same when pulling 587879e7ace6b281e7144e7e56f295cbd8141ffd on grammar-seed-bug into 07eb3bff8ad6887f127946907ff5e6515cad1e9c on main.