zeek/testing/btest/language/on_change-recurse.test
Johanna Amann b1040f88c9 &on_change wrapup: documentation, tests, whitespacing
Adds documentation, fixes a whitespace issues, fixes compiler warning on
some Linux system, extends test.
2020-02-05 14:15:14 -08:00

31 lines
669 B
Text

# @TEST-EXEC: zeek %INPUT >output
# @TEST-EXEC: btest-diff output
module TestModule;
function change_function(t: table[string, int] of count, tpe: TableChange, idxa: string, idxb: int, val: count)
{
print "change_function", idxa, idxb, val, tpe;
t[idxa, idxb] = val+1;
}
function set_change(t: set[string], tpe: TableChange, idx: string)
{
print "set_change", idx, tpe;
}
global t: table[string, int] of count &on_change=change_function;
global s: set[string] &on_change=set_change;
event zeek_init()
{
print "inserting";
t["a", 1] = 5;
add s["hi"];
print "changing";
t["a", 1] = 2;
print "deleting";
delete t["a", 1];
delete s["hi"];
print t;
}