/
niceSOFT
/
swig
Обзор
Документация
Войти
/
niceSOFT
/
swig
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Examples/test-suite/lua/exception_order_runme.lua
40 строк
937 B
Erez Geva
Improve Lua test syntax (#3463)
02 июн 2026, 01:23
Не верифицирован
02 июн 2026, 01:23
d483ae4
Код
Авторство
О чём код?
-- demo of lua swig capacilities (operator overloading) eo=require("exception_order") catch_undef_globs() -- catch "undefined" global variables a = eo.A() function try1() a:foo() end function try2() a:bar() end function try3() a:foobar() end -- the following code used to work -- but now no longer works, as the lua bindings don't throw objects any more -- all objects are converted to string & thrown -- it could be made to work, if E1 & E2 were thrown by value (see lua.swg) --[[ ok,ex=pcall(try1) print(ok,ex) assert(not ok and swig_type(ex)==swig_type(eo.E1())) ok,ex=pcall(try2) assert(not ok and swig_type(ex)==swig_type(eo.E2())) ]] -- this new code does work, but has to look at the string ok,ex=pcall(try1) assert(not ok and ex=="object exception:E1") ok,ex=pcall(try2) assert(not ok and ex=="object exception:E2") -- the SWIG_exception is just an error string ok,ex=pcall(try3) assert(not ok and type(ex)=="string")