shnewto / bnf

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

Feat/property tests from generate #27

Closed shnewto closed 6 years ago

shnewto commented 6 years ago

Revised generate test.

Prior to this commit the generate tests only generated one random grammar to parse per run. This commit revises the approach and instead uses the generate function as an arbitrary property to test the the Grammar::from_str functionality with.

Additions relevant to the reopening of this PR:

First, a new error kind was introduced to indicate that the generation error isn't generic but the result of the limits of recursion being reached. This allows the property tests for the Grammar type to disregard problematic sentence generation, it is testing that what it gets is parsable.

In order to manage meeting recursion limits being met in the property tests, a new use case was accounted for, one that I belive implementaion for is useful. Logic was added to allow the "from_str" trait for bnf types to be parallel to Type::new() in all cases except the Term type. Because the Term type does not have a sensical way to implement new(), "from_str" for Term types corresponds to a Terminal rule for the empty string which is allowed in parsable gramamrs.

As this commit represents that addition of a new error kind it seemed that there is enough variety now to make our Error type public in order for users can match on them.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.05%) to 93.758% when pulling d58dec230b81794b952060a36db2d7af31d859fb on feat/property-tests-from-generate into 69d84d656420db480268350c803ee798bc85ee5b on master.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.09%) to 93.625% when pulling fc7c34b58acdd0b0c9b3613cc60f3f28948e2f23 on feat/property-tests-from-generate into 69d84d656420db480268350c803ee798bc85ee5b on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.05%) to 93.766% when pulling ca08e5d59a765b5df77bc69ca2c76da6123aa935 on feat/property-tests-from-generate into 69d84d656420db480268350c803ee798bc85ee5b on master.

shnewto commented 6 years ago

Some revision needs to happen to allow Grammar::generate to expose the functionality required for reproducible tests.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.1%) to 93.82% when pulling e180c01fe7cd52b14872018a1986dedc63f046d7 on feat/property-tests-from-generate into 69d84d656420db480268350c803ee798bc85ee5b on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.1%) to 93.82% when pulling e180c01fe7cd52b14872018a1986dedc63f046d7 on feat/property-tests-from-generate into 69d84d656420db480268350c803ee798bc85ee5b on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.1%) to 93.82% when pulling e180c01fe7cd52b14872018a1986dedc63f046d7 on feat/property-tests-from-generate into 69d84d656420db480268350c803ee798bc85ee5b on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.2%) to 93.865% when pulling 762db35e660fdc47175b8b6627b14e7e1d3ab1d0 on feat/property-tests-from-generate into 69d84d656420db480268350c803ee798bc85ee5b on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.2%) to 93.865% when pulling 524a3344f18e71f432a695d2e436e59f40acd0cd on feat/property-tests-from-generate into 69d84d656420db480268350c803ee798bc85ee5b on master.

CrockAgile commented 6 years ago

Is your rustfmt still working? Or are we somehow on major different versions? Because when I pulled this down to play with it, my editor made a lot of auto changes. I'm on 0.9.0-nightly rustfmt

shnewto commented 6 years ago

ha no the VS code started crashing my computer so I disabled it. That's a bummer about formatting, I can manually run rustfmt on it all tho

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.1%) to 93.58% when pulling cdb20f065c8416acdc603fb73ec4af537a904503 on feat/property-tests-from-generate into 69d84d656420db480268350c803ee798bc85ee5b on master.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.2%) to 93.525% when pulling 0199933e8c1b304f376c892930831bc79397df6a on feat/property-tests-from-generate into 69d84d656420db480268350c803ee798bc85ee5b on master.

shnewto commented 6 years ago

I'd like to revise the grammar property tests to handle the excessive recursion potential as well as factor out the logic to potentially grow the stack to account for that heavy recursion.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.7%) to 92.993% when pulling 75d68fc131ea51c238cd71f68877dffae319ee03 on feat/property-tests-from-generate into 98dc357b3384a8fd87bbffcefaf40042df439b4c on master.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.7%) to 92.993% when pulling 75d68fc131ea51c238cd71f68877dffae319ee03 on feat/property-tests-from-generate into 98dc357b3384a8fd87bbffcefaf40042df439b4c on master.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.2%) to 93.473% when pulling b19a530482e7d6d6803ab78f9590a2e827dc37ef on feat/property-tests-from-generate into 98dc357b3384a8fd87bbffcefaf40042df439b4c on master.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-1.5%) to 92.177% when pulling 9ec5a8da6092395c4671be052be47d9c61dc612c on feat/property-tests-from-generate into 98dc357b3384a8fd87bbffcefaf40042df439b4c on master.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-1.5%) to 92.177% when pulling 608f6669cab06c65d1cb2e8120c5509c1d3fee09 on feat/property-tests-from-generate into 98dc357b3384a8fd87bbffcefaf40042df439b4c on master.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-1.5%) to 92.177% when pulling 89b23c9292480e1c7a66e0becc10eab086532dd0 on feat/property-tests-from-generate into 98dc357b3384a8fd87bbffcefaf40042df439b4c on master.