use crate::brain::agent::service::phantom::claims_uncalled_commands;
#[test]
fn a_command_the_turn_never_ran_is_caught() {
let text = "Ran `gh issue list --state open` for real this turn. \
The actual output is above, and it corrects me precisely:";
let executed = vec![
r#"{"command":"grep -rn foo src/"}"#.to_string(),
r#"{"path":"src/main.rs"}"#.to_string(),
];
let found = claims_uncalled_commands(text, &executed);
assert_eq!(found, vec!["gh issue list --state open"]);
}
#[test]
fn a_command_that_really_ran_is_clean() {
let text = "Ran `gh issue list --state open` and here is what came back:";
let executed = vec![r#"{"command":"gh issue list --state open --json number"}"#.to_string()];
assert!(claims_uncalled_commands(text, &executed).is_empty());
}
#[test]
fn extra_flags_on_the_real_call_are_not_a_fabrication() {
let text = "Checked with `wc -l src/tui/mod.rs`, real output above:";
let executed = vec![r#"{"command":"cd /repo && wc -l src/tui/mod.rs | tail -1"}"#.to_string()];
assert!(claims_uncalled_commands(text, &executed).is_empty());
}
#[test]
fn a_proposed_command_is_not_a_claim() {
for proposal in [
"I could run `gh issue list --state open` if you want the full set.",
"You can verify with `shasum -a 256 src/main.rs` yourself.",
"The next step would be `cargo test --all-features` on a clean tree.",
] {
assert!(
claims_uncalled_commands(proposal, &[]).is_empty(),
"a proposal must not be flagged: {proposal}"
);
}
}
#[test]
fn backticked_prose_is_not_a_command() {
let text = "Ran the check and `mod.rs` is declarations only, see `src/tui/mod.rs`.";
assert!(claims_uncalled_commands(text, &[]).is_empty());
}
#[test]
fn an_unknown_program_is_left_alone() {
let text = "Ran `frobnicate the widgets` and it worked.";
assert!(claims_uncalled_commands(text, &[]).is_empty());
}
#[test]
fn several_claims_are_all_reported() {
let text = "Ran `git log --oneline -5` and `cargo test --all-features`, output above.";
let found = claims_uncalled_commands(text, &[]);
assert_eq!(found.len(), 2, "got: {found:?}");
}
#[test]
fn a_claim_in_portuguese_is_caught() {
let text = "Executei `gh issue list --state open` e a saída está acima.";
assert_eq!(
claims_uncalled_commands(text, &[]),
vec!["gh issue list --state open"]
);
}
#[test]
fn a_claim_in_spanish_is_caught() {
let text = "Ejecuté `git log --oneline -5` y la salida está arriba.";
assert_eq!(
claims_uncalled_commands(text, &[]),
vec!["git log --oneline -5"]
);
}
#[test]
fn a_claim_in_french_is_caught() {
let text = "J'ai exécuté `cargo test --all-features`, la sortie ci-dessus le confirme.";
assert_eq!(
claims_uncalled_commands(text, &[]),
vec!["cargo test --all-features"]
);
}
#[test]
fn a_claim_in_russian_is_caught() {
let text = "Я запустил `git status --short` и вывод выше.";
assert_eq!(
claims_uncalled_commands(text, &[]),
vec!["git status --short"]
);
}
#[test]
fn a_real_call_in_another_language_stays_clean() {
let text = "Executei `gh issue list --state open` e a saída está acima.";
let executed = vec![r#"{"command":"gh issue list --state open --json number"}"#.to_string()];
assert!(claims_uncalled_commands(text, &executed).is_empty());
}