]> Git — Sourcephile - haskell/symantic.git/blob - Language/LOL/Symantic/Repr/Host/Test.hs
init
[haskell/symantic.git] / Language / LOL / Symantic / Repr / Host / Test.hs
1 {-# LANGUAGE ConstraintKinds #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE OverloadedStrings #-}
4 {-# LANGUAGE ScopedTypeVariables #-}
5 {-# LANGUAGE Rank2Types #-}
6
7 module Repr.Host.Test where
8
9 -- import Data.Function (($))
10 -- import Data.Functor.Identity (Identity)
11 import Test.Tasty
12 import Test.Tasty.HUnit
13
14 import Data.Text (Text)
15 import qualified Data.Text as Text
16 import Prelude hiding (and, not, or)
17
18 import Language.LOL.Symantic.Repr
19 import Language.LOL.Symantic.Expr
20 import qualified Expr.Lambda.Test as Lambda.Test
21 import qualified Expr.Bool.Test as Bool.Test
22 import qualified Expr.Maybe.Test as Maybe.Test
23 import qualified Expr.If.Test as If.Test
24
25 tests :: TestTree
26 tests = testGroup "Host" $
27 [ testGroup "Bool" $
28 let (==>) (expr::forall repr. Sym_of_Expr (Expr_Lambda_Bool IO) repr => repr h) expected =
29 testCase (Text.unpack $ (text_from_expr :: Repr_Text IO _h -> Text) $ expr) $
30 (>>= (@?= expected)) $
31 host_from_expr expr in
32 [ Bool.Test.e1 ==> False
33 , Bool.Test.e2 ==> True
34 , Bool.Test.e3 ==> True
35 , Bool.Test.e4 ==> True
36 ]
37 , testGroup "Lambda" $
38 let (==>) (expr::forall repr. Sym_of_Expr (Expr_Lambda_Bool IO) repr => repr h) expected =
39 testCase (Text.unpack $ (text_from_expr :: Repr_Text IO _h -> Text) $ expr) $
40 (>>= (@?= expected)) $
41 host_from_expr expr in
42 [ (Lambda.Test.e1 `app` bool True `app` bool True) ==> False
43 , (Lambda.Test.e1 `app` bool True `app` bool False) ==> True
44 , (Lambda.Test.e1 `app` bool False `app` bool True) ==> True
45 , (Lambda.Test.e1 `app` bool False `app` bool False) ==> False
46
47 , (Lambda.Test.e2 `app` bool True `app` bool True) ==> False
48 , (Lambda.Test.e2 `app` bool True `app` bool False) ==> True
49 , (Lambda.Test.e2 `app` bool False `app` bool True) ==> True
50 , (Lambda.Test.e2 `app` bool False `app` bool False) ==> False
51
52 , Lambda.Test.e3 ==> True
53 , Lambda.Test.e4 ==> True
54
55 , (Lambda.Test.e5 `app` bool True `app` bool True) ==> True
56 , (Lambda.Test.e5 `app` bool True `app` bool False) ==> False
57 , (Lambda.Test.e5 `app` bool False `app` bool True) ==> False
58 , (Lambda.Test.e5 `app` bool False `app` bool False) ==> False
59
60 , Lambda.Test.e6 ==> False
61 , (Lambda.Test.e7 `app` val id) ==> True
62 , (Lambda.Test.e7 `app` val not) ==> False
63 ]
64 , testGroup "Maybe" $
65 let (==>) (expr::forall repr. Sym_of_Expr (Expr_Lambda_Maybe_Bool IO) repr => repr h) expected =
66 testCase (Text.unpack $ (text_from_expr :: Repr_Text IO _h -> Text) $ expr) $
67 (>>= (@?= expected)) $
68 host_from_expr expr in
69 [ Maybe.Test.e1 ==> False
70 ]
71 , testGroup "If" $
72 let (==>) (expr::forall repr. Sym_of_Expr (Expr_Lambda_If_Bool IO) repr => repr h) expected =
73 testCase (Text.unpack $ (text_from_expr :: Repr_Text IO _h -> Text) $ expr) $
74 (>>= (@?= expected)) $
75 host_from_expr expr in
76 [ If.Test.e1 ==> False
77 ]
78 ]