Re-write test generator with templates and unit tests #663
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I decided to re-write the test generator based on template files instead of
nikic/php-parser
. It had too many limitations. And I didn't want to dig into another huge PHP generation library. Producing the code is not the main problem here.While learning about the data structure behind the canonical data, I understood that the basic problem is not writing the PHP code but interpreting the data. Based on that idea, showing everything unknown to the user of the generator is key to informed usage.
So I developed a tree of data structures for the known data using TDD. Rendering these structures using templates simplified the process of dumping the code to the file. I documented all that in
contribution/documentation/generator
.It now works for all remaining practice exercises, but does not produce the students file, yet.
What do you think about this approach, @homersimpsons @tomasnorre ?