]> Git — Sourcephile - haskell/symantic.git/blob - Language/Symantic/Repr/Text/Test.hs
polish names
[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 import qualified Expr.Functor.Test as Functor.Test
16 import qualified Expr.Applicative.Test as Applicative.Test
17 import qualified Expr.Foldable.Test as Foldable.Test
18 import qualified Expr.Map.Test as Map.Test
19
20 tests :: TestTree
21 tests = testGroup "Text" $
22 let (==>) expr expected =
23 testCase (Text.unpack expected) $
24 (@?= expected) $
25 text_from_expr expr in
26 [ testGroup "Bool"
27 [ Bool.Test.e1 ==> "True && False"
28 , Bool.Test.e2 ==> "True && False || True && True"
29 , Bool.Test.e3 ==> "(True || False) && (True || True)"
30 , Bool.Test.e4 ==> "True && not False"
31 , Bool.Test.e5 ==> "True && not x"
32 , Bool.Test.e6 ==> "x `xor` y"
33 , Bool.Test.e7 ==> "(x `xor` y) `xor` z"
34 , Bool.Test.e8 ==> "x `xor` (y `xor` True)"
35 ]
36 , testGroup "Lambda"
37 [ Lambda.Test.e1 ==> "\\x0 -> (\\x1 -> (x0 || x1) && not (x0 && x1))"
38 , Lambda.Test.e2 ==> "\\x0 -> (\\x1 -> x0 && not x1 || not x0 && x1)"
39 , Lambda.Test.e3 ==> "let x0 = True in x0 && x0"
40 , Lambda.Test.e4 ==> "let x0 = \\x1 -> x1 && x1 in x0 True"
41 , Lambda.Test.e5 ==> "\\x0 -> (\\x1 -> x0 && x1)"
42 , Lambda.Test.e6 ==> "(let x0 = True in id x0) && False"
43 , Lambda.Test.e7 ==> "\\x0 -> x0 True && True"
44 , Lambda.Test.e8 ==> "\\x0 -> x0 (True && True)"
45 ]
46 , testGroup "Maybe"
47 [ Maybe.Test.e1 ==> "maybe True (\\x0 -> not x0) (just True)"
48 ]
49 , testGroup "Eq"
50 [ Eq.Test.e1 ==> "if True && True == True || False then True else False"
51 , Eq.Test.e2 ==> "if True && True || False == True && (True || False) then True else False"
52 , Eq.Test.e3 ==> "if not (True == False) == (True == True) then True else False"
53 ]
54 , testGroup "If"
55 [ If.Test.e1 ==> "if True then False else True"
56 , If.Test.e2 ==> "if True && True then False else True"
57 ]
58 , testGroup "List"
59 [ List.Test.e1 ==> "list_filter (\\x0 -> if x0 `mod` 2 == 0 then True else False) [1, 2, 3, 4, 5]"
60 ]
61 , testGroup "Functor"
62 [ Functor.Test.e1 ==> "fmap (\\x0 -> x0 + 1) [1, 2, 3]"
63 ]
64 , testGroup "Applicative"
65 [ Applicative.Test.e1 ==> "fmap (\\x0 -> (\\x1 -> x0 + x1)) (just 1) <*> just 2"
66 ]
67 , testGroup "Foldable"
68 [ Foldable.Test.e1 ==> "foldMap (\\x0 -> [x0, x0]) [1, 2, 3]"
69 ]
70 , testGroup "Map"
71 [ Map.Test.e1 ==> "map_from_list (list_zipWith (\\x0 -> (\\x1 -> (x0, x1))) [1, 2, 3, 4, 5] [\"a\", \"b\", \"c\", \"d\", \"e\"])"
72 ]
73 ]