source: sizechecking/branches/macs/Tests/LambdaTest.hs @ 26

Last change on this file since 26 was 26, checked in by gobi, 11 years ago

lambda

File size: 735 bytes
RevLine 
[19]1{-# LANGUAGE NoMonomorphismRestriction #-}
[20]2
[21]3module Tests.LambdaTest where
4
[19]5import Lambda
[21]6import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool )
7import qualified Control.Monad
[19]8
9test1 :: (Lambda l) => l Int
[24]10test1 = app (lam $ \_ -> lit 3) (lit 2)
[20]11
[26]12const2 :: (Lambda l) => l ( Int -> Int )
13const2 = lam $ \_ -> lit 2
14
15t3 :: (Lambda l) => l ( (a -> a) -> (a -> a) )
16t3 = (lam $ \f -> lam $ \v -> f `app` (f `app` (f `app` v)))
17
18
[21]19test1ast :: IO Bool
20test1ast = do
21    t <- ast test1
22    return $ t "" == "(λa.3) 2"
[20]23
[21]24test1eval :: IO Bool
25test1eval = return $ eval test1 == 3
26
27tests :: [IO Bool]
28tests = [ 
29      test1ast
30    , test1eval
31    ]
32
33runTests :: IO Bool
34runTests = Control.Monad.liftM and $ sequence tests
Note: See TracBrowser for help on using the repository browser.