Skip to content

Generate strain's test suite from the canonical data - #1011

Merged
rabestro merged 2 commits into
mainfrom
strain-generated-tests
Nov 14, 2026
Merged

rabestro merged 2 commits into
mainfrom
strain-generated-tests

Conversation

@rabestro

Copy link
Copy Markdown
Member

strain's suite is now generated from the canonical data by .meta/template.j2, with AnyFunSuite in Scala 3 syntax in place of the AnyFlatSpec one.

  • The canonical predicates are pseudocode ("fn(x) -> starts_with(x, 'z')"); the template maps each of the six to a Scala lambda (x => x.startsWith("z")). The element type is passed explicitly, as before: Strain.keep[Int](list, ...).
  • Three canonical cases were excluded in tests.toml without a reason and are now included: "keeps nothing", "discards everything" and "discards nothing". They fit the track's API.
  • The other cases now use the canonical inputs: the empty-list cases use _ => true instead of x < 10, and "zealot" replaces "zelot".

The example is rewritten in Scala 3 with foldRight, without the library's filter the instructions rule out, and discard is keep with the predicate negated. The stub, which was empty, now declares keep and discard.

The previous example passes the new suite (14 tests). Cases are added, so solutions will be re-run.

Part of #488, #843 and #914.

🤖 Generated with Claude Code

Add .meta/template.j2 and generate the suite with AnyFunSuite in place of
the AnyFlatSpec one. The template turns the canonical pseudocode predicates
into Scala lambdas.

Include the three canonical cases tests.toml excluded without a reason:
"keeps nothing", "discards everything" and "discards nothing". The other
cases now use the canonical inputs, e.g. "zealot" for "zelot".

Rewrite the example in Scala 3 with foldRight, without the library's
filter, and give the empty stub the `keep` and `discard` signatures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rabestro
rabestro requested review from IsaacG and glennj November 14, 2026 18:35
@rabestro rabestro self-assigned this Nov 14, 2026
@rabestro
rabestro requested a review from a team November 14, 2026 18:35
@github-actions

Copy link
Copy Markdown

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!

@github-actions

Copy link
Copy Markdown

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)

strain's template worked out the Scala type of a list's elements in a
macro. Move that into the generator as a `scala_type` filter, next to
`scala`, so other templates can use it: Boolean, Int (Long beyond Int's
range), Double, String, and List and Map typed from their first entry.

strain's rendered suite, and every other generated suite, is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rabestro
rabestro requested a review from IsaacG November 14, 2026 19:24
@rabestro
rabestro merged commit a7079e5 into main Nov 14, 2026
8 checks passed
@rabestro
rabestro deleted the strain-generated-tests branch November 14, 2026 19:29
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