{-# LANGUAGE TemplateHaskell #-}
module Test.Tasty.Lua.Module
( pushModule )
where
import Data.ByteString (ByteString)
import Data.FileEmbed
import HsLua.Core
(LuaE, LuaError, NumResults, Status (OK), dostring, throwErrorAsException)
tastyScript :: ByteString
tastyScript :: ByteString
tastyScript = $(embedFile "tasty.lua")
pushModule :: LuaError e => LuaE e NumResults
pushModule :: LuaE e NumResults
pushModule = do
Status
result <- ByteString -> LuaE e Status
forall e. ByteString -> LuaE e Status
dostring ByteString
tastyScript
if Status
result Status -> Status -> Bool
forall a. Eq a => a -> a -> Bool
== Status
OK
then NumResults -> LuaE e NumResults
forall (m :: * -> *) a. Monad m => a -> m a
return NumResults
1
else LuaE e NumResults
forall e a. LuaError e => LuaE e a
throwErrorAsException
{-# INLINABLE pushModule #-}