Repository navigation
Add templates 11 - #1165
Merged
Merged
Add templates 11#1165
Conversation
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. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
82 tasks done
Contributor
Pretty much! I'll have a closer look at this tomorrow |
colinleach
marked this pull request as ready for review
October 25, 2026 01:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jlis regenerated from canonical data, and every exercise passes against its example solution. Every templated exercise still passesgenerate_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:
.meta/example.jl.row < 0twice and never checkedcol < 0, soQueen(2, -2)didn't throw.Queen(-2, 2)andQueen(2, -2)), andtests.tomldoesn't exclude them, so both are now generated.@test Queen(2, 2) isa Queen. The oldQueen(2, 2) == Queen(2, 2)couldn't fail.@test_throws InvalidPosition, andcanAttackbecomes@test canattack(...)/@test !canattack(...), as before.using Dates, the same way knapsack's template does. It doesn't useheader(), so this PR doesn't depend on theimportsargument added in Add templates 10 #1163. Once Add templates 10 #1163 is merged, clock could switch tomacros.header(imports=["Dates"]).createcase checks bothClock(h, m) == Clock(...)andsprint(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."hh:mm"results ofadd/subtractare written asClockvalues, e.g.Clock(10, 0) + Dates.Minute(3) == Clock(10, 3), as before.@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.@test_nothrowhelper macro is still defined in the test file. Its comment no longer mentions the equality test, which has been removed.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.Student = NamedTuple{(:name, :grade),Tuple{String,Int}}alias after theinclude, and students are written asStudent(("Aimee", 2)).tests.tomlexcludes 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".