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.LOL.Symantic.Repr
19 import Language.LOL.Symantic.AST
20 import Language.LOL.Symantic.Expr
21 import Language.LOL.Symantic.Type
31 case expr_lambda_if_bool_from (Proxy::Proxy IO) ast of
32 Left err -> Left err @?= snd `left` expected
33 Right (Exists_Type_and_Repr ty (Forall_Repr r)) ->
35 Left (_, err) -> Right ("…"::String) @?= Left err
36 Right (ty_expected::Type_Root_of_Expr (Expr_Lambda_If_Bool IO) h, _::h, _::Text) ->
37 (>>= (@?= (\(_::Proxy h, err) -> err) `left` expected)) $
38 case ty `type_eq` ty_expected of
39 Nothing -> return $ Left $
40 error_expr (Proxy::Proxy (Expr_Lambda_If_Bool IO)) $
41 Error_Expr_Type_mismatch ast
43 (Exists_Type ty_expected)
51 -- , (text_from_expr :: Repr_String IO h -> String) r
55 tests = testGroup "If"
57 [ AST "bool" [AST "True" []]
58 , AST "bool" [AST "False" []]
59 , AST "bool" [AST "True" []]
63 , "if True then False else True" )