zeek/testing/btest/language/on_change-copy.test
Arne Welzel b2c4f8fd92 TableVal: Propagate &on_change attribute through copy()
Mostly for consistency with &default, &expire_func and other attributes
being propagated through a copy(). Seems this was just missed during
the implementation and/or was never tested for.
2023-02-17 16:21:32 +01:00

31 lines
670 B
Text

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