on master help sign in
Add tests that looking up attributes works properly
commitf09f1134ae9bb9c46eb9fe6ed233fe3b47f9deaa authorNeil Mitchell <ndmitchell@gmail.com> dateWed 30 Nov 2016, 19:08 (10 years ago) parentb4b0036
1 file changed+8−1
src/Main.hs+8−1
src/Main.hs+8−1
@@ -45,7 +45,14 @@ main = do
4545
4646 Right _ <- return $ parse $ "<test " <> BS.unwords [BS.pack $ "x" ++ show i ++ "='value'" | i <- [1..10000]] <> " />"
4747 Right _ <- return $ parse $ BS.unlines $ replicate 10000 "<test x='value' />"
48− return ()
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>"
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+
4956
5057a === b = if a == b then putStrLn "success" else fail "mismatch"
5158