@@ -14,24 +14,80 @@ import Test.Hspec
14import Servant.API
14import Servant.API
15{-import Servant.API.QQ-}
15{-import Servant.API.QQ-}
17−data HTrue
17+--------------------------------------------------------------------------
18−data HFalse
18+-- Types for testing
19+--------------------------------------------------------------------------
20−-- Kiselyov's Type Equality predicate
21−class TypeEq x y b | x y -> b where { areEq :: x -> y -> Bool }
22−instance TypeEq x x HTrue where { areEq _ _ = True }
23−instance b ~ HFalse => TypeEq x y b where { areEq _ _ = False}
25type SimpleGet = [sitemap|
22type SimpleGet = [sitemap|
26GET hello ()
23GET hello ()
29type SimpleGet' = "hello" :> Get ()
25type SimpleGet' = "hello" :> Get ()
30type SimpleGet'' = "hello" :> Get Bool
26type SimpleGet'' = "hello" :> Get Bool
28+type SimpleGet2 = [sitemap|
31+type SimpleGet2' = "hello" :> Get Bool
32+type SimpleGet2'' = "hello" :> Get Int
34+type SimplePost = [sitemap|
37+type SimplePost' = "hello" :> Post ()
38+type SimplePost'' = "hello" :> Post Bool
40+type SimplePost2 = [sitemap|
43+type SimplePost2' = "hello" :> Post Bool
44+type SimplePost2'' = "hello" :> Post ()
46+type SimpleReqBody = [sitemap|
49+type SimpleReqBody' = "hello" :> ReqBody () :> Post Bool
50+type SimpleReqBody'' = "hello" :> ReqBody Bool :> Post ()
52+--------------------------------------------------------------------------
54+--------------------------------------------------------------------------
32spec :: Spec
56spec :: Spec
34 describe "'sitemap' QuasiQuoter" $ do
58 describe "'sitemap' QuasiQuoter" $ do
35 it "Handles simple GET types" $ do
59 it "Handles simple GET types" $ do
36− areEq (undefined::SimpleGet) (undefined::SimpleGet') `shouldBe` True
60+ (u::SimpleGet) ~= (u::SimpleGet' ) ~> True
37− areEq (undefined::SimpleGet) (undefined::SimpleGet'') `shouldBe` False
61+ (u::SimpleGet) ~= (u::SimpleGet'' ) ~> False
62+ (u::SimpleGet2) ~= (u::SimpleGet2' ) ~> True
63+ (u::SimpleGet2) ~= (u::SimpleGet2'') ~> False
64+ it "Handles simple POST types" $ do
65+ (u::SimplePost) ~= (u::SimplePost' ) ~> True
66+ (u::SimplePost) ~= (u::SimplePost'' ) ~> False
67+ (u::SimplePost2) ~= (u::SimplePost2' ) ~> True
68+ (u::SimplePost2) ~= (u::SimplePost2'') ~> False
69+ it "Handles simple request body types" $ do
70+ (u::SimpleReqBody) ~= (u::SimpleReqBody' ) ~> True
71+ (u::SimpleReqBody) ~= (u::SimpleReqBody'') ~> False
74+--------------------------------------------------------------------------
76+--------------------------------------------------------------------------
80+-- Kiselyov's Type Equality predicate
81+class TypeEq x y b | x y -> b where { areEq :: x -> y -> Bool }
82+instance TypeEq x x HTrue where { areEq _ _ = True }
83+instance b ~ HFalse => TypeEq x y b where { areEq _ _ = False}
86+(~=) :: TypeEq x y b => x -> y -> Bool