diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-26 18:09:21 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-26 18:09:21 -0500 |
| commit | 1338b2ae757b7143fe4d211fc5a354c73cee526b (patch) | |
| tree | d9b1afbc6b15754439314ad47cbcc053ad9d3598 /tests/test-org-drill-multicloze-dispatch.el | |
| parent | 1a53381a176e99f5c7f9bed1589dbaf689f38390 (diff) | |
| download | org-drill-1338b2ae757b7143fe4d211fc5a354c73cee526b.tar.gz org-drill-1338b2ae757b7143fe4d211fc5a354c73cee526b.zip | |
chore: coverage, autoload fix, and internal cleanup for org-drill
A batch of test-coverage and hardening work, squashed from the test-work branch.
Tests: deduplicated a colliding leitner-capture test name so make test-name loads again. Added SM2 assert-failure cases, the six basic multicloze variant delegations, the three English-side spanish-verb branches, and org-drill-current-scope branch coverage.
Fix: the entry-point commands (org-drill itself, cram-tree, tree, directory, resume, relearn-item, strip-all-data, merge-buffers) carried no autoload cookies, so M-x failed from a fresh install until something pulled the file in. They're autoloaded now.
Perf: org-drill-shuffle was quadratic because it indexed a list with elt on every swap. It runs a linear Fisher-Yates pass over a vector now, and it checks its argument is a list.
Feat: added org-drill-version, a constant plus an interactive command, so a bug reporter doesn't have to open the file header.
Refactor: extracted org-drill--format-tense-mood, shared by the two verb-conjugation presenters that each carried a copy.
Docs: explained the SM8 magic numbers in the simple8 helpers as empirical fits rather than tunable knobs.
Diffstat (limited to 'tests/test-org-drill-multicloze-dispatch.el')
| -rw-r--r-- | tests/test-org-drill-multicloze-dispatch.el | 62 |
1 files changed, 62 insertions, 0 deletions
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 |
