
> {-# LANGUAGE OverloadedStrings #-}
> module Database.HsSqlPpp.Tests.TypeChecking.CaseExpressions
>     (caseExpressions) where
>
> import Database.HsSqlPpp.Tests.TestTypes


> import Database.HsSqlPpp.Types
>
>
> caseExpressions :: Item
> caseExpressions =
>   Group "case expressions" [
>       e "case\n\
>         \ when true then 1\n\
>         \end" $ Right typeInt
>      ,e "case\n\
>         \ when 1=2 then 'stuff'\n\
>         \ when 2=3 then 'blah'\n\
>         \ else 'test'\n\
>         \end" $ Right UnknownType
>      ,e "case\n\
>         \ when 1=2 then 'stuff'\n\
>         \ when 2=3 then 'blah'\n\
>         \ else 'test'::text\n\
>         \end" $ Right $ ScalarType "text"
>      ,e "case\n\
>         \ when 1=2 then 'stuff'\n\
>         \ when true=3 then 'blah'\n\
>         \ else 'test'\n\
>         \end" $ Left [NoMatchingOperator "=" [typeBool,typeInt]]
>      ,e "case\n\
>         \ when 1=2 then true\n\
>         \ when 2=3 then false\n\
>         \ else 1\n\
>         \end" $ Left [IncompatibleTypeSet [typeBool
>                                         ,typeBool
>                                         ,typeInt]]
>      ,e "case\n\
>         \ when 1=2 then false\n\
>         \ when 2=3 then 1\n\
>         \ else true\n\
>         \end" $ Left [IncompatibleTypeSet [typeBool
>                                           ,typeInt
>                                           ,typeBool]]
>      ,e "case 1 when 2 then 3 else 4 end" $ Right typeInt
>      ,e "case 1 when true then 3 else 4 end"
>             $ Left [IncompatibleTypeSet [ScalarType "int4"
>                                          ,ScalarType "bool"]]
>      ,e "case 1 when 2 then true else false end" $ Right typeBool
>      ,e "case 1 when 2 then 3 else false end"
>             $ Left [IncompatibleTypeSet [ScalarType "int4"
>                                          ,ScalarType "bool"]]
>      ]
>  where
>    e = ScalExpr

