on master help sign in
Add tests that looking up attributes works properly
f09f113Neil Mitchell
src/Main.hs+8−1
@@ -45,7 +45,14 @@ main = do
45
45
46 Right _ <- return $ parse $ "<test " <> BS.unwords [BS.pack $ "x" ++ show i ++ "='value'" | i <- [1..10000]] <> " />"
46 Right _ <- return $ parse $ "<test " <> BS.unwords [BS.pack $ "x" ++ show i ++ "='value'" | i <- [1..10000]] <> " />"
47 Right _ <- return $ parse $ BS.unlines $ replicate 10000 "<test x='value' />"
47 Right _ <- return $ parse $ BS.unlines $ replicate 10000 "<test x='value' />"
48+
49+ let attrs = ["usd:jpy","test","extra","more","stuff","jpy:usd","xxx","xxxx"]
50+ Right doc <- return $ parse $ "<test " <> BS.unwords [x <> "='" <> x <> "'" | x <- attrs] <> ">middle</test>"
48− return ()
51+ [c] <- return $ childrenBy doc "test"
52+ forM_ attrs $ \a -> attributeBy c a === Just (Attribute a a)
53+ forM_ ["missing","gone","nothing"] $ \a -> attributeBy c a === Nothing
54+ putStrLn "Done"
55+
49
56
50a === b = if a == b then putStrLn "success" else fail "mismatch"
57a === b = if a == b then putStrLn "success" else fail "mismatch"
51
58