70 #ifndef LIB_TEST_EVENT_LOG_H 71 #define LIB_TEST_EVENT_LOG_H 100 using Log = std::vector<Entry>;
103 buildSearchFilter(Log
const& srcSeq)
106 return iter::chainSearch (Cursor{srcSeq.begin(), srcSeq.end()});
122 using Filter = decltype( buildSearchFilter (std::declval<Log const&>()) );
125 using RExSeq = std::vector<std::regex>;
153 operator bool()
const 155 if (not util::isnil (violation_))
157 cerr <<
"__Log_condition_violated__\n"+violation_ <<
"\n";
187 EventMatch& afterEvent (
string classifier,
string match);
196 template<
typename...ARGS>
215 template<
typename...ARGS>
220 util::join(collectStr<ArgSeq>(regExps...)));
225 template<
typename ARG>
247 return this->
on(targetID);
282 log (std::initializer_list<string>
const& ili)
284 log_->emplace_back(ili);
287 template<
typename ATTR,
typename ARGS>
289 log (
Symbol typeID, ATTR&& attribs, ARGS&& args)
291 log_->emplace_back(typeID, std::forward<ATTR>(attribs)
292 , std::forward<ARGS>(args));
319 return log_->front().get(
"this");
333 EventLog& clear (
string alteredLogID);
334 EventLog& clear (
const char* alteredLogID);
338 clear (
const X *
const obj)
356 EventLog& event (
string classifier,
string text);
358 template<
typename...ELMS>
360 event (
string classifier, ELMS
const& ...initialiser)
362 log (
"event", ArgSeq{
"ID="+classifier}, collectStr<ArgSeq> (initialiser...));
370 EventLog& call (
string target,
string function);
373 EventLog& call (
string target,
string function, ArgSeq&& args);
375 EventLog& call (
const char* target,
const char*
function, ArgSeq&& args);
378 template<
typename...ARGS>
380 call (
string target,
string function, ARGS
const& ...args)
382 return call (target,
function, collectStr<ArgSeq>(args...));
386 template<
class X,
typename...ARGS>
388 call (
const X *
const targetObj,
string function, ARGS
const& ...args)
393 template<
typename...ARGS>
395 call (
const char* target,
string function, ARGS
const& ...args)
397 return call (
string(target),
function, args...);
400 template<
typename...ELMS>
402 note (ELMS
const& ...initialiser)
404 log_->emplace_back (collectStr<ArgSeq> (initialiser...));
429 template<
typename X,
typename...ARGS>
433 REQUIRE (not isnil (*log_));
434 mutateInPlace (log_->back())
435 .
attrib(key,initialiser, std::forward<ARGS>(args)...);
447 return 1 >= log_->size();
454 typedef const Entry value_type;
456 const_iterator begin()
const {
return Iter(log_->begin(), log_->end()); }
457 const_iterator end()
const {
return Iter(); }
459 friend const_iterator begin (
EventLog const& log) {
return log.begin(); }
460 friend const_iterator end (
EventLog const& log) {
return log.end(); }
497 EventMatch verifyEvent (
string classifier,
string match)
const;
501 verifyEvent (
string classifier,
X const& something)
const 503 return verifyEvent (classifier, util::toString (something));
513 ensureNot (
string match)
const;
522 return l1.log_ == l2.log_
523 or (l1.log_ and l2.log_
524 and *l1.log_ == *l2.log_);
529 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"