A
B
C
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Text.HTML.Scalpel
import Control.Applicative
import Control.Monad (guard)
import Data.List (isInfixOf)
import System.Exit
import Test.HUnit
import qualified Text.HTML.TagSoup as TagSoup
import qualified Text.Regex.TDFA
main = exit . failures =<< runTestTT (TestList [scrapeTests])
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"
(Just [])
(htmls ("b" @: []))
, scrapeTest
"foo"
(Just [""])
(htmls ("a" @: []))
, scrapeTest
"foobar"
(Just ["bar"])
(htmls ("a" @: ["key" @= "value"]))
, scrapeTest
"
A
B
C
A
B
C