Add test for error global

This commit is contained in:
Filip Tibell 2023-08-21 19:10:20 -05:00
parent 2f3fb07b7c
commit 851589c695
2 changed files with 16 additions and 0 deletions

View file

@ -81,6 +81,7 @@ create_tests! {
global_g_table: "globals/_G",
global_version: "globals/_VERSION",
global_coroutine: "globals/coroutine",
global_error: "globals/error",
global_pcall: "globals/pcall",
global_type: "globals/type",
global_typeof: "globals/typeof",

15
tests/globals/error.luau Normal file
View file

@ -0,0 +1,15 @@
local errValue = newproxy(false)
local success, result = pcall(function()
error({
Inner = errValue,
})
end)
assert(not success, "Pcall succeeded when erorred")
assert(result ~= nil, "Pcall did not return error")
assert(type(result) == "table", "Pcall error value should have been a table")
assert(result.Inner ~= nil, "Pcall error table should contain inner value")
assert(result.Inner == errValue, "Pcall error table should have correct inner value")