Pin that the lowering prompt moves with the stance alone
One dao packet admitted with its own stance, an anger-and-restraint stance and none: three digests, each packet line ending in exactly that stance's JSON, the rest of the text byte-equal, the stance features glossed in the one inventory listing. No prompt change; the lowerer already reads the stance. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e0e3c93d97
commit
633bf831dc
1 changed files with 44 additions and 0 deletions
|
|
@ -642,6 +642,50 @@ mod lowering {
|
|||
assert!(!prompt.text().contains(item.as_str()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lower_prompt_moves_with_the_stance_alone() {
|
||||
use weksa::packet::{FeatValue, FeatureValue, Grade, Stance};
|
||||
let (_, inv, entities, item) = dao(2);
|
||||
let store = InventoryStore::open(&data("daodejing/inventory.cc")).unwrap();
|
||||
let own = packets().remove(2).stance;
|
||||
let grade = |feature: &str, v: u16| FeatureValue {
|
||||
feature: feature.parse().unwrap(),
|
||||
value: FeatValue::Grade(Grade::new(v).unwrap()),
|
||||
};
|
||||
let angry = Stance {
|
||||
features: vec![grade("feature:9", 800), grade("feature:18", 900)],
|
||||
};
|
||||
let prompt_of = |stance: Stance| {
|
||||
let mut packet = packets().remove(2);
|
||||
packet.stance = stance.clone();
|
||||
let view = admitted(packet, &store, "daodejing/corpus.cc", &entities);
|
||||
let prompt = Prompt::lower(&view, &item, &inv, &entities).unwrap();
|
||||
(stance, prompt)
|
||||
};
|
||||
let three = [prompt_of(own), prompt_of(angry), prompt_of(Stance::default())];
|
||||
|
||||
// Three stances, three prompts.
|
||||
let digests: std::collections::BTreeSet<String> =
|
||||
three.iter().map(|(_, p)| p.digest()).collect();
|
||||
assert_eq!(digests.len(), 3);
|
||||
// Each packet line ends with exactly that stance's JSON, and the prompt
|
||||
// with the packet line taken out is the same text for all three.
|
||||
let without_packet_line = |text: &str| -> String {
|
||||
text.lines().filter(|l| !l.starts_with("packet: ")).collect::<Vec<_>>().join("\n")
|
||||
};
|
||||
let bare = without_packet_line(three[0].1.text());
|
||||
for (stance, prompt) in &three {
|
||||
let line = prompt.text().lines().find(|l| l.starts_with("packet: ")).unwrap();
|
||||
let json = serde_json::to_string(stance).unwrap();
|
||||
assert!(line.ends_with(&format!(r#","stance":{json}}}"#)), "{line}");
|
||||
assert_eq!(without_packet_line(prompt.text()), bare);
|
||||
}
|
||||
// The stance's feature ids are glossed in the one inventory listing.
|
||||
let text = three[1].1.text();
|
||||
assert!(text.contains("\nfeature:9: anger [grade; slots Stance]\n"));
|
||||
assert!(text.contains("\nfeature:18: restraint [grade; slots Stance]\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_entity_referent_prints_its_en_us_forms_citation_first() {
|
||||
let cast = InventoryStore::open(&data("interlingua/inventory.cc")).unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue