2019-03-03 17:45:10 +03:00
|
|
|
module Util.FibTest where
|
2019-03-01 00:41:14 +03:00
|
|
|
|
|
|
|
import Test.Tasty.Hspec
|
2019-03-03 17:45:10 +03:00
|
|
|
import Test.Tasty.QuickCheck
|
2021-11-11 15:26:20 +03:00
|
|
|
import Wasp.Util.Fib
|
2019-03-01 00:41:14 +03:00
|
|
|
|
|
|
|
spec_fibonacci :: Spec
|
|
|
|
spec_fibonacci = do
|
|
|
|
describe "Fibonacci" $ do
|
|
|
|
it "fibonacci element #0 is 0" $ do
|
|
|
|
fibonacci 0 `shouldBe` 0
|
|
|
|
it "fibonacci element #1 is 1" $ do
|
|
|
|
fibonacci 1 `shouldBe` 1
|
|
|
|
it "fibonacci element #2 is 1" $ do
|
|
|
|
fibonacci 2 `shouldBe` 1
|
|
|
|
it "fibonacci element #3 is 2" $ do
|
|
|
|
fibonacci 3 `shouldBe` 2
|
|
|
|
|
2019-03-03 17:45:10 +03:00
|
|
|
-- NOTE: Most likely not the best way to write QuickCheck test, I just did this in order
|
|
|
|
-- to get something working as an example.
|
2019-04-22 13:58:31 +03:00
|
|
|
prop_fibonacci :: Property
|
2019-03-03 17:45:10 +03:00
|
|
|
prop_fibonacci = forAll (choose (0, 10)) $ testFibSequence
|
|
|
|
where
|
|
|
|
testFibSequence :: Int -> Bool
|
|
|
|
testFibSequence x = (fibonacci x) + (fibonacci (x + 1)) == fibonacci (x + 2)
|