Lumiera  0.pre.03
»edit your freedom«
TreeMutatorBinding_test Class Reference

Description

Test:
Building blocks to map generic changes to arbitrary private data structures.
  • use a dummy diagnostic implementation to verify the interface
  • verify an adapter to apply structure modification to a generic collection
  • use closures to translate mutation into manipulation of private attributes
  • integrate the standard case of tree diff application to Rec<GenNode>
Remarks
even while this is a very long and detail oriented test, it barely scratches the surface of what is possible with layering multiple bindings on top of each other. In fact, what follows are several self contained tests, each performing roughly the same scenario, yet targeted at different local data structures through appropriate special bindings given as lambda.
you should note that the scenario executed in each of these tests precisely corresponds to the application of the test diff used in (DiffComplexApplication_test)
to help with understanding this, please consider how diff application is actually implemented on top of a set of "primitives". The TreeMutator interface on the other hand offers precisely these building blocks necessary to implement diff application to an arbitrary hierarchical data structure. In this way, the following test cases demonstrate the intermediary steps executed when applying this test diff through the concrete binding exemplified in each case
the test diff implied here reads as follows
ins(ATTRIB1)
ins(ATTRIB3)
ins(ATTRIB3)
ins(CHILD_B)
ins(CHILD_B)
ins(CHILD_T)
// ==> ATTRIB1, ATTRIB3, ATTRIB3, CHILD_B, CHILD_B, CHILD_T
ins(ATTRIB2)
del(CHILD_B)
ins(SUB_NODE)
find(CHILD_T)
pick(CHILD_B)
skip(CHILD_T)
// ==> ATTRIB1, ATTRIB3, (ATTRIB3), ATTRIB2, SUB_NODE, CHILD_T, CHILD_B
after(CHILD_B)
after(Ref::END)
set(GAMMA_PI)
mut(SUB_NODE)
ins(TYPE_X)
ins(ATTRIB2)
ins(CHILD_B)
ins(CHILD_A)
emu(SUB_NODE)
ins(ATTRIB_NODE)
mut(ATTRIB_NODE)
ins(TYPE_Z)
ins(CHILD_A)
ins(CHILD_A)
ins(CHILD_A)
emu(ATTRIB_NODE)
// ==> ATTRIB1, ATTRIB3 := π, (ATTRIB3), ATTRIB2,
// ATTRIB_NODE{ type ζ, CHILD_A, CHILD_A, CHILD_A }
// SUB_NODE{ type ξ, ATTRIB2, CHILD_B, CHILD_A },
// CHILD_T, CHILD_B
See also
TreeMutator
TreeMutator_test
DiffTreeApplication_test
GenNode_test
AbstractTangible_test::mutate()

Definition at line 154 of file tree-mutator-binding-test.cpp.

Private Member Functions

void mutateAttribute ()
 
void mutateCollection ()
 
void mutateDummy ()
 
void mutateGenNode ()
 
virtual void run (Arg)
 

Member Function Documentation

◆ mutateDummy()

void mutateDummy ( )
inlineprivate
Test:
diagnostic binding: how to monitor and verify the mutations applied

Definition at line 169 of file tree-mutator-binding-test.cpp.

References TreeMutator::build(), and MARK_TEST_FUN.

+ Here is the call graph for this function:

◆ mutateCollection()

void mutateCollection ( )
inlineprivate
Test:
map mutation primitives onto a STL collection managed locally.
  • we perform literally the same diff steps as in mutateDummy()
  • but now we have a completely opaque implementation data structure, where even the data type is unknown beyond this functions's scope.
  • thus we build a custom mutator, installing lambdas to tie into this local data structure, without disclosing any details. In fact we even install different lambdas on each usage cycle, according to the specific mutation operations to perform. Of course, it would be pointless to do so in real world usage, yet nicely demonstrates the point that the implementation really remains in control about anything regarding its private data structure.
  • and still, by exposing such a custom configured mutator, this private structure can be populated, reordered and even altered recursively, by generic instructions.

Definition at line 363 of file tree-mutator-binding-test.cpp.

References TreeMutator::build(), lib::diff::anonymous_namespace{tree-mutator-collection-binding.hpp}::collection(), MARK_TEST_FUN, lib::operator==(), and lib::diff::anonymous_namespace{test-mutation-target.hpp}::render().

+ Here is the call graph for this function:

◆ mutateAttribute()

void mutateAttribute ( )
inlineprivate
Test:
translate generic mutation into attribute manipulation
  • here we bind directly to data fields local to this scope
  • we execute the same diff primitives used in the preceding tests
  • yet binding to data fields has certain intrinsic limits; due to the fixed non-dynamic nature of data fields, it is impossible to define an "ordering" and consequently there is no sequence of diff application.
  • so the only form of actually applying a change is to invoke the given setter or use the given mechanism to construct a nested mutator.

Definition at line 681 of file tree-mutator-binding-test.cpp.

References TreeMutator::build(), and MARK_TEST_FUN.

+ Here is the call graph for this function:

◆ mutateGenNode()

void mutateGenNode ( )
inlineprivate
Test:
apply mutation primitives to a GenNode tree.
  • again we perform literally the same diff steps as before
  • but we use the pre-configured binding for Record<GenNode>
  • internally this is comprised of two collection binding layers
  • we start with an empty root node, to be populated and transformed

Definition at line 957 of file tree-mutator-binding-test.cpp.

References TreeMutator::build(), and MARK_TEST_FUN.

+ Here is the call graph for this function:
+ Inheritance diagram for TreeMutatorBinding_test:
+ Collaboration diagram for TreeMutatorBinding_test:

The documentation for this class was generated from the following file: