module HTMLRender.HTMLTest where 

import Data.List ((\\))
import Data.Char (isSpace)

import HTMLRender.HTML
import HTMLRender.HTMLPretty
import HTMLRender.HTMLParser

import Test.QuickCheck

validTags = ["h1", "h2", "h3", "h4", "h5", "h6", "p", "em", "ol", "ul", "li"]
validChars = [' ' .. '~'] \\ ['<', '>', '&'] -- anything that's legal in tag contents

trim :: String -> String
trim = filter (not . isSpace)

generateHTML tags = do {
    tag <- elements tags;
    str <- listOf (elements validChars);
    return ("<" ++ tag ++ ">" ++ (trim str) ++ "</" ++ tag ++ ">");
}

prop_htmlValue = forAll (generateHTML validTags) $ 
    \xs -> toString (customParse htmlValue xs) == xs
    