79 #ifndef LIB_TEST_EVENT_LOG_H 80 #define LIB_TEST_EVENT_LOG_H 109 using Log = std::vector<Entry>;
112 buildSearchFilter(Log
const& srcSeq)
115 return iter::chainSearch (Cursor{srcSeq.begin(), srcSeq.end()});
131 using Filter = decltype( buildSearchFilter (std::declval<Log const&>()) );
134 using RExSeq = std::vector<std::regex>;
162 operator bool()
const 164 if (not util::isnil (violation_))
166 cerr <<
"__Log_condition_violated__\n"+violation_ <<
"\n";
196 EventMatch& afterEvent (
string classifier,
string match);
205 template<
typename...ARGS>
224 template<
typename...ARGS>
229 util::join(collectStr<ArgSeq>(regExps...)));
234 template<
typename ARG>
256 return this->
on(targetID);
291 log (std::initializer_list<string>
const& ili)
293 log_->emplace_back(ili);
296 template<
typename ATTR,
typename ARGS>
298 log (
Symbol typeID, ATTR&& attribs, ARGS&& args)
300 log_->emplace_back(typeID, std::forward<ATTR>(attribs)
301 , std::forward<ARGS>(args));
328 return log_->front().get(
"this");
342 EventLog& clear (
string alteredLogID);
343 EventLog& clear (
const char* alteredLogID);
347 clear (
const X *
const obj)
365 EventLog& event (
string classifier,
string text);
371 EventLog& call (
string target,
string function);
374 EventLog& call (
string target,
string function, ArgSeq&& args);
376 EventLog& call (
const char* target,
const char*
function, ArgSeq&& args);
379 template<
typename...ARGS>
381 call (
string target,
string function, ARGS
const& ...args)
383 return call (target,
function, collectStr<ArgSeq>(args...));
387 template<
class X,
typename...ARGS>
389 call (
const X *
const targetObj,
string function, ARGS
const& ...args)
394 template<
typename...ARGS>
396 call (
const char* target,
string function, ARGS
const& ...args)
398 return call (
string(target),
function, args...);
401 template<
typename...ELMS>
403 note (ELMS
const& ...initialiser)
405 log_->emplace_back (collectStr<ArgSeq> (initialiser...));
430 template<
typename X,
typename...ARGS>
434 REQUIRE (not isnil (*log_));
435 mutateInPlace (log_->back())
436 .
attrib(key,initialiser, std::forward<ARGS>(args)...);
448 return 1 >= log_->size();
455 typedef const Entry value_type;
457 const_iterator begin()
const {
return Iter(log_->begin(), log_->end()); }
458 const_iterator end()
const {
return Iter(); }
460 friend const_iterator begin (
EventLog const& log) {
return log.begin(); }
461 friend const_iterator end (
EventLog const& log) {
return log.end(); }
498 EventMatch verifyEvent (
string classifier,
string match)
const;
502 verifyEvent (
string classifier,
X const& something)
const 504 return verifyEvent (classifier, util::toString (something));
514 ensureNot (
string match)
const;
523 return l1.log_ == l2.log_
524 or (l1.log_ and l2.log_
525 and *l1.log_ == *l2.log_);
530 return not (l1 == l2);
void refineSerach_matchArgument(size_t idx, string match)
EventMatch & type(string typeID)
refine filter to additionally require a matching log entry type
EventMatch & locateCall(string match)
basic search for some specific function invocation
string violation_
record when the underlying query has failed
Filter solution_
match predicate evaluator
EventMatch & beforeCall(string match)
find a match for some function invocation after the current point of reference
inline string literal This is a marker type to indicate that
Helper to log and verify the occurrence of events.
bool operator==(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
Supporting equality comparisons...
EventMatch & beforeMatch(string regExp)
find a match with the given regular expression
EventMatch & after(string match)
find a match (substring match) of the given text in an EventLog entry before the current position...
An iterator with the ability to switch direction.
EventMatch & arg(ARGS const &...args)
refine filter to additionally require specific arguments
EventMatch & locateMatch(string regExp)
basic search like locate() but with the given regular expression
EventMatch & afterCall(string match)
find a function invocation backwards, before the current point of reference
Implementation namespace for support and library code.
Generic functions to build identification schemes.
void evaluateQuery(string matchSpec, Literal rel="after")
this is actually called after each refinement of the filter and matching conditions.
EventMatch & attrib(string key, string valueMatch)
refine filter to additionally match on a specific attribute
EventMatch(Log const &srcSeq)
Token or Atom with distinct identity.
Special collection to represent object-like data.
Evaluation mechanism to apply a sequence of conditions onto a linear search.
bool foundSolution()
core of the evaluation machinery: apply a filter predicate and then pull through the log to find a ac...
EventMatch & beforeEvent(string match)
find a match for an "event" after the current point of reference
Marker types to indicate a literal string and a Symbol.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
EventMatch & argPos(size_t idx, ARG const &arg)
refine filter to additionally require match on a specific positional argument
bool look_for_match_
support for positive and negative queries.
EventMatch & argMatch(ARGS const &...regExps)
refine filter to additionally cover all arguments with a series of regular expressions.
EventMatch & id(string classifier)
refine filter to additionally match on the ID attribute
void refineSerach_matchArguments(ArgSeq &&argSeq)
Lumiera error handling (C++ interface).
string instanceTypeID(const TY *const obj)
designation of an distinct object instance
EventMatch & locate(string match)
basic search function: continue linear lookup over the elements of the EventLog to find a match (subs...
EventLog & addAttrib(string const &key, X &&initialiser, ARGS &&...args)
Qualify the latest entry: set further attribute(s)
EventLog & call(const X *const targetObj, string function, ARGS const &...args)
Log a function call on given object ("`this`")...
void refineSerach_matchArgsRegExp(RExSeq &®ExpSeq, string rendered_regExps)
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
EventLog & call(string target, string function, ARGS const &...args)
Log a function call with arbitrary arguments.
EventMatch & on(string targetID)
refine filter to additionally match the 'this' attribute
object-like record of data.
EventMatch & key(string key)
refine filter to additionally require the presence an attribute
string lastMatch_
record last match for diagnostics
EventMatch & before(string match)
find a match (substring match) of the given text in an EventLog entry after the current position ...
EventMatch & locateEvent(string match)
basic search for a matching "event"