zeek/testing/btest/language/global-unset-addto.zeek
Robin Sommer 45bef16be0 Catch if &add_func/&delete_func is applied to IDs that don't have values.
We do to allow adding &add_func to a global that's not immediately
initialized, as a later redef may fix that.

Closes #467.
2020-08-18 10:34:05 +00:00

15 lines
475 B
Text

# @TEST-EXEC-FAIL: zeek -b %INPUT >output 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output
global a: count &add_func = function(old: count, new: count): count { return 3; };
global b: count &delete_func = function(old: count, new: count): count { return 3; };
redef a += 13;
redef b -= 13;
# The following is ok.
global c: count &redef &add_func = function(old: count, new: count): count { return 3; };
redef c = 0;
redef c += 13;