From b1040f88c9f202c657f8ce9c0d4c2ef6e80318d2 Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Wed, 5 Feb 2020 14:15:14 -0800 Subject: [PATCH] &on_change wrapup: documentation, tests, whitespacing Adds documentation, fixes a whitespace issues, fixes compiler warning on some Linux system, extends test. --- doc | 2 +- src/Val.cc | 2 +- src/scan.l | 2 +- testing/btest/Baseline/language.on_change-recurse/output | 7 +++++-- testing/btest/language/on_change-recurse.test | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/doc b/doc index 87b63d810d..7ee302e3d7 160000 --- a/doc +++ b/doc @@ -1 +1 @@ -Subproject commit 87b63d810d345172084d15c9c7feb132688456fe +Subproject commit 7ee302e3d78a3fc759610664cefd15e0578b557f diff --git a/src/Val.cc b/src/Val.cc index 41f68dce03..d1145c245c 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -1969,7 +1969,7 @@ void TableVal::CallChangeFunc(const Val* index, Val* old_value, OnChangeType tpe const Func* f = thefunc->AsFunc(); val_list vl { Ref() }; - EnumVal* type; + EnumVal* type = nullptr; switch ( tpe ) { case element_new: diff --git a/src/scan.l b/src/scan.l index fcf61d6440..ccc501860c 100644 --- a/src/scan.l +++ b/src/scan.l @@ -301,7 +301,7 @@ when return TOK_WHEN; &read_expire return TOK_ATTR_EXPIRE_READ; &redef return TOK_ATTR_REDEF; &write_expire return TOK_ATTR_EXPIRE_WRITE; -&on_change return TOK_ATTR_ON_CHANGE; +&on_change return TOK_ATTR_ON_CHANGE; @deprecated.* { auto num_files = file_stack.length(); diff --git a/testing/btest/Baseline/language.on_change-recurse/output b/testing/btest/Baseline/language.on_change-recurse/output index 300b6fd502..5dcb8410e7 100644 --- a/testing/btest/Baseline/language.on_change-recurse/output +++ b/testing/btest/Baseline/language.on_change-recurse/output @@ -2,7 +2,10 @@ inserting change_function, a, 1, 5, TABLE_ELEMENT_NEW set_change, hi, TABLE_ELEMENT_NEW changing -change_function, a, 1, 5, TABLE_ELEMENT_CHANGED +change_function, a, 1, 6, TABLE_ELEMENT_CHANGED deleting -change_function, a, 1, 5, TABLE_ELEMENT_REMOVED +change_function, a, 1, 7, TABLE_ELEMENT_REMOVED set_change, hi, TABLE_ELEMENT_REMOVED +{ +[a, 1] = 8 +} diff --git a/testing/btest/language/on_change-recurse.test b/testing/btest/language/on_change-recurse.test index b3cc8d61e0..184505f636 100644 --- a/testing/btest/language/on_change-recurse.test +++ b/testing/btest/language/on_change-recurse.test @@ -6,7 +6,7 @@ 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; + t[idxa, idxb] = val+1; } function set_change(t: set[string], tpe: TableChange, idx: string) @@ -27,4 +27,5 @@ event zeek_init() print "deleting"; delete t["a", 1]; delete s["hi"]; + print t; }