stub and decide about further part of the API

This commit is contained in:
Fischlurch 2016-03-04 21:13:49 +01:00
parent 7d63167276
commit b0ee330737
4 changed files with 67 additions and 44 deletions

View file

@ -217,6 +217,12 @@ namespace diff{
return content_.empty();
}
bool
emptySrc() const
{
return prev_content_.empty();
}
/** check for recorded element */
bool
contains (string spec) const

View file

@ -291,15 +291,9 @@ namespace diff{
/* == Forwarding: mutation primitives == */
void
skipSrc (GenNode const& n)
skipSrc()
{
UNIMPLEMENTED("skip matching src element and advance abstract source position");
}
void
acceptSrc (GenNode const& n)
{
UNIMPLEMENTED("accept existing element");
UNIMPLEMENTED("skip next src element and advance abstract source position");
}
void
@ -308,6 +302,18 @@ namespace diff{
UNIMPLEMENTED("inject a new element at current abstract position");
}
bool
matchSrc (GenNode const& n)
{
UNIMPLEMENTED("ensure the next source element matches with given spec");
}
bool
acceptSrc (GenNode const& n)
{
UNIMPLEMENTED("accept existing element, when matching the given spec");
}
bool
findSrc (GenNode const& n)
{
@ -352,7 +358,7 @@ namespace diff{
del (GenNode const& n) override
{
__expect_in_target(n, "remove");
skipSrc (n);
skipSrc();
}
virtual void
@ -366,7 +372,7 @@ namespace diff{
skip (GenNode const& n) override
{
__expect_further_elements (n);
skipSrc (n);
skipSrc();
} // assume the actual content has been moved away by a previous find()
virtual void

View file

@ -121,22 +121,34 @@ namespace diff{
/* ==== operation API ==== */
virtual void
skipSrc ()
{
UNIMPLEMENTED("skip next src element and advance abstract source position");
}
virtual void
injectNew (GenNode const& n)
{
UNIMPLEMENTED("establish new child node at current position");
}
virtual void
deleteChild (ID id)
virtual bool
matchSrc (GenNode const& n)
{
UNIMPLEMENTED("destroy child node at current position");
UNIMPLEMENTED("ensure the next source element matches with given spec");
}
virtual void
findChild (ID id)
virtual bool
acceptSrc (GenNode const& n)
{
UNIMPLEMENTED("look ahead, find and retrieve denoted child to be relocated at current position");
UNIMPLEMENTED("accept existing element, when matching the given spec");
}
virtual bool
findSrc (GenNode const& n)
{
UNIMPLEMENTED("locate designated element and accept it at current position");
}
virtual TreeMutator&

View file

@ -142,51 +142,50 @@ namespace test{
<< join(target) <<endl;
// now attach new mutator for second round...
mutator =
auto mutator2 =
TreeMutator::build()
.attachDummy (target);
CHECK (isnil (target)); // the "visible" new content is still void
CHECK (not target.emptySrc()); // content was moved into hiden "src" buffer
CHECK (mutator.matchSrc (ATTRIB1)); // current head element of src "matches" the given spec
CHECK (isnil (target)); // the "visible" new content is still void
CHECK (not target.emptySrc()); // content was moved into hiden "src" buffer
CHECK (mutator2.matchSrc (ATTRIB1)); // current head element of src "matches" the given spec
CHECK (isnil (target)); // the match didn't change anything
CHECK (mutator.findSrc (ATTRIB3)); // serach for an element further down into src...
CHECK (!isnil (target)); // ...pick and accept it into the "visible" part of target
CHECK (isnil (target)); // the match didn't change anything
CHECK (mutator2.findSrc (ATTRIB3)); // serach for an element further down into src...
CHECK (!isnil (target)); // ...pick and accept it into the "visible" part of target
CHECK (join(target) == "γ = 3.45");
CHECK (mutator.matchSrc (ATTRIB1)); // element at head of src is still ATTRIB1 (as before)
CHECK (mutator.acceptSrc (ATTRIB1)); // now pick and accept this src element
CHECK (mutator2.matchSrc (ATTRIB1)); // element at head of src is still ATTRIB1 (as before)
CHECK (mutator2.acceptSrc (ATTRIB1)); // now pick and accept this src element
CHECK (join(target) == "γ = 3.45, α = 1");
CHECK (not target.emptySrc()); // next we have to clean up waste
CHECK (mutator.skipSrc()); // left behind by the findSrc() operation
CHECK (not target.emptySrc()); // next we have to clean up waste
mutator2.skipSrc(); // left behind by the findSrc() operation
CHECK (join(target) == "γ = 3.45, α = 1");
mutator.injectNew (ATTRIB2);
mutator2.injectNew (ATTRIB2);
CHECK (not target.emptySrc());
CHECK (mutator.matchSrc (ATTRIB3));
CHECK (mutator.acceptSrc (ATTRIB3));
CHECK (mutator2.matchSrc (ATTRIB3));
CHECK (mutator2.acceptSrc (ATTRIB3));
CHECK (join(target) == "γ = 3.45, α = 1, β = 2, γ = 3.45");
// now proceding with the children.
// NOTE: the TestWireTap / TestMutationTarget does not enforce the attribute / children distinction!
CHECK (not target.emptySrc());
CHECK (mutator.matchSrc (CHILD_B)); // first child waiting in src is CHILD_B
CHECK (not mutator.skipSrc (ATTRIB1)); // refusing to skip a non matching element
CHECK (mutator.skipSrc (CHILD_B)); // but a matching element will be skipt (and thus discarded)
mutator.injectNew (SUB_NODE); // inject a new nested sub-structure here
CHECK (mutator.matchSrc (CHILD_B)); // yet another B-child is waiting
CHECK (not mutator.findSrc (CHILD_A)); // unsuccessful find operation won't do anything
CHECK (mutator2.matchSrc (CHILD_B)); // first child waiting in src is CHILD_B
mutator2.skipSrc(); // ...which will be skipt (and thus discarded)
mutator2.injectNew (SUB_NODE); // inject a new nested sub-structure here
CHECK (mutator2.matchSrc (CHILD_B)); // yet another B-child is waiting
CHECK (not mutator2.findSrc (CHILD_A)); // unsuccessful find operation won't do anything
CHECK (not target.emptySrc());
CHECK (mutator.matchSrc (CHILD_B)); // child B still waiting, unaffected
CHECK (not mutator.acceptSrc (CHILD_T)); // refusing to accept/pick a non matching element
CHECK (mutator.matchSrc (CHILD_B)); // child B still patiently waiting, unaffected
CHECK (mutator.acceptSrc (CHILD_B));
CHECK (mutator.matchSrc (CHILD_T));
CHECK (mutator.acceptSrc (CHILD_T));
CHECK (target.emptySrc()); // source contents exhausted
CHECK (not mutator.acceptSrc (CHILD_T));
CHECK (mutator2.matchSrc (CHILD_B)); // child B still waiting, unaffected
CHECK (not mutator2.acceptSrc (CHILD_T)); // refusing to accept/pick a non matching element
CHECK (mutator2.matchSrc (CHILD_B)); // child B still patiently waiting, unaffected
CHECK (mutator2.acceptSrc (CHILD_B));
CHECK (mutator2.matchSrc (CHILD_T));
CHECK (mutator2.acceptSrc (CHILD_T));
CHECK (target.emptySrc()); // source contents exhausted
CHECK (not mutator2.acceptSrc (CHILD_T));
cout << "Content after reordering; "
<< join(target) <<endl;