diff options
author | Asbjørn Sloth Tønnesen <ast@2e8.dk> | 2019-07-17 19:03:45 +0000 |
---|---|---|
committer | Asbjørn Sloth Tønnesen <ast@2e8.dk> | 2019-07-17 19:03:45 +0000 |
commit | 7ef8929a8ef9abed1877d31e5e9426af512b0dc0 (patch) | |
tree | 252bd92737a7d5a6088c0924af51f6bc33a935bd | |
parent | 69d3a49eba0d984580a07d54d34a87b6aae8b802 (diff) | |
download | lua-inet-7ef8929a8ef9abed1877d31e5e9426af512b0dc0.tar.gz lua-inet-7ef8929a8ef9abed1877d31e5e9426af512b0dc0.tar.xz lua-inet-7ef8929a8ef9abed1877d31e5e9426af512b0dc0.zip |
tests: readme: improve error reporting
Signed-off-by: Asbjørn Sloth Tønnesen <ast@2e8.dk>
-rw-r--r-- | test/readme.lua | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/test/readme.lua b/test/readme.lua index 6f63276..35d934e 100644 --- a/test/readme.lua +++ b/test/readme.lua @@ -48,17 +48,24 @@ local env = { require = require, } +local function run_error(code, err) + print() + print('code:', code) + print('error:', err) + print() + return { true, nil, n=3 } +end + local function run(name, code) - local f = assert(load(code, name, 't', env)) + local f, err = load(code, name, 't', env) + if not f then + return run_error(code, err) + end local ret = pack(pcall(f)) if ret[1] then return ret else - print() - print('code:', code) - print('error:', ret[2]) - print() - return { true, nil, n=3 } + return run_error(code, ret[2]) end end |