From 1148b99b003ceda1599dd83311adeae772f6010d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Tue, 3 Oct 2023 19:10:54 -0700 Subject: [PATCH] Update contributing section (#154) --- README.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d116e85..eaf0123 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,52 @@ This command will iterate over all exercises and check to see if their exemplar/ Please see [Exercism's contributing guide](https://exercism.org/docs/building). At the moment, there's not a generator for Pyret exercises. -Make sure `use context essentials2020` is the first line in all Pyret files to explicitly set the default namespace. + +Here's the basic template for an `exercise-slug-test`.arr. +Each `check` block corresponds to a single test case, and the string label is reported to the student. +Each `check` block is wrapped inside a no-parameter function which is then stored inside the `run` field of a `test` value of the `TestRun` datatype. +This `test` value also contains an `active` field which indicates whether a test should be run (`true`) or not (`false`). +All `test` values go inside a list that Pyret iterates over at runtime, executing the functions within each `test` value marked as active. + +A contributor is responsible for copying this template, adding the appropriate functions and `check` blocks, and populating the list at the bottom. + +```pyret + +use context essentials2020 + +include file("exercise-slug.arr") + +#| + When working offline, all tests except the first one are skipped by default. + Once you get the first test running, unskip the next one until all tests pass locally. + Check the block comment below for further details. +|# + +fun foo-returns-1(): + check "foo returns 1": + foo() is 1 + end +end + +fun bar-returns-2(): + check "bar returns 2": + bar() is 2 + end +end + +#| + Code to run each test. Each line corresponds to a test above and whether it should be run. + To mark a test to be run, replace `false` with `true` on that same line after the comma. + test(test-a, true) will be run. test(test-a, false) will be skipped. +|# + +data TestRun: test(run, active) end + +[list: + test(foo true), + test(bar, false), +].each(lam(t): when t.active: t.run() end end) +``` ## Track linting