Skip to content

Add templates 7 - #1160

Merged
colinleach merged 1 commit into
exercism:mainfrom
colinleach:add-templates-7
Oct 25, 2026
Merged

colinleach merged 1 commit into
exercism:mainfrom
colinleach:add-templates-7

Conversation

@colinleach

@colinleach colinleach commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

The main issue here is perfect-numbers, where the Julia implementation is far away from the problem specifications: three boolean functions, instead of one returning a string. I wonder whether we should just rewrite this from scratch? There are 543 completions. Alternatively, forget the template and keep it idiosyncratic.


Adds Jinja2 test templates for wordy, all-your-base, change, protein-translation, phone-number, perfect-numbers, allergies, pythagorean-triplet and space-age

Each runtests.jl is regenerated from canonical data, and every exercise passes against its example solution. Every templated exercise still passes generate_tests.py --check. In line with the canonical-only decision, the hand-written tests that weren't in the canonical data have been removed. No shared macros changed in this PR.

Things to look at:

  • Exception types for canonical error cases. These match both the old tests and what the example solutions throw:
    • ArgumentError: wordy, phone-number
    • DomainError: all-your-base, change, protein-translation, perfect-numbers
  • perfect-numbers: the canonical classify(n) becomes the matching Julia predicate, e.g. classify(12) == "abundant" becomes @test isabundant(12). Each canonical error case checks that all three predicates (isperfect, isabundant, isdeficient) throw DomainError, as the old tests did. That's three assertions for one canonical case.
  • all-your-base: empty digit lists are written as Int[], not [], so that solutions with typed signatures such as digits::Vector{Int} accept them. A bare [] is a Vector{Any}.
  • allergies: list cases compare against a Set, e.g. allergy_list(3) == Set(["eggs", "peanuts"]), because the Julia API returns a Set.
  • pythagorean-triplet: the canonical nested lists are written as a vector of tuples, e.g. [(3, 4, 5)], to match the Julia return type.
  • space-age: the canonical planet becomes the function name (onEarth, onMars, ...), compared with isapprox(...; rtol = 0.01). The canonical "invalid planet" case stays excluded in tests.toml, because the Julia API has no function to call for it. The Earth expected value changes from 31.60 to the canonical 31.69.
  • Removed non-canonical tests:
    • phone-number: the loop-built tests are now one named testset per canonical case (3 assertions became 18). Removed inputs: " 1 223 456 7890 " and "1223456789", which aren't canonical, and "123-@:!-7890", which tests.toml excludes in favour of the newer "523-@:!-7890" case.
    • perfect-numbers: six negative checks such as !isperfect(12) and !isdeficient(28).
    • allergies: allergic_to(257, "eggs"). The canonical allergy_list(257) == Set(["eggs"]) is now included; the old file didn't have it.
    • protein-translation: proteins("AAA"). tests.toml excludes this canonical case (1e75ea2a), but the old hand-written file tested it anyway. AAA is a real codon (lysine) that the exercise doesn't support, so the exclusion looks deliberate. Worth confirming.
  • Unchanged: wordy, change and pythagorean-triplet have the same assertions as before. Only the testset names and layout 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 mentioned this pull request Oct 24, 2026
82 tasks done
@depial

depial commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

I'm open to whatever on perfect-numbers. I think fixing that was my first contribution here.

Personally, I would prefer the three logical functions over a returned string, but that's probably just my mathiness. I don't really care either way, so I'll leave that up to you.

@colinleach
colinleach marked this pull request as ready for review October 24, 2026 22:03
@colinleach

Copy link
Copy Markdown
Contributor Author

Let's keep it as in this PR, with 3 boolean functions but using a translation of the canonical tests.

I thought about adding a comment to the stub, or even an instructions append, but the canonical instructions are vague enough to accommodate various track-specific implementations. The tests are pretty clear and readable.

@colinleach
colinleach requested a review from depial October 24, 2026 22:07
@colinleach
colinleach merged commit 85e7e43 into exercism:main Oct 25, 2026
8 checks passed
colinleach added a commit that referenced this pull request Oct 25, 2026
* Add templates 11

* Add templates 7 (#1160)

* Fix the bin/missing-templates script (#1164)

* Add templates 10 (#1163)

* Add templates 11

* Clock updated template macro
@colinleach
colinleach deleted the add-templates-7 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