diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-12-28 15:42:34 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-12-28 15:42:34 -0200 |
commit | 437a5b07d415e1a74160ddfd804017171d6cc5cb (patch) | |
tree | 861f9a56ae175eaed91c163409c33ab85bee7ff9 /testes/all.lua | |
parent | ba7da13ec5938f978c37d63aa40a3e340b301f79 (diff) | |
download | lua-437a5b07d415e1a74160ddfd804017171d6cc5cb.tar.gz lua-437a5b07d415e1a74160ddfd804017171d6cc5cb.tar.bz2 lua-437a5b07d415e1a74160ddfd804017171d6cc5cb.zip |
Added a warning system to Lua
The warning system is just a way for Lua to emit warnings, messages
to the programmer that do not interfere with the running program.
Diffstat (limited to 'testes/all.lua')
-rw-r--r-- | testes/all.lua | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/testes/all.lua b/testes/all.lua index 84ba80a6..bde4195e 100644 --- a/testes/all.lua +++ b/testes/all.lua | |||
@@ -5,8 +5,8 @@ | |||
5 | 5 | ||
6 | local version = "Lua 5.4" | 6 | local version = "Lua 5.4" |
7 | if _VERSION ~= version then | 7 | if _VERSION ~= version then |
8 | io.stderr:write("\nThis test suite is for ", version, ", not for ", _VERSION, | 8 | warn(string.format( |
9 | "\nExiting tests\n") | 9 | "This test suite is for %s, not for %s\nExiting tests\n", version, _VERSION)) |
10 | return | 10 | return |
11 | end | 11 | end |
12 | 12 | ||
@@ -190,11 +190,10 @@ assert(dofile('verybig.lua', true) == 10); collectgarbage() | |||
190 | dofile('files.lua') | 190 | dofile('files.lua') |
191 | 191 | ||
192 | if #msgs > 0 then | 192 | if #msgs > 0 then |
193 | print("\ntests not performed:") | 193 | warn("*tests not performed:\n ") |
194 | for i=1,#msgs do | 194 | for i=1,#msgs do |
195 | print(msgs[i]) | 195 | warn(msgs[i]); warn("\n ") |
196 | end | 196 | end |
197 | print() | ||
198 | end | 197 | end |
199 | 198 | ||
200 | -- no test module should define 'debug' | 199 | -- no test module should define 'debug' |
@@ -220,6 +219,10 @@ local _G, showmem, print, format, clock, time, difftime, assert, open = | |||
220 | local fname = T and "time-debug.txt" or "time.txt" | 219 | local fname = T and "time-debug.txt" or "time.txt" |
221 | local lasttime | 220 | local lasttime |
222 | 221 | ||
222 | |||
223 | warn("*This is "); warn("an expected"); warn(" warning\n") | ||
224 | warn("*This is"); warn(" another one\n") | ||
225 | |||
223 | if not usertests then | 226 | if not usertests then |
224 | -- open file with time of last performed test | 227 | -- open file with time of last performed test |
225 | local f = io.open(fname) | 228 | local f = io.open(fname) |