diff options
Diffstat (limited to '')
| -rw-r--r-- | testes/errors.lua | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/testes/errors.lua b/testes/errors.lua index a3f07021..4249f570 100644 --- a/testes/errors.lua +++ b/testes/errors.lua | |||
| @@ -24,8 +24,9 @@ local function doit (s) | |||
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | local function checkmessage (prog, msg) | 27 | local function checkmessage (prog, msg, debug) |
| 28 | local m = doit(prog) | 28 | local m = doit(prog) |
| 29 | if debug then print(m) end | ||
| 29 | assert(string.find(m, msg, 1, true)) | 30 | assert(string.find(m, msg, 1, true)) |
| 30 | end | 31 | end |
| 31 | 32 | ||
| @@ -120,6 +121,17 @@ assert(not string.find(doit"a={13}; local bbbb=1; a[bbbb](3)", "'bbbb'")) | |||
| 120 | checkmessage("a={13}; local bbbb=1; a[bbbb](3)", "number") | 121 | checkmessage("a={13}; local bbbb=1; a[bbbb](3)", "number") |
| 121 | checkmessage("a=(1)..{}", "a table value") | 122 | checkmessage("a=(1)..{}", "a table value") |
| 122 | 123 | ||
| 124 | -- calls | ||
| 125 | checkmessage("local a; a(13)", "local 'a'") | ||
| 126 | checkmessage([[ | ||
| 127 | local a = setmetatable({}, {__add = 34}) | ||
| 128 | a = a + 1 | ||
| 129 | ]], "metamethod 'add'") | ||
| 130 | checkmessage([[ | ||
| 131 | local a = setmetatable({}, {__lt = {}}) | ||
| 132 | a = a > a | ||
| 133 | ]], "metamethod 'lt'") | ||
| 134 | |||
| 123 | -- tail calls | 135 | -- tail calls |
| 124 | checkmessage("local a={}; return a.bbbb(3)", "field 'bbbb'") | 136 | checkmessage("local a={}; return a.bbbb(3)", "field 'bbbb'") |
| 125 | checkmessage("a={}; do local a=1 end; return a:bbbb(3)", "method 'bbbb'") | 137 | checkmessage("a={}; do local a=1 end; return a:bbbb(3)", "method 'bbbb'") |
