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-explain-and-language-cards.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-explain-and-language-cards.el')
| -rw-r--r-- | tests/test-org-drill-explain-and-language-cards.el | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test-org-drill-explain-and-language-cards.el b/tests/test-org-drill-explain-and-language-cards.el index 301705d..9454a0d 100644 --- a/tests/test-org-drill-explain-and-language-cards.el +++ b/tests/test-org-drill-explain-and-language-cards.el @@ -171,6 +171,34 @@ on whether the buffer ends with a newline." (face (get-text-property 0 'face (nth 0 info)))) (should (equal "red" (plist-get face :foreground)))))) +;;;; org-drill--read-property-string + +(ert-deftest test-org-drill-read-property-string-strips-one-read () + "A Lisp-readable property string is read down to its datum." + (should (equal "hablar" (org-drill--read-property-string "\"hablar\"")))) + +(ert-deftest test-org-drill-read-property-string-nil-is-nil () + "A nil property (absent) returns nil rather than erroring." + (should (null (org-drill--read-property-string nil)))) + +;;;; org-drill--face-from-alist + +(ert-deftest test-org-drill-face-from-alist-hit-returns-colour () + "A key present in the alist returns its mapped colour." + (should (equal "tomato" + (org-drill--face-from-alist "present" org-drill-verb-tense-alist "x")))) + +(ert-deftest test-org-drill-face-from-alist-is-case-insensitive () + "Lookup ignores case, matching the assoc-string call sites." + (should (equal "tomato" + (org-drill--face-from-alist "PRESENT" org-drill-verb-tense-alist "x")))) + +(ert-deftest test-org-drill-face-from-alist-miss-returns-default () + "A key absent from the alist falls back to the supplied default." + (should (equal "fallback" + (org-drill--face-from-alist "no-such-tense" + org-drill-verb-tense-alist "fallback")))) + (provide 'test-org-drill-explain-and-language-cards) ;;; test-org-drill-explain-and-language-cards.el ends here |
