Add test suite (#42)
This commit is contained in:
parent
b99648999a
commit
ca40559cdc
13
dhall.cabal
13
dhall.cabal
|
@ -69,3 +69,16 @@ Executable dhall
|
|||
GHC-Options: -Wall
|
||||
Other-Modules:
|
||||
Paths_dhall
|
||||
|
||||
Test-Suite test
|
||||
Type: exitcode-stdio-1.0
|
||||
Hs-Source-Dirs: tests
|
||||
Main-Is: Tests.hs
|
||||
Other-Modules:
|
||||
Normalization
|
||||
Build-Depends:
|
||||
base >= 4 && < 5,
|
||||
dhall,
|
||||
tasty >= 0.11.2 && < 0.12,
|
||||
tasty-hunit >= 0.9.2 && < 0.10,
|
||||
text >= 0.11.1.0 && < 1.3
|
||||
|
|
|
@ -84,7 +84,7 @@ import qualified NeatInterpolation
|
|||
Note that Dhall does not support functions from terms to types and therefore
|
||||
Dhall is not a dependently typed language
|
||||
-}
|
||||
data Const = Type | Kind deriving (Show, Bounded, Enum)
|
||||
data Const = Type | Kind deriving (Show, Eq, Bounded, Enum)
|
||||
|
||||
instance Buildable Const where
|
||||
build = buildConst
|
||||
|
@ -287,7 +287,7 @@ data Expr s a
|
|||
| Note s (Expr s a)
|
||||
-- | > Embed path ~ path
|
||||
| Embed a
|
||||
deriving (Functor, Foldable, Traversable, Show)
|
||||
deriving (Functor, Foldable, Traversable, Show, Eq)
|
||||
|
||||
instance Applicative (Expr s) where
|
||||
pure = Embed
|
||||
|
|
18
tests/Normalization.hs
Normal file
18
tests/Normalization.hs
Normal file
|
@ -0,0 +1,18 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Normalization (normalizationTests) where
|
||||
|
||||
import Dhall.Core
|
||||
import Test.Tasty
|
||||
import Test.Tasty.HUnit
|
||||
|
||||
normalizationTests :: TestTree
|
||||
normalizationTests = testGroup "normalization" [ constantFolding ]
|
||||
|
||||
constantFolding :: TestTree
|
||||
constantFolding = testGroup "folding of constants" [ naturalPlus ]
|
||||
|
||||
naturalPlus :: TestTree
|
||||
naturalPlus = testCase "natural plus" $ normalize' (NaturalPlus (NaturalLit 1) (NaturalLit 2)) @?= NaturalLit 3
|
||||
|
||||
normalize' :: Expr () () -> Expr () ()
|
||||
normalize' = normalize
|
7
tests/Tests.hs
Normal file
7
tests/Tests.hs
Normal file
|
@ -0,0 +1,7 @@
|
|||
module Main where
|
||||
|
||||
import Normalization (normalizationTests)
|
||||
import Test.Tasty
|
||||
|
||||
main :: IO ()
|
||||
main = defaultMain (testGroup "Dhall Tests" [ normalizationTests ])
|
Loading…
Reference in New Issue
Block a user