From 03a1d5819834b933db45668df5d770a456ca0a23 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 19 Sep 2018 02:29:02 +0200 Subject: [PATCH] EventLog: verify and complete the TestEventLog_test can now cover all the cases as initially intended, including backtracking --- src/lib/test/event-log.hpp | 6 +++ tests/00support.tests | 6 +++ tests/library/test/test-event-log-test.cpp | 16 +++++--- wiki/thinkPad.ichthyo.mm | 43 +++++++++++++++++----- 4 files changed, 55 insertions(+), 16 deletions(-) diff --git a/src/lib/test/event-log.hpp b/src/lib/test/event-log.hpp index 013823ab5..90897c7f0 100644 --- a/src/lib/test/event-log.hpp +++ b/src/lib/test/event-log.hpp @@ -32,6 +32,12 @@ ** ** Failure of match prints a detailed trace message to `STDERR`, in order ** to deliver a precise indication what part of the condition failed. + ** @note this sequence prints the matches succeeding _at the point_ where each + ** condition is added to the chain. Adding more conditions, especially when + ** combined with changed search direction, might lead to backtracking, which + ** happens silently within the search engine, without printing any further + ** diagnostics. This means: the sequence of matches you see in this diagnostic + ** output is not necessarily the last match patch, which lead to the final failure ** ** @see TestEventLog_test ** @see [usage example](\ref AbstractTangible_test) diff --git a/tests/00support.tests b/tests/00support.tests index 6d11e9424..68857d8d1 100644 --- a/tests/00support.tests +++ b/tests/00support.tests @@ -34,6 +34,12 @@ err-lit: ..before match("beans") @ Rec(EventLogHeader| this = baked beans ) err-lit: ..before match("spam") @ Rec(event|{spam}) err-lit: ..after HEAD baked beans err-lit: __Log_condition_violated__ +err-lit: FAILED to match("spam") +err-lit: ..before match("spam") @ Rec(event|{spam}) +err-lit: ..before match("ham") @ Rec(event|{ham}) +err-lit: ..before match("beans") @ Rec(EventLogHeader| this = baked beans ) +err-lit: ..after HEAD baked beans +err-lit: __Log_condition_violated__ err-lit: FOUND at least match("ham") @ Rec(event|{ham}) err-lit: ..after match("eggs") @ Rec(EventLogHeader| this = eggs ) err-lit: ..before match("spam") @ Rec(event|{spam}) diff --git a/tests/library/test/test-event-log-test.cpp b/tests/library/test/test-event-log-test.cpp index c6ad29d90..f8293bbec 100644 --- a/tests/library/test/test-event-log-test.cpp +++ b/tests/library/test/test-event-log-test.cpp @@ -110,8 +110,14 @@ namespace test{ CHECK (not log.verify("spam").after("beans").after("ham")); log.event("beans"); - CHECK (log.verify("beans").after("spam")); - } + CHECK (log.verify("beans").after("spam")); // Note: Backtracking! The first match on beans fails, + // only the match on second beans succeeds. + + // consecutive matches always move by at least one step + CHECK ( log.verify("beans").after("ham").after("spam") .after("baked")); + CHECK (not log.verify("beans").after("ham").after("spam").after("spam").after("baked")); + CHECK ( log.verify("beans").after("ham").after("spam").locate("spam").locate("spam").after("baked")); + } // ^^^^^^ locate re-applies at current pos without moving void @@ -342,14 +348,12 @@ namespace test{ "with shallots and aubergines garnished with truffle pate, brandy and with a fried egg on top and spam"); CHECK (log.verify("spam").before("(spam|").before("egg on top and spam")); + CHECK (log.verify("and spam").after("(spam|").after("spam!").before("bacon")); CHECK (log.ensureNot("and spam").after("(spam|").after("spam!").after("bacon")); - // note: each consecutive match starts with the same element, on which the previous one succeeded - CHECK (log.verify("spam").before("spam").before("spam").before("spam").before("spam").before("bacon")); - // RegExp on full String representation CHECK (log.verifyMatch("spam.+spam")); - CHECK (log.verifyMatch("spam.+spam").beforeMatch("spam(?!spam)")); + CHECK (log.verifyMatch("spam.+spam").beforeMatch("spam(?!.+spam)")); CHECK (log.verifyEvent("fatal","spam").afterMatch("(spam.*){15}")); // Cover all arguments with sequence of regular expressions diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 6f4704ff0..f63628e37 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -31695,6 +31695,23 @@ + + + + + + +

+ ...um "Hängenbleiben" auf dem gleichen Element auszuschließen. +

+

+ Vorsicht: um sauber genau einen Schritt machen zu können, müssen wir explizit vorübergehend den Filter abschalten +

+ + +
+ +
@@ -31749,7 +31766,7 @@ - + @@ -31762,6 +31779,7 @@ + @@ -31793,8 +31811,9 @@ - + + @@ -31810,8 +31829,8 @@ - - + + @@ -31819,17 +31838,21 @@ - + + + + + - - - + + + - + @@ -31862,7 +31885,7 @@ - +