aboutsummaryrefslogtreecommitdiff
path: root/tests/testutil-scheduler.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-29 09:20:08 -0500
committerCraig Jennings <c@cjennings.net>2026-04-29 09:20:08 -0500
commitf707f95d80ace08db2b65a17f2e391a5edaa278e (patch)
treebf4cb48b3399cceaa8f2b345ebd00bcf7abdf7e6 /tests/testutil-scheduler.el
parentbc8167388ce076c5b2a690c4d1e63c8dc82d6dfe (diff)
downloadorg-drill-f707f95d80ace08db2b65a17f2e391a5edaa278e.tar.gz
org-drill-f707f95d80ace08db2b65a17f2e391a5edaa278e.zip
refactor: extract shared scheduler test extractors
Three test files (SM2, SM5, and the upcoming Simple8) all extract the same fields from a scheduler result list. Pull the shared extractors into tests/testutil-scheduler.el so each algorithm's test file can use them. Position 2 holds an EF in SM2 and SM5 and an EASE in Simple8. Both names are exposed as aliases pointing at the same nth position so each call site reads accurately. SM2 and SM5 test files now require testutil-scheduler and call the shared helpers. 69 of 69 scheduler tests still green. Full unit suite at 180 of 180.
Diffstat (limited to 'tests/testutil-scheduler.el')
-rw-r--r--tests/testutil-scheduler.el47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/testutil-scheduler.el b/tests/testutil-scheduler.el
new file mode 100644
index 0000000..72811e8
--- /dev/null
+++ b/tests/testutil-scheduler.el
@@ -0,0 +1,47 @@
+;;; testutil-scheduler.el --- Shared extractors for scheduler tests -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Common result-list element extractors used by the SM2, SM5, and Simple8
+;; scheduler test files. Each algorithm's result list shares the same layout
+;; for INTERVAL / REPEATS / FAILURES / MEAN / TOTAL-REPEATS. Position 2 holds
+;; either the EF (SM2, SM5) or the EASE (Simple8); both names are exposed as
+;; aliases pointing at the same `nth' position so each call site reads
+;; accurately.
+
+;;; Code:
+
+(defsubst test-scheduler--extract-interval (result)
+ "Extract the next-interval (position 0) from a scheduler RESULT list."
+ (nth 0 result))
+
+(defsubst test-scheduler--extract-repeats (result)
+ "Extract the repeats count (position 1) from a scheduler RESULT list."
+ (nth 1 result))
+
+(defsubst test-scheduler--extract-ef (result)
+ "Extract the easiness factor (position 2) from an SM2 or SM5 RESULT list."
+ (nth 2 result))
+
+(defsubst test-scheduler--extract-ease (result)
+ "Alias for `test-scheduler--extract-ef' (same `nth' position).
+Use this name in Simple8 tests where the field is called `ease' not `ef'."
+ (nth 2 result))
+
+(defsubst test-scheduler--extract-failures (result)
+ "Extract the failure count (position 3) from a scheduler RESULT list."
+ (nth 3 result))
+
+(defsubst test-scheduler--extract-meanq (result)
+ "Extract the mean quality (position 4) from a scheduler RESULT list."
+ (nth 4 result))
+
+(defsubst test-scheduler--extract-total-repeats (result)
+ "Extract the total repeats count (position 5) from a scheduler RESULT list."
+ (nth 5 result))
+
+(defsubst test-scheduler--extract-of-matrix (result)
+ "Extract the optimal-factor matrix (position 6) from an SM5 RESULT list."
+ (nth 6 result))
+
+(provide 'testutil-scheduler)
+;;; testutil-scheduler.el ends here