Skip to content

Add templates 11 - #1165

Merged
colinleach merged 7 commits into
exercism:mainfrom
colinleach:add-templates-11
Oct 25, 2026
Merged

colinleach merged 7 commits into
exercism:mainfrom
colinleach:add-templates-11

Conversation

@colinleach

Copy link
Copy Markdown
Contributor

Four templates, plus a rather important fix to an example solution. It's been buggy since being added 2 years ago, and the tests never caught it till now.

I'll mark this draft. Once #1163 is merged, we can simplify the template for clock.

I'm knocking off for the day, and I expect/hope you already have.


Adds Jinja2 test templates for isbn-verifier, queen-attack, clock and grade-school

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. No shared macros changed in this PR. 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:

  • queen-attack: bug fix in .meta/example.jl.
    • The constructor checked row < 0 twice and never checked col < 0, so Queen(2, -2) didn't throw.
    • The old tests didn't catch this because they had no negative-position cases. The canonical data has two (Queen(-2, 2) and Queen(2, -2)), and tests.toml doesn't exclude them, so both are now generated.
  • queen-attack: other changes.
    • The valid-position case is now @test Queen(2, 2) isa Queen. The old Queen(2, 2) == Queen(2, 2) couldn't fail.
    • Errors are still @test_throws InvalidPosition, and canAttack becomes @test canattack(...) / @test !canattack(...), as before.
  • clock:
    • The template writes its own header with using Dates, the same way knapsack's template does. It doesn't use header(), so this PR doesn't depend on the imports argument added in Add templates 10 #1163. Once Add templates 10 #1163 is merged, clock could switch to macros.header(imports=["Dates"]).
    • Each canonical create case checks both Clock(h, m) == Clock(...) and sprint(show, Clock(h, m)) == "\"hh:mm\"". This merges the old separate "displaying clocks" testset into the canonical cases. The file has exactly the same 72 assertions as before. Only the testset names and nesting changed.
    • The canonical "hh:mm" results of add / subtract are written as Clock values, e.g. Clock(10, 0) + Dates.Minute(3) == Clock(10, 3), as before.
  • isbn-verifier:
    • Valid cases are @test_nothrow ISBN("..."), and invalid cases are @test_throws DomainError ISBN("..."), as before. Each canonical case now has its own named testset; before, the valid and invalid inputs were each grouped into one testset with comments.
    • The @test_nothrow helper macro is still defined in the test file. Its comment no longer mentions the equality test, which has been removed.
    • Removed:
      • The non-canonical ISBN("3-598-21508-8") == ISBN("3598215088") != ISBN("3-598-21507-X").
      • "3-598-21507-XX" and "3-598-2K507-0", which are no longer in the canonical data. problem-specifications #1217 replaced the second one.
  • grade-school:
    • The generated file keeps the Student = NamedTuple{(:name, :grade),Tuple{String,Int}} alias after the include, and students are written as Student(("Aimee", 2)).
    • 23 assertions became 20:
      • Three hand-written tests (four assertions) removed, because tests.toml excludes their canonical cases: "A student can't be in two different grades", "A student can only be added to the same grade in the roster once" and "A student cannot be added to more than one grade in the sorted roster".
      • One canonical case added that the old file didn't have: "Adding students in multiple grades".

@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 25, 2026

Copy link
Copy Markdown
Contributor

I expect/hope you already have

Pretty much! I'll have a closer look at this tomorrow

@colinleach
colinleach marked this pull request as ready for review October 25, 2026 01:18
@colinleach
colinleach requested a review from depial October 25, 2026 01:23

@depial depial left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lg2m!

@colinleach
colinleach merged commit 78503a7 into exercism:main Oct 25, 2026
9 checks passed
@colinleach
colinleach deleted the add-templates-11 branch October 25, 2026 22:21
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