| Line | |
|---|
| 1 | {-# LANGUAGE NoMonomorphismRestriction #-} |
|---|
| 2 | |
|---|
| 3 | module Tests.LambdaTest where |
|---|
| 4 | |
|---|
| 5 | import Lambda |
|---|
| 6 | import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool ) |
|---|
| 7 | import qualified Control.Monad |
|---|
| 8 | |
|---|
| 9 | test1 :: (Lambda l) => l Int |
|---|
| 10 | test1 = app (lam $ \_ -> lit 3) (lit 2) |
|---|
| 11 | |
|---|
| 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 | |
|---|
| 19 | test1ast :: IO Bool |
|---|
| 20 | test1ast = do |
|---|
| 21 | t <- ast test1 |
|---|
| 22 | return $ t "" == "(λa.3) 2" |
|---|
| 23 | |
|---|
| 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.