zeek/testing/btest/language/table-redef.zeek
Robin Sommer 789cb376fd GH-239: Rename bro to zeek, bro-config to zeek-config, and bro-path-dev to zeek-path-dev.
This also installs symlinks from "zeek" and "bro-config" to a wrapper
script that prints a deprecation warning.

The btests pass, but this is still WIP. broctl renaming is still
missing.

#239
2019-05-01 21:43:45 +00:00

26 lines
664 B
Text

# @TEST-EXEC: zeek -b %INPUT > out
# @TEST-EXEC: btest-diff out
const foo: table[string] of double &redef;
# full (re)initialization
redef foo = { ["nope"] = 37.0 };
# full (re)initialization, discards "nope" index
redef foo = { ["abc"] = 42.0 };
# add elements
redef foo += { ["def"] = -42.0, ["ghi"] = 7.0 };
# remove elements from LHS based on indices shared with RHS
redef foo -= { ["ghi"] = 0.0 };
# RHS can be a table value
redef foo += table(["cool"] = 5.0, ["neat"] = 1.0);
# Redef at a single index is allowed, same as += when RHS has overlapping index
redef foo["cool"] = 28.0;
redef foo["abc"] = 8.0;
redef foo += { ["def"] = 99.0 };
print foo;