diff options
| -rw-r--r-- | lang.cabal | 10 | ||||
| -rw-r--r-- | package.yaml | 1 | ||||
| -rw-r--r-- | src/Lib.hs | 1 | ||||
| -rw-r--r-- | stack.yaml | 4 | ||||
| -rw-r--r-- | stack.yaml.lock | 14 | ||||
| -rw-r--r-- | test/Spec.hs | 15 | ||||
| -rw-r--r-- | test/TestUtils.hs | 19 |
7 files changed, 58 insertions, 6 deletions
@@ -37,7 +37,8 @@ library src ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints build-depends: - base >=4.7 && <5 + HUnit ==1.6.2.0 + , base >=4.7 && <5 , containers , haskeline ==0.8.2 , mtl @@ -52,7 +53,8 @@ executable lang-exe app ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N build-depends: - base >=4.7 && <5 + HUnit ==1.6.2.0 + , base >=4.7 && <5 , containers , haskeline ==0.8.2 , lang @@ -64,12 +66,14 @@ test-suite lang-test type: exitcode-stdio-1.0 main-is: Spec.hs other-modules: + TestUtils Paths_lang hs-source-dirs: test ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N build-depends: - base >=4.7 && <5 + HUnit ==1.6.2.0 + , base >=4.7 && <5 , containers , haskeline ==0.8.2 , lang diff --git a/package.yaml b/package.yaml index 7a2296c..c17363e 100644 --- a/package.yaml +++ b/package.yaml @@ -25,6 +25,7 @@ dependencies: - mtl - haskeline == 0.8.2 - regex-tdfa == 1.3.2 +- HUnit == 1.6.2.0 ghc-options: - -Wall @@ -36,4 +36,3 @@ runInlineScript env src = do (newAccEnv, newAst) <- evaluate accEnv ast (retEnv, restEvaled) <- foldEvaluate newAccEnv rest return $ (retEnv, newAst : restEvaled) - @@ -7,4 +7,6 @@ require-stack-version: ==2.7.5 extra-deps: - haskeline-0.8.2 - regex-base-0.94.0.2 - - regex-tdfa-1.3.2
\ No newline at end of file + - regex-tdfa-1.3.2 + - call-stack-0.4.0 + - HUnit-1.6.2.0 diff --git a/stack.yaml.lock b/stack.yaml.lock index 81770bd..d8ea52a 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -25,4 +25,18 @@ packages: sha256: 2725c8313eaf9dc1403f27b691b02143aa6ec546adaea7ab5c985b0f9a777014 original: hackage: regex-tdfa-1.3.2 +- completed: + hackage: call-stack-0.4.0@sha256:ac44d2c00931dc20b01750da8c92ec443eb63a7231e8550188cb2ac2385f7feb,1200 + pantry-tree: + size: 501 + sha256: 04134fa69cdd824b4e4bb7f77e7173e0705f27deabdbbf99549c549400191e1e + original: + hackage: call-stack-0.4.0 +- completed: + hackage: HUnit-1.6.2.0@sha256:1a79174e8af616117ad39464cac9de205ca923da6582825e97c10786fda933a4,1588 + pantry-tree: + size: 878 + sha256: 4f20a5a33866171260d0ee1e256c27f53cc84d37a68d498c3e12347f4e3d05b4 + original: + hackage: HUnit-1.6.2.0 snapshots: [] 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 |
