summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-05-01 02:15:24 +1000
committerJed Barber <jjbarber@y7mail.com>2014-05-01 02:15:24 +1000
commit1294b57dbbec16f2b9c1a07542a970f38e1b735d (patch)
tree44243c00b6dea5993cf147f5fc61536cd9746330
parent8025724edf1620fa9f3d529effa7a5736ac4470f (diff)
Added initial tests for grasp parser
-rw-r--r--src/Grasp/Test.hs38
-rw-r--r--src/test.hs4
2 files changed, 42 insertions, 0 deletions
diff --git a/src/Grasp/Test.hs b/src/Grasp/Test.hs
new file mode 100644
index 0000000..ec45fb3
--- /dev/null
+++ b/src/Grasp/Test.hs
@@ -0,0 +1,38 @@
+module Grasp.Test (
+ parserTests,
+ tests
+ ) where
+
+
+import Test.HUnit
+import Text.Parsec.Error
+import Grasp.Parser
+
+
+instance Eq Text.Parsec.Error.ParseError
+
+
+
+
+isParseError :: Either a b -> Bool
+isParseError (Left _) = True
+isParseError (Right _) = False
+
+
+
+parser0 = TestCase (assertBool "" (isParseError (parseGrasp "")) )
+
+parser1 = TestCase (assertBool "" (isParseError (parseGrasp "digraph {")) )
+
+parser2 = TestCase (assertBool "" (isParseError (parseGrasp "digraph { }")) )
+
+
+
+parserTests :: Test
+parserTests = TestList [parser0, parser1, parser2]
+
+
+
+tests :: Test
+tests = parserTests
+
diff --git a/src/test.hs b/src/test.hs
index 5fc3533..1e75fb6 100644
--- a/src/test.hs
+++ b/src/test.hs
@@ -3,6 +3,7 @@ import Test.HUnit
import qualified Fractran.Test
import qualified Thue.Test
import qualified Unlambda.Test
+import qualified Grasp.Test
@@ -27,3 +28,6 @@ main = do
tests <- Unlambda.Test.interpreterTests
runTestTT tests
+ putStrLn "\nGrasp Parser"
+ runTestTT Grasp.Test.parserTests
+