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