-
-
Save bChiquet/6dd711d58db49e5e4cc75dfbd4d4dad0 to your computer and use it in GitHub Desktop.
append only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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