40 using LERR_(ITER_EXHAUST);
64 ATTRIB2(
"β", int64_t(2)),
70 CHILD_T(
Time(12,34,56,78)),
72 ATTRIB_NODE =
MakeRec().genNode(
"δ"),
73 CHILD_NODE = SUB_NODE;
128 verify_diagnostics();
150 : Source{snapshot({ins(TYPE_X)
164 CHECK (0 == instances);
167 CHECK (!isnil (diffMsg));
168 CHECK (1 == instances);
171 CHECK (ins(TYPE_X) == *diffMsg);
174 CHECK (
"ins" ==
string(diffMsg->verb()));
175 CHECK (
"type" == diffMsg->elm().idi.getSym());
176 CHECK (
"X" == diffMsg->elm().data.get<
string>());
181 CHECK (
set(ATTRIB1) == *diffMsg);
182 CHECK (
"set" ==
string(diffMsg->verb()));
183 CHECK (
"α" == diffMsg->elm().idi.getSym());
184 CHECK ( 1 == diffMsg->elm().data.get<
int>());
190 CHECK (clone == diffMsg);
191 CHECK (
set(ATTRIB1) == *clone);
193 CHECK (1 == instances);
196 CHECK (del(CHILD_T) == *clone);
197 CHECK (
set(ATTRIB1) == *diffMsg);
198 CHECK (clone != diffMsg);
202 CHECK (isnil (clone));
208 CHECK (
set(ATTRIB1) == *diffMsg);
214 CHECK (2 == instances);
216 CHECK (ins(TYPE_X) == *clone);
218 CHECK (
set(ATTRIB1) == *clone);
221 CHECK (isnil (diffMsg));
224 CHECK (0 == instances);
235 CHECK (!isnil (diffMsg));
236 CHECK (ins(TYPE_X) == *diffMsg);
237 CHECK (
set(ATTRIB1) == *++diffMsg);
238 CHECK (del(CHILD_T) == *++diffMsg);
239 CHECK (isnil (++diffMsg));
250 CHECK (!isnil (diffMsg));
251 CHECK (ins(TYPE_X) == *diffMsg);
252 CHECK (
set(ATTRIB1) == *++diffMsg);
253 CHECK (del(CHILD_T) == *++diffMsg);
254 CHECK (isnil (++diffMsg));
264 CHECK (!isnil (diffMsg));
265 CHECK (ins(TYPE_X) == *diffMsg);
266 CHECK (
set(ATTRIB1) == *++diffMsg);
267 CHECK (del(CHILD_T) == *++diffMsg);
268 CHECK (isnil (++diffMsg));
273 std::vector<DiffStep> steps;
274 CHECK (isnil (steps));
275 append_all(snapshot({ins(TYPE_X)
277 ,del(CHILD_T)}), steps);
281 CHECK (!isnil (diffMsg));
282 CHECK (ins(TYPE_X) == *diffMsg);
283 CHECK (
set(ATTRIB1) == *++diffMsg);
284 CHECK (del(CHILD_T) == *++diffMsg);
285 CHECK (isnil (++diffMsg));
297 CHECK (
string(diffMsg) ==
"IterSource<DiffLanguage<TreeDiffInterpreter, GenNode>::DiffStep>");
300 diffMsg.updateDiagnostics();
303 string expectedRendering = join ({ins(TYPE_X),
set(ATTRIB1), del(CHILD_T)});
304 CHECK (contains (
string(diffMsg), expectedRendering));
306 CHECK (
string(
set(ATTRIB1)) ==
"set(GenNode-ID(\"α\")-DataCap|«int»|1)");
309 CHECK (!isnil (diffMsg));
310 CHECK (ins(TYPE_X) == *diffMsg);
311 CHECK (
set(ATTRIB1) == *++diffMsg);
314 diffMsg.updateDiagnostics();
315 CHECK (not contains (
string(diffMsg),
string(ins(TYPE_X))));
316 CHECK ( contains (
string(diffMsg),
string(
set(ATTRIB1))));
317 CHECK ( contains (
string(diffMsg),
string(del(CHILD_T))));
320 CHECK (del(CHILD_T) == *++diffMsg);
321 CHECK (isnil (++diffMsg));
323 diffMsg.updateDiagnostics();
324 CHECK (
string(diffMsg) ==
"Diff--{}");
355 GenNode childA_upper(CHILD_A.idi.getSym(),
"A");
391 Rec& subject = target;
395 application.consume (populationDiff());
397 CHECK (!isnil (subject));
398 CHECK (
"X" == subject.getType());
399 CHECK (1 == subject.get(
"α").data.get<
int>());
400 CHECK (2L == subject.get(
"β").data.get<int64_t>());
401 CHECK (3.45 == subject.get(
"γ").data.get<
double>());
402 auto scope = subject.scope();
403 CHECK ( *scope == CHILD_A);
404 CHECK (*++scope == CHILD_T);
405 CHECK (*++scope == CHILD_T);
406 CHECK (*++scope ==
MakeRec().appendChild(CHILD_B)
407 .appendChild(CHILD_A)
408 .genNode(SUB_NODE.idi.getSym()));
409 CHECK (isnil(++scope));
412 application.consume (mutationDiff());
413 CHECK (join (subject.keys()) ==
"α, β, γ");
414 scope = subject.scope();
415 CHECK ( *scope == CHILD_T);
416 CHECK (*++scope == CHILD_A);
417 Rec nested = (++scope)->data.get<
Rec>();
418 CHECK (nested.get(
"γ").data.get<
double>() == 3.45);
419 CHECK (nested.get(
"δ") ==
MakeRec().appendChild(CHILD_A)
420 .appendChild(CHILD_A)
421 .appendChild(CHILD_A)
423 auto subScope = nested.scope();
424 CHECK ( *subScope != CHILD_A);
425 CHECK (CHILD_A.idi == subScope->idi);
426 CHECK (
"A" == subScope->data.get<
string>());
427 CHECK (*++subScope ==
MakeRec().type(
"Y")
428 .
set(
"β", int64_t(2))
429 .genNode(CHILD_NODE.idi.getSym()));
430 CHECK (*++subScope == CHILD_T);
431 CHECK (isnil (++subScope));
432 CHECK (isnil (++scope));
Concrete implementation to apply structural changes to hierarchical data structures.
void demonstrate_standardUsage()
Generic Message with an embedded diff, to describe changes to model elements.
void demonstrate_treeApplication()
int instances
verify instance management
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
iter_stl::IterSnapshot< VAL > snapshot(std::initializer_list< VAL > const &&ili)
Take a snapshot of the given std::initializer_list.
Opaque message to effect a structural change on a target, which is likewise only known in an abstract...
Implementation namespace for support and library code.
Lumiera's internal time value datatype.
static const Ref END
symbolic ID ref "_END_"
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A collection of frequently used helper functions to support unit testing.
static const Ref ATTRIBS
symbolic ID ref "_ATTRIBS_"
materialised iterator contents.
Preconfigured adapters for some STL container standard usage situations.
a family of time value like entities and their relationships.
object-like record of data.
Standard implementation of the IterSource interface: a wrapped "Lumiera Forward Iterator".
generic data element node within a tree
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container
generic builder to apply a diff description to a given target data structure.