use std::time::Duration;
use thal::Reactor;
#[tokio::test(flavor = "multi_thread")]
async fn timer_counter_increments() {
let program = thal::load("examples/timer-counter.thal").expect("load");
let reactor = Reactor::new(program);
let store = reactor.store();
let task = tokio::spawn(reactor.run());
tokio::time::sleep(Duration::from_millis(550)).await;
task.abort();
let counter = store
.get_singleton("Counter")
.expect("Counter molecule was emitted");
let value = counter
.fields
.get("value")
.expect("value field present")
.as_int()
.expect("value is Int");
assert!(
value >= 4,
"expected at least 4 ticks in 550ms, got {value}"
);
}