{-# LANGUAGE OverloadedStrings #-}
-- | Simple test suite.
module Main where
import Data.ByteString (ByteString)
import Test.Hspec
import Xeno.SAX
import Xeno.DOM
import Xeno.Types
-- import Control.Monad.Catch
import Data.Either
-- main = print "hello!"
main :: IO ()
main = hspec spec
spec :: SpecWith ()
spec =
describe
"hexml tests"
(do mapM_
(\(v, i) -> it (show i) (shouldBe (Xeno.SAX.validate i) v))
hexml_examples_sax
let doc =
parse
"\n"
it
"children test"
(shouldBe
(map name (children $ fromRightE doc))
["test", "test", "b", "test", "test"])
it
"attributes"
(shouldBe
(attributes (head (children $ fromRightE doc)))
[("id", "1"), ("extra", "2")]))
hexml_examples_sax :: [(Bool, ByteString)]
hexml_examples_sax =
[(True, "herethere")
,(True, "")
,(True, "")
,(True, "here more text at the end")
,(True, "") -- SAX doesn't care about tag balancing
,(False, "\nHello, world!")
]
-- | Horrible hack. Don't try this at home.
fromRightE :: Either XenoException a -> a
fromRightE = either (error. show) id