fix: redundant compute-layout per child, framebuffer diff size test, test file cleanup

This commit is contained in:
Hermes Agent
2026-05-12 14:19:48 +00:00
parent a153746111
commit 6e73c3bb19
8 changed files with 102 additions and 378 deletions

View File

@@ -58,6 +58,29 @@
(is (eql #\A (cell-char (aref cells 6 6))) "inside scissor draws")
(is (eql #\space (cell-char (aref cells 1 1))) "outside scissor is clipped"))))
(test flush-different-sized-fbs-handles-edge-cells
"flush-framebuffer handles prev and curr framebuffers of different sizes
without errors. Cells in the overlapping region are diffed; cells outside
the overlap are silently ignored (no crash on array bounds)."
(let* ((small-fb (make-framebuffer 5 5))
(large-fb (make-framebuffer 10 10))
(be (make-simple-backend :output-stream (make-string-output-stream))))
;; Set a cell in the small one for a change in the overlapping region
(setf (aref small-fb 0 0) (make-cell :char #\X :fg :red))
;; diff-framebuffers should use min dimensions (5,5) — no crash
(let ((changes (diff-framebuffers small-fb large-fb)))
(is (= 1 (length changes)) "one cell changed in overlap region"))
;; flush-framebuffer should also handle different sizes gracefully
(let ((changed (flush-framebuffer small-fb large-fb be)))
(is (= 1 changed) "flush reports 1 changed cell"))
;; Reverse: large as prev, small as curr — extra cells in prev ignored
(setf (aref large-fb 9 9) (make-cell :char #\Y :fg :blue))
(let ((changes2 (diff-framebuffers large-fb small-fb)))
(is (= 1 (length changes2)) "only overlapping region diffed (smaller bounds)"))
;; flush should also work with shrunk framebuffer
(let ((changed2 (flush-framebuffer large-fb small-fb be)))
(is (= 1 changed2) "flush with shrunk fb reports 1 changed cell"))))
(test flush-fb-copies-to-backend
(let* ((real-be (make-simple-backend :output-stream (make-string-output-stream)))
(fb (make-framebuffer-backend)))