Skip to content

Commit

Permalink
Commit failing test: route capture should not match empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorycollins committed Mar 9, 2012
1 parent 42d77f3 commit d0e4b72
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/suite/Snap/Internal/Routing/Tests.hs
Expand Up @@ -6,6 +6,7 @@ module Snap.Internal.Routing.Tests
( tests ) where

------------------------------------------------------------------------------
import Control.Applicative ((<|>))
import Control.Monad
import Data.ByteString (ByteString)
import qualified Data.ByteString as S
Expand Down Expand Up @@ -55,6 +56,7 @@ tests = [ testRouting1
, testRouteLocal
, testRouteUrlDecode
, testRouteUrlEncodedPath
, testRouteEmptyCapture
]


Expand Down Expand Up @@ -128,6 +130,11 @@ routes7 = route [ ("foo/:id" , fooCapture )
, ("" , topTop ) ]


------------------------------------------------------------------------------
routesEmptyCapture :: Snap ByteString
routesEmptyCapture = route [ ("foo/:id", fooCapture) ]


------------------------------------------------------------------------------
topTop, topFoo, fooBar, fooCapture, getRqPathInfo, bar,
getRqContextPath, barQuux, dblA, zabc, topCapture,
Expand Down Expand Up @@ -393,3 +400,17 @@ testRouteLocal = testCase "route/routeLocal" $ do
r4 <- go routesLocal "foo/bar/baz/quux"
assertEqual "/foo/bar/baz/quux" "foo/bar/baz/quux" r4
expectExceptionH $ go routesLocal "bar"


------------------------------------------------------------------------------
testRouteEmptyCapture :: Test
testRouteEmptyCapture = testCase "route/emptyCapture" $ do
r <- go m "foo"
assertEqual "empty capture must fail" expected r

r2 <- go m "foo/"
assertEqual "empty capture must fail" expected r2

where
expected = "ZOMG_OK"
m = routesEmptyCapture <|> return expected

0 comments on commit d0e4b72

Please sign in to comment.