diff options
| author | HampusM <hampus@hampusmat.com> | 2026-05-02 18:47:18 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-05-02 18:47:18 +0200 |
| commit | 9dfd0a9ef9a54dab5fb88ed9158bd4184212008e (patch) | |
| tree | e40cbfb018c487d78ef1c570258a87a1d2245e98 /ecs/tests/phase.rs | |
| parent | e698922e86c217a261db114ce0392060503f0013 (diff) | |
fix(ecs): make system with local comps not low/high priority in run order
Diffstat (limited to 'ecs/tests/phase.rs')
| -rw-r--r-- | ecs/tests/phase.rs | 36 |
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); +} |
