Repository navigation
fmt: make the tests read back what fmt wrote - #216
Merged
Merged
Conversation
Contributor
|
Conflicts. |
Every test in this file compared an empty list against its expected output, and the failure named a file argument rather than the thing that was wrong: fmt: failed to open file "Now is the time for all good" fmt is handed a closure to write through, and setup() built one that appended to a `&[]string` pointing at a local in setup(). That local is gone by the time fmt runs, so nothing was ever appended. Measured on current V: closure appending to a captured `mut []string` reads back empty closure appending through a `&[]string` reads back empty, and crashes in array__push A pointer to a heap struct does share, so the sink is a `&Sink` with a `mut` field and the two closures capture that. The same trap in tail_test.v is vlang#207. fmt itself was never wrong here; it is handed the file, it reads it, and what came back was being thrown away. src/fmt is 1 of 1 and `v fmt -verify src/fmt` passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fmt: make the tests read back what fmt wrote
Every test in this file compared an empty list against its expected output, and the
failure named a file argument rather than the thing that was wrong:
fmt is handed a closure to write through, and setup() built one that appended to a
&[]stringpointing at a local in setup(). That local is gone by the time fmt runs,so nothing was ever appended. Measured on current V:
A pointer to a heap struct does share, so the sink is a
&Sinkwith amutfieldand the two closures capture that. The same trap in tail_test.v is #207.
fmt itself was never wrong here; it is handed the file, it reads it, and what came
back was being thrown away.
Tests
src/fmt is 1 of 1 and
v fmt -verify src/fmtpasses.