diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-26 19:58:21 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-26 19:58:21 -0500 |
| commit | 7eece407772d7c5cfba93ba914439094f0d9fbf2 (patch) | |
| tree | 4b25307c895ab134312cd31141c48c0aea3c530e /tests/test-org-drill-entry-f.el | |
| parent | 5c8d908a943470e3e4738c090cf8eaa1deee5a1f (diff) | |
| download | org-drill-7eece407772d7c5cfba93ba914439094f0d9fbf2.tar.gz org-drill-7eece407772d7c5cfba93ba914439094f0d9fbf2.zip | |
refactor: dedupe presenters, group defcustoms, and fill in docstrings
A cleanup pass over org-drill internals, squashed from the refactor/wave3-cleanup branch. No behavior change. Each step kept the existing tests green and added its own.
I shared two duplicated helpers across the language card getters: org-drill--read-property-string and org-drill--face-from-alist.
I factored the cloze body-scan out of the two multicloze presenters into org-drill--cloze-body-bounds, org-drill--count-cloze-matches, and org-drill--hide-cloze-by-index, so each presenter just picks which indices to hide.
I pulled the presenter resolution and the four-way result classification out of org-drill-entry-f into org-drill--resolve-presenter and org-drill--classify-presentation-result, untangling the pivot of every drill iteration.
I split the 37 defcustoms (and the three cloze faces) into four customize sub-groups (display, algorithm, session, leech) so customize-group org-drill is navigable. There's no leitner group because the Leitner settings are defvars.
I documented the 22 defuns that had no docstring, rewrote the corrupted org-drill-presentation-prompt-in-mini-buffer docstring, and switched eleven docstrings to the imperative "Return" (issue #2).
Diffstat (limited to 'tests/test-org-drill-entry-f.el')
| -rw-r--r-- | tests/test-org-drill-entry-f.el | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test-org-drill-entry-f.el b/tests/test-org-drill-entry-f.el index e99a171..1beed34 100644 --- a/tests/test-org-drill-entry-f.el +++ b/tests/test-org-drill-entry-f.el @@ -97,6 +97,48 @@ the complete-func (e.g., reschedule) is invoked with the session." (lambda (_) (setq complete-called t))) (should complete-called))))) +;;;; org-drill--resolve-presenter + +(ert-deftest test-org-drill-resolve-presenter-bare-symbol () + "A bare presenter symbol pairs with the default answer function." + (let ((org-drill-card-type-alist '(("simple" . my-present)))) + (should (equal '(my-present . org-drill-present-default-answer) + (org-drill--resolve-presenter "simple"))))) + +(ert-deftest test-org-drill-resolve-presenter-list-with-answer () + "A list entry uses its first element as presenter and second as answer." + (let ((org-drill-card-type-alist '(("two" my-present my-answer)))) + (should (equal '(my-present . my-answer) + (org-drill--resolve-presenter "two"))))) + +(ert-deftest test-org-drill-resolve-presenter-list-without-answer () + "A single-element list entry falls back to the default answer function." + (let ((org-drill-card-type-alist '(("one" my-present)))) + (should (equal '(my-present . org-drill-present-default-answer) + (org-drill--resolve-presenter "one"))))) + +(ert-deftest test-org-drill-resolve-presenter-unknown-is-nil () + "An unknown card type resolves to a nil presenter (which entry-f skips)." + (let ((org-drill-card-type-alist '(("simple" . my-present)))) + (should (equal '(nil . org-drill-present-default-answer) + (org-drill--resolve-presenter "no-such-type"))))) + +;;;; org-drill--classify-presentation-result + +(ert-deftest test-org-drill-classify-result-nil-is-quit () + (should (eq 'quit (org-drill--classify-presentation-result nil)))) + +(ert-deftest test-org-drill-classify-result-edit () + (should (eq 'edit (org-drill--classify-presentation-result 'edit)))) + +(ert-deftest test-org-drill-classify-result-skip () + (should (eq 'skip (org-drill--classify-presentation-result 'skip)))) + +(ert-deftest test-org-drill-classify-result-other-is-answer () + "Any other non-nil value means proceed to the answer." + (should (eq 'answer (org-drill--classify-presentation-result t))) + (should (eq 'answer (org-drill--classify-presentation-result 5)))) + (provide 'test-org-drill-entry-f) ;;; test-org-drill-entry-f.el ends here |
