I tried running runhaskell InterpretSpec.hs
, which then pulls from Interpret.hs
this:
-- Look at how testing is set up in FORTH project and emulate here
-- Make sure you unit test every function you write
import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)
import Pascal.Data
import Pascal.Interpret
import Control.Monad.State
import Data.Map (Map)
import qualified Data.Map as Map
main :: IO ()
main = hspec $ do
let startscope=SymbolTable{variables=Map.empty, global=Map.empty, loop=["notrunning"], functions=Map.empty, procedures=Map.empty, returnstring="", inmain=True}
describe "eval" $ do
it "takes the square root" $ do
evalState (eval(Op1 "sqrt" (Real1 25.0))) startscope `shouldBe` (5.0)
it "takes the cos" $ do
evalState (eval(Op1 "cos" (Real1 0.0))) startscope `shouldBe` (1.0)
it "takes the sin" $ do
evalState (eval(Op1 "sin" (Real1 0.0))) startscope `shouldBe` (0.0)
it "takes the sin" $ do
evalState (eval(Op1 "sin" (Real1 0.0))) startscope `shouldBe` (0.0)
it "takes the sin" $ do
evalState (eval(Op1 "sin" (Real1 0.0))) startscope `shouldBe` (0.0)
mtl is included in the .cabal
file, and I've referenced the suggested solutions at:
and
and neither solves the issue.