From f15589f3b0da477e5dda8863cbf4c0b36469e36d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 3 Dec 2020 12:11:15 -0300 Subject: Added test cases for error messages about goto/label --- testes/errors.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/testes/errors.lua b/testes/errors.lua index 422c1128..a3f07021 100644 --- a/testes/errors.lua +++ b/testes/errors.lua @@ -67,6 +67,27 @@ checksyntax([[ ]], "'}' expected (to close '{' at line 1)", "", 3) +do -- testing errors in goto/break + local function checksyntax (prog, msg, line) + local st, err = load(prog) + assert(string.find(err, "line " .. line)) + assert(string.find(err, msg, 1, true)) + end + + checksyntax([[ + ::A:: a = 1 + ::A:: + ]], "label 'A' already defined", 1) + + checksyntax([[ + a = 1 + goto A + do ::A:: end + ]], "no visible label 'A'", 2) + +end + + if not T then (Message or print) ('\n >>> testC not active: skipping memory message test <<<\n') -- cgit v1.2.3-55-g6feb