summaryrefslogtreecommitdiff
path: root/core/test_pla_apply.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/test_pla_apply.cpp')
-rw-r--r--core/test_pla_apply.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/core/test_pla_apply.cpp b/core/test_pla_apply.cpp
new file mode 100644
index 0000000..7e18c93
--- /dev/null
+++ b/core/test_pla_apply.cpp
@@ -0,0 +1,56 @@
+#include <boost/mpl/list.hpp>
+#include <boost/mpl/pair.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <iostream>
+
+#include "index.hpp"
+#include "index_spike.hpp"
+#include "pla_apply.hpp"
+#include "property_composition.hpp"
+#include "property_access.hpp"
+#include "context.hpp"
+
+#include "model.hpp" // for Voltage, Weight
+
+
+int main() {
+ using boost::mpl::pair;
+ using boost::mpl::list;
+ using boost::mpl::bool_;
+ using boost::make_tuple;
+
+ // define a fake sim env
+ typedef PropertyComposition<Lists::all> pc_t;
+ pc_t pc;
+
+ // set weight to 3.0
+ pc.cast(PLA_Set<Weight>{0.0, Ptr<Synapse>{0}, 3.0});
+
+ // create and call an apply PLA
+ DelieverContext<SpikeArrival, Neuron>
+ ctx(make_tuple(Ptr<SpikeArrival>{0}, Ptr<Synapse>{0}),
+ Ptr<Neuron>(0));
+ PLA_Apply<SpikeArrival, Neuron, pc_t> apply(Time(0), ctx);
+
+ assert(Property_Get<Voltage>::eval(pc, ctx, Time(0)) == 0.0);
+ pc.call(apply);
+ assert(Property_Get<Voltage>::eval(pc, ctx, Time(0)) == 0.0);
+
+
+ // check for desired event generation pattern
+ assert(!apply.generate<SpikeArrival>());
+ assert(!apply.generate<GlobalMsg>());
+ assert(apply.generate<Spike>());
+ assert(apply.generateAny());
+
+ // commit and test for proper change
+ assert(Property_Get<Voltage>::eval(pc, ctx, Time(0)) == 0.0);
+ apply.commit(pc);
+ assert(Property_Get<Voltage>::eval(pc, ctx, Time(0)) == 3.0);
+
+ // additional compile time checks of helper classes
+ BOOST_MPL_ASSERT((ContinuousProperty_ApplyChangesProp<Voltage, SpikeArrival>));
+ BOOST_MPL_ASSERT_NOT((ContinuousProperty_ApplyChangesProp<Weight, SpikeArrival>));
+
+ return 0;
+}
contact: Jan Huwald // Impressum