-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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._ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @matteobaglini |
it was a pleasure. 😃 |
Hi all,
I have ported the "beer-song" exercise. Let me know if there are any problems.