aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-08-14 23:41:18 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-08-14 23:41:18 +0100
commita9c6c592595d1b893e10c5d682146c003f8ec1c1 (patch)
tree846e52092843643dfa4c42323ef1b027e0956ed8
parent641de5e4f68385da3b53bfc532c2d6585a6d958d (diff)
downloadmicro-lang-hs-a9c6c592595d1b893e10c5d682146c003f8ec1c1.tar.gz
micro-lang-hs-a9c6c592595d1b893e10c5d682146c003f8ec1c1.zip
Introduced tests
-rw-r--r--.gitignore10
-rw-r--r--README.md6
-rw-r--r--micro2.cabal30
-rw-r--r--test/Language.hs11
-rw-r--r--test/Main.hs8
5 files changed, 59 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 681f07f..adac87b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
-dist
-dist-newstyle
-*.o
-*.hi
-.ghc.environment.*
+/dist
+/dist-newstyle
+/cabal.project.local
+/.ghc.environment.*
input
+*~
diff --git a/README.md b/README.md
index e5b990c..4e26eeb 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,12 @@ Requires Haskel and Cabal:
cabal run micro2
```
+To run the tests use:
+
+```
+cabal test
+```
+
## Running the compiler
TODO
diff --git a/micro2.cabal b/micro2.cabal
index bcdb59a..30bec21 100644
--- a/micro2.cabal
+++ b/micro2.cabal
@@ -24,11 +24,39 @@ executable micro2
Error
Env
Compiler
+ build-depends:
+ base ^>= 4.16.1.0
+ , parsec ^>= 3.1.15.1
+ , mtl ^>= 2.2.2
+ , containers ^>= 0.6.5.1
+ hs-source-dirs: src
+ default-language: Haskell2010
- build-depends:
+library
+ exposed-modules:
+ Ast
+ Lexer
+ Parser
+ Error
+ Env
+ Compiler
+ build-depends:
base ^>= 4.16.1.0
, parsec ^>= 3.1.15.1
, mtl ^>= 2.2.2
, containers ^>= 0.6.5.1
hs-source-dirs: src
default-language: Haskell2010
+
+test-suite tests
+ type: exitcode-stdio-1.0
+ main-is: Main.hs
+ other-modules:
+ Language
+ build-depends:
+ base ^>= 4.16.1.0
+ , HUnit
+ , micro2
+ hs-source-dirs: test
+ default-language: Haskell2010
+
diff --git a/test/Language.hs b/test/Language.hs
new file mode 100644
index 0000000..9479380
--- /dev/null
+++ b/test/Language.hs
@@ -0,0 +1,11 @@
+module Language where
+
+import Compiler
+import Lexer (scan)
+import Parser (parse)
+import Test.HUnit
+
+testCase = TestCase $ do
+ assertEqual "placeholder" True True
+
+language = [testCase]
diff --git a/test/Main.hs b/test/Main.hs
new file mode 100644
index 0000000..a5d03a3
--- /dev/null
+++ b/test/Main.hs
@@ -0,0 +1,8 @@
+import Language (language)
+import System.Exit
+import Test.HUnit
+
+main :: IO Counts
+main = do
+ counts <- runTestTT $ test language
+ if errors counts + failures counts == 0 then exitSuccess else exitFailure