1 module Repr.Text.Test where
4 import Test.Tasty.HUnit
6 import qualified Data.Text as Text
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
20 tests = testGroup "Text" $
21 let (==>) expr expected =
22 testCase (Text.unpack expected) $
24 text_from_expr expr in
26 [ Bool.Test.e1 ==> "True && False"
27 , Bool.Test.e2 ==> "True && False || True && True"
28 , Bool.Test.e3 ==> "(True || False) && (True || True)"
29 , Bool.Test.e4 ==> "True && !False"
30 , Bool.Test.e5 ==> "True && !x"
31 , Bool.Test.e6 ==> "xor x y"
32 , Bool.Test.e7 ==> "xor (xor x y) z"
33 , Bool.Test.e8 ==> "xor x (xor y True)"
36 [ Lambda.Test.e1 ==> "\\x0 -> (\\x1 -> (x0 || x1) && !(x0 && x1))"
37 , Lambda.Test.e2 ==> "\\x0 -> (\\x1 -> x0 && !x1 || !x0 && x1)"
38 , Lambda.Test.e3 ==> "let x0 = True in x0 && x0"
39 , Lambda.Test.e4 ==> "let x0 = \\x1 -> x1 && x1 in x0 True"
40 , Lambda.Test.e5 ==> "\\x0 -> (\\x1 -> x0 && x1)"
41 , Lambda.Test.e6 ==> "(let x0 = True in x0) && False"
42 , Lambda.Test.e7 ==> "\\x0 -> x0 True && True"
43 , Lambda.Test.e8 ==> "\\x0 -> x0 (True && True)"
46 [ Maybe.Test.e1 ==> "maybe True (\\x0 -> !x0) (just True)"
49 [ Eq.Test.e1 ==> "if True && True == True || False then True else False"
50 , Eq.Test.e2 ==> "if True && True || False == True && (True || False) then True else False"
51 , Eq.Test.e3 ==> "if !(True == False) == (True == True) then True else False"
54 [ If.Test.e1 ==> "if True then False else True"
55 , If.Test.e2 ==> "if True && True then False else True"
58 [ List.Test.e1 ==> "list_filter (\\x0 -> if x0 % 2 == 0 then True else False) [1, 2, 3, 4, 5]"
61 [ Functor.Test.e1 ==> "fmap (\\x0 -> x0 + 1) [1, 2, 3]"
63 , testGroup "Applicative"
64 [ Applicative.Test.e1 ==> "fmap (\\x0 -> (\\x1 -> x0 + x1)) (just 1) <*> just 2"
66 , testGroup "Foldable"
67 [ Foldable.Test.e1 ==> "foldMap (\\x0 -> [x0, x0]) [1, 2, 3]"