summaryrefslogtreecommitdiff
path: root/ecs/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/tests')
-rw-r--r--ecs/tests/phase.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/ecs/tests/phase.rs b/ecs/tests/phase.rs
new file mode 100644
index 0000000..af2646b
--- /dev/null
+++ b/ecs/tests/phase.rs
@@ -0,0 +1,36 @@
+use std::sync::atomic::{AtomicUsize, Ordering};
+
+use ecs::component::local::Local;
+use ecs::phase::UPDATE;
+use ecs::system::Into;
+use ecs::system::initializable::Initializable;
+use ecs::{Component, World};
+
+#[derive(Component)]
+struct Thing;
+
+#[test]
+fn system_run_order_correct_when_one_has_local_comp()
+{
+ static COUNTER: AtomicUsize = AtomicUsize::new(0);
+
+ fn first_system(_thing: Local<Thing>)
+ {
+ assert_eq!(COUNTER.fetch_add(1, Ordering::Relaxed), 0);
+ }
+
+ fn second_system()
+ {
+ assert_eq!(COUNTER.fetch_add(1, Ordering::Relaxed), 1);
+ }
+
+ let mut world = World::new();
+
+ world.register_system(*UPDATE, first_system.into_system().initialize((Thing,)));
+
+ world.register_system(*UPDATE, second_system);
+
+ world.step();
+
+ assert_eq!(COUNTER.load(Ordering::Relaxed), 2);
+}