From b303bcebc0913b9122923f814a1a69635626a6f6 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 31 Mar 2017 03:27:26 +0200 Subject: [PATCH] Commands: complete the test case verify the commands where indeed defined as given by the lambda --- src/proc/control/command-setup.hpp | 2 +- .../core/proc/control/command-setup-test.cpp | 24 +++++++++++++++---- wiki/renderengine.html | 6 ++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/proc/control/command-setup.hpp b/src/proc/control/command-setup.hpp index fcf67a2ba..522ee01f8 100644 --- a/src/proc/control/command-setup.hpp +++ b/src/proc/control/command-setup.hpp @@ -44,7 +44,7 @@ ** @see command-def.hpp ** @see command.hpp ** @see command-accessor.hpp - ** @see TODO_CommandSetup_test + ** @see CommandSetup_test ** */ diff --git a/tests/core/proc/control/command-setup-test.cpp b/tests/core/proc/control/command-setup-test.cpp index 801a4c08f..1d98faf9f 100644 --- a/tests/core/proc/control/command-setup-test.cpp +++ b/tests/core/proc/control/command-setup-test.cpp @@ -70,9 +70,7 @@ namespace test { void do_something_pointless (CommandDef&) { - cout << "before-->" << testString << endl; testString = "Ichthyostega wuz here"; - cout << "after--->" << testString << endl; } @@ -98,8 +96,8 @@ namespace test { /***********************************************************************//** - * @test cover the behaviour of the CommandSetup helper for inserting - * actual command definitions into the Session. + * @test cover the behaviour of the CommandSetup helper intended for + * inserting actual command definitions into the Session. * * @see cmd.hpp * @see session-cmd.cpp actual usage example @@ -141,7 +139,7 @@ namespace test { CHECK (def_empty != CommandSetup("to pee or not to pee")); //////////// does not compile -- copy assignment prohibited... -// def_empty = def_1; +// def_empty = CommandSetup{"to peel whatever"}; // add actual definition closures... @@ -198,6 +196,22 @@ namespace test { // but the other two entries did indeed define commands CHECK (Command::defined("test.CommandSetup.def_1")); CHECK (Command::defined("test.CommandSetup.def_2")); + + // ...and they defined the commands as specified + Command com1{"test.CommandSetup.def_1"}; + Command com2{"test.CommandSetup.def_2"}; + + com1.bind (string{"^(\\w+)"}, string{"No $1"}); + com2.bind (uint(42)); + + com1(); + CHECK (testString == "No Ichthyostega wuz here"); + + com2(); + CHECK (testString == "No Ichthyostega wuz here 42 times."); + + com1.undo(); + CHECK (testString == "Ichthyostega wuz here"); } diff --git a/wiki/renderengine.html b/wiki/renderengine.html index a12fb3a25..b3bd967b7 100644 --- a/wiki/renderengine.html +++ b/wiki/renderengine.html @@ -1605,13 +1605,13 @@ When a command has been executed (and maybe undone), it's best to leave it alone State predicates are accessible through the Command (frontend); additionally there are static query functions in class {{{Command}}} -
+
//Helper facility to ease the creation of actual command definitions.//
-A [[Proc-Layer command|CommandHandling]] is a functor, which can be parametrised with actual arguments. It needs to be [defined](command-def.hpp) beforehand, which means to establish an unique name and to supply three functions, one for the actual command operation, one to capture state and one to [[UNDO]] the effect of the command invocation. 
+A [[Proc-Layer command|CommandHandling]] is a functor, which can be parametrised with actual arguments. It needs to be [[defined|CommandDefinition]] beforehand, which means to establish an unique name and to supply three functions, one for the actual command operation, one to capture state and one to [[UNDO]] the effect of the command invocation.
 
 The helper class {{{CommandSetup}}} allows to create series of such definitions with minimal effort. Since any access and mutation from the UI into the Session data must be performed by invoking such commands, a huge amount of individual command definitions need to be written eventually. These are organised into a series of implementation translation units with location {{{poc/cmd/*-cmd.cpp}}}.
 
-Each of these files is specialised to defining a set of thematically related command, supplying the code for the actual command scripts. Each definition is introduced by a single line with the macro {{{COMMAND_DEFINITION(name)}}}, followed by a code block, which actually ends up as the body of a lambda function, and receives the bare [[CommandDef|CommandDefinition]] as single argument with name {{{cmd}}}. The {{{name}}} argument of the macro ends up both stringified as the value of the command-~ID, and as an identifier holding a new {{{CommandSetup}}} instance. It is assumed that a header with //corresponding declarations// (the header {{{cmd.hpp}}}) is included by all UI elements actually to use, handle and invoke commands towards the SessionSubsystem
+Each of these files is specialised to defining a set of thematically related commands, supplying the code for the actual command scripts. Each definition is introduced by a single line with the macro {{{COMMAND_DEFINITION(name)}}}, followed by a code block, which actually ends up as the body of a lambda function, and receives the bare [[CommandDef|CommandDefinition]] as single argument with name {{{cmd}}}. The {{{name}}} argument of the macro ends up both stringified as the value of the command-ID, and as an identifier holding a new {{{CommandSetup}}} instance. It is assumed that a header with //corresponding declarations// (the header {{{cmd.hpp}}}) is included by all UI elements actually to use, handle and invoke commands towards the SessionSubsystem