Repository navigation
Generate simple-cipher's test suite from the canonical data - #1012
Conversation
Add .meta/template.j2 and regenerate the suite in Scala 3 syntax, with the twelve canonical cases. New are "Can wrap on decode", the two cases with a message longer than the key, and the random key's lowercase check; the random-key encode and decode are now separate tests. The canonical values that are expressions on the cipher are written out in Scala. Keep the three invalid-key tests at the end of the template: they are not in the canonical data, but the instructions ask for a key of lowercase letters. Rewrite the example in Scala 3. It repeats the key for longer messages, and its random key is 100 letters drawn from all 26, as the instructions ask. Give the empty stub the `key`, `encode` and `decode` the tests call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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 |
|
Hello 👋 Thanks for your PR. This repo does not currently have dedicated maintainers. Our cross-track maintainers team will attempt to review and merge your PR, but it will likely take longer for your PR to be reviewed. If you enjoy contributing to Exercism and have a track-record of doing so successfully, you might like to become an Exercism maintainer for this track. Please feel free to ask any questions, or chat to us about anything to do with this PR or the reviewing process on the Exercism forum. (cc @exercism/cross-track-maintainers) |
The four random-key cases have expressions on the cipher as their canonical values, which made the template translate them case by case. Write those tests out by hand instead, and generate only the cases with a key. The rendered suite is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Go back to one loop over the canonical cases, as review asked, with one branch per kind of case: the key check, "is reversible", a case with a key, and encoding or decoding with the random key. The rendered suite is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simple-cipher's suite is now generated from the canonical data by
.meta/template.j2, in Scala 3 syntax.fullyMatch regex). The random-key encode and decode are now separate tests.cipher.key.substring(0, plaintext.length),cipher.encode); the template writes them out in Scala.The previous example fails the two cases with a message longer than the key, since it indexed past the end of the key. Its random key was also 26 letters instead of at least 100, and never contained a
z(nextInt(25)). The example is rewritten in Scala 3: it repeats the key, rotates withMath.floorMod, and draws a random key of 100 letters from all 26. The stub, which was empty, now declareskey,encodeanddecode.Cases are added, so solutions will be re-run.
Part of #488, #843 and #914.
🤖 Generated with Claude Code