1 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE NoMonomorphismRestriction #-}
4 {-# LANGUAGE ScopedTypeVariables #-}
5 {-# LANGUAGE TypeOperators #-}
6 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
8 module Expr.Eq.Test where
11 import Test.Tasty.HUnit
13 import qualified Control.Arrow as Arrow
14 import qualified Control.Monad as Monad
15 import Data.Proxy (Proxy(..))
16 import Data.Text (Text)
17 import Data.Type.Equality ((:~:)(Refl))
18 import Prelude hiding ((&&), not, (||), (==))
20 import Language.Symantic.Type
21 import Language.Symantic.Expr
22 import Language.Symantic.Repr
29 e1 = if_ ((t && t) == (t || f)) t f
30 e2 = if_ (((t && t) || f) == (t && (t || f))) t f
31 e3 = if_ (not (t == f) == (t == t)) t f
39 ex_from = root_expr_from (Proxy::Proxy Ex)
44 Left err -> Left err @?= Prelude.snd `Arrow.left` expected
45 Right (Exists_Type0_and_Repr ty (Forall_Repr r)) ->
47 Left (_, err) -> Right ("…"::String) @?= Left err
48 Right (ty_expected::Type_Root_of_Expr Ex h, _::h, _::Text) ->
49 (Monad.>>= (@?= (\(_::Proxy h, err) -> err) `Arrow.left` expected)) $
50 case ty `type0_eq` ty_expected of
51 Nothing -> Monad.return $ Left $
52 error_expr (Proxy::Proxy Ex) $
53 Error_Expr_Type_mismatch ast
55 (Exists_Type0 ty_expected)
57 let h = host_from_expr r
63 -- , (text_from_expr :: Repr_Text h -> Text) r
67 tests = testGroup "Eq"
68 [ AST "==" [ AST "bool" [AST "True" []]
69 , AST "bool" [AST "True" []]
78 , AST "==" [ AST "var" [AST "x" []]
79 , AST "not" [AST "var" [AST "x" []]] ]
81 , AST "bool" [AST "True" []]
85 , "(\\x0 -> x0 == not x0) True" )