hslua-core 2.0.0 → 2.0.0.1
raw patch · 4 files changed
+32/−5 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +9/−1
- hslua-core.cabal +1/−1
- src/HsLua/Core/Error.hs +1/−1
- test/HsLua/Core/ErrorTests.hs +21/−2
CHANGELOG.md view
@@ -4,9 +4,17 @@ [1]: https://pvp.haskell.org +## hslua-core 2.0.0.1++Released 2021-10-29.++- Fixed bug in pushTypeMismatchError. The function did not use an+ absolute stack index in one place, which sometimes lead to+ incorrect actual types being reported.+ ## hslua-core 2.0.0 -Release pending.+Released 2021-10-21. - Error handling has been reworked completely. The type of exceptions used and handled by HsLua is now exposed to the type
hslua-core.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: hslua-core-version: 2.0.0+version: 2.0.0.1 synopsis: Bindings to Lua, an embeddable scripting language description: Wrappers and helpers to bridge Haskell and <https://www.lua.org/ Lua>.
src/HsLua/Core/Error.hs view
@@ -206,7 +206,7 @@ let pushtype = lua_type l idx' >>= lua_typename l >>= lua_pushstring l pushstring expected pushstring " expected, got "- B.unsafeUseAsCString "__name" (luaL_getmetafield l idx) >>= \case+ B.unsafeUseAsCString "__name" (luaL_getmetafield l idx') >>= \case LUA_TSTRING -> return () -- pushed the name LUA_TNIL -> void pushtype _ -> lua_pop l 1 <* pushtype
test/HsLua/Core/ErrorTests.hs view
@@ -11,9 +11,11 @@ import Data.Typeable (Typeable) import Data.Either (isLeft) import HsLua.Core (Lua, failLua)-import HsLua.Core.Error (LuaError, changeErrorType, popErrorMessage)+import HsLua.Core.Error ( LuaError, changeErrorType, popErrorMessage+ , throwTypeMismatchError) import HsLua.Core.Types (liftLua)-import Test.Tasty.HsLua ( (=:), (?:), shouldBeResultOf, shouldHoldForResultOf)+import Test.Tasty.HsLua ( (=:), (?:), shouldBeResultOf, shouldHoldForResultOf+ , shouldBeErrorMessageOf) import Test.Tasty (TestTree, testGroup) import qualified HsLua.Core as Lua@@ -41,6 +43,23 @@ Just "plant" `shouldBeResultOf` do Lua.pushstring "plant" changeErrorType (Lua.tostring Lua.top)+ ]++ , testGroup "type mismatch"+ [ "got string" =:+ "number expected, got string" `shouldBeErrorMessageOf` do+ Lua.pushstring "moin"+ throwTypeMismatchError "number" Lua.top :: Lua ()+ , "got unnamed userdata" =:+ "number expected, got userdata" `shouldBeErrorMessageOf` do+ Lua.newhsuserdata ()+ throwTypeMismatchError "number" Lua.top :: Lua ()+ , "named userdata" =:+ "Bar expected, got Foo" `shouldBeErrorMessageOf` do+ Lua.newhsuserdata ()+ Lua.newudmetatable "Foo"+ Lua.setmetatable (Lua.nth 2)+ throwTypeMismatchError "Bar" Lua.top :: Lua () ] ]