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 wanted a way to quickly add example gomacro files as test cases.
This change adds TestWriteDeclsAndStmts that essentially constructs a new fast interpreter, calls EvalFile and then WriteDeclsToFile. The testdata directory is searched for test cases; every test case must have a .gomacro file, a .go file and optionally a .err file. The .gomacro file will be passed to EvalFile and its resulting error will be compared against contents of any .err file. Then the contents of the .go file will be compared to the output of WriteDeclsToStream. To create a test just add the .gomacro file and then go test can be called with the UPDATE_SNAPSHOTS envvar set, e.g.
UPDATE_SNAPSHOTS=on go test ./cmd -run=TestWriteDeclsAndStmts
This will call EvalFile and WriteDeclsToFile and generate the .go and .err files. Note the tests will fail because we are generating, not testing against the fixture.
The first test added is failing and demonstrates issue #84, so that issue should be resolved before merging.