Skip to content

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

Merged
merged 1 commit into from
Dec 8, 2016

Conversation

guntbert
Copy link
Contributor

@guntbert guntbert commented Dec 5, 2016

  • only test cases remain that are necessary
  • they have a clear description to help providing good names for tests

related: #462

"description": "leap year two thousand",
"input": 2000,
"expected": true
"description": "year before validity of Gregorian Calendar (no leap years at all): standard year",
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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",
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@kytrinyx
Copy link
Member

kytrinyx commented Dec 6, 2016

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.

@guntbert
Copy link
Contributor Author

guntbert commented Dec 6, 2016

@kytrinyx sorry I have no idea what the "slug of the exercise" might be.

@Insti Insti changed the title Rewrite the test cases and their descriptions leap: Rewrite the test cases and their descriptions Dec 6, 2016
"description": "standard year in nineteenth century",
"input": 1900,
"expected": false
"description": "year divisible by 4, not divisible by 100: leap year",
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

@guntbert guntbert Dec 7, 2016

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 :-)

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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 ?

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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",
Copy link
Contributor

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",
Copy link
Contributor

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."

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@Insti Insti Dec 6, 2016

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

@Insti
Copy link
Contributor

Insti commented Dec 6, 2016

@guntbert the 'slug' is the name of the exercise, in this case leap I have updated the title for you.

@kotp
Copy link
Member

kotp commented Dec 6, 2016

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.

@guntbert
Copy link
Contributor Author

guntbert commented Dec 6, 2016

@kotp thanks for the heads up - does this repo allow squash commits from the webUI or should I squash on the command line?

@kotp
Copy link
Member

kotp commented Dec 6, 2016

Yes, to both questions. Either way you are comfortable with.

@kytrinyx
Copy link
Member

kytrinyx commented Dec 7, 2016

sorry I have no idea what the "slug of the exercise" might be.

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 config.json for it, and the name of the directory containing the metadata files. In this case, leap.

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
@guntbert
Copy link
Contributor Author

guntbert commented Dec 8, 2016

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.

@guntbert
Copy link
Contributor Author

guntbert commented Dec 8, 2016

@kytrinyx thank you for the explanation - in hindsight it's obvious :-)

@kotp kotp merged commit 8b8666e into exercism:master Dec 8, 2016
@kotp
Copy link
Member

kotp commented Dec 8, 2016

Thanks @guntbert and @stevejb71 and @Insti and of course Katrina!

@guntbert guntbert deleted the issue462 branch December 8, 2016 15:08
robphoenix pushed a commit to robphoenix/exercism-go that referenced this pull request Jan 16, 2017
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
robphoenix pushed a commit to robphoenix/exercism-go that referenced this pull request Jan 16, 2017
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
robphoenix pushed a commit to robphoenix/exercism-go that referenced this pull request Jan 16, 2017
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
robphoenix pushed a commit to robphoenix/exercism-go that referenced this pull request Jan 16, 2017
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
robphoenix pushed a commit to robphoenix/exercism-go that referenced this pull request Jan 17, 2017
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
behrtam added a commit to behrtam/python that referenced this pull request Mar 22, 2017
Adds the changes made to the the canonical test data in
exercism/problem-specifications#463
and stores the test data version.
behrtam added a commit to exercism/python that referenced this pull request Mar 28, 2017
Adds the changes made to the the canonical test data in
exercism/problem-specifications#463
and stores the test data version.
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.

5 participants