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

Implement exercise "beer-song" #366

Merged
merged 8 commits into from
May 23, 2017
Merged

Implement exercise "beer-song" #366

merged 8 commits into from
May 23, 2017

Conversation

matteobaglini
Copy link
Contributor

@matteobaglini matteobaglini commented May 22, 2017

Hi all,
I have ported the "beer-song" exercise. Let me know if there are any problems.

Copy link
Contributor

@abo64 abo64 left a comment

Choose a reason for hiding this comment

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

Thank you very much for implementing this exercise, @matteobaglini !

@@ -0,0 +1,5 @@
class BeerSong {
Copy link
Contributor

Choose a reason for hiding this comment

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

In #137 we agreed to just have a .keep file in the src/main/scala directory (except for the first couple of exercises) so that there is some additional fun to find out the function signatures. :)

test("first generic verse") {
val expected = "99 bottles of beer on the wall, 99 bottles of beer.\nTake one down and pass it around, 98 bottles of beer on the wall.\n"
val beerSong = new BeerSong()
assert(expected == beerSong.verse(99))
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I also like the assert macro.
Most exercises use should be from org.scalatest.Matchers.

But perhaps we should be (more liberal) here? @ricemery @ErikSchierboom

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should be strict about about test style. I think it is good from an education standpoint to have a couple different styles used in the exercises.

Copy link
Member

Choose a reason for hiding this comment

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

Same here. The difference is small enough that people won't have much trouble I think


test("first generic verse") {
val expected = "99 bottles of beer on the wall, 99 bottles of beer.\nTake one down and pass it around, 98 bottles of beer on the wall.\n"
val beerSong = new BeerSong()
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no internal state. So it makes more sense to have an object here instead of a class. Just:

assert(expected == Beersong.verse(99))

@@ -0,0 +1,60 @@
import org.scalatest._
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I have written a Code Generator for this exercise, not being aware at that time that the respective exercise did not exist. :)

Don't know if it still works, but feel free to try it out and modify it if you find the time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll look into it, thanks.

}

test("last generic verse") {
pending // remove to run test
Copy link
Contributor

Choose a reason for hiding this comment

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

The first test should not be pending.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't first generic verse the first test?

Before start coding the test suite I checked the common and ruby reference and it seemed to me that it was the first.

@abo64 abo64 merged commit 94c5fb0 into exercism:master May 23, 2017
@abo64
Copy link
Contributor

abo64 commented May 23, 2017

thank you @matteobaglini

@matteobaglini
Copy link
Contributor Author

it was a pleasure. 😃

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.

4 participants