diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-08-15 13:44:36 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-08-15 13:44:36 -0300 |
| commit | a1d8eb27431c02c4529be1efd92143ad65434f3a (patch) | |
| tree | 58db9340ba2b8ea1cb91004b96f15a955f167c58 /testes/main.lua | |
| parent | f64a1b175a5fa65434a073e6d071b32bb7b0ab69 (diff) | |
| download | lua-a1d8eb27431c02c4529be1efd92143ad65434f3a.tar.gz lua-a1d8eb27431c02c4529be1efd92143ad65434f3a.tar.bz2 lua-a1d8eb27431c02c4529be1efd92143ad65434f3a.zip | |
Added control messages to warnings
Added the concept of control messages to the warning system, plus the
implementation of the controls "@on"/"@off" to turn warnings on/off.
Moreover, the warning system in the test library adds some other
controls to ease the test of warnings.
Diffstat (limited to 'testes/main.lua')
| -rw-r--r-- | testes/main.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/testes/main.lua b/testes/main.lua index b224b54e..0ef4822d 100644 --- a/testes/main.lua +++ b/testes/main.lua | |||
| @@ -221,6 +221,28 @@ assert(string.find(getoutput(), "error calling 'print'")) | |||
| 221 | RUN('echo "io.stderr:write(1000)\ncont" | lua -e "require\'debug\'.debug()" 2> %s', out) | 221 | RUN('echo "io.stderr:write(1000)\ncont" | lua -e "require\'debug\'.debug()" 2> %s', out) |
| 222 | checkout("lua_debug> 1000lua_debug> ") | 222 | checkout("lua_debug> 1000lua_debug> ") |
| 223 | 223 | ||
| 224 | -- test warnings | ||
| 225 | RUN('echo "io.stderr:write(1); warn[[XXX]]" | lua -q 2> %s', out) | ||
| 226 | checkout("1") | ||
| 227 | |||
| 228 | prepfile[[ | ||
| 229 | warn("@allow") -- unknown control, ignored | ||
| 230 | warn("@off", "XXX", "@off") -- these are not control messages | ||
| 231 | warn("@off") -- this one is | ||
| 232 | warn("@on", "YYY", "@on") -- not control, but warn is off | ||
| 233 | warn("@off") -- keep it off | ||
| 234 | warn("@on") -- restart warnings | ||
| 235 | warn("", "@on") -- again, no control, real warning | ||
| 236 | warn("@on") -- keep it "started" | ||
| 237 | warn("Z", "Z", "Z") -- common warning | ||
| 238 | ]] | ||
| 239 | RUN('lua %s 2> %s', prog, out) | ||
| 240 | checkout[[ | ||
| 241 | Lua warning: @offXXX@off | ||
| 242 | Lua warning: @on | ||
| 243 | Lua warning: ZZZ | ||
| 244 | ]] | ||
| 245 | |||
| 224 | -- test many arguments | 246 | -- test many arguments |
| 225 | prepfile[[print(({...})[30])]] | 247 | prepfile[[print(({...})[30])]] |
| 226 | RUN('lua %s %s > %s', prog, string.rep(" a", 30), out) | 248 | RUN('lua %s %s > %s', prog, string.rep(" a", 30), out) |
| @@ -355,8 +377,15 @@ if T then -- test library? | |||
| 355 | NoRun("not enough memory", "env MEMLIMIT=100 lua") | 377 | NoRun("not enough memory", "env MEMLIMIT=100 lua") |
| 356 | 378 | ||
| 357 | -- testing 'warn' | 379 | -- testing 'warn' |
| 380 | warn("@store") | ||
| 358 | warn("@123", "456", "789") | 381 | warn("@123", "456", "789") |
| 359 | assert(_WARN == "@123456789") | 382 | assert(_WARN == "@123456789") |
| 383 | |||
| 384 | warn("zip", "", " ", "zap") | ||
| 385 | assert(_WARN == "zip zap") | ||
| 386 | warn("ZIP", "", " ", "ZAP") | ||
| 387 | assert(_WARN == "ZIP ZAP") | ||
| 388 | warn("@normal") | ||
| 360 | end | 389 | end |
| 361 | 390 | ||
| 362 | do | 391 | do |
