Add standard tests for Queen Attack#211
Conversation
e3a8a7e to
5a9aec9
Compare
https://github.com/exercism/todo/issues/133 While implementing Queen Attack for Rust (exercism/rust#89), I surveyed all current implementations of this exercise and documented which tests they used. That full list of tests is here: https://gist.github.com/IanWhitney/dd34f8a16c730f3cd77c In order of prevalence, the five most common test types cover: 1. Can 2 queens attack each other? 2. [Can 2 pieces occupy the same space](https://github.com/exercism/xelixir/blob/0965c4e107de68979a493b82f9f0859773fcb83b/exercises/queen-attack/queen_attack_test.exs#L26)? 3. [Comparing string representations of the chessboard](https://github.com/exercism/xelixir/blob/0965c4e107de68979a493b82f9f0859773fcb83b/exercises/queen-attack/queen_attack_test.exs#L33) 4. [Does a chessboard start with the queens in their default positions?](https://github.com/exercism/xelixir/blob/0965c4e107de68979a493b82f9f0859773fcb83b/exercises/queen-attack/queen_attack_test.exs#L12) 5. [Errors are raised if an invalid position is used](https://github.com/exercism/xpython/blob/b9dfe291845a31301029d947b3cf3a2ffc85b0b6/exercises/queen-attack/queen_attack_test.py#L55) Then there are some uncommon edge-case tests. Can there be more than one chessboard? Can the board be empty? Algebraic chess notation? Etc. Of the top five, I found that only numbers 1 and 5 really cover the exercise as stated -- if I place two queens on the board, can they attack each other? So, those are the tests that I've documented in this json file. Implementing the other tests requires the introduction of a Chessboard object, and also a way to identify pieces (which team they belong to, how they are represented as strings, etc.) That can be interesting to do, but I find it beyond the scope of this exercise as written. At best, I think these tests should be suggested as Extra Credit. Test order also varied between implementations. I have found that the faster I can get the first test to pass, the better. So my first test requires nothing more than a `can_attack` function that returns false. The tests then build on that, adding complexity. Then, once `can_attack` is fully implemented, I add the curveball test of invalid chess positions, which will get students thinking about bad inputs and error handling.
5a9aec9 to
ed35c0f
Compare
|
This is great stuff! Thanks so much for conducting the cross-track survey. I think that you've chosen a very good set of canonical tests, and that these reflect the problem as described in the README. The algebraic notation and graphical representations are not particularly interesting in general (though I'm sure they could be interesting in some languages or to some people). |
|
Would you be interested in writing up an issue that could be posted to all the tracks about the canonical test inputs/outputs and observations made during the survey? |
|
@kytrinyx Sure. How's this? Hello, As part of the following issues: #89 We'd like to have a standard set of tests for Queen Attack. A set of standard tests was merged into x-common with #211 which you can find them here: https://github.com/exercism/x-common/blob/master/queen-attack.json If this track is missing tests that are part of the standard set, implementing them will ensure students a more consistent experience between tracks. And if this track implements tests beyond the standard, can they be removed or clearly marked as "Extra Credit"? |
|
Github auto formatting made that hard to copy & paste into Blazon. Let me try again. |
|
Nice! How about fleshing it out a bit with some of the things mentioned in those issues? (Also, if this gets copy/pasted into a file, then the first line becomes the subject-line of the issue). I've copy/pasted some things from various issues and fleshed things out a bit as well. What do you think? Too prescriptive? |
| "black_queen": { | ||
| "position": "(2,5)" | ||
| }, | ||
| "expected": false |
There was a problem hiding this comment.
should that be true? since their second coordinate are both 5
There was a problem hiding this comment.
The description also suggests that this is expected to be true.
|
@kytrinyx I think that looks good. The one change I'd make is that it mentions string representations both as one of the five test types, and also as an edge case. And I'm not sure if tracks tend to follow the order of the tests as they appear in the JSON. As I mentioned in this PR, I tried to order them in a particular way. But we almost-immediately found that my order does not work well for Rust. So we might want to mention that test order is variable? |
Yeah for the generated ones, definitely. For hand-crafted ones I don't know; probably? Do you want to re-order it in the JSON? Do you think that the order for Rust would make sense for other languages? |
|
It's going to be so language dependent. Rust makes you deal with error cases very differently than Ruby, or PHP, etc. |
|
Hm. Right. Should we split out the error cases in a separate section so that people can either start with errors or start with happy-path? |
|
Maybe. Is there another exercise that we could use as a reference? I toured through the json files before submitting this PR, but didn't see a standard way of handling this. |
|
There's no standard way of handling it, but we have multiple sections in clock.json: https://github.com/exercism/x-common/blob/master/clock.json |
As discussed here: exercism#211 (comment)
Addded raindrops test generator
https://github.com/exercism/todo/issues/133
While implementing Queen Attack for Rust
(exercism/rust#89), I surveyed all current
implementations of this exercise and documented which tests they used.
That full list of tests is here:
https://gist.github.com/IanWhitney/dd34f8a16c730f3cd77c
In order of prevalence, the five most common test types cover:
space?
chessboard
positions?
used
Then there are some uncommon edge-case tests. Can there be more than one
chessboard? Can the board be empty? Algebraic chess notation? Etc.
Of the top five, I found that only numbers 1 and 5 really cover the
exercise as stated -- if I place two queens on the board, can they
attack each other?
So, those are the tests that I've documented in this json file.
Implementing the other tests requires the introduction of a Chessboard
object, and also a way to identify pieces (which team they belong to,
how they are represented as strings, etc.) That can be interesting to
do, but I find it beyond the scope of this exercise as written.
At best, I think these tests should be suggested as Extra Credit.
Test order also varied between implementations.
I have found that the faster I can get the first test to pass, the
better. So my first test requires nothing more than a
can_attackfunction that returns false. The tests then build on that, adding
complexity. Then, once
can_attackis fully implemented, I add thecurveball test of invalid chess positions, which will get students
thinking about bad inputs and error handling.