Robot Name exercise doesn't have canonical data

Does anybody know why the Robot Name exercise doesn’t have canonical data in the Problem specification repo? (problem-specifications/exercises/robot-name at main · exercism/problem-specifications · GitHub)

The exercise involves randomness. Pretty much all the tests that do exist have a deterministic output for a given input. The tests are in the form of assert_equal(function(input), output). That’s challenging to do with a non-deterministic exercise.

I figured that must have been the reason. This is the first one I encounter like this and I wanted to make sure.

There are others in the same situation, for example Simple Linked List.

With no canonical data you have to either borrow tests from another track or make them up from scratch. I went back and look at the exercise and while the names are randoms, the tests checks other properties:

  • Test Name Valid (check name against regex pattern)
  • Test Successive Robots Have Different Names (check names are different)
  • Test Reset Name (check names are different)
  • Test Multiple Names (check for name collisions)
  • Test Collisions (comprehensive name collisions)

So we should be able to define them in the canonical data format. The problem is that adding the canonical data after the fact may impact tracks that have already implemented the exercise.

  1. Tracks don’t need to follow the canonical data.
  2. None of those tests are in the format of assert function(input) == expected which means it’s pretty hard to encode those tests as data.
1 Like

I do understand. I am new at building exercises and am just trying to figure things out. Thank you for the insights.

1 Like

Maybe it would be a good idea to collect the properties to test for in the comments of the canonical-data.json (similar to these)? Currently there is no “official” way for doing such higher level documentation, but maybe that could be a starting point?

Another good example is baffling birthdays.