From a2a7471f88a8c0f5c710d5ffb90511fc54b432d7 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 27 May 2026 21:40:43 -0500 Subject: refactor: take card-state in org-drill-determine-next-interval-sm5 Stage 4 of #147. sm5 now takes (state quality of-matrix &optional delta-days) instead of nine positional args, binding the recall fields from the struct at the top so the algorithm body is unchanged. Both call-site branches pass the state they already hold, dropping the per-branch accessor unpacking. The testutil adapter test-scheduler--call-sm5 keeps the sm5 test calls a one-symbol rename per site. I also kept the return as the existing list, matching the stage-3 refinement: the goal is reducing the input signature, and changing the return shape would force the shared return-extractors and every return-read to change for no real gain. Also folds in two stage-3 follow-ons I missed when sm2 landed: a direct sm5 call in tests/test-org-drill-small-branch-coverage.el now uses the new struct API inline, and five direct sm2 calls in the simple-workflow integration test now go through the testutil adapter (the integration file picks up the testutil-scheduler require). Caught by running make test-integration this stage, which I should have run on the sm2 stage. --- ...ion-drill-session-simple-workflow-integration-test.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'tests/test-integration-drill-session-simple-workflow-integration-test.el') diff --git a/tests/test-integration-drill-session-simple-workflow-integration-test.el b/tests/test-integration-drill-session-simple-workflow-integration-test.el index e6f0aae..f0335af 100644 --- a/tests/test-integration-drill-session-simple-workflow-integration-test.el +++ b/tests/test-integration-drill-session-simple-workflow-integration-test.el @@ -7,7 +7,7 @@ ;; 1. Entry detection (org-drill-entry-p) ;; 2. Entry enumeration (org-drill-map-entries) ;; 3. Data retrieval (test-int--state-as-list (org-drill-get-item-data)) -;; 4. Scheduling algorithm (org-drill-determine-next-interval-sm2) +;; 4. Scheduling algorithm (test-scheduler--call-sm2) ;; 5. Data storage (org-drill-store-item-data) ;; ;; This test uses actual org-mode buffers with drill entries to verify @@ -19,6 +19,10 @@ (require 'assess) (require 'org-drill) +(add-to-list 'load-path + (file-name-directory (or load-file-name buffer-file-name))) +(require 'testutil-scheduler) + ;;; Helpers (defun test-int--state-as-list (state) @@ -195,7 +199,7 @@ Verifies integration between data retrieval and SM2 algorithm." (test-int--state-as-list (org-drill-get-item-data)) ;; Simulate quality rating of 4 (good recall) (let* ((quality 4) - (result (org-drill-determine-next-interval-sm2 + (result (test-scheduler--call-sm2 last-interval repeats ease quality failures meanq total-repeats)) (next-interval (nth 0 result)) @@ -220,7 +224,7 @@ Verifies that failure handling works correctly in integrated workflow." (test-int--state-as-list (org-drill-get-item-data)) ;; Simulate complete failure (quality 0) (let* ((quality 0) - (result (org-drill-determine-next-interval-sm2 + (result (test-scheduler--call-sm2 last-interval repeats ease quality failures meanq total-repeats)) (next-interval (nth 0 result)) @@ -249,7 +253,7 @@ Verifies org-drill-store-item-data updates properties correctly." ;; Calculate new scheduling data (let* ((quality 5) ; Perfect recall - (result (org-drill-determine-next-interval-sm2 + (result (test-scheduler--call-sm2 last-interval repeats ease quality failures meanq total-repeats)) (next-interval (nth 0 result)) @@ -339,7 +343,7 @@ Simulates reviewing a card and verifies all components work together." ;; Step 4: Simulate review with quality 4 (let* ((quality 4) - (result (org-drill-determine-next-interval-sm2 + (result (test-scheduler--call-sm2 last-interval repeats ease quality failures meanq total-repeats)) (next-interval (nth 0 result)) @@ -459,7 +463,7 @@ Question content. ;; Verify scheduling can handle extreme values (cl-destructuring-bind (last-interval repeats failures total-repeats meanq ease) data - (let ((result (org-drill-determine-next-interval-sm2 + (let ((result (test-scheduler--call-sm2 last-interval repeats ease 4 failures meanq total-repeats))) (should (listp result))))))))) -- cgit v1.2.3