From 82b9e3f4bf70e911916cf000655cdae2492060df Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sun, 25 Sep 2022 23:37:49 +0300 Subject: Add a test to suite --- test/Spec.hs | 15 ++++++++++++++- test/TestUtils.hs | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/TestUtils.hs (limited to 'test') diff --git a/test/Spec.hs b/test/Spec.hs index cd4753f..cbe73d7 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1,2 +1,15 @@ +{-# OPTIONS_GHC -Wno-missing-signatures #-} +import Test.HUnit +import Control.Monad.Except +import Tokenizer ( tokenize ) +import TestUtils + +test1 = (runLContext $ tokenize "+ 1 2") + >>= assertEqual "tokenize \"+ 1 2\"" ["+", "1", "2"] + +tests = TestList $ map TestCase [ + test1 + ] + main :: IO () -main = putStrLn "Test suite not yet implemented" +main = void $ runTestTT tests diff --git a/test/TestUtils.hs b/test/TestUtils.hs new file mode 100644 index 0000000..478d923 --- /dev/null +++ b/test/TestUtils.hs @@ -0,0 +1,19 @@ +{-# OPTIONS_GHC -Wno-missing-export-lists #-} +module TestUtils where + +import Control.Monad.Except +import Control.Monad.Reader +import Utils + +initialConfig :: Config +initialConfig = Config { + configScriptFileName = Nothing, + configVerboseMode = False, + configShowHelp = False +} + +runLContext :: LContext a -> IO a +runLContext lc = do res <- runExceptT $ runReaderT lc initialConfig + case res of + Left (LException err) -> error err + Right val -> return val -- cgit v1.3