Skip to content

go-counting: Rewrite tests to use hspec with fail-fast. #352

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
Sep 24, 2016
Merged

go-counting: Rewrite tests to use hspec with fail-fast. #352

merged 1 commit into from
Sep 24, 2016

Conversation

rbasso
Copy link
Contributor

@rbasso rbasso commented Sep 24, 2016

  • Completely rewrite tests to use hspec.
  • Add test suite's dependency on package multiset.

Related to #211.

This was one of the most challenging re-writings since we started migrating the exercises to hspec, so I think I owe a few explanations:

  • shouldScore is pointfree madness, but I couldn't make it more readable any other way.
  • toOccurList . fromOccurList is the best way I could find to sum all the scores.
  • first and swap are not commonly used in this repository, but I think they really make sense.

- Completely rewrite tests to use `hspec`.
- Add test suite's dependency on package `multiset`.
@petertseng
Copy link
Member

shouldScore is pointfree madness, but I couldn't make it more readable any other way.

It didn't seem so hard to understand to me. It gets harder for me if I see compositions of compositions, like

 > pl \x y z -> f (g x y z)
 ((f .) .) . g

toOccurList . fromOccurList is the best way I could find to sum all the scores.

That seems OK. Shorter than what I might have come up with (which would be folding with insertWithKey then toList

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.

These new tests seem easier to read, so I like how shouldHaveTerritories and shouldScore were done!

@petertseng
Copy link
Member

petertseng commented Sep 24, 2016

(OK I realize shouldHaveTerritories is pretty much the same as terrs helper of the previous, but shouldScore I think has improved compared to the original because it makes clear which score belongs to whom)

@rbasso
Copy link
Contributor Author

rbasso commented Sep 24, 2016

Thank you very much, @petertseng! 😄

@rbasso rbasso merged commit 7e63fb2 into exercism:master Sep 24, 2016
@rbasso rbasso deleted the hspec-go-counting branch September 24, 2016 14:33
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