blob: 126e6e89ddd5823eb4f939204efb66522b5ca151 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
;;; 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))
;;;; Call adapters
;; The schedulers now take an `org-drill-card-state' plus QUALITY rather than a
;; long positional list (org-drill #147). These adapters pack the positional
;; args into the struct so the test call sites keep reading as the documented
;; algorithm inputs, making each migration a one-symbol rename at the call.
(defun test-scheduler--call-sm2 (last-interval n ef quality failures meanq total-repeats)
"Call the SM2 scheduler from positional args, packing them into a card-state."
(org-drill-determine-next-interval-sm2
(make-org-drill-card-state
:last-interval last-interval :repetitions n :ease ef
:failures failures :meanq meanq :total-repeats total-repeats)
quality))
(defun test-scheduler--call-sm5 (last-interval n ef quality failures meanq
total-repeats of-matrix &optional delta-days)
"Call the SM5 scheduler from positional args, packing them into a card-state."
(org-drill-determine-next-interval-sm5
(make-org-drill-card-state
:last-interval last-interval :repetitions n :ease ef
:failures failures :meanq meanq :total-repeats total-repeats)
quality of-matrix delta-days))
(defun test-scheduler--call-simple8 (last-interval repeats quality failures
meanq totaln &optional delta-days)
"Call the Simple8 scheduler from positional args, packing them into a card-state.
Simple8 doesn't use the ease slot; it's left unset in the struct."
(org-drill-determine-next-interval-simple8
(make-org-drill-card-state
:last-interval last-interval :repetitions repeats
:failures failures :meanq meanq :total-repeats totaln)
quality delta-days))
(provide 'testutil-scheduler)
;;; testutil-scheduler.el ends here
|