Skip to content

Add templates 8 - #1161

Merged
colinleach merged 2 commits into
exercism:mainfrom
colinleach:add-templates-8
Oct 24, 2026
Merged

colinleach merged 2 commits into
exercism:mainfrom
colinleach:add-templates-8

Conversation

@colinleach

Copy link
Copy Markdown
Contributor

Five template and another macro. Some tweaks to how matrices and empty values are handled, but I don't think these should break many solutions.


Adds Jinja2 test templates for flower-field, game-of-life, spiral-matrix, saddle-points and matrix

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, so the existing generated files don't change. Each exercise has the same number of assertions and covers the same cases as before, so no tests were removed.

Things to look at:

  • New julia_matrix macro (config/generator_macros.j2). It turns the canonical list of rows into a real Julia Matrix:
    • [[1, 2], [4, 3]] becomes [1 2; 4 3]. A single row such as [2 5 3 5] is already a 1×n matrix.
    • A single column, including 1×1, becomes reshape([2, 1, 4, 1], :, 1). A plain [1] would be a Vector, and a Vector is never == to a Matrix.
    • An empty matrix ([] or [[]] in the canonical data) becomes Matrix{Int}(undef, 0, 0).
  • game-of-life: the empty case was reshape([], 0, 2) and is now the canonical 0×0 Matrix{Int}.
  • saddle-points:
    • The test is now sort(saddlepoints(M)) == [...], with the expected points sorted by the template. Saddle points have no natural order, and the canonical data lists (1, 3) before (1, 1) in one case, while the example returns them in column-major order. Solutions can return the points in any order.
    • The empty case used Int[], a Vector, and is now a 0×0 matrix.
    • The expected values were typed NTuple{2,Int}[...] literals and are now plain tuple vectors, because == doesn't compare element types.
  • flower-field: the empty input is String[] instead of [], so solutions with a typed signature such as garden::Vector{String} accept it. A bare [] is a Vector{Any}. Expected values stay as written.
  • matrix: keeps the existing API, rows, columns = matrix(s). The canonical row / column property decides whether the test indexes rows or columns.
  • spiral-matrix: only the outer "Different valid values" testset is gone; testset names now follow the canonical wording.

@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 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.

Just one note, but you can feel free to leave things as they are.

Comment thread config/generator_macros.j2 Resolved
@colinleach
colinleach merged commit bf896c9 into exercism:main Oct 24, 2026
9 checks passed
@colinleach
colinleach deleted the add-templates-8 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