Commands: draft test case to cover lifecycle sanity checks
This commit is contained in:
parent
228f7d441f
commit
f7d4a3c83e
2 changed files with 53 additions and 2 deletions
|
|
@ -42,6 +42,7 @@
|
|||
#define LIB_SYMBOL_H
|
||||
|
||||
#include "lib/hash-standard.hpp"
|
||||
#include "include/logging.h" /////////////TODO only temporarily
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
|
@ -100,6 +101,25 @@ namespace lib {
|
|||
Symbol (Symbol const& o)
|
||||
: Literal(o)
|
||||
{ }
|
||||
|
||||
Symbol (Literal const& base, std::string ext)
|
||||
: Literal(NULL)
|
||||
{
|
||||
UNIMPLEMENTED ("symbol table");
|
||||
}
|
||||
|
||||
Symbol (Literal const& base, Literal ext)
|
||||
: Literal(NULL)
|
||||
{
|
||||
UNIMPLEMENTED ("symbol table");
|
||||
}
|
||||
|
||||
explicit
|
||||
Symbol (std::string definition)
|
||||
: Literal(NULL)
|
||||
{
|
||||
UNIMPLEMENTED ("symbol table");
|
||||
}
|
||||
|
||||
Symbol&
|
||||
operator= (Literal const& otherSym)
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ namespace test {
|
|||
using std::move;
|
||||
using std::rand;
|
||||
|
||||
using lumiera::error::LUMIERA_ERROR_LIFECYCLE;
|
||||
|
||||
|
||||
|
||||
|
|
@ -279,11 +280,41 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
/** @test */
|
||||
/** @test verify sane command lifecycle is enforced
|
||||
* - instance need to be opened (created) prior to access
|
||||
* - can not dispatch an instance not yet created
|
||||
* - can not create new instance before dispatching the existing one
|
||||
* - can not dispatch an instance before binding its arguments
|
||||
* - can not access an instance already dispatched
|
||||
*/
|
||||
void
|
||||
verify_lifecycle()
|
||||
{
|
||||
UNIMPLEMENTED ("lifecycle sanity");
|
||||
Fixture fixture;
|
||||
CommandInstanceManager iManager{fixture};
|
||||
|
||||
Symbol instanceID{COMMAND_PROTOTYPE, INVOCATION_ID};
|
||||
VERIFY_ERROR (INVALID_COMMAND, iManager.getInstance (instanceID));
|
||||
VERIFY_ERROR (LIFECYCLE, iManager.dispatch (instanceID));
|
||||
|
||||
Symbol i2 = iManager.newInstance (COMMAND_PROTOTYPE, INVOCATION_ID);
|
||||
CHECK (i2 == instanceID);
|
||||
CHECK (iManager.getInstance (instanceID));
|
||||
|
||||
Command cmd = iManager.getInstance (instanceID);
|
||||
CHECK (cmd);
|
||||
CHECK (not cmd.canExec());
|
||||
|
||||
VERIFY_ERROR (UNBOUND_ARGUMENTS, iManager.dispatch (instanceID));
|
||||
VERIFY_ERROR (DUPLICATE_COMMAND, iManager.newInstance (COMMAND_PROTOTYPE, INVOCATION_ID));
|
||||
|
||||
cmd.bind(23);
|
||||
CHECK (cmd.canExec());
|
||||
iManager.dispatch (instanceID);
|
||||
|
||||
CHECK (not iManager.contains (instanceID));
|
||||
VERIFY_ERROR (INVALID_COMMAND, iManager.getInstance (instanceID));
|
||||
CHECK (instanceID == iManager.newInstance (COMMAND_PROTOTYPE, INVOCATION_ID));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue