-
-
Notifications
You must be signed in to change notification settings - Fork 554
leap: Rewrite the test cases and their descriptions #463
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
Conversation
"description": "leap year two thousand", | ||
"input": 2000, | ||
"expected": true | ||
"description": "year before validity of Gregorian Calendar (no leap years at all): standard year", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think Gregorian calendar checks should be introduced in an exercise as early as this.
Also, 1581 is not a leap year by the check on divisibility by 4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that you would omit the boundary check completely, although there were no leap years before 1582 - thus only relying on the three rules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think that is better for this exercise. It is the first one on some tracks, better to keep it simple.
{ | ||
"description": "even standard year in twentieth century", | ||
"input": 1998, | ||
"description": "year not divisible by 4: standard year", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does the term standard year come from? I see common year on Wikipedia. I would think just "not leap year" would be best though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"standard year" was not from me, "not a leap year" is fine by me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreeing with Wikipedia: "A year that is not a leap year is called a common year." is a good idea.
Would you mind amending the commit so that the slug of the exercise is included? It makes it a lot easier to dig through the logs later. |
@kytrinyx sorry I have no idea what the "slug of the exercise" might be. |
"description": "standard year in nineteenth century", | ||
"input": 1900, | ||
"expected": false | ||
"description": "year divisible by 4, not divisible by 100: leap year", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "not divisible by 100" restriction is not relevant here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, only years that are not divisible by 100 are leap years, aren't they? So IMO "year divisible by 4" alone is not enough, we should also state that the exception does not apply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only rule that applies here is 'year divisible by 4' you do not need any other rules to determine if 2016 is a leap year.
The 100 rule is only relevant when we have a year that is divisible by 100, which 2016 is not.
Why do you not also reference the 400 year rule here?
What if there were more rules? ("only in evenly numbered decades, unless the decade is 1") Would you include them all in the description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still disagree - we have a decision tree, where the next rule ("unless") leads to an exemption of the current rule.
So
- rule 1 fails => common year: only one rule to check, so only one rule in the description
- rule 1 succeeds => possibly a leap year, we need to check rule 2
- rule 2 fails: no exemption, so the result of rule 1 holds => leap year, no need to check further roles, so rule 1 and rule 2 in the description
- rule 2 succeeds => exemption, possibly a common year, we need to check rule 3
- rule 3 fails: no exemption, the result of rule 2 holds => common year, I mention the two really relevant rules (divisibility by 4 is obvious from mathematics if the number is divisible by 100)
- rule 3 succeeds: exemption =>leap year only the last rule is really relevant (divisibility by 4 and by 100 is (again) obvious from mathematics.
I really appreciate how you force me to rethink the issue :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that decision tree was very helpful for me to be able to see the way you're approaching the problem, and I can now see how the test descriptions you've used make sense in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also appreciate the effort you've put into this and hope my differing opinions have not discouraged you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries - its good to make well thought decisions - especially when aiming at relatively inexperienced people - and in the end many future tests will draw from the templates in x-common.
How do I proceed from now on? I intend to squash all my commits, thereby amending the commit description. Should I wait on @stevejb71 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the squash and commit message changes and then @stevejb71 can review the "final" version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guntbert from this perspect, you will want to do a squash locally, and then force push your branch, which will set this up like you want it to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now looks fine to me.
{ | ||
"description": "even standard year in twentieth century", | ||
"input": 1998, | ||
"description": "year not divisible by 4: not a leap year", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreeing with Wikipedia: "A year that is not a leap year is called a common year." is a good idea.
"not a leap year" is a little too self referential.
}, | ||
{ | ||
"description": "standard year in eighteenth century", | ||
"input": 1800, | ||
"description": "year divisible by 100, not divisible by 400: not a leap year", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "not divisible by 400" is not relevant here.
What is important: "this year is divisible by 4 and also by 100."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree: every year divisible by 100 is divisible by 4 too, so to me the important part is that in this case rule 3 does not apply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we do not need to implement rule 3 at all for this test to pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps switching the order of the 3rd and 4th tests would be better.
Edit: No, it's not. Test results should be false, true, false, true
@guntbert the 'slug' is the name of the exercise, in this case |
Updating the title won't update the commit though. You can amend the commit and do a force push on the branch, it will be OK. When you make the changes, if you also squash the commits, that might be a good time to make that change. |
@kotp thanks for the heads up - does this repo allow squash commits from the webUI or should I squash on the command line? |
Yes, to both questions. Either way you are comfortable with. |
Sorry about that @guntbert, it's the url-friendly identifier that each exercise has. It's the same name that we would use in the When looking through a few thousand commits, the subject line of the commit message Rewrite the test cases and their descriptions doesn't say which exercise it is referring to, which makes it harder to find things later. |
- only test cases remain that are necessary - they have a clear description to help providing good names for tests
I guess I am finished with this one now - thank you all for being clear, patient and attentive for details. A big praise for the quick responses I got from the team - those made me feel welcome and supported. |
@kytrinyx thank you for the explanation - in hindsight it's obvious :-) |
Thanks @guntbert and @stevejb71 and @Insti and of course Katrina! |
the filepath needed used by example_gen.go was changed in exercism#224 the test cases were changed in this commit: exercism/problem-specifications#463
the filepath needed used by example_gen.go was changed in exercism#224 the test cases were changed in this commit: exercism/problem-specifications#463
the filepath needed used by example_gen.go was changed in exercism#224 the test cases were changed in this commit: exercism/problem-specifications#463
the filepath needed used by example_gen.go was changed in exercism#224 the test cases were changed in this commit: exercism/problem-specifications#463
the filepath needed used by example_gen.go was changed in exercism#224 the test cases were changed in this commit: exercism/problem-specifications#463
Adds the changes made to the the canonical test data in exercism/problem-specifications#463 and stores the test data version.
Adds the changes made to the the canonical test data in exercism/problem-specifications#463 and stores the test data version.
related: #462