/
niceSOFT
/
swig
Обзор
Документация
Войти
/
niceSOFT
/
swig
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Examples/test-suite/lua/contract_runme.lua
47 строк
2 KB
Erez Geva
More Lua tests (#3405)
31 май 2026, 17:09
31 май 2026, 17:09
a1b3ca8
Код
Авторство
О чём код?
local v=require("contract") v.test_preassert(1, 2) assert(not pcall(function () v.test_preassert(-1, 3) end), "Preassertions") v.test_postassert(3) assert(not pcall(function () v.test_postassert(-3) end), "Postassertions") v.test_prepost(2, 3) v.test_prepost(5, -4) assert(not pcall(function () v.test_prepost(-3, 4) end), "Preassertions") assert(not pcall(function () v.test_prepost(4, -10) end), "Postassertions") local f = v.Foo() assert(f ~= nil) f:test_preassert(4, 5) assert(not pcall(function () f:test_preassert(-2, 3) end), "Method preassertion.") f:test_postassert(4) assert(not pcall(function () f:test_postassert(-4) end), "Method postassertion") f:test_prepost(3, 4) f:test_prepost(4, -3) assert(not pcall(function () f:test_prepost(-4, 2) end), "Method preassertion.") assert(not pcall(function () f:test_prepost(4, -10) end), "Method postassertion.") v.Foo.stest_prepost(4, 0) assert(not pcall(function () v.Foo.stest_prepost(-4, 2) end), "Static method preassertion") assert(not pcall(function () v.Foo.stest_prepost(4, -10) end), "Static method posteassertion") local b = v.Bar() assert(b ~= nil) assert(not pcall(function () b:test_prepost(2, -4) end), "Inherited preassertion.") local d = v.D() assert(d ~= nil) assert(not pcall(function () d:foo(-1, 1, 1, 1, 1) end), "Inherited preassertion (D).") assert(not pcall(function () d:foo(1, -1, 1, 1, 1) end), "Inherited preassertion (D).") assert(not pcall(function () d:foo(1, 1, -1, 1, 1) end), "Inherited preassertion (D).") assert(not pcall(function () d:foo(1, 1, 1, -1, 1) end), "Inherited preassertion (D).") assert(not pcall(function () d:foo(1, 1, 1, 1, -1) end), "Inherited preassertion (D).") assert(not pcall(function () d:bar(-1, 1, 1, 1, 1) end), "Inherited preassertion (D).") assert(not pcall(function () d:bar(1, -1, 1, 1, 1) end), "Inherited preassertion (D).") assert(not pcall(function () d:bar(1, 1, -1, 1, 1) end), "Inherited preassertion (D).") assert(not pcall(function () d:bar(1, 1, 1, -1, 1) end), "Inherited preassertion (D).") assert(not pcall(function () d:bar(1, 1, 1, 1, -1) end), "Inherited preassertion (D).") -- Namespace local my = v.myClass(1) assert(my ~= nil) assert(not pcall(function () v.myClass(0) end), "constructor preassertion")