Skip to content

Add templates 6 - #1158

Merged
colinleach merged 3 commits into
exercism:mainfrom
colinleach:add-templates-6
Oct 24, 2026
Merged

colinleach merged 3 commits into
exercism:mainfrom
colinleach:add-templates-6

Conversation

@colinleach

Copy link
Copy Markdown
Contributor

Another 8 templates, plus some template macros.

I finally thought to ask for the comments to be written to a Markdown file with proper formatting. Better late than never?


Adds Jinja2 test templates for word-count, nucleotide-count, etl, resistor-color-trio, kindergarten-garden, food-chain, proverb and yacht

Each runtests.jl is regenerated from canonical data, and every exercise passes against its example solution. In line with the canonical-only decision, the hand-written tests that weren't in the canonical data have been removed.

Things to look at:

  • Shared macros (config/generator_macros.j2):
    • julia_string now also escapes newlines and tabs as \n and \t. word-count and kindergarten-garden need this.
    • New julia_dict(d, char_keys=false) macro. It writes a Dict(...) literal, quoting string keys, or writing them as Char literals ('A') when char_keys=true. Values reuse julia_string and julia_vector.
    • Every previously templated exercise still passes --check, so their generated files don't change.
  • Char keys: nucleotide-count and etl use Char keys and letters where the canonical data has strings, so their templates use char_keys=true. etl also turns the canonical string score keys into integers: transform(Dict(1 => ['A'])) == Dict('a' => 1).
  • resistor-color-trio: the canonical {value, unit} becomes the string the Julia label returns, e.g. "2 kiloohms".
  • proverb: the Julia recite returns a single string, so the canonical list of lines is joined with \n.
  • kindergarten-garden: its canonical groups are nested two levels deep ("partial garden" contains "multiple students for the same garden with three students"), so the template uses a recursive macro.
  • nucleotide-count: the canonical error case keeps the existing DomainError.
  • Removed non-canonical tests:
    • resistor-color-trio: five cases, including every decimal value such as "3.3 kiloohms". The canonical data only has whole numbers, so decimal formatting is no longer tested. Worth a look, because the example solution handles decimals.
    • word-count: the "no words" test, wordcount(" .\n,\t!^&*()~@#\$%{}[]:;'/<>") == Dict(), and the "Should've could've would've" check.
  • Unchanged: for food-chain, proverb, yacht, etl and nucleotide-count, the assertions are the same as before. Only the layout and testset names changed.

@github-actions

Copy link
Copy Markdown
Contributor

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.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

@colinleach
colinleach merged commit e566caf into exercism:main Oct 24, 2026
9 checks passed
@colinleach colinleach mentioned this pull request Oct 24, 2026
82 tasks done
@colinleach
colinleach deleted the add-templates-6 branch October 25, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants