summaryrefslogtreecommitdiff
path: root/core/test_pla_evolve.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/test_pla_evolve.cpp')
-rw-r--r--core/test_pla_evolve.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/core/test_pla_evolve.cpp b/core/test_pla_evolve.cpp
new file mode 100644
index 0000000..4187c9a
--- /dev/null
+++ b/core/test_pla_evolve.cpp
@@ -0,0 +1,88 @@
+#include <iostream>
+#include <boost/mpl/list.hpp>
+#include <boost/mpl/pair.hpp>
+#include <boost/mpl/bool.hpp>
+
+
+#include "context.hpp"
+#include "continuous_property.hpp"
+#include "pla_evolve.hpp"
+#include "pla_get.hpp"
+#include "pla_init_default.hpp"
+#include "property_composition.hpp"
+
+#include "mempool.hpp"
+
+// create some extra properties
+
+#include "property_abbrevations_begin.hpp"
+
+GEN_CP(Neuron, ConstProp, "const_prop", int, 42);
+GEN_CP_EVOLVE(ConstProp, _CP(ConstProp));
+
+GEN_CP(Neuron, ArithProp, "arith_prop", int, 0);
+GEN_CP_EVOLVE(ArithProp, (_CP(ArithProp) + 1));
+
+GEN_CP(Neuron, GeomProp, "geom_prop", int, 1);
+GEN_CP_EVOLVE(GeomProp, (2*_CP(GeomProp)));
+
+GEN_CP(Neuron, TimeProp, "time_prop", Time, 0.0);
+GEN_CP_EVOLVE(TimeProp, _CP(TimeProp) + td);
+
+GEN_CP(Neuron, Alter1, "alter1", bool, true);
+GEN_CP(Neuron, Alter2, "alter2", bool, false);
+GEN_CP_EVOLVE(Alter1, _CP(Alter2));
+GEN_CP_EVOLVE(Alter2, _CP(Alter1));
+
+#include "property_abbrevations_end.hpp"
+
+using namespace std;
+
+int main() {
+ using boost::mpl::pair;
+ using boost::mpl::list;
+ using boost::mpl::bool_;
+
+ // below is bullshit
+ PropertyComposition<list<
+ pair<ConstProp, bool_<true>>,
+ pair<ArithProp, bool_<true>>,
+ pair<GeomProp, bool_<true>>,
+ pair<TimeProp, bool_<true>>,
+ pair<Alter1, bool_<true>>,
+ pair<Alter2, bool_<true>>
+ >> pc;
+
+ // init with default values
+ //PLA_Init_Default<ArithProp> action_init;
+ // pc.call(action_init);
+
+ // create an instance ptr (we only consider a single instance)
+ Ptr<Neuron> inst{0};
+ ContinuousContext<Neuron> context{inst};
+
+ // evolve and check result using specific gets
+ for (int i=1; i<20; i++) {
+ Time t{double{i}};
+ PLA_Evolve<Neuron> evolve(context, t);
+
+ // evolve
+ pc.call(evolve);
+
+ // check
+ #define CHECK(PN, COND) { \
+ PLA_Get<PN> action{t,inst}; \
+ PN::type res(pc.call(action)); \
+ assert(res == (COND)); \
+ }
+
+ CHECK(ConstProp, 42);
+ CHECK(ArithProp, i);
+ CHECK(GeomProp, (1 << i));
+ CHECK(TimeProp, t);
+
+ PLA_Get<Alter1> ag_a1 (t, inst);
+ PLA_Get<Alter2> ag_a2 (t, inst);
+ assert(pc.call(ag_a1) ^ pc.call(ag_a2));
+ }
+}
contact: Jan Huwald // Impressum