Export pushAny, safePeekAny from Foreign.Lua
Those are the main functions intended for library users.
@@ -46,7 +46,7 @@ tests = testGroup "Userdata"
assertEqual "" "HSLUA_Data.Word.Word64" (metatableName (0 :: Word64))
]
- , testGroup "pushAsUserdata"
+ , testGroup "pushAny"
[ "metatable is named Dummy" =:
(Just "HSLUA_Dummy") `shouldBeResultOf` do
pushAny (Dummy 23 "Nichts ist wie es scheint")
@@ -60,6 +60,23 @@ tests = testGroup "Userdata"
Lua.tostring' Lua.stackTop
]
+ , testGroup "toAny"
+ [ "get back pushed value" =:
+ Just (Dummy 0 "zero") `shouldBeResultOf` do
+ pushAny (Dummy 0 "zero")
+ toAny Lua.stackTop
+
+ , "fail on boolean" =:
+ (Nothing :: Maybe Dummy) `shouldBeResultOf` do
+ Lua.pushboolean False
+ toAny Lua.stackTop
+
+ , "fail on wrong userdata" =:
+ (Nothing :: Maybe Dummy) `shouldBeResultOf` do
+ pushAny (0 :: Word64)
+ toAny Lua.stackTop
+ ]
+
, testGroup "Peekable & Pushable"
[ "push and peek" =:
Dummy 5 "sum of digits" `shouldBeResultOf` do
