Repository navigation
Add templates 7 - #1160
Add templates 7#1160
Conversation
|
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 |
|
I'm open to whatever on 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. |
|
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. |
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.jlis regenerated from canonical data, and every exercise passes against its example solution. Every templated exercise still passesgenerate_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:
ArgumentError: wordy, phone-numberDomainError: all-your-base, change, protein-translation, perfect-numbersclassify(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) throwDomainError, as the old tests did. That's three assertions for one canonical case.Int[], not[], so that solutions with typed signatures such asdigits::Vector{Int}accept them. A bare[]is aVector{Any}.Set, e.g.allergy_list(3) == Set(["eggs", "peanuts"]), because the Julia API returns aSet.[(3, 4, 5)], to match the Julia return type.planetbecomes the function name (onEarth,onMars, ...), compared withisapprox(...; rtol = 0.01). The canonical "invalid planet" case stays excluded intests.toml, because the Julia API has no function to call for it. The Earth expected value changes from31.60to the canonical31.69." 1 223 456 7890 "and"1223456789", which aren't canonical, and"123-@:!-7890", whichtests.tomlexcludes in favour of the newer"523-@:!-7890"case.!isperfect(12)and!isdeficient(28).allergic_to(257, "eggs"). The canonicalallergy_list(257) == Set(["eggs"])is now included; the old file didn't have it.proteins("AAA").tests.tomlexcludes 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.