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

series: Make test cases more consistent #1048

Closed
wants to merge 1 commit into from
Closed

Conversation

mgw93
Copy link

@mgw93 mgw93 commented Feb 26, 2022

This would fix issue #1047

Copy link
Member

@petertseng petertseng left a comment

Choose a reason for hiding this comment

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

Based on the equation of length (series n xs) == min 0 (length xs - n + 1), these changes would make the exercise less consistent, not more. Therefore, we wouldn't want to accept them as-is.

We would want to take exactly one of the two following actions:

@@ -46,7 +46,7 @@ specs = do
]

it "slices of zero" $ do
slices 0 "" `shouldHaveSlices` [[]]
slices 0 "012" `shouldHaveSlices` [[],[],[],[]]
slices 0 "" `shouldHaveSlices` []
Copy link
Member

Choose a reason for hiding this comment

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

For series n xs, you would expect that length (series n xs) == min 0 (length xs - n + 1)

If n == 0 and length xs == 0, then length (series n xs) should be 0 - 0 + 1 == 1. This tells us that there is one way to make a series of length 0 from the empty series: the empty series. Therefore, the result should remain [[]] here.

slices 0 "" `shouldHaveSlices` [[]]
slices 0 "012" `shouldHaveSlices` [[],[],[],[]]
slices 0 "" `shouldHaveSlices` []
slices 0 "012" `shouldHaveSlices` [[],[],[]]
Copy link
Member

Choose a reason for hiding this comment

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

For series n xs, you would expect that length (series n xs) == min 0 (length xs - n + 1)

If n == 0 and length xs == 3, then length (series n xs) should be 3 - 0 + 1 == 4. Therefore, the result should remain [[],[],[],[]] here.

@petertseng petertseng closed this Mar 22, 2022
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.

2 participants