From 851589c695ea86aa3d3ad1a811dcc551639de753 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Mon, 21 Aug 2023 19:10:20 -0500 Subject: [PATCH] Add test for error global --- src/tests.rs | 1 + tests/globals/error.luau | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/globals/error.luau diff --git a/src/tests.rs b/src/tests.rs index 2d59658..9db8368 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -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", diff --git a/tests/globals/error.luau b/tests/globals/error.luau new file mode 100644 index 0000000..903bf34 --- /dev/null +++ b/tests/globals/error.luau @@ -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")