From 1338b2ae757b7143fe4d211fc5a354c73cee526b Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 26 May 2026 18:09:21 -0500 Subject: 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. --- tests/test-org-drill-current-scope.el | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/test-org-drill-current-scope.el (limited to 'tests/test-org-drill-current-scope.el') 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 -- cgit v1.2.3