@@ -28,6 +28,7 @@ main = do
2828 Left err -> when parses $ fail $ "Unexpected parse failure, " ++ show err
2929 Right doc -> do
3030 unless parses $ fail "Unexpected parse success"
31+ checkFind doc
3132 let r = render doc
3233 print r
3334 print $ rerender doc
@@ -54,6 +55,16 @@ main = do
5455 putStrLn "Done"
5556
5657
58+checkFind :: Node -> IO ()
59+checkFind n = do
60+ forM_ (attributes n) $ \a -> attributeBy n (attributeName a) === Just a
61+ attributeBy n "xxx" === Nothing
62+ let cs = children n
63+ forM_ ("xxx":map name cs) $ \c ->
64+ map outer (filter ((==) c . name) cs) === map outer (childrenBy n c)
65+ mapM_ checkFind $ children n
66+
67+
5768a === b = if a == b then putStrLn "success" else fail "mismatch"
5869
5970rerender :: Node -> BS.ByteString