summaryrefslogtreecommitdiff
path: root/Unlambda
diff options
context:
space:
mode:
Diffstat (limited to 'Unlambda')
-rw-r--r--Unlambda/Test.hs41
1 files changed, 40 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
+