Skip to content

queen-attack: Make exercise schema-compliant #655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 125 additions & 109 deletions exercises/queen-attack/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"#": [
"exercise": "queen-attack",
"version": "1.0.0",
"comments": [
"Testing invalid positions will vary by language. The expected",
"value of -1 is there to indicate some sort of failure should",
"occur, while a 0 means no failure.",
Expand All @@ -8,119 +10,133 @@
"the board graphically, or using standard chess notation. Those",
"tests can be offered as extra credit"
],
"create": {
"description": "Test creation of Queens with valid and invalid positions",
"cases" : [
{
"description": "queen with a valid position",
"queen": {
"position": "(2,2)"
"cases": [
{
"description": "Test creation of Queens with valid and invalid positions",
"cases": [
{
"description": "queen with a valid position",
"property": "create",
"queen": {
"position": "(2,2)"
},
"expected": 0
},
"expected": 0
},
{
"description": "queen must have positive rank",
"queen": {
"position": "(-2,2)"
{
"description": "queen must have positive rank",
"property": "create",
"queen": {
"position": "(-2,2)"
},
"expected": -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't -1 be replaced with an error object? If so, the description in the "comments" key should also be updated.

Copy link
Contributor Author

@rbasso rbasso Mar 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree you you. It should be an error, or maybe null.

A lot of other test suites have exactly the same problem, but in #625 we are just making changes that do not affect the contents of the test suite, only changes in structure (with some unavoidable small exceptions), so that they formally complies with the JSON schema.

Maybe we should open a new force after finishing this one to make sure that all the test suite follow the best practices and error encoding conventions. For now, I would really like to avoid it, because even the mechanical work of adapting them to the new schema is already taking a lot of time. 😩

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Let's do what you suggested then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, thanks for reviewing all this.

},
"expected": -1
},
{
"description": "queen must have rank on board",
"queen": {
"position": "(8,4)"
{
"description": "queen must have rank on board",
"property": "create",
"queen": {
"position": "(8,4)"
},
"expected": -1
},
"expected": -1
},
{
"description": "queen must have positive file",
"queen": {
"position": "(2,-2)"
{
"description": "queen must have positive file",
"property": "create",
"queen": {
"position": "(2,-2)"
},
"expected": -1
},
"expected": -1
},
{
"description": "queen must have file on board",
"queen": {
"position": "(4,8)"
{
"description": "queen must have file on board",
"property": "create",
"queen": {
"position": "(4,8)"
},
"expected": -1
}
]
},
{
"description": "Test the ability of one queen to attack another",
"cases": [
{
"description": "can not attack",
"property": "canAttack",
"white_queen": {
"position": "(2,4)"
},
"black_queen": {
"position": "(6,6)"
},
"expected": false
},
"expected": -1
}
]
},
"can_attack": {
"description": "Test the ability of one queen to attack another",
"cases": [
{
"description": "can not attack",
"white_queen": {
"position": "(2,4)"
{
"description": "can attack on same rank",
"property": "canAttack",
"white_queen": {
"position": "(2,4)"
},
"black_queen": {
"position": "(2,6)"
},
"expected": true
},
"black_queen": {
"position": "(6,6)"
{
"description": "can attack on same file",
"property": "canAttack",
"white_queen": {
"position": "(4,5)"
},
"black_queen": {
"position": "(2,5)"
},
"expected": true
},
"expected": false
},
{
"description": "can attack on same rank",
"white_queen": {
"position": "(2,4)"
},
"black_queen": {
"position": "(2,6)"
},
"expected": true
},
{
"description": "can attack on same file",
"white_queen": {
"position": "(4,5)"
},
"black_queen": {
"position": "(2,5)"
},
"expected": true
},
{
"description": "can attack on first diagonal",
"white_queen": {
"position": "(2,2)"
},
"black_queen": {
"position": "(0,4)"
},
"expected": true
},
{
"description": "can attack on second diagonal",
"white_queen": {
"position": "(2,2)"
},
"black_queen": {
"position": "(3,1)"
},
"expected": true
},
{
"description": "can attack on third diagonal",
"white_queen": {
"position": "(2,2)"
},
"black_queen": {
"position": "(1,1)"
},
"expected": true
},
{
"description": "can attack on fourth diagonal",
"white_queen": {
"position": "(2,2)"
},
"black_queen": {
"position": "(5,5)"
},
"expected": true
}
]
}
{
"description": "can attack on first diagonal",
"property": "canAttack",
"white_queen": {
"position": "(2,2)"
},
"black_queen": {
"position": "(0,4)"
},
"expected": true
},
{
"description": "can attack on second diagonal",
"property": "canAttack",
"white_queen": {
"position": "(2,2)"
},
"black_queen": {
"position": "(3,1)"
},
"expected": true
},
{
"description": "can attack on third diagonal",
"property": "canAttack",
"white_queen": {
"position": "(2,2)"
},
"black_queen": {
"position": "(1,1)"
},
"expected": true
},
{
"description": "can attack on fourth diagonal",
"property": "canAttack",
"white_queen": {
"position": "(2,2)"
},
"black_queen": {
"position": "(5,5)"
},
"expected": true
}
]
}
]
}