Exercism exercises in V.
Important
We are not accepting community contributions at this time.
We love our community, and we're grateful you are interested in improving the V track. But our maintainers are not accepting community issues or pull requests at this time. If you would like to suggest a change or discuss an issue, please open a thread in the V section of the Exercism forum.
This community blog post contains more details.
To test the exercises, run ./bin/test.
This command will iterate over all exercises and check to see if their example implementation passes all the tests.
configlet is an Exercism-wide tool for working with tracks. You can download it by running:
$ ./bin/fetch-configletRun its lint command to verify if all exercises have all the necessary files and if config files are correct:
$ ./bin/configlet lint
The lint command is under development.
Please re-run this command regularly to see if your track passes the latest linting rules.
Basic linting finished successfully:
- config.json exists and is valid JSON
- config.json has these valid fields:
language, slug, active, blurb, version, status, online_editor, key_features, tags
- Every concept has the required .md files
- Every concept has a valid links.json file
- Every concept has a valid .meta/config.json file
- Every concept exercise has the required .md files
- Every concept exercise has a valid .meta/config.json file
- Every practice exercise has the required .md files
- Every practice exercise has a valid .meta/config.json file
- Required track docs are present
- Required shared exercise docs are presentCommunity contributions are currently paused (see above). The information below is for the track maintainers.
See INSTALLATION.md
Before committing, please run bin/reformat to ensure every V file is formatted properly.
It runs v fmt -w [FILE_NAME] using the same version of V as the test runner.
More info on V formatting can be found in the docs
Please raise problems and suggestions in the V section of the Exercism forum rather than opening issues here. To make the process as smooth as possible, please include as much information as possible about the issue.
- Please use conventional commits
- If your PR is related to or fixes an open issue, please reference the issue number in the PR title. Here's an example.
A good place to start in the docs is to understand how the Hello World exercise is created. Make sure you've fetched configlet!
There are two ways to implement a practice exercise. You can follow all the 14 steps listed below from start to finish, or you can run ./bin/bootstrap_practice_exercise.sh [SLUG] to create all the files and folders you'll need. This will allow you to skip a few steps and jump right into writing your example solution, but you'll need bash and jq to run the script.
- Pick an exercise from the problem-specifications repo.
- Create a new entry for the exercise in config.json. Include
- a new UUID for the exercise (generated with
bin/configlet uuid) - the slug of the exercise (should be the same as in problem-specifications)
- the name of the exercise (should be the same as in problem-specifications)
- any concepts it practices and prereqs it has (safe to leave blank usually!)
- your best estimate of how difficult the task is
- Create the directory for the exercise and download shared files using these two commands:
bin/configlet sync --update --yes --docs --metadata --exercise [SLUG]bin/configlet sync --update --tests include --exercise [SLUG]
- Create 3 files in the new directory (located at
exercises/practice/[SLUG]):
[SLUG].v.meta/example.v.meta/test_generator.py
- Write an example implementation in
[SLUG].v - Write a test generator in
.meta/test_generator.py. It will receive the canonical data in problem-specifications. Here's an example of canonical data. - Generate
run_test.vby runninggenerators/generate.py [SLUG] - Run the test suite with
v -stats test run_test.v - Once all tests pass, make sure code is formatted properly by running
bin/reformat, orv fmt -w [V_FILE]on all the v files (example and test files) - Copypaste everything in
[SLUG].vinto.meta/example.v - Remove everything from
[SLUG].vexcept the stub of the needed function, themodule mainat the top, and make a stub of a struct or two. - Add needed info to the
...[SLUG]/.meta/config.jsonfile:
- Author's GitHub username
- solution file name (should be
[SLUG].v) - test file name (should be
run_test.v) - example solution file name (should be
.meta/example.v)
- Commit changes with conventional commits
- Make your PR and do a little happy dance
(putting these here for now until someone tells me a better place or I find a better place)
See solution #3 in this excellent repo
example.v
run_test.v
"All test functions have to be inside a test file whose name ends in _test.v."
