35#ifndef LIB_DIFF_TEST_MUTATION_TARGET_H
36#define LIB_DIFF_TEST_MUTATION_TARGET_H
127 struct StringRenderer
128 :
public Variant<DataValues>::Visitor
130 string representation{
""};
132#define STRINGIFY_CONTENT(_TY_) \
133 virtual void handle (_TY_& val) override { representation = util::toString (val); }
151 handle (
Rec & rec)
override
157 handle (
RecRef & ref)
override
162 representation = util::BOTTOM_INDICATOR;
166 StringRenderer visitor;
167 unConst(content).accept (visitor);
168 return visitor.representation;
189 using VecG = std::vector<GenNode>;
227 content_.emplace_back (forward<GenNode>(elm));
234 while (pos and not pos->matches(targetID))
251 log_.
event (
"skipSrc", isnil(content.
idi.
getSym())? util::BOTTOM_INDICATOR : renderNode(content));
260 % render(target.
data));
268 % render(target.
data));
274 log_.
event (
"completeScope",
_Fmt{
"⤴ scope%s completed / %d waste elm(s)"}
275 % (processingPos?
" NOT":
"")
361 : PAR{forward<PAR> (chain)}
388 return PAR::injectNew (n);
403 return PAR::matchSrc(n)
413 GenNode const& skippedElm = *pos_;
424 bool isSrcMatch = pos_ and n.
matches(*pos_);
427 target_.
inject (move(*pos_),
"acceptSrc");
430 return PAR::acceptSrc(n)
438 Iter found = TestMutationTarget::search (ref.
idi, pos_);
441 target_.
inject (move(*found),
"findSrc");
443 return PAR::findSrc(ref)
451 bool foundTarget =
true;
454 for ( ; pos_; ++pos_)
455 target_.
inject (move(*pos_),
"accept_until END");
457 if (spec.
matches (Ref::ATTRIBS))
458 for ( ; pos_ and pos_->isNamed(); ++pos_)
459 target_.
inject (move(*pos_),
"accept_until after ATTRIBS");
462 string logMsg{
"accept_until "+spec.
idi.
getSym()};
463 while (pos_ and not TestWireTap::matchSrc(spec))
465 target_.
inject (move(*pos_), logMsg);
468 if (TestWireTap::matchSrc(spec))
470 target_.
inject (move(*pos_), logMsg);
476 return PAR::accept_until(spec)
488 string logOldPayload{
render(targetElm->data)};
492 return PAR::assignElm(spec)
501 if (PAR::mutateChild (spec, targetBuff))
508 targetBuff.
emplace (TreeMutator::build());
522 return PAR::completeScope()
523 and isnil(this->pos_);
532 return chainedBuilder<TestWireTap<PAR>> (dummy);
A handle to allow for safe »remote implantation« of an unknown subclass into a given opaque InPlaceBu...
SUB & emplace(SUB &&implementation)
move-construct an instance of a subclass into the opaque buffer
wrapped record reference.
object-like record of data.
scopeIter attribs() const
Test adapter to watch and verify how the TreeMutator binds to custom tree data structures.
static iterator search(GenNode::ID const &targetID, iterator pos)
const_iterator begin() const
iterator initMutation(string mutatorID)
friend const_iterator begin(TestMutationTarget const &target)
iterator locate(GenNode::ID const &targetID)
EventMatch verifyEvent(string classifier, string match) const
EventLog const & getLog() const
EventMatch verify(string match) const
string showContent() const
render payload content for diagnostics
std::vector< GenNode > VecG
iter_stl::_SeqT< const VecG >::Range const_iterator
void logMutation(GenNode const &target)
EventMatch verifyCall(string match) const
EventMatch verifyEvent(string match) const
EventMatch verifyMatch(string regExp) const
void inject(GenNode &&elm, string operationID)
friend const_iterator end(TestMutationTarget const &target)
void logSkip(GenNode const &content)
const_iterator end() const
void logScopeCompletion(iterator processingPos)
EventMatch ensureNot(string match) const
string showSrcBuffer() const
render elements waiting in source buffer to be accepted
void logAssignment(GenNode const &target, string oldPayload)
iter_stl::_SeqT< VecG >::Range iterator
virtual bool acceptSrc(GenNode const &n) override
accept existing element, when matching the given spec
virtual bool accept_until(GenNode const &spec)
repeatedly accept, until after the designated location
virtual bool hasSrc() override
TestMutationTarget::iterator Iter
virtual bool assignElm(GenNode const &spec)
locate element already accepted into the target sequence and assign the designated payload value to i...
virtual void init() override
virtual bool completeScope()
verify all our pending (old) source elements where mentioned.
TestWireTap(Target &dummy, PAR &&chain)
virtual void skipSrc(GenNode const &n) override
skip next recorded src element without touching it
virtual bool injectNew(GenNode const &n) override
record in the test target that a new child element is being inserted at current position
virtual bool findSrc(GenNode const &ref) override
locate designated element and accept it at current position
virtual bool matchSrc(GenNode const &n) override
ensure the next recorded source element matches on a formal level with given spec
virtual bool mutateChild(GenNode const &spec, TreeMutator::Handle targetBuff)
locate the designated target element and build a suitable sub-mutator for this element into the provi...
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor,...
string const & getSym() const
Helper to log and verify the occurrence of events.
EventLog & event(string text)
log some text as event
EventMatch verify(string match) const
start a query to match for some substring.
EventMatch verifyCall(string match) const
start a query to match especially a function call
EventMatch verifyEvent(string match) const
start a query to match for some event.
EventMatch verifyMatch(string regExp) const
start a query to match with a regular expression
EventMatch ensureNot(string match) const
start a query to ensure the given expression does not match.
Duration is the internal Lumiera time metric.
Offset measures a distance in time.
A time interval anchored at a specific point in time.
Lumiera's internal time value datatype.
Any copy and copy construction prohibited.
A front-end for using printf-style formatting.
Lumiera error handling (C++ interface).
Support for verifying the occurrence of events from unit tests.
Generic functions to build identification schemes.
string renderChild(GenNode const &elm)
string identify(const T *const entity)
string renderAttribute(GenNode const &elm)
string renderRecord(Rec const &record)
string renderNode(GenNode const &n)
string render(DataCap const &)
string instanceTypeID(const TY *const obj)
designation of an distinct object instance
_SeqT< CON >::Range eachElm(CON &coll)
Implementation namespace for support and library code.
auto transformIterator(IT const &src, FUN processingFunc)
Build a TransformIter: convenience free function shortcut, picking up the involved types automaticall...
OBJ * unConst(const OBJ *)
shortcut to save some typing when having to define const and non-const variants of member functions
string join(COLL &&coll, string const &delim=", ")
enumerate a collection's contents, separated by delimiter.
bool isnil(lib::time::Duration const &dur)
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Special collection to represent object-like data.
generic data element node within a tree
bool matches(GenNode const &o) const
Builder-DSL to create and configure a concrete TreeMutator.
Marker types to indicate a literal string and a Symbol.
#define STRINGIFY_CONTENT(_TY_)
Customisable intermediary to abstract generic tree mutation operations.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...