Skip to content

Instantly share code, notes, and snippets.

@bChiquet
Created April 3, 2017 15:28
Show Gist options
  • Save bChiquet/6dd711d58db49e5e4cc75dfbd4d4dad0 to your computer and use it in GitHub Desktop.
Save bChiquet/6dd711d58db49e5e4cc75dfbd4d4dad0 to your computer and use it in GitHub Desktop.
append only
import Test.Hspec
main = hspec $ do
describe "fizbuzz" $ do
it "1 gives 1" $ do
fizzBuzz 1 `shouldBe` "1"
it "2 gives 2" $ do
fizzBuzz 2 `shouldBe` "2"
it "3 gives fizz" $ do
fizzBuzz 3 `shouldBe` "fizz"
it "4 gives 4" $ do
fizzBuzz 4 `shouldBe` "4"
it "5 gives buzz" $ do
fizzBuzz 5 `shouldBe` "buzz"
it "any mod of 3 gives fizz" $ do
fizzBuzz 6 `shouldBe` "fizz"
fizzBuzz 9 `shouldBe` "fizz"
it "any mod of 5 gives buzz" $ do
fizzBuzz 10 `shouldBe` "buzz"
fizzBuzz 20 `shouldBe` "buzz"
fizzBuzz i | i`mod`3==0 = "fizz" -- correctif 2
fizzBuzz i | i`mod`5==0 = "buzz"
fizzBuzz i | i`mod`3==0 = "Fizz" -- erreur 2
fizzBuzz 5 = "buzz"
fizzBuzz 3 = "fizz" --inutile 1
fizzBuzz i = show i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment