| 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") |