diff options
author | Jed Barber <jjbarber@y7mail.com> | 2014-03-18 01:57:23 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2014-03-18 01:57:23 +1100 |
commit | 0ca67c7536c8ab158c6271d8d72e9786f0e0652b (patch) | |
tree | 33860dd4e6863c6f68db73ce14bf16bd358d4e67 /Thue | |
parent | eecb6118d595caffa169e4ababce30e6b8829088 (diff) |
Refactored testcases into separate modules for each language
Diffstat (limited to 'Thue')
-rw-r--r-- | Thue/Test.hs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/Thue/Test.hs b/Thue/Test.hs new file mode 100644 index 0000000..2e30f6b --- /dev/null +++ b/Thue/Test.hs @@ -0,0 +1,68 @@ +module Thue.Test ( + parserTests, + extractInfixTests, + tests + ) where + + +import Test.HUnit +import Text.Parsec.Error +import Thue.Parser +import Thue.Interpreter + + +instance Eq Text.Parsec.Error.ParseError + + + + +parser0 = TestCase (assertEqual "" + (Right (ThueProgram [ThueRule "a" "b"] "a")) + (parseThue "a::=b\n::=\na")) + +parser1 = TestCase (assertEqual "" + (Right (ThueProgram [] "b")) + (parseThue "::=\nb")) + + + +extractInfix0 = TestCase (assertEqual "" + Nothing + (extractInfix [1,2] [3,4,5])) + +extractInfix1 = TestCase (assertEqual "" + (Just ([1,2],[5,6])) + (extractInfix [3,4] [1,2,3,4,5,6])) + +extractInfix2 = TestCase (assertEqual "" + (Just ([],[3,4])) + (extractInfix [0,1,2] [0,1,2,3,4])) + +extractInfix3 = TestCase (assertEqual "" + (Just ([1],[])) + (extractInfix [2,3] [1,2,3])) + +extractInfix4 = TestCase (assertEqual "" + (Just ([],[1])) + (extractInfix [] [1])) + +extractInfix5 = TestCase (assertEqual "" + (Just ("before","after")) + (extractInfix "middle" "beforemiddleafter")) + + + +parserTests :: Test +parserTests = TestList [parser0, parser1] + + + +extractInfixTests :: Test +extractInfixTests = TestList [extractInfix0, extractInfix1, extractInfix2, extractInfix3, extractInfix4, extractInfix5] + + + +tests :: Test +tests = case (parserTests, extractInfixTests) of + (TestList a, TestList b) -> TestList (a ++ b) + |