real tests!
This commit is contained in:
35
tst/GMSpec.hs
Normal file
35
tst/GMSpec.hs
Normal file
@@ -0,0 +1,35 @@
|
||||
{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
|
||||
module GMSpec
|
||||
( spec
|
||||
)
|
||||
where
|
||||
----------------------------------------------------------------------------------
|
||||
import Test.Hspec
|
||||
import Arith
|
||||
import Test.QuickCheck
|
||||
import GM (Node(..), resultOf, resultOfExpr)
|
||||
import Core.TH
|
||||
import Core.Examples qualified as Ex
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
it "should correctly evaluate 3-2 with inlining" $ do
|
||||
resultOf [coreProg|main = (-#) 3 2;|] `shouldBe` Just (NNum 1)
|
||||
|
||||
it "should correctly evaluate 3-2 without inlining" $ do
|
||||
resultOf [coreProg|id x = x; main = (id (-#)) 3 2;|] `shouldBe` Just (NNum 1)
|
||||
|
||||
it "should correctly evaluate arbitrary arithmetic" $ do
|
||||
property $ \e ->
|
||||
let arithRes = Just (evalArith e)
|
||||
coreRes = evalCore e
|
||||
in coreRes `shouldBe` arithRes
|
||||
|
||||
describe "test programs" $ do
|
||||
it "fac 3" $ do
|
||||
resultOf Ex.fac3 `shouldBe` Just (NNum 6)
|
||||
|
||||
it "sum [1,2,3]" $ do
|
||||
resultOf Ex.sumList `shouldBe` Just (NNum 6)
|
||||
|
||||
Reference in New Issue
Block a user