Skip to content
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

trinary: Add canonical-data.json #510

Merged
merged 1 commit into from
Jan 28, 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
62 changes: 62 additions & 0 deletions exercises/trinary/canonical-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"to_decimal": {
"description": "returns the decimal representation of the input trinary value",
"cases": [
{
"description": "trinary 1 is decimal 1",
"input": 1,
"expected": 1
},
{
"description": "trinary 2 is decimal 2",
"input": 2,
"expected": 2
},
{
"description": "trinary 10 is decimal 3",
"input": 10,
"expected": 3
},
{
"description": "trinary 11 is decimal 4",
"input": 11,
"expected": 4
},
{
"description": "trinary 100 is decimal 9",
"input": 100,
"expected": 9
},
{
"description": "trinary 112 is decimal 14",
"input": 112,
"expected": 14
},
{
"description": "trinary 222 is decimal 26",
"input": 222,
"expected": 26
},
{
"description": "trinary 1122000120 is decimal 32091",
"input": 1122000120,
"expected": 32091
},
{
"description": "invalid trinary digits returns 0",
"input": "1234",
"expected": 0
Copy link
Member

Choose a reason for hiding this comment

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

Ah. Looks like binary and trinary started the same, but trinary didn't get the af4e4a0 treatment. That's too bad. I do dislike to encourage behaviour that can't distinguish between valid and invalid inputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we make these { expected: { error: "invalid input" }}

I suppose as I've been doing this work of generating the canonical, i wonder how much I'm supposed to make it match the tests that exist or if it's supposed to become the "rule" and i should just expect that the tests that are out there that don't match will someday get updated. It becomes about how much of these should be "what we think the canonical test suite should look like" and how much of it is "what the majority of tests say the canonical test suite is right now"

},
{
"description": "invalid word as input returns 0",
"input": "carrot",
"expected": 0
},
{
"description": "invalid numbers with letters as input returns 0",
"input": "0a1b2c",
"expected": 0
}
]
}
}