Repository navigation
Conversation
- allergies: replace sorted_with_compare() in run_test.v. V 0.5.2 emits calls to the builtin compare(int*, int*) when a custom compare function is used with a non-int element type, which fails in the C backend. Sorting a mapped []int instead avoids the broken codegen. - intergalactic-transmission: u8 shift results are now widened to int, so cast the packed byte back to u8 before handing it to add_parity(). - zebra-puzzle: the 'in' operator on an array of structs generates a comparison between int and the struct in C. Use an explicit any() predicate comparing the fields that identify a constraint.
\� fmt\ in V 0.5.2 aligns the values of consecutive struct fields and drops leading blank lines inside empty function bodies. Running it over every exercise file keeps the track consistent with the formatter that CI and contributors get from a current V install.
Both exercises follow the track conventions: a snake_case stub in the exercise root, an example solution in .meta, and a run_test.v suite built from the canonical data in problem-specifications.
|
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
For NowThis is a very large PR. Let's work on the first commit in a new PR, and then we can discuss creating subsequent PRs after that PR is merged. We run exercise tests in a test runner. bin/verify-exercises-in-dockerYour fixes in For LaterI checked if your proposed exercise additions also work with our current test runner The follow did not.
The second work item might be to update the test runner to a more recent V release. |
|
Splitting this up as suggested. The first commit is now on its own: #308. It is verified on both ends of the supported range — For the 15 new exercises: I reproduced the six failures and they are all source-level incompatibilities with the V 0.4.8 that the test runner pins, not test-runner limitations:
Each has a small, behaviour-preserving equivalent that compiles on 0.4.8 and 0.5.2 alike, so the track can stay on the current test runner. I will send the exercises as separate PRs — the nine that already pass first, then the six adjusted ones — starting after #308 is merged. This PR stays open for the reformat and the exercises. |
|
First exercise PR, split out as one self-contained commit: #309 ( Built from Next, in difficulty order: |
It might be merged soon. The next step is 'discuss creating subsequent PRs'
Please be patient. |
|
The remaining eight exercises that already work with the current test runner are now up as one PR each, each a single self-contained commit:
Each was verified with What is left in this PR is the |
|
The six exercises that did not build with the V 0.4.8 of the current test runner are up as one PR each. Every one of them is a small, behaviour-preserving adjustment, so the track does not need a V upgrade in the test runner:
The causes, in short:
All six are verified with One thing worth a decision: That leaves the |
|
The last piece is up on its own: #324, the That completes all 16 PRs from this branch: #308 (three fixes), #309 to #317 (nine exercises), #318 to #323 (six exercises), #324 (reformat). One unrelated thing turned up while verifying #324, and it is not caused by any of these PRs -- it is on V reports a test named It affects any exercise with a
That is 160 tests where a student gets no per-test feedback from the test runner. I can open an issue and a fix for it separately, since renaming the test functions would change the test outcome of those exercises and so should not ride along with any of the PRs above. |
|
Two things came out of verifying #324, both unrelated to the exercise PRs here. First, a bug that is already on It is a bug in the test runner rather than in the track, so I filed it and fixed it there:
With that fix mounted over the current image, all 12 exercises report every test, Second, the |
|
I'm done. Now I wait. |
@metif12 Thanks for your contributions. Please be aware that while it's very fast to generate code with LLMs, we still have to manually read, review and assess it all before it can be merged. And that process takes time. |
v vet emits a notice for plain.len > 0 on both the stub and the example. Behaviour is identical.
Adds the save-the-cow practice exercise (difficulty 2), split out of exercism#307. The example keeps the game in a `mut` struct with a `State` enum and rejects a guess that comes after the game is over. `played` in run_test.v takes the guessed letters as a string and turns them into bytes itself, instead of taking an array of char literals. V 0.4.8 -- the version the current test runner image pins -- infers `[]rune` for an array literal of char literals and then refuses to pass it where `[]u8` is expected, while V 0.5.2 infers `[]u8` and accepts it. Passing the letters as a string and calling `.bytes()` reads the same on every V version, and the test cases are easier to read for it. Registers the exercise in config.json. Verified with bin/verify-exercises-in-docker (the current test runner image) and with V 0.5.2 for bin/test. configlet lint passes, and v fmt -l / v vet are clean on the new files.
What
Three independent groups of commits, so each can be reviewed and merged on its
own:
against a current V.
v fmt -wover every exercise file.Verified with V 0.5.2
c111a52(vlang/v master) on Windows.bin/testis green on all 129 exercises,configlet lintpasses, andv fmt -lis clean on every touched file.v vetreports no new diagnostics:the pre-existing exercises this touches already emitted the same doc warnings
on
main.The track goes from 114 to 129 practice exercises.
1. Fixes for V 0.5.2
allergiessorted_with_compare()on a[]Allergenmakes V emit calls to the builtincompare(int*, int*); the C backend rejects the pointer types.run_test.vsorts a mapped[]intinstead, so no customcompareis needed.intergalactic-transmissionu8 << intis now widened toint, soadd_parity(current)received anintwhere au8is required.u8(...).zebra-puzzleconstraint !in queue.array()— theinoperator on an array of structs generates anintvs struct comparison in C..any()predicate over the fields that identify a constraint.2. Formatting
v fmt -woutput for 30 files. Most of it is whitespace — the 0.5.2 formatteraligns the values of consecutive struct fields and drops leading blank lines in
empty bodies — but it is not whitespace-only, and
git diff -w 49d40df~1 49d40dfshows 7 files with changes beyond whitespace:
grains,hello-world,pangram,space-age.meta/example.v"…"to'…'leap.meta/example.vifexpression used as a valuekindergarten-garden.meta/example.vintergalactic-transmissionstubAll four kinds are behaviour-preserving, but flagging them here so the commit is
not dropped on the assumption that it is pure whitespace.
Kept as its own commit so it can be dropped independently.
grade-school.vandrobot-name.vare deliberately skipped, because theformatter cannot be run over them safely:
grade-school.vfails to parse atall, and although
robot-name.vparses,v fmtrewrites its<TYPE>placeholders into garbage (
fn create_robot(mut robots <TYPE>)becomesfn create_robot(mut robots , TYPE, )). The.meta/example.vof both wasformatted normally, since it has no placeholders.
3. New exercises (15)
Stateenum +mutstruct; errors for guessing after the game endsf64; needs a collinearity tolerance because the canonical data rounds coordinatestype Tree = Empty | Branchsum type plus a path of stepsspawn+sync.Mutex; V's concurrency is a good fit hereNodestruct, error messages match the canonical stringsEvery suite has exactly one
fn test_*()per canonical case that is included(
tests.tomlminusinclude = false), which matches the convention usedelsewhere in the track.
dnd-characterskips 1 excluded case,sgf-parsingskips 1,
pokerskips 2.Points worth a reviewer's attention
baffling-birthdaysis inherently random. The canonical data is aprobability estimate, so the reference solution is a Monte Carlo simulation
and the tests average 25 runs against a 1.5 percentage-point tolerance
(~4.7σ, roughly 1e-6 failure odds per assertion; 30 consecutive green runs
observed). If you would rather not carry a probabilistic test in CI, this is
the one to drop from the PR.
markdownandtree-buildingare refactoring exercises, so their stubsare complete but deliberately poor implementations instead of empty bodies.
That follows the
problem-specificationsguidance ("the expectation is thatthe stub file has a poorly written but working implementation"), but this
track has no other exercise of that shape yet. Both stubs pass the suite
unchanged — note that
bin/testonly exercises.meta/example.v, so thestubs have to be tested separately.
prismneeds a collinearity tolerance of about 0.1. The canonicalcoordinates are rounded to one decimal and the angles to three, so the
intended beam is never exactly collinear. Both the stub and the example
document this.
PR:
types__resolve_type_name_for_method: RUNTIME ERROR: invalid memory access, roughly 1 run in 40, and it reproduces onmaintoo. When it hits,the assertions still all pass and only the exit code is non-zero. If
bin/testreports a failure on an exercise this PR did not touch, re-run itbefore investigating.
Reviewing
The three sections are separate commits.
git rebase -i upstream/mainlets youdrop or reorder any of them, and every exercise is a single self-contained
commit if you would prefer one PR per exercise.