tasty-hslua-1.1.1: Tasty helpers to test HsLua.

Copyright | © 2017-2024 Albert Krewinkel
License | MIT
Maintainer | Albert Krewinkel <tarleb@hslua.org>
Stability | beta
Portability | non-portable (depends on GHC)
Safe Haskell | None
Language | Haskell2010

Test.Tasty.HsLua

Description

Utilities for testing of HsLua operations.

Synopsis

- assertLuaBool :: HasCallStack => LuaE e Bool -> Assertion
- pushLuaExpr :: LuaError e => ByteString -> LuaE e ()
- shouldBeErrorMessageOf :: (HasCallStack, Show a) => String -> Lua a -> Assertion
- shouldBeResultOf :: (HasCallStack, Eq a, Show a) => a -> Lua a -> Assertion
- shouldHoldForResultOf :: (HasCallStack, Show a) => (a -> Bool) -> Lua a -> Assertion
- (=:) :: String -> Assertion -> TestTree
- (?:) :: HasCallStack => String -> LuaE e Bool -> TestTree

# Documentation

assertLuaBool :: HasCallStack => LuaE e Bool -> Assertion Source #

Checks whether the operation returns `True`.

pushLuaExpr :: LuaError e => ByteString -> LuaE e () Source #

Takes a Lua expression as a `ByteString`, evaluates it and pushes the result to the stack.

    -- will return "12"
    run $ do
      pushLuaExpr "7 + 5"
      tointeger top

shouldBeErrorMessageOf :: (HasCallStack, Show a) => String -> Lua a -> Assertion Source #

Checks whether a `Lua` operation fails with the given string as error message.

shouldBeResultOf :: (HasCallStack, Eq a, Show a) => a -> Lua a -> Assertion Source #

Takes a value and a `Lua` operation and turns them into an `Assertion` which checks that the operation produces the given value.

shouldHoldForResultOf :: (HasCallStack, Show a) => (a -> Bool) -> Lua a -> Assertion Source #

Checks whether the return value of an operation holds for the given predicate.

(=:) :: String -> Assertion -> TestTree infix 3 Source #

Infix alias for `testCase`.

(?:) :: HasCallStack => String -> LuaE e Bool -> TestTree infixr 3 Source #

Infix alias for `luaTestBool`.