diff options
Diffstat (limited to '')
-rw-r--r-- | testes/errors.lua | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/testes/errors.lua b/testes/errors.lua index 5fdb7722..4230a352 100644 --- a/testes/errors.lua +++ b/testes/errors.lua | |||
@@ -1,5 +1,5 @@ | |||
1 | -- $Id: testes/errors.lua $ | 1 | -- $Id: testes/errors.lua $ |
2 | -- See Copyright Notice in file all.lua | 2 | -- See Copyright Notice in file lua.h |
3 | 3 | ||
4 | print("testing errors") | 4 | print("testing errors") |
5 | 5 | ||
@@ -46,7 +46,7 @@ end | |||
46 | assert(doit("error('hi', 0)") == 'hi') | 46 | assert(doit("error('hi', 0)") == 'hi') |
47 | 47 | ||
48 | -- test nil error message | 48 | -- test nil error message |
49 | assert(doit("error()") == "<error object is nil>") | 49 | assert(doit("error()") == "<no error object>") |
50 | 50 | ||
51 | 51 | ||
52 | -- test common errors/errors that crashed in the past | 52 | -- test common errors/errors that crashed in the past |
@@ -162,6 +162,9 @@ checkmessage("aaa=(1)..{}", "a table value") | |||
162 | -- bug in 5.4.6 | 162 | -- bug in 5.4.6 |
163 | checkmessage("a = {_ENV = {}}; print(a._ENV.x + 1)", "field 'x'") | 163 | checkmessage("a = {_ENV = {}}; print(a._ENV.x + 1)", "field 'x'") |
164 | 164 | ||
165 | -- a similar bug, since 5.4.0 | ||
166 | checkmessage("print(('_ENV').x + 1)", "field 'x'") | ||
167 | |||
165 | _G.aaa, _G.bbbb = nil | 168 | _G.aaa, _G.bbbb = nil |
166 | 169 | ||
167 | -- calls | 170 | -- calls |
@@ -300,14 +303,14 @@ do | |||
300 | local f = function (a) return a + 1 end | 303 | local f = function (a) return a + 1 end |
301 | f = assert(load(string.dump(f, true))) | 304 | f = assert(load(string.dump(f, true))) |
302 | assert(f(3) == 4) | 305 | assert(f(3) == 4) |
303 | checkerr("^%?:%-1:", f, {}) | 306 | checkerr("^%?:%?:", f, {}) |
304 | 307 | ||
305 | -- code with a move to a local var ('OP_MOV A B' with A<B) | 308 | -- code with a move to a local var ('OP_MOV A B' with A<B) |
306 | f = function () local a; a = {}; return a + 2 end | 309 | f = function () local a; a = {}; return a + 2 end |
307 | -- no debug info (so that 'a' is unknown) | 310 | -- no debug info (so that 'a' is unknown) |
308 | f = assert(load(string.dump(f, true))) | 311 | f = assert(load(string.dump(f, true))) |
309 | -- symbolic execution should not get lost | 312 | -- symbolic execution should not get lost |
310 | checkerr("^%?:%-1:.*table value", f) | 313 | checkerr("^%?:%?:.*table value", f) |
311 | end | 314 | end |
312 | 315 | ||
313 | 316 | ||
@@ -486,6 +489,14 @@ if not b then | |||
486 | end | 489 | end |
487 | end]], 5) | 490 | end]], 5) |
488 | 491 | ||
492 | lineerror([[ | ||
493 | _ENV = 1 | ||
494 | global function foo () | ||
495 | local a = 10 | ||
496 | return a | ||
497 | end | ||
498 | ]], 2) | ||
499 | |||
489 | 500 | ||
490 | -- bug in 5.4.0 | 501 | -- bug in 5.4.0 |
491 | lineerror([[ | 502 | lineerror([[ |
@@ -504,7 +515,7 @@ end | |||
504 | 515 | ||
505 | 516 | ||
506 | if not _soft then | 517 | if not _soft then |
507 | -- several tests that exaust the Lua stack | 518 | -- several tests that exhaust the Lua stack |
508 | collectgarbage() | 519 | collectgarbage() |
509 | print"testing stack overflow" | 520 | print"testing stack overflow" |
510 | local C = 0 | 521 | local C = 0 |
@@ -614,7 +625,7 @@ do | |||
614 | assert(not res and msg == t) | 625 | assert(not res and msg == t) |
615 | 626 | ||
616 | res, msg = pcall(function () error(nil) end) | 627 | res, msg = pcall(function () error(nil) end) |
617 | assert(not res and msg == "<error object is nil>") | 628 | assert(not res and msg == "<no error object>") |
618 | 629 | ||
619 | local function f() error{msg='x'} end | 630 | local function f() error{msg='x'} end |
620 | res, msg = xpcall(f, function (r) return {msg=r.msg..'y'} end) | 631 | res, msg = xpcall(f, function (r) return {msg=r.msg..'y'} end) |
@@ -731,7 +742,7 @@ assert(c > 255 and string.find(b, "too many upvalues") and | |||
731 | 742 | ||
732 | -- local variables | 743 | -- local variables |
733 | s = "\nfunction foo ()\n local " | 744 | s = "\nfunction foo ()\n local " |
734 | for j = 1,300 do | 745 | for j = 1,200 do |
735 | s = s.."a"..j..", " | 746 | s = s.."a"..j..", " |
736 | end | 747 | end |
737 | s = s.."b\n" | 748 | s = s.."b\n" |