Stmt: Introduce assert statement and related hooks

including two hooks called assertion_failure() and assertion_result() for
customization and tracking of assertion results.
This commit is contained in:
Arne Welzel 2023-06-05 19:13:14 +02:00
parent a25b1a9d59
commit 25ea678626
41 changed files with 635 additions and 3 deletions

View file

@ -0,0 +1,28 @@
# @TEST-DOC: Test Describe() of assert statement. Expressions may be canonicalized.
#
# @TEST-EXEC: zeek -b %INPUT >out 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
function test_function()
{
assert getpid() > 0;
}
event zeek_init()
{
local f = function() {
assert getpid() > 0, fmt("my pid is funny: %s", getpid());
};
local g = function() {
assert to_count("42") == 42;
};
print "f", f;
f();
print "g", g;
g();
print "test_function", test_function;
test_function();
}