aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--org-drill.el105
-rw-r--r--tests/test-org-drill-autoloads.el47
-rw-r--r--tests/test-org-drill-current-scope.el48
-rw-r--r--tests/test-org-drill-determine-next-interval-sm2.el21
-rw-r--r--tests/test-org-drill-final-helpers.el4
-rw-r--r--tests/test-org-drill-language-presenters.el19
-rw-r--r--tests/test-org-drill-map-leitner-capture.el4
-rw-r--r--tests/test-org-drill-multicloze-dispatch.el62
-rw-r--r--tests/test-org-drill-spanish-and-top-level.el42
-rw-r--r--tests/test-org-drill-utilities-and-leitner.el6
-rw-r--r--tests/test-org-drill-version.el28
11 files changed, 345 insertions, 41 deletions
diff --git a/org-drill.el b/org-drill.el
index d52fbe9..836f754 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -64,6 +64,18 @@
:tag "Org-Drill"
:group 'org-link)
+(defconst org-drill-version "2.7.0"
+ "Version of the org-drill package.
+Keep this in sync with the Version header at the top of this file.")
+
+;;;###autoload
+(defun org-drill-version ()
+ "Report the installed org-drill version in the echo area.
+Returns the version string so it is useful in non-interactive code too."
+ (interactive)
+ (message "org-drill %s" org-drill-version)
+ org-drill-version)
+
(defcustom org-drill-question-tag
"drill"
"Tag for topics which are review topics."
@@ -1271,6 +1283,10 @@ Returns a list:
Returns the optimal FIRST interval for an item which has previously been
forgotten on FAILURES occasions."
+ ;; SM8 first-interval model. An item never forgotten gets ~2.4849 days;
+ ;; each prior failure shrinks that by a factor of e^-0.057 (~5.5% per
+ ;; failure). Both constants are the empirical fit from the SM8 algorithm
+ ;; and are not meant to be tuned individually.
(* 2.4849 (exp (* -0.057 failures))))
(defun org-drill-simple8-interval-factor (ease repetition)
@@ -1281,11 +1297,19 @@ forgotten on FAILURES occasions."
Returns:
The factor by which the last interval should be
multiplied to give the next interval. Corresponds to `RF' or `OF'."
+ ;; 1.2 is the SM8 floor for the interval factor: it never drops below 1.2,
+ ;; so intervals always grow. The amount above the floor decays as
+ ;; learn-fraction raised to log2(repetition), pulling later repetitions
+ ;; toward the floor.
(+ 1.2 (* (- ease 1.2) (expt org-drill-learn-fraction (log repetition 2)))))
(defun org-drill-simple8-quality->ease (quality)
"Returns the ease (`AF' in the SM8 algorithm) which corresponds
to a mean item quality of QUALITY."
+ ;; Quality (0-5 mean recall score) maps to ease/AF through this 4th-degree
+ ;; polynomial, a least-squares fit carried over from the SM8 algorithm.
+ ;; The five coefficients are empirical and only meaningful together, so
+ ;; treat them as one fitted curve rather than independent knobs.
(+ (* 0.0542 (expt quality 4))
(* -0.4848 (expt quality 3))
(* 1.4916 (expt quality 2))
@@ -3142,6 +3166,7 @@ and optionally saves buffers."
(sit-for 1)
(message nil))))
+;;;###autoload
(defun org-drill (&optional scope drill-match resume-p cram)
"Begin an interactive \\='drill session\\='. The user is asked to
review a series of topics (headers). Each topic is initially
@@ -3223,6 +3248,7 @@ hours."
(interactive)
(org-drill scope drill-match nil t))
+;;;###autoload
(defun org-drill-cram-tree ()
"Run an interactive drill session in \\='cram mode\\=' using subtree at point.
@@ -3230,12 +3256,14 @@ See also, `org-drill-cram' and `org-drill-tree'."
(interactive)
(org-drill-cram 'tree))
+;;;###autoload
(defun org-drill-tree ()
"Run an interactive drill session using drill items within the
subtree at point."
(interactive)
(org-drill 'tree))
+;;;###autoload
(defun org-drill-directory ()
"Run an interactive drill session using drill items from all org
files in the same directory as the current file."
@@ -3265,6 +3293,7 @@ scan will be performed."
(t
(org-drill scope drill-match)))))
+;;;###autoload
(defun org-drill-resume ()
"Resume a suspended drill session. Sessions are suspended by
exiting them with the `edit' or `quit' options."
@@ -3287,6 +3316,7 @@ need reviewing. Start a new drill session? "
(message "You have finished the drill session.")))))
+;;;###autoload
(defun org-drill-relearn-item ()
"Make the current item due for revision, and set its last interval to 0.
Makes the item behave as if it has been failed, without actually recording a
@@ -3301,6 +3331,7 @@ failure. This command can be used to \\='reset\\=' repetitions for an item."
(org-schedule '(4)))
+;;;###autoload
(defun org-drill-strip-all-data (&optional scope)
"Delete scheduling data from every drill entry in scope. This
function may be useful if you want to give your collection of
@@ -3450,6 +3481,7 @@ deck owner is opting in to a clean migration."
(set-marker m nil))
org-drill-dest-id-table))
+;;;###autoload
(defun org-drill-merge-buffers (src &optional dest ignore-new-items-p)
"SRC and DEST are two org mode buffers containing drill items.
For each drill item in DEST that shares an ID with an item in SRC,
@@ -3543,32 +3575,34 @@ the name of the tense.")
(if mood (setq mood (propertize mood 'face highlight-face)))
(list infinitive inf-hint translation tense mood)))
+(defun org-drill--format-tense-mood (tense mood)
+ "Return a human-readable label for a verb's TENSE and MOOD.
+Either argument may be nil. Returns nil when both are nil."
+ (cond
+ ((and tense mood)
+ (format "%s tense, %s mood" tense mood))
+ (tense
+ (format "%s tense" tense))
+ (mood
+ (format "%s mood" mood))))
+
(defun org-drill-present-verb-conjugation (session)
"Present a drill entry whose card type is \\='conjugate\\='."
- (cl-flet ((tense-and-mood-to-string
- (tense mood)
- (cond
- ((and tense mood)
- (format "%s tense, %s mood" tense mood))
- (tense
- (format "%s tense" tense))
- (mood
- (format "%s mood" mood)))))
- (cl-destructuring-bind (infinitive inf-hint translation tense mood)
- (org-drill-get-verb-conjugation-info)
- (org-drill-present-card-using-text
- session
- (cond
- ((zerop (cl-random 2))
- (format "\nTranslate the verb\n\n%s\n\nand conjugate for the %s.\n\n"
- infinitive (tense-and-mood-to-string tense mood)))
-
- (t
- (format "\nGive the verb that means\n\n%s %s\n
+ (cl-destructuring-bind (infinitive inf-hint translation tense mood)
+ (org-drill-get-verb-conjugation-info)
+ (org-drill-present-card-using-text
+ session
+ (cond
+ ((zerop (cl-random 2))
+ (format "\nTranslate the verb\n\n%s\n\nand conjugate for the %s.\n\n"
+ infinitive (org-drill--format-tense-mood tense mood)))
+
+ (t
+ (format "\nGive the verb that means\n\n%s %s\n
and conjugate for the %s.\n\n"
- translation
- (if inf-hint (format " [HINT: %s]" inf-hint) "")
- (tense-and-mood-to-string tense mood))))))))
+ translation
+ (if inf-hint (format " [HINT: %s]" inf-hint) "")
+ (org-drill--format-tense-mood tense mood)))))))
(defun org-drill-show-answer-verb-conjugation (session reschedule-fn)
"Show the answer for a drill item whose card type is \\='conjugate\\='.
@@ -3578,14 +3612,7 @@ returns its return value."
(org-drill-get-verb-conjugation-info)
(org-drill-with-replaced-entry-heading
(format "%s of %s ==> %s\n\n"
- (capitalize
- (cond
- ((and tense mood)
- (format "%s tense, %s mood" tense mood))
- (tense
- (format "%s tense" tense))
- (mood
- (format "%s mood" mood))))
+ (capitalize (org-drill--format-tense-mood tense mood))
infinitive translation)
(org-drill-hide-drawers)
(funcall reschedule-fn session))))
@@ -3852,12 +3879,16 @@ Returns a list of strings."
(setf (elt LIST el2) tmp)))
(defun org-drill-shuffle (LIST)
- "Shuffle the elements in LIST.
-shuffling is done in place."
- (cl-loop for i in (reverse (number-sequence 1 (1- (length LIST))))
- do (let ((j (random (+ i 1))))
- (org-drill-swap LIST i j)))
- LIST)
+ "Return a random permutation of the elements in LIST.
+The shuffle runs over a temporary vector with a Fisher-Yates pass,
+so the cost is linear in the length of LIST rather than quadratic
+\(the previous version indexed a list with `elt' on every swap)."
+ (cl-check-type LIST list)
+ (let ((vec (vconcat LIST)))
+ (cl-loop for i from (1- (length vec)) downto 1
+ do (let ((j (random (1+ i))))
+ (cl-rotatef (aref vec i) (aref vec j))))
+ (append vec nil)))
(defun org-drill-leitner-start-box (number)
"Box some items for the first time."
diff --git a/tests/test-org-drill-autoloads.el b/tests/test-org-drill-autoloads.el
new file mode 100644
index 0000000..5bfefce
--- /dev/null
+++ b/tests/test-org-drill-autoloads.el
@@ -0,0 +1,47 @@
+;;; test-org-drill-autoloads.el --- Autoload-cookie coverage -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; The user-facing entry-point commands must carry an `;;;###autoload' cookie
+;; so they work from a fresh package install before org-drill is loaded.
+;; Without it, `M-x org-drill-resume' (etc.) fails with "command not found"
+;; until something pulls the file in.
+;;
+;; This reads the source via `find-library-name' (the .el, not a compiled
+;; .elc which would have the cookies stripped) and checks each command.
+
+;;; Code:
+
+(require 'ert)
+(require 'org-drill)
+
+(defconst test-org-drill-autoloaded-commands
+ '("org-drill"
+ "org-drill-cram"
+ "org-drill-cram-tree"
+ "org-drill-tree"
+ "org-drill-directory"
+ "org-drill-again"
+ "org-drill-resume"
+ "org-drill-relearn-item"
+ "org-drill-strip-all-data"
+ "org-drill-merge-buffers")
+ "Entry-point commands that should be autoloaded.")
+
+(ert-deftest test-org-drill-entry-commands-carry-autoload-cookie ()
+ "Each user-facing entry-point command is preceded by an autoload cookie."
+ (let ((src (with-temp-buffer
+ (insert-file-contents (find-library-name "org-drill"))
+ (buffer-string))))
+ (dolist (cmd test-org-drill-autoloaded-commands)
+ (should (string-match-p
+ (concat ";;;###autoload\n(defun " (regexp-quote cmd) " ")
+ src)))))
+
+(ert-deftest test-org-drill-entry-commands-are-interactive ()
+ "Every command in the autoload list is actually an interactive command."
+ (dolist (cmd test-org-drill-autoloaded-commands)
+ (should (commandp (intern cmd)))))
+
+(provide 'test-org-drill-autoloads)
+
+;;; test-org-drill-autoloads.el ends here
diff --git a/tests/test-org-drill-current-scope.el b/tests/test-org-drill-current-scope.el
new file mode 100644
index 0000000..9743c5f
--- /dev/null
+++ b/tests/test-org-drill-current-scope.el
@@ -0,0 +1,48 @@
+;;; test-org-drill-current-scope.el --- Tests for org-drill-current-scope -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; org-drill-current-scope translates a drill scope into the scope argument
+;; org-map-entries expects, and org-drill-map-entries delegates to it. The
+;; map-entries mapping itself and drill-match filtering are covered in
+;; test-org-drill.el (find-entries / find-tagged-entries); this file covers
+;; the scope-translation branches, which had no tests.
+
+;;; Code:
+
+(require 'ert)
+(require 'cl-lib)
+(require 'org-drill)
+
+(ert-deftest test-org-drill-current-scope-file-returns-nil ()
+ "Scope `file' maps to nil — the current buffer, respecting narrowing."
+ (should (null (org-drill-current-scope 'file))))
+
+(ert-deftest test-org-drill-current-scope-file-no-restriction-returns-file ()
+ "Scope `file-no-restriction' maps to `file' — whole buffer, ignoring narrowing."
+ (should (eq 'file (org-drill-current-scope 'file-no-restriction))))
+
+(ert-deftest test-org-drill-current-scope-custom-symbol-passes-through ()
+ "An unrecognized scope such as `tree' is returned unchanged."
+ (should (eq 'tree (org-drill-current-scope 'tree))))
+
+(ert-deftest test-org-drill-current-scope-nil-falls-back-to-org-drill-scope ()
+ "A nil scope falls back to the value of `org-drill-scope'."
+ (let ((org-drill-scope 'tree))
+ (should (eq 'tree (org-drill-current-scope nil)))))
+
+(ert-deftest test-org-drill-current-scope-directory-lists-org-files ()
+ "Scope `directory' returns the .org files in the current file's directory."
+ (let (captured-dir)
+ (cl-letf (((symbol-function 'buffer-file-name)
+ (lambda (&rest _) "/tmp/deck/cards.org"))
+ ((symbol-function 'directory-files)
+ (lambda (dir _full _match)
+ (setq captured-dir dir)
+ '("/tmp/deck/a.org" "/tmp/deck/b.org"))))
+ (let ((result (org-drill-current-scope 'directory)))
+ (should (equal "/tmp/deck/" captured-dir))
+ (should (equal '("/tmp/deck/a.org" "/tmp/deck/b.org") result))))))
+
+(provide 'test-org-drill-current-scope)
+
+;;; test-org-drill-current-scope.el ends here
diff --git a/tests/test-org-drill-determine-next-interval-sm2.el b/tests/test-org-drill-determine-next-interval-sm2.el
index 622744d..3bf5cf3 100644
--- a/tests/test-org-drill-determine-next-interval-sm2.el
+++ b/tests/test-org-drill-determine-next-interval-sm2.el
@@ -417,5 +417,26 @@ Simulates inconsistent learning."
(should (= interval-2 -1))
(should (= failures-2 1))))
+;;; Error Cases - cl-assert invariant violations
+
+;; The function asserts (> n 0) and (and (>= quality 0) (<= quality 5)).
+;; n is normalized from 0 to 1 first, so only a negative n trips its assert.
+
+(ert-deftest test-org-drill-determine-next-interval-sm2-error-quality-above-max ()
+ "Quality above the 0-5 range trips the quality assertion."
+ (should-error (org-drill-determine-next-interval-sm2 1 2 2.5 6 0 4.0 1)
+ :type 'cl-assertion-failed))
+
+(ert-deftest test-org-drill-determine-next-interval-sm2-error-quality-below-min ()
+ "Quality below the 0-5 range trips the quality assertion."
+ (should-error (org-drill-determine-next-interval-sm2 1 2 2.5 -1 0 4.0 1)
+ :type 'cl-assertion-failed))
+
+(ert-deftest test-org-drill-determine-next-interval-sm2-error-negative-n ()
+ "A negative repeat count trips the (> n 0) assertion. Note n=0 is
+normalized to 1 before the assert, so zero is not an error case."
+ (should-error (org-drill-determine-next-interval-sm2 1 -1 2.5 4 0 4.0 1)
+ :type 'cl-assertion-failed))
+
(provide 'test-org-drill-determine-next-interval-sm2)
;;; test-org-drill-determine-next-interval-sm2.el ends here
diff --git a/tests/test-org-drill-final-helpers.el b/tests/test-org-drill-final-helpers.el
index c9cb0a3..b09efb7 100644
--- a/tests/test-org-drill-final-helpers.el
+++ b/tests/test-org-drill-final-helpers.el
@@ -111,8 +111,8 @@ matches leitner-tagged entries)."
(should (null org-drill-leitner-boxed-entries))
(should (null org-drill-leitner-unboxed-entries))))))
-(ert-deftest test-map-leitner-capture-non-drill-entry-skipped ()
- "Non-drill entries (no :drill: tag inheritance) are skipped silently."
+(ert-deftest test-map-leitner-capture-untagged-heading-skipped ()
+ "A heading carrying no drill/leitner tag is skipped silently."
(with-org-buffer "* Plain heading\n"
(let ((session (org-drill-session))
(org-drill-leitner-boxed-entries nil)
diff --git a/tests/test-org-drill-language-presenters.el b/tests/test-org-drill-language-presenters.el
index 6375b5f..da0a3a8 100644
--- a/tests/test-org-drill-language-presenters.el
+++ b/tests/test-org-drill-language-presenters.el
@@ -154,6 +154,25 @@
(lambda (_) (setq reschedule-called t))))
(should reschedule-called))))
+;;;; org-drill--format-tense-mood
+
+(ert-deftest test-org-drill-format-tense-mood-both ()
+ "With both tense and mood, the label names both."
+ (should (equal "past tense, subjunctive mood"
+ (org-drill--format-tense-mood "past" "subjunctive"))))
+
+(ert-deftest test-org-drill-format-tense-mood-tense-only ()
+ "With only a tense, the label names the tense."
+ (should (equal "present tense" (org-drill--format-tense-mood "present" nil))))
+
+(ert-deftest test-org-drill-format-tense-mood-mood-only ()
+ "With only a mood, the label names the mood."
+ (should (equal "imperative mood" (org-drill--format-tense-mood nil "imperative"))))
+
+(ert-deftest test-org-drill-format-tense-mood-neither-is-nil ()
+ "With neither tense nor mood, there is no label."
+ (should (null (org-drill--format-tense-mood nil nil))))
+
(provide 'test-org-drill-language-presenters)
;;; test-org-drill-language-presenters.el ends here
diff --git a/tests/test-org-drill-map-leitner-capture.el b/tests/test-org-drill-map-leitner-capture.el
index bc43c7d..114f51e 100644
--- a/tests/test-org-drill-map-leitner-capture.el
+++ b/tests/test-org-drill-map-leitner-capture.el
@@ -60,8 +60,8 @@
(should (= 0 (length org-drill-leitner-boxed-entries)))
(should (= 0 (length org-drill-leitner-unboxed-entries))))))
-(ert-deftest test-map-leitner-capture-non-drill-entry-skipped ()
- "Non-drill heading is skipped entirely."
+(ert-deftest test-map-leitner-capture-no-headline-skipped ()
+ "A buffer with no headline at all is skipped entirely."
(with-leitner-tempfile "Just text, no headlines\n"
(let ((session (org-drill-session))
(org-drill-question-tag org-drill-leitner-tag))
diff --git a/tests/test-org-drill-multicloze-dispatch.el b/tests/test-org-drill-multicloze-dispatch.el
index e871105..99861c7 100644
--- a/tests/test-org-drill-multicloze-dispatch.el
+++ b/tests/test-org-drill-multicloze-dispatch.el
@@ -138,6 +138,68 @@ piece is guaranteed not to be the first)."
(args (cdr call)))
(should (eq -1 (nth 1 args))))))))
+;;;; Basic variants — delegation contract
+;;
+;; hide1/hide2/hide-first/hide-last are thin wrappers. The hiding
+;; mechanics they delegate to (hide-n / hide-nth) are exercised directly
+;; in test-org-drill-multicloze-hiding.el, so re-driving present-and-reveal
+;; here would just re-test those. What's untested is the wiring: which
+;; delegate each variant calls and with what argument.
+
+(ert-deftest test-multicloze-hide1-delegates-to-hide-n-1 ()
+ "hide1 hides one piece: delegates to hide-n with number-to-hide = 1."
+ (with-fresh-drill-entry
+ (let (recorded)
+ (cl-letf (((symbol-function 'org-drill-present-multicloze-hide-n)
+ (lambda (_session n &rest _) (setq recorded n) t)))
+ (org-drill-present-multicloze-hide1 (org-drill-session))
+ (should (eql 1 recorded))))))
+
+(ert-deftest test-multicloze-hide2-delegates-to-hide-n-2 ()
+ "hide2 hides two pieces: delegates to hide-n with number-to-hide = 2."
+ (with-fresh-drill-entry
+ (let (recorded)
+ (cl-letf (((symbol-function 'org-drill-present-multicloze-hide-n)
+ (lambda (_session n &rest _) (setq recorded n) t)))
+ (org-drill-present-multicloze-hide2 (org-drill-session))
+ (should (eql 2 recorded))))))
+
+(ert-deftest test-multicloze-hide-first-delegates-to-hide-nth-1 ()
+ "hide-first hides the first piece: delegates to hide-nth with 1."
+ (with-fresh-drill-entry
+ (let (recorded)
+ (cl-letf (((symbol-function 'org-drill-present-multicloze-hide-nth)
+ (lambda (_session nth &rest _) (setq recorded nth) t)))
+ (org-drill-present-multicloze-hide-first (org-drill-session))
+ (should (eql 1 recorded))))))
+
+(ert-deftest test-multicloze-hide-last-delegates-to-hide-nth-last ()
+ "hide-last hides the last piece: delegates to hide-nth with -1."
+ (with-fresh-drill-entry
+ (let (recorded)
+ (cl-letf (((symbol-function 'org-drill-present-multicloze-hide-nth)
+ (lambda (_session nth &rest _) (setq recorded nth) t)))
+ (org-drill-present-multicloze-hide-last (org-drill-session))
+ (should (eql -1 recorded))))))
+
+(ert-deftest test-multicloze-show1-delegates-to-hide-n-minus-1 ()
+ "show1 reveals one piece (hides the rest): delegates to hide-n with -1."
+ (with-fresh-drill-entry
+ (let (recorded)
+ (cl-letf (((symbol-function 'org-drill-present-multicloze-hide-n)
+ (lambda (_session n &rest _) (setq recorded n) t)))
+ (org-drill-present-multicloze-show1 (org-drill-session))
+ (should (eql -1 recorded))))))
+
+(ert-deftest test-multicloze-show2-delegates-to-hide-n-minus-2 ()
+ "show2 reveals two pieces: delegates to hide-n with -2."
+ (with-fresh-drill-entry
+ (let (recorded)
+ (cl-letf (((symbol-function 'org-drill-present-multicloze-hide-n)
+ (lambda (_session n &rest _) (setq recorded n) t)))
+ (org-drill-present-multicloze-show2 (org-drill-session))
+ (should (eql -2 recorded))))))
+
(provide 'test-org-drill-multicloze-dispatch)
;;; test-org-drill-multicloze-dispatch.el ends here
diff --git a/tests/test-org-drill-spanish-and-top-level.el b/tests/test-org-drill-spanish-and-top-level.el
index 61fc546..465d82f 100644
--- a/tests/test-org-drill-spanish-and-top-level.el
+++ b/tests/test-org-drill-spanish-and-top-level.el
@@ -88,6 +88,48 @@ hablo, hablas, ...
(org-drill-present-spanish-verb (org-drill-session))
(should (string-match-p "future perfect" shown-prompt))))))
+(ert-deftest test-present-spanish-verb-branch-1-present-tense-conjugate ()
+ "Branch 1 reveals the English side and asks to conjugate the present tense."
+ (with-card-buffer "* Verb :drill:\n** Infinitive\nhablar\n** English\nto speak\n** Present Tense\nfoo\n"
+ (let ((shown-prompt nil))
+ (cl-letf (((symbol-function 'cl-random) (lambda (_) 1))
+ ((symbol-function 'org-drill-presentation-prompt)
+ (lambda (_session &optional prompt &rest _)
+ (setq shown-prompt prompt) t))
+ ((symbol-function 'org-drill--show-latex-fragments) #'ignore)
+ ((symbol-function 'org-display-inline-images) #'ignore))
+ (org-drill-present-spanish-verb (org-drill-session))
+ (should (string-match-p "present.* tense" shown-prompt))
+ (should (string-match-p "English verb" shown-prompt))))))
+
+(ert-deftest test-present-spanish-verb-branch-3-past-tense-conjugate ()
+ "Branch 3 reveals the English side and asks to conjugate the past tense."
+ (with-card-buffer "* Verb :drill:\n** Infinitive\nhablar\n** English\nto speak\n** Past Tense\nfoo\n"
+ (let ((shown-prompt nil))
+ (cl-letf (((symbol-function 'cl-random) (lambda (_) 3))
+ ((symbol-function 'org-drill-presentation-prompt)
+ (lambda (_session &optional prompt &rest _)
+ (setq shown-prompt prompt) t))
+ ((symbol-function 'org-drill--show-latex-fragments) #'ignore)
+ ((symbol-function 'org-display-inline-images) #'ignore))
+ (org-drill-present-spanish-verb (org-drill-session))
+ (should (string-match-p "past.* tense" shown-prompt))
+ (should (string-match-p "English verb" shown-prompt))))))
+
+(ert-deftest test-present-spanish-verb-branch-5-future-perfect-conjugate ()
+ "Branch 5 reveals the English side and asks to conjugate the future perfect."
+ (with-card-buffer "* Verb :drill:\n** Infinitive\nhablar\n** English\nto speak\n** Future Perfect Tense\nfoo\n"
+ (let ((shown-prompt nil))
+ (cl-letf (((symbol-function 'cl-random) (lambda (_) 5))
+ ((symbol-function 'org-drill-presentation-prompt)
+ (lambda (_session &optional prompt &rest _)
+ (setq shown-prompt prompt) t))
+ ((symbol-function 'org-drill--show-latex-fragments) #'ignore)
+ ((symbol-function 'org-display-inline-images) #'ignore))
+ (org-drill-present-spanish-verb (org-drill-session))
+ (should (string-match-p "future perfect" shown-prompt))
+ (should (string-match-p "English verb" shown-prompt))))))
+
;;;; org-drill-cram and friends
(ert-deftest test-org-drill-cram-passes-cram-flag ()
diff --git a/tests/test-org-drill-utilities-and-leitner.el b/tests/test-org-drill-utilities-and-leitner.el
index cc0157c..02761a2 100644
--- a/tests/test-org-drill-utilities-and-leitner.el
+++ b/tests/test-org-drill-utilities-and-leitner.el
@@ -61,6 +61,12 @@
(ert-deftest test-org-drill-shuffle-single-element-unchanged ()
(should (equal '(42) (org-drill-shuffle (list 42)))))
+(ert-deftest test-org-drill-shuffle-rejects-non-list ()
+ "The argument must be a list. A non-list (number, vector) is rejected
+with a clear type error rather than silently coerced."
+ (should-error (org-drill-shuffle 42) :type 'wrong-type-argument)
+ (should-error (org-drill-shuffle [1 2 3]) :type 'wrong-type-argument))
+
;;;; org-drill-pop-random (macro)
(ert-deftest test-org-drill-pop-random-removes-one-element ()
diff --git a/tests/test-org-drill-version.el b/tests/test-org-drill-version.el
new file mode 100644
index 0000000..4dc71d3
--- /dev/null
+++ b/tests/test-org-drill-version.el
@@ -0,0 +1,28 @@
+;;; test-org-drill-version.el --- Tests for org-drill-version -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; org-drill-version is both a constant (the package version string) and an
+;; interactive command that reports it, so bug reporters don't have to open
+;; the file header.
+
+;;; Code:
+
+(require 'ert)
+(require 'org-drill)
+
+(ert-deftest test-org-drill-version-is-a-version-string ()
+ "The constant is a non-empty dotted version string."
+ (should (stringp org-drill-version))
+ (should (string-match-p "\\`[0-9]+\\.[0-9]+" org-drill-version)))
+
+(ert-deftest test-org-drill-version-command-returns-the-version ()
+ "Calling the command returns the version string."
+ (should (equal org-drill-version (org-drill-version))))
+
+(ert-deftest test-org-drill-version-command-is-interactive ()
+ "The version reporter is an interactive command."
+ (should (commandp 'org-drill-version)))
+
+(provide 'test-org-drill-version)
+
+;;; test-org-drill-version.el ends here