file-embed/test/main.hs
2015-08-14 09:47:56 +03:00

22 lines
580 B
Haskell

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad (unless)
import Data.FileEmbed
import System.FilePath ((</>))
infix 1 @?=
(@?=) :: (Eq a, Show a) => a -> a -> IO ()
actual @?= expected = unless (actual == expected) (error $ "expected: " ++ show expected ++ "\n but got: " ++ show actual)
main :: IO ()
main = do
let received = $(embedDir "test/sample")
received @?=
[ ("foo", "foo\r\n")
, ("bar" </> "baz", "baz\r\n")
]
let str = $(embedStringFile "test/sample/foo") :: String
str @?= "foo\r\n"