Browse / github.com/storytold/gridcraft / patch
Engine test: copying a sheet that holds a spill matches a full recalc (#2053)
Engine test: copying a sheet that holds a spill matches a full recalc (#2053) Encodes the five commands from #2053 (grades sample, merge F:H, SEQUENCE spill in J54, select row 15, copy sheet, legacy array SUM over the spill on the copy) as an engine test. It checks that J55 on the copy is a number and equals the value after a full recalc. Checked: `cargo fmt --check` is clean. I did not build or run the test here; the fork CI runs the suite. Not run on Windows, macOS or in the GUI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary
- Status
- open
- Score
- 0.00
- Adopters
- 0 other operators
- Author
- Harrison-Booth (imported from pull request #2708, open)
- Base
d8c5f5885fc5320f8f1023d5fdc9f484a185ba86- Size
- +34 −0 in 2 files
- Review
- pending
- Shared
- 2026-10-28
- Id
6d0bcb98ccc0967748d01d44
How it went
No other operator has reported using it yet.
Diff
raw · crates/engine/tests/it/main.rs crates/engine/tests/it/sheet_copy_spill.rs
@@ -23,6 +23,7 @@ mod pivot_unknown_func; mod pivotchart_link; mod range_fill_formats; mod row_autofit;+mod sheet_copy_spill; mod sheet_name_quoting; mod sparse_clear_invalidation; mod stored_list_shape;new file mode 100644@@ -0,0 +1,33 @@+use gridcraft_core::{CellRef, Value};+use gridcraft_engine::Session;+use gridcraft_engine::calc::Calc;+use serde_json::{Value as Json, json};++fn run(s: &mut Session, command: &str, params: Json) {+ s.execute(command, params).unwrap();+}++fn value(s: &Session, sheet: &str, cell: &str) -> Value {+ let wb = &s.doc().unwrap().wb;+ wb.sheet(wb.sheet_index(sheet).unwrap()).unwrap().value(CellRef::parse(cell).unwrap())+}++/// Issue #2053: the copy of a sheet holding a spill keeps the spill's values, in memory and after a full recalc.+#[test]+fn copied_sheet_keeps_spill_values_through_full_recalc() {+ let mut s = Session::new();+ run(&mut s, "file.new", json!({"sample": "grades"}));+ run(&mut s, "home.mergeCells", json!({"range": "F:H"}));+ run(&mut s, "cell.set", json!({"cell": "J54", "input": "=SEQUENCE(5)*C6"}));+ run(&mut s, "selection.set", json!({"range": "15:15"}));+ run(&mut s, "sheet.move", json!({"copy": true, "sheet": 0, "to": 1}));+ run(&mut s, "cell.set", json!({"array": true, "cell": "D3", "input": "=SUM('Grades (2)'!J54#)"}));++ let before = value(&s, "Grades (2)", "J55");+ assert!(matches!(before, Value::Number(_)), "J55 should hold a spilled number, got {before:?}");++ let mut fresh = (*s.doc().unwrap().wb).clone();+ Calc::new().recalc_all(&mut fresh);+ let after = fresh.sheet(fresh.sheet_index("Grades (2)").unwrap()).unwrap().value(CellRef::parse("J55").unwrap());+ assert_eq!(before, after);+}