//! A tool result may not state when it happened in a way that decays. These are the two
//! halves of that claim: an absolute instant, and how long the cell took. A relative
//! rendering ("4 minutes ago") is deliberately absent, because the same stored block is
//! replayed later and would then assert something false.
use klbr_core::runtime_turn::{observation_header, ran_for, stamped};
const INSTANT_MS: i64 = 1_789_325_845_941;
#[test]
fn a_stamp_states_the_instant_it_happened_in_utc() {
assert_eq!(
observation_header(INSTANT_MS, Some(420)),
"[2026-09-13T18:57:25Z · ran 420ms]"
);
}
#[test]
fn a_result_that_never_ran_claims_no_duration() {
assert_eq!(
observation_header(INSTANT_MS, None),
"[2026-09-13T18:57:25Z]"
);
}
#[test]
fn an_unanswerable_clock_says_so_instead_of_inventing_a_time() {
assert_eq!(observation_header(0, Some(5)), "[time unknown · ran 5ms]");
}
#[test]
fn durations_stay_readable_across_magnitudes() {
assert_eq!(ran_for(0), "0ms");
assert_eq!(ran_for(999), "999ms");
assert_eq!(ran_for(1_000), "1.00s");
assert_eq!(ran_for(9_999), "10.00s");
assert_eq!(ran_for(10_000), "10.0s");
assert_eq!(ran_for(59_900), "59.9s");
assert_eq!(ran_for(60_000), "1m00s");
assert_eq!(ran_for(3_723_000), "62m03s");
}
#[test]
fn the_body_keeps_its_own_first_line_below_the_stamp() {
let result = stamped(&observation_header(INSTANT_MS, Some(12)), "1\ntraceback");
assert_eq!(result, "[2026-09-13T18:57:25Z · ran 12ms]\n1\ntraceback");
// A multi-line body stays exactly as the cell produced it.
assert_eq!(result.lines().count(), 3);
}