diff options
Diffstat (limited to 'src/Thue/Test.hs')
-rw-r--r-- | src/Thue/Test.hs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/Thue/Test.hs b/src/Thue/Test.hs new file mode 100644 index 0000000..0273c48 --- /dev/null +++ b/src/Thue/Test.hs @@ -0,0 +1,52 @@ +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 = (Right (ThueProgram [ThueRule "a" "b"] "a")) ~=? (parseThue "a::=b\n::=\na") + +parser1 = (Right (ThueProgram [] "b")) ~=? (parseThue "::=\nb") + + + +extractInfix0 = Nothing ~=? (extractInfix [1,2] [3,4,5]) + +extractInfix1 = (Just ([1,2],[5,6])) ~=? (extractInfix [3,4] [1,2,3,4,5,6]) + +extractInfix2 = (Just ([],[3,4])) ~=? (extractInfix [0,1,2] [0,1,2,3,4]) + +extractInfix3 = (Just ([1],[])) ~=? (extractInfix [2,3] [1,2,3]) + +extractInfix4 = (Just ([],[1])) ~=? (extractInfix [] [1]) + +extractInfix5 = (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) + |