From f86d829f323caf67f29c1fe52d78ce32d9deae95 Mon Sep 17 00:00:00 2001 From: AsynchronousMatrix Date: Thu, 10 Aug 2023 14:40:43 +0100 Subject: [PATCH] feature: add test for '\0' byte when given invalid lua code --- tests/luau/compile.luau | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/luau/compile.luau b/tests/luau/compile.luau index e257d66..f8e09f8 100644 --- a/tests/luau/compile.luau +++ b/tests/luau/compile.luau @@ -1,8 +1,16 @@ local luau = require("@lune/luau") +local EMPTY_LUAU_CODE_BLOCK = "do end" +local BROKEN_LUAU_CODE_BLOCK = "do" + assert(type(luau.compile) == "function", "expected `luau.compile` to be a function") assert( - type(luau.compile("do end")) == "string", + type(luau.compile(EMPTY_LUAU_CODE_BLOCK)) == "string", "expected `luau.compile` to return bytecode string" ) + +assert( + string.byte(luau.compile(BROKEN_LUAU_CODE_BLOCK), 1, 1) == 0, + "expected errors to return with \0 byte, error message attached afterwards." +)