@@ -5,7 +5,7 @@ import Test.Framework (defaultMain, testGroup, Test)
55import Test.Framework.Providers.HUnit
66import Test.HUnit hiding (Test)
77
8−import Network.Wai.Handler.Warp (takeLineMax, takeHeaders, InvalidRequest (..))
8+import Network.Wai.Handler.Warp (takeHeaders, InvalidRequest (..))
99import Data.Enumerator (run_, ($$), enumList, run)
1010import Control.Exception (fromException)
1111
@@ -14,54 +14,21 @@ main = defaultMain [testSuite]
1414
1515testSuite :: Test
1616testSuite = testGroup "Text.Hamlet"
17− [ testCase "takeLineMax safe" caseTakeLineMaxSafe
18− , testCase "takeUntilBlank safe" caseTakeUntilBlankSafe
19− , testCase "takeLineMax unsafe" caseTakeLineMaxUnsafe
20− , testCase "takeLineMax incomplete" caseTakeLineMaxIncomplete
17+ [ testCase "takeUntilBlank safe" caseTakeUntilBlankSafe
2118 , testCase "takeUntilBlank too many lines" caseTakeUntilBlankTooMany
2219 , testCase "takeUntilBlank too large" caseTakeUntilBlankTooLarge
2320 ]
2421
25−caseTakeLineMaxSafe = do
26− x <- run_ $ (enumList 1 ["f", "oo\n\n", "bar\n\r\nbaz\n"]) $$ do
27− a <- takeLineMax 0 id
28− b <- takeLineMax 0 id
29− c <- takeLineMax 0 id
30− d <- takeLineMax 0 id
31− e <- takeLineMax 0 id
32− return (a, b, c, d, e)
33− x @?= ("foo", "", "bar", "", "baz")
34−
3522caseTakeUntilBlankSafe = do
3623 x <- run_ $ (enumList 1 ["f", "oo\n", "bar\nbaz\n\r\n"]) $$ takeHeaders
3724 x @?= ["foo", "bar", "baz"]
3825
39−caseTakeLineMaxUnsafe = do
40− x <- run $ (enumList 1 $ repeat "abc") $$ do
41− a <- takeLineMax 0 id
42− b <- takeLineMax 0 id
43− c <- takeLineMax 0 id
44− d <- takeLineMax 0 id
45− e <- takeLineMax 0 id
46− return (a, b, c, d, e)
47− assertException OverLargeHeader x
48−
4926assertException x (Left se) =
5027 case fromException se of
5128 Just e -> e @?= x
5229 Nothing -> assertFailure "Not an exception"
5330assertException _ _ = assertFailure "Not an exception"
5431
55−caseTakeLineMaxIncomplete = do
56− x <- run $ (enumList 1 ["f", "oo\n\n", "bar\n\nbaz"]) $$ do
57− a <- takeLineMax 0 id
58− b <- takeLineMax 0 id
59− c <- takeLineMax 0 id
60− d <- takeLineMax 0 id
61− e <- takeLineMax 0 id
62− return (a, b, c, d, e)
63− assertException IncompleteHeaders x
64−
6532caseTakeUntilBlankTooMany = do
6633 x <- run $ (enumList 1 $ repeat "f\n") $$ takeHeaders
6734 assertException OverLargeHeader x