Repository navigation
Conversation
Adds the react practice exercise (difficulty 6), split out of exercism#307. The example settles a reaction into a new stable state before it reports a change, and only calls a callback for the cells whose value actually moved. `new_callback` in run_test.v now hands out `recorder.record` as a method value instead of a closure that captures the recorder, and `Recorder` is marked `@[heap]` so that its method can be used as a value. A closure that calls a `mut` method on a captured variable is rejected by V 0.4.8 -- the version the current test runner image pins -- which asks for the captured variable to be declared `mut`, and that is not accepted by V 0.5.2. A method value is the same on every V version the track supports. 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.
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.
What
Adds the React practice exercise (difficulty 6), split out of #307.
react.v-- stub.meta/example.v-- example solutionrun_test.v-- 14 tests, built from the canonical data inproblem-specifications.meta/config.json,.meta/tests.toml,.docs/config.json-- registers the exerciseAdjustments for the test runner's V version
new_callbackinrun_test.vhands outrecorder.recordas a method valueinstead of a closure that captures the recorder, and
Recorderis marked@[heap]so its method can be used as a value. A closure that calls amutmethod on a captured variable is rejected by V 0.4.8, which wants the captured
variable declared
mut-- and that is not accepted by V 0.5.2. A method valueis the same on every V version.
One self-contained commit that touches nothing outside the exercise, so it can be merged on its own.
Verification
bin/verify-exercises-in-docker(the currentvlang-test-runnerimage, V 0.4.8): pass, 14/14 tests.vlang/setup-vinstalls forbin/testin CI: pass.configlet lintpasses;v fmt -landv vetare clean on the new files.For the merge commit
Not needed: a brand new exercise does not change the outcome of any existing exercise's tests.