on master help sign in
Added bigtable tests
commit7078cc5633f19268ec6ca06763de67b1d856092c authorMichael <michael@snoyman.com> dateFri 7 Jan 2011, 13:33 (16 years ago) parent1c5837e
2 files changed+46
bigtable-single.hs+22 bigtable-stream.hs+24
bigtable-single.hsnew file+22
@@ -0,0 +1,22 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+import Network.Wai
3+import Blaze.ByteString.Builder (Builder, fromByteString)
4+import Blaze.ByteString.Builder.Char8 (fromShow)
5+import Data.Monoid (mappend)
6+import Network.Wai.Handler.Warp (run)
7+
8+bigtable :: Builder
9+bigtable =
10+ fromByteString "<table>"
11+ `mappend` foldr mappend (fromByteString "</table>") (replicate 2 row)
12+ where
13+ row = fromByteString "<tr>"
14+ `mappend` foldr go (fromByteString "</tr>") [1..2]
15+ go i rest = fromByteString "<td>"
16+ `mappend` fromShow i
17+ `mappend` fromByteString "</td>"
18+ `mappend` rest
19+
20+main = run 3000 app
21+
22+app _ = return $ ResponseBuilder status200 [("Content-Type", "text/html")] bigtable
bigtable-stream.hsnew file+24
@@ -0,0 +1,24 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+import Network.Wai
3+import Blaze.ByteString.Builder (Builder, fromByteString)
4+import Blaze.ByteString.Builder.Char8 (fromShow)
5+import Data.Monoid (mappend)
6+import Network.Wai.Handler.Warp (run)
7+import Data.Enumerator (enumList, ($$), run_)
8+
9+bigtable :: [Builder]
10+bigtable =
11+ fromByteString "<table>"
12+ : foldr (:) [fromByteString "</table>"] (replicate 2 row)
13+ where
14+ row = fromByteString "<tr>"
15+ `mappend` foldr go (fromByteString "</tr>") [1..2]
16+ go i rest = fromByteString "<td>"
17+ `mappend` fromShow i
18+ `mappend` fromByteString "</td>"
19+ `mappend` rest
20+
21+main = run 3000 app
22+
23+app _ = return $ ResponseEnumerator $ \f ->
24+ run_ $ enumList 4 bigtable $$ f status200 [("Content-Type", "text/html")]