summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Unlambda/Test.hs41
-rw-r--r--test.hs4
2 files changed, 44 insertions, 1 deletions
diff --git a/Unlambda/Test.hs b/Unlambda/Test.hs
index 9c0024c..504ae07 100644
--- a/Unlambda/Test.hs
+++ b/Unlambda/Test.hs
@@ -1,11 +1,15 @@
module Unlambda.Test (
parserTests,
- tests
+ interpreterTests,
+ tests,
+ ioTests
) where
import Test.HUnit
import Text.Parsec.Error
+import Control.Monad
+import System.IO.Silently
import Unlambda.Types
import Unlambda.Parser
import Unlambda.Interpreter
@@ -44,12 +48,47 @@ parser12 = (Right Reed) ~=? (parseUnlambda "@")
+interpretString :: String -> IO (Maybe (String,UnlambdaTerm))
+interpretString input =
+ let t = parseUnlambda input
+ in case t of
+ Left _ -> return Nothing
+ Right term -> do
+ c <- capture (unlambda term)
+ return (Just c)
+
+
+
+interpreter0 = (liftM2 (~=?))
+ (return (Just ("\n",R)) )
+ (interpretString "``cir")
+
+interpreter1 = (liftM2 (~=?))
+ (return (Just ("",I)) )
+ (interpretString "`c``s`kr``si`ki")
+
+
+
+
parserTests :: Test
parserTests = TestList [parser0, parser1, parser2, parser3, parser4, parser5, parser6, parser7, parser8
,parser9, parser10, parser11, parser12]
+interpreterTests :: IO Test
+interpreterTests = do
+ t0 <- interpreter0
+ t1 <- interpreter1
+ return (TestList [t0,t1])
+
+
+
tests :: Test
tests = parserTests
+
+
+ioTests :: IO Test
+ioTests = interpreterTests
+
diff --git a/test.hs b/test.hs
index a3c4fac..5fc3533 100644
--- a/test.hs
+++ b/test.hs
@@ -23,3 +23,7 @@ main = do
putStrLn "\nUnlambda Parser"
runTestTT Unlambda.Test.parserTests
+ putStrLn "\nUnlambda Interpreter"
+ tests <- Unlambda.Test.interpreterTests
+ runTestTT tests
+