diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-12-03 12:11:15 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-12-03 12:11:15 -0300 |
| commit | f15589f3b0da477e5dda8863cbf4c0b36469e36d (patch) | |
| tree | bc53bf45dcc4ddc1a2a09bae42be6acbcfcbddb8 /testes | |
| parent | 754ca0060fcac9829cfb90dd68d96cbe14aa84f7 (diff) | |
| download | lua-f15589f3b0da477e5dda8863cbf4c0b36469e36d.tar.gz lua-f15589f3b0da477e5dda8863cbf4c0b36469e36d.tar.bz2 lua-f15589f3b0da477e5dda8863cbf4c0b36469e36d.zip | |
Added test cases for error messages about goto/label
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/errors.lua | 21 |
1 files changed, 21 insertions, 0 deletions
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([[ | |||
| 67 | ]], "'}' expected (to close '{' at line 1)", "<eof>", 3) | 67 | ]], "'}' expected (to close '{' at line 1)", "<eof>", 3) |
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | do -- testing errors in goto/break | ||
| 71 | local function checksyntax (prog, msg, line) | ||
| 72 | local st, err = load(prog) | ||
| 73 | assert(string.find(err, "line " .. line)) | ||
| 74 | assert(string.find(err, msg, 1, true)) | ||
| 75 | end | ||
| 76 | |||
| 77 | checksyntax([[ | ||
| 78 | ::A:: a = 1 | ||
| 79 | ::A:: | ||
| 80 | ]], "label 'A' already defined", 1) | ||
| 81 | |||
| 82 | checksyntax([[ | ||
| 83 | a = 1 | ||
| 84 | goto A | ||
| 85 | do ::A:: end | ||
| 86 | ]], "no visible label 'A'", 2) | ||
| 87 | |||
| 88 | end | ||
| 89 | |||
| 90 | |||
| 70 | if not T then | 91 | if not T then |
| 71 | (Message or print) | 92 | (Message or print) |
| 72 | ('\n >>> testC not active: skipping memory message test <<<\n') | 93 | ('\n >>> testC not active: skipping memory message test <<<\n') |
