diff --git a/src/lib/time/timevalue.hpp b/src/lib/time/timevalue.hpp index 6de086b50..b036c9d18 100644 --- a/src/lib/time/timevalue.hpp +++ b/src/lib/time/timevalue.hpp @@ -194,6 +194,9 @@ namespace time { /** @internal diagnostics */ operator std::string () const; + /** @return is in-domain, not a boundary value */ + bool isRegular() const; + // Supporting totally_ordered friend bool operator< (TimeValue const& t1, TimeValue const& t2) { return t1.t_ < t2.t_; } friend bool operator< (TimeValue const& t1, gavl_time_t t2) { return t1.t_ < t2 ; } @@ -768,6 +771,13 @@ namespace time { : TimeSpan{start, extension}; } + inline bool + TimeValue::isRegular() const + { + return Time::MIN < *this + and *this < Time::MAX; + } + inline TimeVar::TimeVar (FSecs const& fractionalSeconds) diff --git a/tests/vault/gear/activity-detector-test.cpp b/tests/vault/gear/activity-detector-test.cpp index f74d42d35..6e19d6411 100644 --- a/tests/vault/gear/activity-detector-test.cpp +++ b/tests/vault/gear/activity-detector-test.cpp @@ -262,10 +262,16 @@ namespace test { Activity& probe = detector.buildActivationProbe (someID); CHECK (probe.is (Activity::HOOK)); + CHECK (not detector.wasInvoked (probe)); + Time realTime = RealClock::now(); probe.activate (realTime, detector.executionCtx); CHECK (detector.verifyInvocation(someID).timeArg(realTime)); + + // Probe instance recalls last invocation "now" argument + CHECK (realTime == detector.invokeTime (probe)); + CHECK (detector.wasInvoked (probe)); } diff --git a/tests/vault/gear/activity-detector.hpp b/tests/vault/gear/activity-detector.hpp index 98398a896..259e40f2f 100644 --- a/tests/vault/gear/activity-detector.hpp +++ b/tests/vault/gear/activity-detector.hpp @@ -345,16 +345,18 @@ namespace test { */ class ActivityProbe : public Activity - , activity::Hook + , public activity::Hook { Logger log_; - + TimeVar invoked_{Time::ANYTIME}; + activity::Proc activation ( Activity& thisHook , Time now , void* executionCtx) override { REQUIRE (thisHook.is (Activity::HOOK)); + invoked_ = now; if (data_.callback.arg == 0) {// no adapted target; just record this activation log_(util::toString(now) + " ⧐ "); @@ -375,6 +377,7 @@ namespace test { , void* executionCtx) override { REQUIRE (thisHook.is (Activity::HOOK)); + invoked_ = now; if (data_.callback.arg == 0) {// no adapted target; just record this notification log_(util::toString(now) + " --notify-↯• "); @@ -412,6 +415,19 @@ namespace test { { return diagnostic(); } + + + static Time + lastInvoked (Activity const* act) + { + if (act and act->verb_ == HOOK) + { + ActivityProbe* probe = dynamic_cast (act->data_.callback.hook); + if (probe) + return probe->invoked_; + } + return Time::NEVER; + } }; @@ -543,6 +559,12 @@ namespace test { } + Time invokeTime (Activity const* hook) { return ActivityProbe::lastInvoked (hook); } + bool wasInvoked (Activity const* hook) { return invokeTime(hook).isRegular(); } + Time invokeTime (Activity const& hook) { return invokeTime (&hook); } + bool wasInvoked (Activity const& hook) { return wasInvoked (&hook); } + + struct FakeExecutionCtx; using SIG_post = activity::Proc(Time, Activity*, FakeExecutionCtx&); using SIG_work = void(Time, size_t); diff --git a/tests/vault/gear/scheduler-service-test.cpp b/tests/vault/gear/scheduler-service-test.cpp index d46674b28..43e3a484b 100644 --- a/tests/vault/gear/scheduler-service-test.cpp +++ b/tests/vault/gear/scheduler-service-test.cpp @@ -30,6 +30,7 @@ #include "vault/gear/scheduler.hpp" #include "lib/time/timevalue.hpp" #include "lib/format-cout.hpp" +#include "lib/test/diagnostic-output.hpp"///////////////TODO //#include "lib/util.hpp" //#include @@ -106,6 +107,14 @@ namespace test { cout << detector.showLog()< - + + + + + + + + + + +

+ ...und das erscheint adäquat für moderne Maschinen +

+ + +
+
+ + + +
+ + + + + + +
- + + @@ -88163,8 +88191,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + +