Skip to content

Write generators for all exercises #605

Open
@petertseng

Description

@petertseng

In x-common, we have various exercises with canonical-data.json representing the recommended set of tests for that exercise. We created generators to more easily keep up with changes in x-common. Whenever x-common changes, the task is as simple as re-running the generator.

The current documentation is at https://github.com/exercism/xgo#generating-test-cases - if at any point we find that we should explain something better, we should add any necessary documentation.

Preliminaries:

  • I find the list of our generators using ls exercises/*/cases_test.go | cut -d/ -f2 from the root of the xgo directory.
  • I find the list of exercises with canonical-data.json using ls exercises/*/canonical-data.json | cut -d/ -f2 from the root of the x-common directory.

This issue concerns exercises that don't yet have a generator.

For each exercise, first we should decide whether we even want a generator.
An example where we don't want one is diamond, since property-based tests aren't represented in canonical-data.json.
So don't be afraid to suggest that we pass on having a generator if it creates more work than it saves.
After all, the point is to make maintenance of this track easy.

Or, we may decide to lazy-evaluate the generator:
If our current tests already match x-common, there is no current need to have a generator since it will make no difference currently.
So we may decide that we'll make a generator the next time the x-common JSON changes, and until then we'll stick with what we have.

If we decide we do want a generator for a given exercise:
First, we should check whether there are any cases that our track has that the common JSON doesn't have.
For each of those, we should consider the options:

  • Propose adding it to the common JSON if we feel it can be valuable to other tracks
  • Do nothing and just run the new generator (thus losing the extra case) if we feel the extra case does not contribute anything meaningful to this track
  • Have our track's generator add the case after the JSON is parsed if we feel it adds value to the track but wouldn't add value to other tracks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions