1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-deprecations #-}
{-|
Module : HsLua.Core.RunTests
Copyright : © 2017-2024 Albert Krewinkel
License : MIT
Maintainer : Albert Krewinkel <tarleb@hslua.org>
Stability : stable
Portability : portable
Tests for different convenience functions to run Lua operations.
-}
module HsLua.Core.RunTests (tests) where
import Data.Either (isLeft, isRight)
import HsLua.Core as Lua
import Test.Tasty.HsLua ((=:), shouldHoldForResultOf)
import Test.Tasty (TestTree, testGroup)
-- | Specifications for Attributes parsing functions.
tests :: TestTree
tests = testGroup "Run"
[ testGroup "runEither"
[ "Lua errors are caught" =:
isLeft `shouldHoldForResultOf`
liftIO (runEither (failLua "failing" :: Lua Bool))
, "error-less code gives 'Right'" =:
isRight `shouldHoldForResultOf`
liftIO (runEither @Lua.Exception (pushboolean True *> toboolean top))
]
]
|