stub and rectify interfaces defined thus far.
...compilation PASS again
This commit is contained in:
parent
d4c017fa73
commit
b2542b86f7
11 changed files with 337 additions and 51 deletions
|
|
@ -77,6 +77,13 @@ namespace ctrl {
|
|||
return std::move( BusTerm(newAddress, *this));
|
||||
}
|
||||
|
||||
BusTerm::ID
|
||||
BusTerm::getID() const
|
||||
{
|
||||
return endpointID_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ==== standard implementation of the BusTerm interface ==== */
|
||||
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ namespace ctrl{
|
|||
|
||||
BusTerm&& attach (ID newAddress);
|
||||
|
||||
ID getID() const;
|
||||
|
||||
/** may be moved, but not copied,
|
||||
* due to the embedded identity */
|
||||
BusTerm(BusTerm&&) = default;
|
||||
|
|
|
|||
|
|
@ -58,15 +58,6 @@ namespace interact {
|
|||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
string
|
||||
fun (string& id)
|
||||
{
|
||||
return "x"+id;
|
||||
}
|
||||
/** nonsense */
|
||||
|
||||
}} // namespace gui::interact
|
||||
|
|
|
|||
|
|
@ -51,6 +51,13 @@
|
|||
#include <string>
|
||||
|
||||
|
||||
/** @todo unused as of 11/2015
|
||||
* some additional instantiation metadata
|
||||
* could be passed alongside with the invocation.
|
||||
*/
|
||||
#define RESERVED_FOR_FUTURE_USE_ 42
|
||||
|
||||
|
||||
namespace gui {
|
||||
namespace interact {
|
||||
|
||||
|
|
@ -84,7 +91,7 @@ namespace interact {
|
|||
|
||||
GenNode bang() const
|
||||
{
|
||||
return GenNode(cmdID_, FLAGS);
|
||||
return GenNode(cmdID_, RESERVED_FOR_FUTURE_USE_);
|
||||
}
|
||||
|
||||
operator string() const
|
||||
|
|
@ -93,12 +100,6 @@ namespace interact {
|
|||
}
|
||||
|
||||
private:
|
||||
|
||||
/** @todo unused as of 11/2015
|
||||
* some additional instantiation metadata
|
||||
* could be passed alongside with the invocation.
|
||||
*/
|
||||
static const int FLAGS = 42;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,14 @@ namespace model {
|
|||
|
||||
|
||||
|
||||
/** */
|
||||
void
|
||||
Tangible::reset()
|
||||
{
|
||||
this->doReset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare a command or action for actual invocation, once the execution context
|
||||
* has been established. The action is not executed right away, but it is now ready
|
||||
|
|
|
|||
|
|
@ -88,23 +88,23 @@ namespace model {
|
|||
void prepareCommand (Cmd const& prototype, Rec&& arguments);
|
||||
void issueCommand (Cmd const& preparedAction);
|
||||
|
||||
void slotExpand();
|
||||
void slotReveal();
|
||||
void slotExpand() { this->doExpand(); }
|
||||
void slotReveal() { this->doReveal(); }
|
||||
|
||||
void noteMsg();
|
||||
void noteErr();
|
||||
void noteFlash();
|
||||
void noteMark();
|
||||
void noteMsg (string m) { this->doMsg(m); }
|
||||
void noteErr (string e) { this->doErr(e); }
|
||||
void noteFlash() { this->doFlash();}
|
||||
void noteMark(GenNode const& n) { this->doMark(n);}
|
||||
|
||||
protected:
|
||||
virtual void doReset() =0;
|
||||
virtual void doExpand() =0;
|
||||
virtual void doReveal() =0;
|
||||
|
||||
virtual void doMsg() =0;
|
||||
virtual void doErr() =0;
|
||||
virtual void doFlash() =0;
|
||||
virtual void doMark() =0;
|
||||
virtual void doMsg (string) =0;
|
||||
virtual void doErr (string) =0;
|
||||
virtual void doFlash() =0;
|
||||
virtual void doMark(GenNode const&) =0;
|
||||
private:
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -44,10 +44,14 @@
|
|||
|
||||
|
||||
#include "lib/error.hpp"
|
||||
#include "lib/idi/entry-id.hpp"
|
||||
#include "lib/iter-adapter-stl.hpp"
|
||||
#include "lib/diff/record.hpp"
|
||||
//#include "lib/time/timevalue.hpp"
|
||||
|
||||
//#include <boost/lexical_cast.hpp>
|
||||
//#include <string>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
|
|
@ -55,16 +59,204 @@ namespace lib {
|
|||
namespace test{
|
||||
|
||||
// using lib::Literal;
|
||||
// using std::string;
|
||||
using std::string;
|
||||
// using std::rand;
|
||||
|
||||
/**
|
||||
* @internal ongoing evaluation and match within an [EventLog].
|
||||
* @throws error::Fatal when the expected match fails (error::LUMIERA_ERROR_ASSERTION)
|
||||
*/
|
||||
class EventMatch
|
||||
{
|
||||
friend class EventLog;
|
||||
|
||||
public:
|
||||
|
||||
EventMatch&
|
||||
before (string match)
|
||||
{
|
||||
UNIMPLEMENTED("process combined relational match");
|
||||
}
|
||||
|
||||
EventMatch&
|
||||
beforeMatch (string regExp)
|
||||
{
|
||||
UNIMPLEMENTED("process combined relational regular expression match");
|
||||
}
|
||||
|
||||
EventMatch&
|
||||
beforeEvent (string match)
|
||||
{
|
||||
UNIMPLEMENTED("process combined relational match");
|
||||
}
|
||||
|
||||
EventMatch&
|
||||
beforeCall (string match)
|
||||
{
|
||||
UNIMPLEMENTED("process combined relational match");
|
||||
}
|
||||
|
||||
EventMatch&
|
||||
after (string match)
|
||||
{
|
||||
UNIMPLEMENTED("process combined relational match backwards");
|
||||
}
|
||||
|
||||
EventMatch&
|
||||
afterMatch (string regExp)
|
||||
{
|
||||
UNIMPLEMENTED("process combined relational regular expression match backwards");
|
||||
}
|
||||
|
||||
EventMatch&
|
||||
afterEvent (string match)
|
||||
{
|
||||
UNIMPLEMENTED("process combined relational match backwards");
|
||||
}
|
||||
|
||||
EventMatch&
|
||||
afterCall (string match)
|
||||
{
|
||||
UNIMPLEMENTED("process combined relational match backwards");
|
||||
}
|
||||
|
||||
EventMatch&
|
||||
arg ()
|
||||
{
|
||||
UNIMPLEMENTED("process match on no-arg call argument list");
|
||||
}
|
||||
|
||||
template<typename... MORE>
|
||||
EventMatch&
|
||||
arg (string match, MORE...args)
|
||||
{
|
||||
UNIMPLEMENTED("process match on call argument list");
|
||||
}
|
||||
|
||||
template<typename... MORE>
|
||||
EventMatch&
|
||||
argMatch (string regExp, MORE...args)
|
||||
{
|
||||
UNIMPLEMENTED("process regular expression match on call argument list");
|
||||
}
|
||||
|
||||
EventMatch&
|
||||
on (string sourceID)
|
||||
{
|
||||
UNIMPLEMENTED("process additional filter on source of log entry");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper to log and verify the occurrence of events.
|
||||
*/
|
||||
class EventLog
|
||||
{
|
||||
using Entry = lib::diff::Record<string>;
|
||||
using Log = std::vector<Entry>;
|
||||
using Iter = Log::const_iterator;
|
||||
|
||||
string logID_;
|
||||
Log log_;
|
||||
|
||||
public:
|
||||
explicit
|
||||
EventLog (string logID)
|
||||
: logID_(logID)
|
||||
{
|
||||
UNIMPLEMENTED("initial log entry");
|
||||
}
|
||||
|
||||
template<class X>
|
||||
explicit
|
||||
EventLog (const X *const)
|
||||
: EventLog(idi::typeSymbol<X>())
|
||||
{ }
|
||||
|
||||
|
||||
// standard copy operations acceptable
|
||||
|
||||
|
||||
EventLog&
|
||||
join (EventLog& otherLog)
|
||||
{
|
||||
UNIMPLEMENTED("log join");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ==== Logging API ==== */
|
||||
|
||||
EventLog&
|
||||
event (string text)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class X>
|
||||
static string
|
||||
instanceHash(const X *const)
|
||||
{
|
||||
UNIMPLEMENTED ("generate an object instance hash");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ==== Iteration ==== */
|
||||
|
||||
bool
|
||||
empty() const
|
||||
{
|
||||
UNIMPLEMENTED ("collection behaviour");
|
||||
}
|
||||
|
||||
|
||||
typedef Iter const_iterator;
|
||||
typedef const Entry value_type;
|
||||
|
||||
const_iterator begin() const { return log_.begin(); }
|
||||
const_iterator end() const { return log_.end(); }
|
||||
|
||||
friend const_iterator begin (EventLog const& log) { return log.begin(); }
|
||||
friend const_iterator end (EventLog const& log) { return log.end(); }
|
||||
|
||||
|
||||
|
||||
|
||||
/* ==== Query/Verification API ==== */
|
||||
|
||||
EventMatch
|
||||
verify (string match)
|
||||
{
|
||||
UNIMPLEMENTED("start matching sequence");
|
||||
}
|
||||
|
||||
EventMatch
|
||||
verifyMatch (string regExp)
|
||||
{
|
||||
UNIMPLEMENTED("start matching sequence for regular expression match");
|
||||
}
|
||||
|
||||
EventMatch
|
||||
verifyEvent (string match)
|
||||
{
|
||||
UNIMPLEMENTED("start matching sequence");
|
||||
}
|
||||
|
||||
EventMatch
|
||||
verifyCall (string match)
|
||||
{
|
||||
UNIMPLEMENTED("start matching sequence");
|
||||
}
|
||||
|
||||
EventMatch
|
||||
ensureNot (string match)
|
||||
{
|
||||
UNIMPLEMENTED("start matching sequence");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@
|
|||
|
||||
#include "lib/test/run.hpp"
|
||||
#include "lib/test/test-helper.hpp"
|
||||
#include "lib/test/event-log.hpp"
|
||||
#include "test/mock-elm.hpp"
|
||||
#include "lib/idi/entry-id.hpp"
|
||||
#include "lib/error.hpp"
|
||||
//#include "gui/model/session-facade.hpp"
|
||||
//#include "gui/model/diagnostics.hpp"
|
||||
|
|
@ -59,6 +61,9 @@
|
|||
//#include <string>
|
||||
//#include <map>
|
||||
|
||||
using gui::test::MockElm;
|
||||
using lib::test::EventLog;
|
||||
using lib::idi::EntryID;
|
||||
//using boost::lexical_cast;
|
||||
//using util::contains;
|
||||
//using std::string;
|
||||
|
|
@ -115,12 +120,13 @@ namespace test {
|
|||
verify_mockManipulation ()
|
||||
{
|
||||
MockElm mock("dummy");
|
||||
|
||||
mock.verify("ctor");
|
||||
mock.verifyEvent("ctor");
|
||||
mock.verify("ctor").arg("dummy");
|
||||
|
||||
CHECK ("dummy" == mock.getID().getSym());
|
||||
CHECK ("ID<gui::model::test::MockElm>-dummy" = string(mock.getID()));
|
||||
CHECK (EntryID<MockElm>("dummy") == mock.getID());
|
||||
|
||||
VERIFY_ERROR (ASSERTION, mock.verifyCall("reset"));
|
||||
|
||||
|
|
@ -156,7 +162,7 @@ namespace test {
|
|||
.before("reset")
|
||||
.before("lorem ipsum");
|
||||
|
||||
MockElm foo("foo"), bar;
|
||||
MockElm foo("foo"), bar("bar");
|
||||
foo.verify("ctor").arg("foo");
|
||||
bar.verify("ctor").arg();
|
||||
|
||||
|
|
@ -165,16 +171,16 @@ namespace test {
|
|||
mock.ensureNot("foo");
|
||||
VERIFY_ERROR (ASSERTION, foo.ensureNot("foo"));
|
||||
|
||||
log.join(bar).join(foo);
|
||||
log.verifyEvent("logJoin").arg(bar.getID())
|
||||
log.join(bar.getLog()).join(foo.getLog());
|
||||
log.verifyEvent("logJoin").arg(bar.getID().getSym())
|
||||
.beforeEvent("logJoin").arg("foo");
|
||||
|
||||
mock.verifyEvent("logJoin").arg(bar.getID())
|
||||
mock.verifyEvent("logJoin").arg(bar.getID().getSym())
|
||||
.beforeEvent("logJoin").arg("foo");
|
||||
mock.verify("ctor").arg("foo");
|
||||
log.verify("ctor").arg("foo");
|
||||
log.verify("ctor").arg("dummy")
|
||||
.before("ctor").arg(bar.getID())
|
||||
.before("ctor").arg(bar.getID().getSym())
|
||||
.before("ctor").arg("foo");
|
||||
|
||||
mock.kill();
|
||||
|
|
|
|||
|
|
@ -43,8 +43,9 @@
|
|||
|
||||
|
||||
#include "lib/error.hpp"
|
||||
#include "lib/idi/entry-id.hpp"
|
||||
//#include "lib/idi/entry-id.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
#include "lib/test/event-log.hpp"
|
||||
#include "gui/model/tangible.hpp"
|
||||
#include "lib/diff/record.hpp"
|
||||
#include "test/nexus.hpp"
|
||||
|
|
@ -56,14 +57,16 @@
|
|||
namespace gui {
|
||||
namespace error = lumiera::error;
|
||||
using error::LUMIERA_ERROR_ASSERTION;
|
||||
using lib::test::EventLog;
|
||||
using lib::test::EventMatch;
|
||||
|
||||
namespace test{
|
||||
|
||||
|
||||
// using lib::HashVal;
|
||||
// using util::isnil;
|
||||
using lib::idi::EntryID;
|
||||
using lib::diff::Record;
|
||||
// using lib::idi::EntryID;
|
||||
// using lib::diff::Record;
|
||||
using std::string;
|
||||
|
||||
|
||||
|
|
@ -81,40 +84,41 @@ namespace test{
|
|||
class MockElm
|
||||
: public gui::model::Tangible
|
||||
{
|
||||
EventLog log_{this};
|
||||
|
||||
/* ==== Tangible interface ==== */
|
||||
|
||||
virtual void doReset()
|
||||
virtual void doReset() override
|
||||
{
|
||||
UNIMPLEMENTED ("mock doReset");
|
||||
}
|
||||
|
||||
virtual void doExpand()
|
||||
virtual void doExpand() override
|
||||
{
|
||||
UNIMPLEMENTED ("mock doExpand");
|
||||
}
|
||||
|
||||
virtual void doReveal()
|
||||
virtual void doReveal() override
|
||||
{
|
||||
UNIMPLEMENTED ("mock doReveal");
|
||||
}
|
||||
|
||||
virtual void doMsg()
|
||||
virtual void doMsg (string text) override
|
||||
{
|
||||
UNIMPLEMENTED ("mock doMsg");
|
||||
}
|
||||
|
||||
virtual void doErr()
|
||||
virtual void doErr (string text) override
|
||||
{
|
||||
UNIMPLEMENTED ("mock doErr");
|
||||
}
|
||||
|
||||
virtual void doFlash()
|
||||
virtual void doFlash() override
|
||||
{
|
||||
UNIMPLEMENTED ("mock doFlash");
|
||||
}
|
||||
|
||||
virtual void doMark()
|
||||
virtual void doMark (GenNode const& mark) override
|
||||
{
|
||||
UNIMPLEMENTED ("mock doMark");
|
||||
}
|
||||
|
|
@ -124,13 +128,87 @@ namespace test{
|
|||
public:
|
||||
explicit
|
||||
MockElm(string id)
|
||||
: MockElm(EntryID<MockElm>(id))
|
||||
: MockElm(lib::idi::EntryID<MockElm>(id))
|
||||
{ }
|
||||
|
||||
explicit
|
||||
MockElm(ID identity, ctrl::BusTerm& nexus =Nexus::testUI())
|
||||
: gui::model::Tangible(identity, nexus)
|
||||
{ }
|
||||
|
||||
|
||||
/* ==== special operations API ==== */
|
||||
|
||||
void
|
||||
kill()
|
||||
{
|
||||
UNIMPLEMENTED ("suicide");
|
||||
}
|
||||
|
||||
|
||||
/* ==== Query/Verification API ==== */
|
||||
|
||||
ID getID() const
|
||||
{
|
||||
return uiBus_.getID();
|
||||
}
|
||||
|
||||
EventLog&
|
||||
getLog()
|
||||
{
|
||||
return log_;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
isTouched() const
|
||||
{
|
||||
UNIMPLEMENTED ("pristine status");
|
||||
}
|
||||
|
||||
bool
|
||||
isExpanded() const
|
||||
{
|
||||
UNIMPLEMENTED ("UI element expansion status");
|
||||
}
|
||||
|
||||
|
||||
EventMatch
|
||||
verify (string match)
|
||||
{
|
||||
return getLog().verify(match);
|
||||
}
|
||||
|
||||
EventMatch
|
||||
verifyMatch (string regExp)
|
||||
{
|
||||
return getLog().verifyMatch(regExp);
|
||||
}
|
||||
|
||||
EventMatch
|
||||
verifyEvent (string match)
|
||||
{
|
||||
return getLog().verifyEvent(match);
|
||||
}
|
||||
|
||||
EventMatch
|
||||
verifyCall (string match)
|
||||
{
|
||||
return getLog().verifyCall(match);
|
||||
}
|
||||
|
||||
EventMatch
|
||||
ensureNot (string match)
|
||||
{
|
||||
return getLog().ensureNot(match);
|
||||
}
|
||||
|
||||
/** special verification match on a "note" message to this element */
|
||||
EventMatch
|
||||
verifyNote (string msgContentMatch)
|
||||
{
|
||||
UNIMPLEMENTED ("generic match");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace test{
|
|||
* which allows to hook up new nodes for test
|
||||
*/
|
||||
ctrl::BusTerm&
|
||||
testUI()
|
||||
Nexus::testUI()
|
||||
{
|
||||
UNIMPLEMENTED("test nexus");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,12 +24,15 @@
|
|||
#include "lib/test/run.hpp"
|
||||
#include "lib/test/test-helper.hpp"
|
||||
#include "lib/format-util.hpp"
|
||||
#include "lib/test/event-log.hpp"
|
||||
#include "lib/error.hpp"
|
||||
#include "lib/util.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using util::join;
|
||||
using util::isnil;
|
||||
using lumiera::error::LUMIERA_ERROR_ASSERTION;
|
||||
|
||||
using std::string;
|
||||
|
|
@ -50,8 +53,6 @@ namespace test{
|
|||
struct Murpf { };
|
||||
|
||||
|
||||
void doThrow() { throw Error("because I feel like it"); }
|
||||
int dontThrow() { return 2+2; }
|
||||
|
||||
|
||||
/***********************************************************//**
|
||||
|
|
@ -84,9 +85,9 @@ namespace test{
|
|||
VERIFY_ERROR (ASSERTION, log.verify("γ"));
|
||||
|
||||
log.verify("α").before("β");
|
||||
VERIFY_ERROR (ASSERTION, verify("β").before("α"));
|
||||
VERIFY_ERROR (ASSERTION, log.verify("β").before("α"));
|
||||
|
||||
CHECK (join(log) == "LOG::TestEventLog_test"+Log::instanceHash(this)
|
||||
CHECK (join(log) == "LOG::TestEventLog_test"+EventLog::instanceHash(this)
|
||||
+ ", Rec(event| |{α}), Rec(event| |{β})");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue