]> Git — Sourcephile - haskell/symantic.git/blob - Language/LOL/Symantic/Repr/Text/Test.hs
init
[haskell/symantic.git] / Language / LOL / Symantic / Repr / Text / Test.hs
1
2 module Repr.Text.Test where
3
4 import Test.Tasty
5 import Test.Tasty.HUnit
6
7 import qualified Data.Text as Text
8
9 import Language.LOL.Symantic.Repr
10 import qualified Expr.Lambda.Test as Lambda.Test
11 import qualified Expr.Bool.Test as Bool.Test
12 import qualified Expr.Maybe.Test as Maybe.Test
13 import qualified Expr.Eq.Test as Eq.Test
14
15 tests :: TestTree
16 tests = testGroup "String" $
17 let (==>) expr expected =
18 testCase (Text.unpack expected) $
19 (@?= expected) $
20 text_from_expr expr in
21 [ testGroup "Bool"
22 [ Bool.Test.e1 ==> "True & False"
23 , Bool.Test.e2 ==> "True & False | True & True"
24 , Bool.Test.e3 ==> "(True | False) & (True | True)"
25 , Bool.Test.e4 ==> "True & !False"
26 , Bool.Test.e5 ==> "True & !x"
27 , Bool.Test.e6 ==> "(x | y) & !(x & y)"
28 , Bool.Test.e7 ==> "((x | y) & !(x & y) | z) & !(((x | y) & !(x & y)) & z)"
29 , Bool.Test.e8 ==> "(x | (y | True) & !(y & True)) & !(x & ((y | True) & !(y & True)))"
30 ]
31 , testGroup "Lambda"
32 [ Lambda.Test.e1 ==> "\\x0 -> (\\x1 -> (x0 | x1) & !(x0 & x1))"
33 , Lambda.Test.e2 ==> "\\x0 -> (\\x1 -> x0 & !x1 | !x0 & x1)"
34 , Lambda.Test.e3 ==> "let x0 = True in x0 & x0"
35 , Lambda.Test.e4 ==> "let x0 = \\x1 -> x1 & x1 in x0 True"
36 , Lambda.Test.e5 ==> "\\x0 -> (\\x1 -> x0 & x1)"
37 , Lambda.Test.e6 ==> "(let x0 = True in x0) & False"
38 , Lambda.Test.e7 ==> "\\x0 -> x0 True & True"
39 , Lambda.Test.e8 ==> "\\x0 -> x0 (True & True)"
40 ]
41 , testGroup "Maybe"
42 [ Maybe.Test.e1 ==> "maybe True (\\x0 -> !x0) (just True)"
43 ]
44 , testGroup "Eq"
45 [ Eq.Test.e1 ==> "if True & True == True | False then True else False"
46 , Eq.Test.e2 ==> "if True & True | False == True & (True | False) then True else False"
47 , Eq.Test.e3 ==> "if !(True == False) == (True == True) then True else False"
48 ]
49 {-, testGroup "If"
50 [ If.e1 ==> "if True then False else True"
51 , If.e2 ==> "if True & True then False else True"
52 ]
53 -}]