WIP improvise-2bac: interactive arm is parse-then-contextualize
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
@@ -357,3 +357,82 @@ fn an_explicit_coordinate_still_beats_the_cursor() {
|
||||
"the named cell survived: {left:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// North=1, South=2, East=3 on the row axis; the cursor starts on North.
|
||||
fn three_cells(scratch: &Scratch, name: &str) -> PathBuf {
|
||||
let doc = three_rows(scratch, name);
|
||||
run_cmd(
|
||||
&[
|
||||
"set-cell 1 Region/North",
|
||||
"set-cell 2 Region/South",
|
||||
"set-cell 3 Region/East",
|
||||
],
|
||||
&doc,
|
||||
);
|
||||
assert_eq!(cell_lines(&doc).len(), 3, "the fixture wrote three cells");
|
||||
doc
|
||||
}
|
||||
|
||||
fn value_of(doc: &Path, item: &str) -> Option<String> {
|
||||
cell_lines(doc)
|
||||
.into_iter()
|
||||
.find(|l| l.contains(&format!("Region={item}")))
|
||||
.and_then(|l| l.rsplit(" = ").next().map(str::to_string))
|
||||
}
|
||||
|
||||
/// Evidence: `context/test-evidence/cli.md`.
|
||||
#[test]
|
||||
fn commit_cell_edit_writes_the_named_cell_and_spares_the_cursors() {
|
||||
let scratch = Scratch::new("commit-explicit");
|
||||
let doc = three_cells(&scratch, "commit.improv");
|
||||
|
||||
let out = run_cmd(
|
||||
&["move-selection 1 0 . commit-cell-edit editing 5 Region/East"],
|
||||
&doc,
|
||||
);
|
||||
assert!(out.status.success(), "the line failed: {}", stderr_of(&out));
|
||||
let cells = cell_lines(&doc);
|
||||
assert_eq!(value_of(&doc, "East").as_deref(), Some("5"), "{cells:?}");
|
||||
assert_eq!(
|
||||
value_of(&doc, "South").as_deref(),
|
||||
Some("2"),
|
||||
"the cell under the cursor was touched: {cells:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
value_of(&doc, "North").as_deref(),
|
||||
Some("1"),
|
||||
"the origin cell was touched: {cells:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Evidence: `context/test-evidence/cli.md`.
|
||||
#[test]
|
||||
fn a_line_whose_gate_passes_runs_whole() {
|
||||
let scratch = Scratch::new("commit-atomic");
|
||||
let doc = scratch.path("atomic.improv");
|
||||
let out = run_cmd(&["add-category Foo . commit-cell-edit editing 5 Foo/x"], &doc);
|
||||
assert!(
|
||||
!stderr_of(&out).contains("Parse error"),
|
||||
"a line the gate accepted was refused part-way: {}",
|
||||
stderr_of(&out)
|
||||
);
|
||||
let text = std::fs::read_to_string(&doc).expect("the document");
|
||||
assert!(
|
||||
text.lines().any(|l| l.contains("Foo=x") && l.ends_with("= 5")),
|
||||
"the commit did not land: {text}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Evidence: `context/test-evidence/cli.md`.
|
||||
#[test]
|
||||
fn a_malformed_commit_line_is_refused_whole() {
|
||||
let scratch = Scratch::new("commit-malformed");
|
||||
let doc = seeded(&scratch, "malformed.improv");
|
||||
let out = run_cmd(&["add-category Foo . commit-cell-edit editing 5"], &doc);
|
||||
assert!(!out.status.success(), "a malformed line exited 0");
|
||||
let text = std::fs::read_to_string(&doc).expect("the document");
|
||||
assert!(
|
||||
!text.contains("Foo"),
|
||||
"the first half of a refused line landed: {text}"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user