1 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE NoMonomorphismRestriction #-}
4 {-# LANGUAGE Rank2Types #-}
5 {-# LANGUAGE ScopedTypeVariables #-}
6 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
7 module Expr.If.Test where
10 import Test.Tasty.HUnit
12 import Control.Arrow (left)
13 import Data.Proxy (Proxy(..))
14 import Data.Text (Text)
15 import Data.Type.Equality ((:~:)(Refl))
16 import Prelude hiding (maybe, not)
18 import Language.Symantic.Repr
19 import Language.Symantic.Expr
20 import Language.Symantic.Type
32 case expr_lambda_if_bool_from (Proxy::Proxy IO) ast of
33 Left err -> Left err @?= snd `left` expected
34 Right (Exists_Type_and_Repr ty (Forall_Repr r)) ->
36 Left (_, err) -> Right ("…"::String) @?= Left err
37 Right (ty_expected::Type_Root_of_Expr (Expr_Lambda_If_Bool IO) h, _::h, _::Text) ->
38 (>>= (@?= (\(_::Proxy h, err) -> err) `left` expected)) $
39 case ty `type_eq` ty_expected of
40 Nothing -> return $ Left $
41 error_expr (Proxy::Proxy (Expr_Lambda_If_Bool IO)) $
42 Error_Expr_Type_mismatch ast
44 (Exists_Type ty_expected)
52 -- , (text_from_expr :: Repr_String IO h -> String) r
56 tests = testGroup "If"
58 [ AST "bool" [AST "True" []]
59 , AST "bool" [AST "False" []]
60 , AST "bool" [AST "True" []]
64 , "if True then False else True" )