mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-11-23 19:29:17 +03:00
Added fibonacci function and some tests for it. Still working on organizing tests.
This commit is contained in:
parent
b02f9cd914
commit
7c2d42fdfd
@ -63,3 +63,4 @@ tests:
|
||||
- stic
|
||||
- tasty
|
||||
- tasty-hspec
|
||||
- tasty-quickcheck
|
||||
|
@ -1,6 +1,13 @@
|
||||
module Lib
|
||||
( someFunc
|
||||
) where
|
||||
module Lib (
|
||||
someFunc,
|
||||
fibonacci
|
||||
) where
|
||||
|
||||
someFunc :: IO ()
|
||||
someFunc = putStrLn "someFunc"
|
||||
|
||||
fibonacci :: (Num a, Ord a, Num b) => a -> b
|
||||
fibonacci 0 = 0
|
||||
fibonacci 1 = 1
|
||||
fibonacci n | n > 1 = (fibonacci (n - 1)) + (fibonacci (n - 2))
|
||||
fibonacci _ = undefined
|
||||
|
@ -1,12 +1,28 @@
|
||||
import qualified Test.Tasty
|
||||
import Test.Tasty.Hspec
|
||||
import Test.Tasty.QuickCheck as QC
|
||||
|
||||
import Lib
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
test <- testSpec "stic-test" spec
|
||||
Test.Tasty.defaultMain test
|
||||
test <- testSpec "stic-test" spec
|
||||
Test.Tasty.defaultMain test
|
||||
|
||||
spec :: Spec
|
||||
spec = parallel $ do
|
||||
it "is trivially true" $ do
|
||||
True `shouldBe` True
|
||||
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
|
||||
|
||||
-- TODO: Figure out how to organize tests for multiple modules!
|
||||
-- I should read https://documentup.com/feuerbach/tasty, especially "Project organization and integration with Cabal"
|
||||
-- part, and then continue from there. Search for some examples, maybe existing projects.
|
||||
-- Also, can tests be mixed with source files as we usually do it in other languages? They certainly can,
|
||||
-- but is that better and if yes how would be implement that?
|
||||
-- Do we need smth like tasty-discovery?
|
||||
|
Loading…
Reference in New Issue
Block a user