31 using LERR_(ITER_EXHAUST);
55 ATTRIB2(
"β", int64_t(2)),
61 CHILD_T(
Time(12,34,56,78)),
63 ATTRIB_NODE =
MakeRec().genNode(
"δ"),
64 CHILD_NODE = SUB_NODE;
119 verify_diagnostics();
141 : Source{snapshot({ins(TYPE_X)
155 CHECK (0 == instances);
158 CHECK (!isnil (diffMsg));
159 CHECK (1 == instances);
162 CHECK (ins(TYPE_X) == *diffMsg);
165 CHECK (
"ins" ==
string(diffMsg->verb()));
166 CHECK (
"type" == diffMsg->elm().idi.getSym());
167 CHECK (
"X" == diffMsg->elm().data.get<
string>());
172 CHECK (
set(ATTRIB1) == *diffMsg);
173 CHECK (
"set" ==
string(diffMsg->verb()));
174 CHECK (
"α" == diffMsg->elm().idi.getSym());
175 CHECK ( 1 == diffMsg->elm().data.get<
int>());
181 CHECK (clone == diffMsg);
182 CHECK (
set(ATTRIB1) == *clone);
184 CHECK (1 == instances);
187 CHECK (del(CHILD_T) == *clone);
188 CHECK (
set(ATTRIB1) == *diffMsg);
189 CHECK (clone != diffMsg);
193 CHECK (isnil (clone));
199 CHECK (
set(ATTRIB1) == *diffMsg);
205 CHECK (2 == instances);
207 CHECK (ins(TYPE_X) == *clone);
209 CHECK (
set(ATTRIB1) == *clone);
212 CHECK (isnil (diffMsg));
215 CHECK (0 == instances);
226 CHECK (!isnil (diffMsg));
227 CHECK (ins(TYPE_X) == *diffMsg);
228 CHECK (
set(ATTRIB1) == *++diffMsg);
229 CHECK (del(CHILD_T) == *++diffMsg);
230 CHECK (isnil (++diffMsg));
241 CHECK (!isnil (diffMsg));
242 CHECK (ins(TYPE_X) == *diffMsg);
243 CHECK (
set(ATTRIB1) == *++diffMsg);
244 CHECK (del(CHILD_T) == *++diffMsg);
245 CHECK (isnil (++diffMsg));
255 CHECK (!isnil (diffMsg));
256 CHECK (ins(TYPE_X) == *diffMsg);
257 CHECK (
set(ATTRIB1) == *++diffMsg);
258 CHECK (del(CHILD_T) == *++diffMsg);
259 CHECK (isnil (++diffMsg));
264 std::vector<DiffStep> steps;
265 CHECK (isnil (steps));
266 append_all(snapshot({ins(TYPE_X)
268 ,del(CHILD_T)}), steps);
272 CHECK (!isnil (diffMsg));
273 CHECK (ins(TYPE_X) == *diffMsg);
274 CHECK (
set(ATTRIB1) == *++diffMsg);
275 CHECK (del(CHILD_T) == *++diffMsg);
276 CHECK (isnil (++diffMsg));
288 CHECK (
string(diffMsg) ==
"IterSource<DiffLanguage<TreeDiffInterpreter, GenNode>::DiffStep>");
291 diffMsg.updateDiagnostics();
294 string expectedRendering = join ({ins(TYPE_X),
set(ATTRIB1), del(CHILD_T)});
295 CHECK (contains (
string(diffMsg), expectedRendering));
297 CHECK (
string(
set(ATTRIB1)) ==
"set(GenNode-ID(\"α\")-DataCap|«int»|1)");
300 CHECK (!isnil (diffMsg));
301 CHECK (ins(TYPE_X) == *diffMsg);
302 CHECK (
set(ATTRIB1) == *++diffMsg);
305 diffMsg.updateDiagnostics();
306 CHECK (not contains (
string(diffMsg),
string(ins(TYPE_X))));
307 CHECK ( contains (
string(diffMsg),
string(
set(ATTRIB1))));
308 CHECK ( contains (
string(diffMsg),
string(del(CHILD_T))));
311 CHECK (del(CHILD_T) == *++diffMsg);
312 CHECK (isnil (++diffMsg));
314 diffMsg.updateDiagnostics();
315 CHECK (
string(diffMsg) ==
"Diff--{}");
346 GenNode childA_upper(CHILD_A.idi.getSym(),
"A");
382 Rec& subject = target;
386 application.consume (populationDiff());
388 CHECK (!isnil (subject));
389 CHECK (
"X" == subject.getType());
390 CHECK (1 == subject.get(
"α").data.get<
int>());
391 CHECK (2L == subject.get(
"β").data.get<int64_t>());
392 CHECK (3.45 == subject.get(
"γ").data.get<
double>());
393 auto scope = subject.scope();
394 CHECK ( *scope == CHILD_A);
395 CHECK (*++scope == CHILD_T);
396 CHECK (*++scope == CHILD_T);
397 CHECK (*++scope ==
MakeRec().appendChild(CHILD_B)
398 .appendChild(CHILD_A)
399 .genNode(SUB_NODE.idi.getSym()));
400 CHECK (isnil(++scope));
403 application.consume (mutationDiff());
404 CHECK (join (subject.keys()) ==
"α, β, γ");
405 scope = subject.scope();
406 CHECK ( *scope == CHILD_T);
407 CHECK (*++scope == CHILD_A);
408 Rec nested = (++scope)->data.get<
Rec>();
409 CHECK (nested.get(
"γ").data.get<
double>() == 3.45);
410 CHECK (nested.get(
"δ") ==
MakeRec().appendChild(CHILD_A)
411 .appendChild(CHILD_A)
412 .appendChild(CHILD_A)
414 auto subScope = nested.scope();
415 CHECK ( *subScope != CHILD_A);
416 CHECK (CHILD_A.idi == subScope->idi);
417 CHECK (
"A" == subScope->data.get<
string>());
418 CHECK (*++subScope ==
MakeRec().type(
"Y")
419 .
set(
"β", int64_t(2))
420 .genNode(CHILD_NODE.idi.getSym()));
421 CHECK (*++subScope == CHILD_T);
422 CHECK (isnil (++subScope));
423 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_"
Simplistic 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.