1{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE ScopedTypeVariables #-}
5{-# OPTIONS_GHC -Wall -Werror -fno-warn-orphans #-}
7module Text.HTML.TreeSpec
10import Control.Applicative
14import Test.QuickCheck.Instances ()
15import Text.HTML.Parser
16import Text.HTML.ParserSpec
21arbitraryTokenForest :: Gen (Forest Token)
22arbitraryTokenForest = listOf arbitraryTokenTree
24arbitraryTokenTree :: Gen (Tree Token)
25arbitraryTokenTree = oneof
26 [ Node <$> validClosingOpen <*> scale (`div` 5) arbitraryTokenForest
27 , Node <$> validNonClosingOpen <*> pure []
28 , Node <$> validFlat <*> pure []
32validNonClosingOpen :: Gen Token
33validNonClosingOpen = TagOpen <$> elements nonClosing <*> arbitrary
35validClosingOpen :: Gen Token
38 let n' = if n `elem` nonClosing then "_" else n
39 TagOpen n' <$> arbitrary
44 it "parseTokenForests and renderTokenForest are inverses"
45 . property . forAllShrink arbitraryTokenForest shrink $
46 \forest -> tokensToForest (tokensFromForest forest) `shouldBe` Right forest
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list