aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-20 23:39:36 -0500
committerCraig Jennings <c@cjennings.net>2026-07-20 23:39:36 -0500
commitaee2a9a5d7e681f597c19f4aa54cf58337c48cc3 (patch)
tree5d158cdd55feabe6d700e34b0d39fd6ca3ae77c4 /tests
parentce176fd3c4f42cf56d423d6a465d7e45e3fbc4a1 (diff)
downloaddotemacs-aee2a9a5d7e681f597c19f4aa54cf58337c48cc3.tar.gz
dotemacs-aee2a9a5d7e681f597c19f4aa54cf58337c48cc3.zip
refactor(comments): extract shared comment-syntax resolution
The comment-start/comment-end resolution was copied into six command wrappers. One cj/--comment-read-syntax now owns it; the block-banner wrapper keeps its own block-specific prompt.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-custom-comments-public-wrappers.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test-custom-comments-public-wrappers.el b/tests/test-custom-comments-public-wrappers.el
index 42842649..2eda9d94 100644
--- a/tests/test-custom-comments-public-wrappers.el
+++ b/tests/test-custom-comments-public-wrappers.el
@@ -188,5 +188,30 @@ text via `read-from-minibuffer'."
(cj/comment-block-banner)
(should (string-match-p "Banner" (buffer-string)))))
+;;; cj/--comment-read-syntax — the shared comment-syntax resolution
+
+(ert-deftest test-comment-read-syntax-uses-buffer-syntax ()
+ "Normal: a buffer with comment syntax resolves without prompting."
+ (with-temp-buffer
+ (setq-local comment-start ";")
+ (setq-local comment-end "")
+ (cl-letf (((symbol-function 'read-string)
+ (lambda (&rest _) (error "should not prompt"))))
+ (should (equal (cj/--comment-read-syntax) '(";" . ""))))))
+
+(ert-deftest test-comment-read-syntax-nil-end-falls-back-to-empty ()
+ "Boundary: a nil comment-end resolves to the empty string."
+ (with-temp-buffer
+ (setq-local comment-start "#")
+ (setq-local comment-end nil)
+ (should (equal (cj/--comment-read-syntax) '("#" . "")))))
+
+(ert-deftest test-comment-read-syntax-prompts-when-unset ()
+ "Error: no buffer comment-start falls back to the prompt."
+ (with-temp-buffer
+ (setq-local comment-start nil)
+ (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "//")))
+ (should (equal (car (cj/--comment-read-syntax)) "//")))))
+
(provide 'test-custom-comments-public-wrappers)
;;; test-custom-comments-public-wrappers.el ends here