/
niceSOFT
/
swig
Обзор
Документация
Войти
/
niceSOFT
/
swig
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Examples/test-suite/lua/catches_runme.lua
24 строки
1 KB
Erez Geva
More Lua tests (#3405)
31 май 2026, 17:09
31 май 2026, 17:09
a1b3ca8
Код
Авторство
О чём код?
local v=require("catches") function test(func, expected) local err, msg = pcall(func) assert(not err, "Failed to propagate C++ exception. Expected '" .. expected .. "', but no exception was thrown.") assert(type(msg) == type(expected), "Failed to propagate C++ proper exception type. " .. "Expected " .. type(expected) .. ", but received " .. type(msg) .. ".") assert(msg == expected, "Failed to propagate C++ exception. Expected '" .. expected .. "', but received '" .. msg .. "'.") end -- unknown exception from SWIG value local unknown_exception="SWIG_RuntimeError:unknown exception" test(function() v.test_catches(1) end, 1) -- the exception is a number! test(function() v.test_catches(2) end, "two") test(function() v.test_catches(3) end, "object exception:ThreeException *") test(function() v.test_exception_specification(1) end, 1) -- the exception is a number! test(function() v.test_exception_specification(2) end, unknown_exception) test(function() v.test_exception_specification(3) end, unknown_exception) test(function() v.test_catches_all(1) end, unknown_exception)