{-# LANGUAGE FlexibleContexts #-}
module Main (main) where
import Text.HTML.Scalpel
import Control.Applicative
import System.Exit
import Test.HUnit
import qualified Text.HTML.TagSoup as TagSoup
import qualified Text.Regex.TDFA
main = exit . failures =<< runTestTT (TestList [
scrapeTests
, scrapeHtmlsTests
, scrapeHtmlTests
])
exit :: Int -> IO ()
exit 0 = exitSuccess
exit n = exitWith $ ExitFailure n
re :: String -> Text.Regex.TDFA.Regex
re = Text.Regex.TDFA.makeRegex
scrapeTests = "scrapeTests" ~: TestList [
scrapeTest
"foo"
(Just ["foo"])
(htmls ("a" @: []))
, scrapeTest
"foobar"
(Just ["foo", "bar"])
(htmls ("a" @: []))
, scrapeTest
"foo"
(Just ["foo"])
(htmls ("a" @: []))
, scrapeTest
"foo"
(Just ["foo", "foo"])
(htmls ("a" @: []))
, scrapeTest
"foo"
Nothing
(htmls ("b" @: []))
, scrapeTest
"foo"
(Just [""])
(htmls ("a" @: []))
, scrapeTest
"foobar"
(Just ["bar"])
(htmls ("a" @: ["key" @= "value"]))
, scrapeTest
"