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

grains: Update tests to match canonical-data #1058

Merged
merged 4 commits into from
Nov 5, 2017

Conversation

denislooby
Copy link
Contributor

Resolves #996

Removes multiple total_after tests in favor of one at the end as specified in canonical-data.

@cmccandless
Copy link
Contributor

@denislooby Thanks for you pull request!

I'm not sure that removing the extra total_after calls is fully necessary. In particular, I think the calls inside the exception tests should probably remain, since there is no guarantee that total_after calls square (therefore invoking the same validation tests).

@N-Parsons thoughts?

@cmccandless cmccandless requested a review from N-Parsons October 26, 2017 20:43
@denislooby
Copy link
Contributor Author

Yes, I was wondering about that.
The canonical-data and the test seems to have had different interpretations of the readme.

Write code that shows:
- how many grains were on each square, and
- the total number of grains

But you could argue for both ways.

@denislooby
Copy link
Contributor Author

Should there be a 1-1 mapping between test asserts and cases in the canonical-data or is it less rigid than that?

@cmccandless
Copy link
Contributor

@denislooby There's nothing wrong with multiple assertions in the same test case (for example: kindergarten-garden does this).

@denislooby
Copy link
Contributor Author

@cmccandless I know multiple asserts in a test are ok, but should the canonical-data reflect all of them?
In kindergarten-garden it does seem to have them all in the json.

@cmccandless
Copy link
Contributor

@denislooby as long as the additional asserts are neither redundant nor contradictory to the canonical ones, I would say that they are fine.

@denislooby
Copy link
Contributor Author

@cmccandless Ok good to know. In that case definitely the exception test cases should be added back.
I'd be happy to add back the others too if you fell it would be for the best.

@cmccandless
Copy link
Contributor

@denislooby I think simply restoring the exception test cases should be enough.

@N-Parsons
Copy link
Contributor

N-Parsons commented Oct 28, 2017

@denislooby, thanks for your work on this.

(This comment got long, so TL;DR: I'm happy to merge once you've added the exception tests back)

I think that at the very least we should keep the exception tests for total_after - lots of implementations won't have the two functions connected, since there are mathematical tricks to jump straight to the answer, so testing for exception handling in both functions will be important.

Adding back the other tests would mean that the functions are being tested more, which would normally be considered a good thing, but realistically, testing one valid value and 3 exceptional values should be sufficient to fully test implementations of total_after. (In other languages these may be important/useful, but Python has no integer overflow). The aim of total_after with regard to the origin story is to know how many grains of rice are owed in total, so just testing square 64 seems fine to me.

Copy link
Contributor

@N-Parsons N-Parsons left a comment

Choose a reason for hiding this comment

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

See comment above.

@denislooby
Copy link
Contributor Author

@N-Parsons Changes done

@N-Parsons
Copy link
Contributor

Thanks @denislooby! Sorry it took a while for me to get back to this.

@N-Parsons N-Parsons merged commit 607c4b0 into exercism:master Nov 5, 2017
smalley pushed a commit to smalley/python that referenced this pull request Nov 12, 2017
smalley pushed a commit to smalley/python that referenced this pull request Nov 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants