1 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
2 module HUnit.Bool where
5 import Data.Proxy (Proxy(..))
6 import Prelude hiding ((&&), not, (||))
8 import Language.Symantic
9 import Language.Symantic.Lib
10 import Testing.Compiling
19 (==>) = readTe @() @SS
22 hunits = testGroup "Bool" $
23 [ "True" ==> Right (tyBool, True , "True")
24 , "xor True True" ==> Right (tyBool, False, "True `xor` True")
25 , "xor False True" ==> Right (tyBool, True , "False `xor` True")
26 , "True `xor` True" ==> Right (tyBool, False, "True `xor` True")
27 , "(\\(xy:Bool) -> xy) True" ==> Right (tyBool, True , "(\\x0 -> x0) True")
28 , "(\\(False:Bool) -> False) True" ==> Right (tyBool, True , "(\\x0 -> x0) True")
29 , "(\\(lett:Bool) -> lett) True" ==> Right (tyBool, True , "(\\x0 -> x0) True")
30 , "(\\(x:Bool) -> xor x x) True" ==> Right (tyBool, False, "(\\x0 -> x0 `xor` x0) True")
31 , "let x = True in xor x True" ==> Right (tyBool, False, "let x0 = True in x0 `xor` True")
32 , "(\\(False:Bool) -> False) (False `xor` True)" ==> Right (tyBool, True, "(\\x0 -> x0) (False `xor` True)")
33 , testGroup "Error_Term"
34 [ "True True" ==> Left (tyBool,
35 Right $ Error_Term_Beta $
36 Error_Beta_Term_not_a_function $
37 TypeVT $ tyBool @_ @'[])
38 , "x" ==> Left (tyBool,
39 Right $ Error_Term_unknown $ NameTe "x")
40 , "x `xor` True" ==> Left (tyBool,
41 Right $ Error_Term_unknown $ NameTe "x")
42 , "(\\(x:Bool) -> x `xor` True) Bool" ==> Left (tyBool,
43 Right $ Error_Term_unknown $ NameTe "Bool")
44 , "(\\(x:Bool) -> x) True True" ==> Left (tyBool,
45 Right $ Error_Term_Beta $
46 Error_Beta_Term_not_a_function $
47 TypeVT $ tyBool @_ @'[])
48 , "(\\(x:Bool -> Bool) -> x True) True" ==> Left (tyBool,
49 Right $ Error_Term_Beta $ Error_Beta_Unify $
50 Error_Unify_Const_mismatch
51 (TypeVT $ tyFun @_ @'[])
52 (TypeVT $ tyBool @_ @'[]))
56 -- * Class 'Sym_Bool_Vars'
57 -- | A few boolean variables.
58 class Sym_Bool_Vars repr where
62 instance Sym_Bool_Vars View where
63 x = View $ \_p _v -> "x"
64 y = View $ \_p _v -> "y"
65 z = View $ \_p _v -> "z"
67 instance -- Trans_Boo_Const
70 ) => Sym_Bool_Vars (Trans_Bool_Const repr) where
77 te1 = bool True && bool False
78 te2 = (bool True && bool False) || (bool True && bool True)
79 te3 = (bool True || bool False) && (bool True || bool True)
80 te4 = bool True && not (bool False)
81 te5 = bool True && not x
83 te7 = (x `xor` y) `xor` z
84 te8 = x `xor` (y `xor` bool True)