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