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

Errors in: Leap #301

Closed
blueglyph opened this issue May 26, 2019 · 7 comments
Closed

Errors in: Leap #301

blueglyph opened this issue May 26, 2019 · 7 comments

Comments

@blueglyph
Copy link

Common problems also found in other tests.

  1. Problem description too vague: Given a year, report if it is a leap year.
  • function/class?
  • name?
  • file name?
  • return type?
  • restrictions?

=> the user has to guess what to do, from the test suite.

  1. Test suite is incomplete, most tests are skipped because of @Ignored tags.

=> test unreliable

class LeapTest {

    @Test
    fun yearNotDivisibleBy4() {
        assertFalse(Year(2015).isLeap)
    }

    @Ignore
    @Test
    fun yearDivisibleBy4NotDivisibleBy100() {
        assertTrue(Year(1996).isLeap)
    }

    @Ignore
    @Test
    fun yearDivisibleBy100NotDivisibleBy400() {
        assertFalse(Year(2100).isLeap)
    }

    @Ignore
    @Test
    fun yearDivisibleBy400() {
        assertTrue(Year(2000).isLeap)
    }

}
@blueglyph
Copy link
Author

blueglyph commented May 26, 2019

As a solution for 1), suggestion:

Given a year, report if it is a leap year.
Define a (data) class Year in the source file Leap.kt,

  • taking an integer for the year as constructor parameter,
  • providing a isLeap boolean property which is true when the year is a leap year
  • years are given with 4 digits, e.g. 2019 (and not only 19 by skipping the century digits).

@blueglyph
Copy link
Author

As a solution for 2), obviously:

import org.junit.Test
import org.junit.Ignore
import kotlin.test.assertFalse
import kotlin.test.assertTrue

class LeapTest {

    @Test
    fun yearNotDivisibleBy4() {
        assertFalse(Year(2015).isLeap)
    }

    @Test
    fun yearDivisibleBy4NotDivisibleBy100() {
        assertTrue(Year(1996).isLeap)
    }

    @Test
    fun yearDivisibleBy100NotDivisibleBy400() {
        assertFalse(Year(2100).isLeap)
    }

    @Test
    fun yearDivisibleBy400() {
        assertTrue(Year(2000).isLeap)
    }
}

@mikegehard
Copy link
Contributor

Thanks for the report. #2 should be addressed in #296. Each assignment description will let folks know to remove the @ignore. Hopefully that helps once it is deployed to prod. If it doesn't, please let me know.

@mikegehard
Copy link
Contributor

In regards to #1, yes it is assumed that the user would use the test suite to answer those questions.

There was a big discussion in this thread (exercism/exercism#856) about the philosophy. Hopefully this helps explain a bit about the dependence on the tests.

@mikegehard
Copy link
Contributor

I'm closing this issue for now. If the two discussions above don't solve this for you, please start a discussion here and we can try to find a solution together.

@blueglyph
Copy link
Author

blueglyph commented May 30, 2019

I see the problem is larger than this specific test and must be addressed differently, so I've just given my thoughts from experience in the problem referenced above (#856) which seemed to be a more appropriate place to do so.

Personally, I know how to proceed now so my own problem is solved already, but one may consider the chance that everyone starting the tests will hit the same wall...

@mikegehard
Copy link
Contributor

Thanks for taking the time to add your thoughts to #865...I'll track that one to see where Exercism as a whole ends up.

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

No branches or pull requests

2 participants