1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

time-stamp: Add test of multi-line start regexp

* test/lisp/time-stamp-tests.el: (time-stamp-custom-start-multiline):
New test, inspired by Amin Bandali.
This commit is contained in:
Stephen Gildea 2025-11-30 12:36:12 -08:00
parent c2e2a86d1b
commit 77a57041d0

View file

@ -164,7 +164,7 @@
(iter-yield-from (time-stamp-test-pattern-sequential)) (iter-yield-from (time-stamp-test-pattern-sequential))
(iter-yield-from (time-stamp-test-pattern-multiply))) (iter-yield-from (time-stamp-test-pattern-multiply)))
(ert-deftest time-stamp-custom-start () (ert-deftest time-stamp-custom-start-0 ()
"Test that `time-stamp' isn't stuck by a start matching 0 characters." "Test that `time-stamp' isn't stuck by a start matching 0 characters."
(with-time-stamp-test-env (with-time-stamp-test-env
(with-time-stamp-test-time ref-time1 (with-time-stamp-test-time ref-time1
@ -189,6 +189,18 @@
(time-stamp) (time-stamp)
(should (equal (buffer-string) "::05::05"))))))) (should (equal (buffer-string) "::05::05")))))))
(ert-deftest time-stamp-custom-start-multiline ()
"Test `time-stamp-start' matching across multiple lines."
(with-time-stamp-test-env
(with-time-stamp-test-time ref-time1
(let ((time-stamp-pattern "l.1\n%Y-%m-%d<-TS")) ;start includes newline
(with-temp-buffer
(insert "l.1\n<-TS\n")
;; we should look for the end on the line where the start ends,
;; not the line where the start starts
(time-stamp)
(should (equal (buffer-string) "l.1\n2006-01-02<-TS\n")))))))
(ert-deftest time-stamp-custom-pattern () (ert-deftest time-stamp-custom-pattern ()
"Test that `time-stamp-pattern' is parsed correctly." "Test that `time-stamp-pattern' is parsed correctly."
(iter-do (pattern-parts (time-stamp-test-pattern-all)) (iter-do (pattern-parts (time-stamp-test-pattern-all))