first commit

This commit is contained in:
Yehowshua Immanuel 2025-02-12 23:54:15 -05:00
commit ef58d5b07e
34 changed files with 2210 additions and 0 deletions

View file

@ -0,0 +1,24 @@
module Tests.Example.Project where
import Prelude
import Test.Tasty
import Test.Tasty.TH
import Test.Tasty.Hedgehog
import Hedgehog ((===))
import qualified Hedgehog as H
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
prop_plusIsCommutative :: H.Property
prop_plusIsCommutative = H.property $ do
a <- H.forAll (Gen.integral (Range.linear minBound maxBound))
b <- H.forAll (Gen.integral (Range.linear minBound maxBound))
plus a b === plus b a
tests :: TestTree
tests = $(testGroupGenerator)
main :: IO ()
main = defaultMain tests

20
tests/doctests.hs Normal file
View file

@ -0,0 +1,20 @@
module Main where
import Prelude
import Build_doctests (flags, pkgs, module_sources)
import Test.DocTest (doctest)
import System.Environment (lookupEnv)
import System.Process
getGlobalPackageDb :: IO String
getGlobalPackageDb = readProcess "ghc" ["--print-global-package-db"] ""
main :: IO ()
main = do
inNixShell <-lookupEnv "IN_NIX_SHELL"
extraFlags <-
case inNixShell of
Nothing -> pure []
Just _ -> pure . ("-package-db="++) <$> getGlobalPackageDb
doctest (flags ++ extraFlags ++ pkgs ++ module_sources)

10
tests/unittests.hs Normal file
View file

@ -0,0 +1,10 @@
import Prelude
import Test.Tasty
import qualified Tests.Example.Project
main :: IO ()
main = defaultMain $ testGroup "."
[ Tests.Example.Project.tests
]