diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-08-16 14:58:02 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-08-16 14:58:02 -0300 |
| commit | b96b0b5abbf40cbdbed7952bf35a5a27ddf75928 (patch) | |
| tree | 5d9d5463cb7d3424833abab20dd87bce1f4b240f /testes/errors.lua | |
| parent | ca13be9af784b7288d3a07d9b5bccb329086e885 (diff) | |
| download | lua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.tar.gz lua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.tar.bz2 lua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.zip | |
Added macro 'luaL_pushfail'
The macro 'luaL_pushfail' documents all places in the standard libraries
that return nil to signal some kind of failure. It is defined as
'lua_pushnil'. The manual also got a notation (@fail) to document those
returns. The tests were changed to be agnostic regarding whether 'fail'
is 'nil' or 'false'.
Diffstat (limited to 'testes/errors.lua')
| -rw-r--r-- | testes/errors.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/testes/errors.lua b/testes/errors.lua index 6e7b8004..f9623b1d 100644 --- a/testes/errors.lua +++ b/testes/errors.lua | |||
| @@ -18,7 +18,7 @@ end | |||
| 18 | 18 | ||
| 19 | local function doit (s) | 19 | local function doit (s) |
| 20 | local f, msg = load(s) | 20 | local f, msg = load(s) |
| 21 | if f == nil then return msg end | 21 | if not f then return msg end |
| 22 | local cond, msg = pcall(f) | 22 | local cond, msg = pcall(f) |
| 23 | return (not cond) and msg | 23 | return (not cond) and msg |
| 24 | end | 24 | end |
| @@ -312,8 +312,8 @@ end | |||
| 312 | 312 | ||
| 313 | local function lineerror (s, l) | 313 | local function lineerror (s, l) |
| 314 | local err,msg = pcall(load(s)) | 314 | local err,msg = pcall(load(s)) |
| 315 | local line = string.match(msg, ":(%d+):") | 315 | local line = tonumber(string.match(msg, ":(%d+):")) |
| 316 | assert(tonumber(line) == l) | 316 | assert(line == l or (not line and not l)) |
| 317 | end | 317 | end |
| 318 | 318 | ||
| 319 | lineerror("local a\n for i=1,'a' do \n print(i) \n end", 2) | 319 | lineerror("local a\n for i=1,'a' do \n print(i) \n end", 2) |
| @@ -359,7 +359,7 @@ local p = [[ | |||
| 359 | g() | 359 | g() |
| 360 | ]] | 360 | ]] |
| 361 | X=3;lineerror((p), 3) | 361 | X=3;lineerror((p), 3) |
| 362 | X=0;lineerror((p), nil) | 362 | X=0;lineerror((p), false) |
| 363 | X=1;lineerror((p), 2) | 363 | X=1;lineerror((p), 2) |
| 364 | X=2;lineerror((p), 1) | 364 | X=2;lineerror((p), 1) |
| 365 | 365 | ||
| @@ -510,7 +510,7 @@ checksyntax("a\1a = 1", "", "<\\1>", 1) | |||
| 510 | checksyntax("\255a = 1", "", "<\\255>", 1) | 510 | checksyntax("\255a = 1", "", "<\\255>", 1) |
| 511 | 511 | ||
| 512 | doit('I = load("a=9+"); a=3') | 512 | doit('I = load("a=9+"); a=3') |
| 513 | assert(a==3 and I == nil) | 513 | assert(a==3 and not I) |
| 514 | print('+') | 514 | print('+') |
| 515 | 515 | ||
| 516 | lim = 1000 | 516 | lim = 1000 |
