Proposed additional test case(s) for Connect exercise

Hello, Python track maintainers!

When working on the Connect exercise, I came up with a solution that passes the existing test suite, but then I realized that it would fail test cases for winning paths with “dead ends.” I added the test shown below, and sure enough, my solution failed. What would folks think about adding one or more such test cases?

    def test_x_wins_using_a_path_with_a_dead_end(self):
        game = ConnectGame(
            """. . X .
                X X . .
                 . X X X
                  O O O O"""
        )
        winner = game.get_winner()
        self.assertEqual(winner, "X")

Note, this is a practice exercise synced from the problem specs. This wouldn’t be Python-specific.

I’d be open to adding a path with a dead-end fork, but we’d want to have both a left-dead-end fork and right-dead-end fork.

Hello again, @IsaacG!

I’d be open to adding a path with a dead-end fork, but we’d want to have both a left-dead-end fork and right-dead-end fork.

Sure, that makes sense.

Note, this is a practice exercise synced from the problem specs. This wouldn’t be Python-specific.

Thanks for the reminder. I assume that the initial PR would just modify exercises/connect/canonical-data.json? After that, how would the tracks get updated?

The first step would be getting buy-in from at least three maintainers ;)

Then a PR to update the canonical data. Then tracks can sync tests from the canonical data. Exactly how that works is different for each track. Some tracks have auto-generated tests that can be used to regenerate the tests from the canonical data. Other tracks do this by hand.

The configlet sync tool if often part of this process.

1 Like

+1 assuming both a left and right dead-end fork are included for completeness.

Tracks can also choose to not use/refuse individual tests from cannonical-data, so just because it is updated doesn’t mean all tracks will use all tests.

I am neutral on the additional tests. You can count me as a +1 if no one else comes out in support in the next day or so.

2 Likes

+1 for both dead-end forks, too.

1 Like

Given that “The aim of exercises’ test suites is not to be comprehensive about all possible cases,” I thought it might be helpful to explain why I think this change would be beneficial for learning the given programming language, and not simply covering edge cases.

The additional test cases would require the student to think about how to represent a set of conditions as true only if any of the conditions in the set is true. In Python and other languages, this would be a good use case for the any idiom.

Opened Add dead-end test cases for Connect by blackk-foxx · Pull Request #2633 · exercism/problem-specifications · GitHub.

Linked back to this conversation, for completeness.

The PR has been merged.

2 Likes