2026-03-24 13:40:42 +00:00

30 lines
733 B
Rust

use prometeu_bytecode::HeapRef;
use prometeu_vm::Scheduler;
#[test]
fn scheduler_wake_and_ready_order_is_deterministic() {
let mut s = Scheduler::new();
let a = HeapRef(1);
let b = HeapRef(2);
let c = HeapRef(3);
s.sleep_until(a, 5);
s.sleep_until(b, 5);
s.sleep_until(c, 6);
// Before tick 5: nothing wakes
s.wake_ready(4);
assert!(s.is_ready_empty());
// At tick 5: a then b become ready (in insertion order)
s.wake_ready(5);
assert_eq!(s.dequeue_next(), Some(a));
assert_eq!(s.dequeue_next(), Some(b));
assert!(s.is_ready_empty());
// At tick 6: c becomes ready
s.wake_ready(6);
assert_eq!(s.dequeue_next(), Some(c));
assert!(s.is_ready_empty());
}