{-# LANGUAGE OverloadedStrings #-}
module Eval ( evalTests
) where
import Language.Dickinson.File
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (Assertion, testCase, (@?=))
evalTests :: TestTree
evalTests = testGroup "Evaluation test"
[ testCase "Should evalutate to a constant" constEval
, testCase "Should allow declarations in other orders" scopeEval
, testCase "Should allow higher-order functions" higherOrderEval
, resultCase "test/demo/animal.dck"
, resultCase "test/data/tuple.dck"
, resultCase "test/demo/tyAnnot.dck"
, resultCase "test/data/quoteify.dck"
, resultCase "test/data/hangIndefinitely.dck"
, resolveCase "test/data/hangIndefinitely.dck"
]
forceResult :: a -> Assertion
forceResult = (`seq` pure ())
resultCase :: FilePath -> TestTree
resultCase fp = testCase fp $ result fp
resolveCase :: FilePath -> TestTree
resolveCase fp = testCase fp $ resolve fp
resolve :: FilePath -> Assertion
resolve fp = do
res <- resolveFile ["prelude", "lib"] fp
forceResult res
result :: FilePath -> Assertion
result fp = do
res <- evalFile ["prelude", "lib"] fp
forceResult res
constEval :: Assertion
constEval = do
res <- evalFile [] "test/eval/context.dck"
res @?= "woman"
scopeEval :: Assertion
scopeEval = do
res <- evalFile [] "test/demo/circular.dck"
res @?= "a"
higherOrderEval :: Assertion
higherOrderEval = do
res <- evalFile [] "test/data/higherOrder.dck"
res @?= "It's me"