aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStephen Gildea2024-11-01 09:32:27 -0700
committerStephen Gildea2024-11-01 09:36:07 -0700
commitffda8dfe847094bd8488059be2f96270fe298fa5 (patch)
treec6b8b50aabf671b7a000fb48e543e520df2244d5 /test
parent872be2bb5febc5a720d6f4dbbd2fd30561385bb6 (diff)
downloademacs-ffda8dfe847094bd8488059be2f96270fe298fa5.tar.gz
emacs-ffda8dfe847094bd8488059be2f96270fe298fa5.zip
; time-stamp: Reformat some long doc strings for clarity.
* lisp/time-stamp.el (time-stamp-format, time-stamp-pattern): Reformat doc strings for clarity. (group time-stamp): is a subgroup of "files", not "data". The "data" group seems to be for editing non-text files. * test/lisp/time-stamp-tests.el: Fix tense of some doc strings.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/time-stamp-tests.el48
1 files changed, 24 insertions, 24 deletions
diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el
index a4c30d64225..36889257724 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -535,7 +535,7 @@
535 (should (equal (time-stamp-string "%#Z" ref-time1) utc-abbr))))) 535 (should (equal (time-stamp-string "%#Z" ref-time1) utc-abbr)))))
536 536
537(ert-deftest time-stamp-format-time-zone-offset () 537(ert-deftest time-stamp-format-time-zone-offset ()
538 "Tests time-stamp legacy format %z and spot tests of new offset format %5z." 538 "Test time-stamp legacy format %z and spot-test new offset format %5z."
539 (with-time-stamp-test-env 539 (with-time-stamp-test-env
540 (let ((utc-abbr (format-time-string "%#Z" ref-time1 t))) 540 (let ((utc-abbr (format-time-string "%#Z" ref-time1 t)))
541 ;; documented 1995-2019, warned since 2019, will change 541 ;; documented 1995-2019, warned since 2019, will change
@@ -617,7 +617,7 @@
617 (should (equal (time-stamp-string "No percent" ref-time1) "No percent")))) 617 (should (equal (time-stamp-string "No percent" ref-time1) "No percent"))))
618 618
619(ert-deftest time-stamp-format-multiple-conversions () 619(ert-deftest time-stamp-format-multiple-conversions ()
620 "Tests that multiple %-conversions are independent." 620 "Test that multiple %-conversions are independent."
621 (with-time-stamp-test-env 621 (with-time-stamp-test-env
622 (let ((Mon (format-time-string "%a" ref-time1 t)) 622 (let ((Mon (format-time-string "%a" ref-time1 t))
623 (MON (format-time-string "%^a" ref-time1 t)) 623 (MON (format-time-string "%^a" ref-time1 t))
@@ -719,7 +719,7 @@
719;;;; Setup for tests of time offset formatting with %z 719;;;; Setup for tests of time offset formatting with %z
720 720
721(defun formatz (format zone) 721(defun formatz (format zone)
722 "Uses FORMAT to format the offset of ZONE, returning the result. 722 "Use FORMAT to format the offset of ZONE, returning the result.
723FORMAT must be time format \"%z\" or some variation thereof. 723FORMAT must be time format \"%z\" or some variation thereof.
724ZONE is as the ZONE argument of the `format-time-string' function. 724ZONE is as the ZONE argument of the `format-time-string' function.
725This function is called by 99% of the `time-stamp' \"%z\" unit tests." 725This function is called by 99% of the `time-stamp' \"%z\" unit tests."
@@ -733,7 +733,7 @@ This function is called by 99% of the `time-stamp' \"%z\" unit tests."
733 ))) 733 )))
734 734
735(defun format-time-offset (format offset-secs) 735(defun format-time-offset (format offset-secs)
736 "Uses FORMAT to format the time zone represented by OFFSET-SECS. 736 "Use FORMAT to format the time zone represented by OFFSET-SECS.
737FORMAT must be time format \"%z\" or some variation thereof. 737FORMAT must be time format \"%z\" or some variation thereof.
738This function is a wrapper around `time-stamp-formatz-from-parsed-options' 738This function is a wrapper around `time-stamp-formatz-from-parsed-options'
739and is called by some low-level `time-stamp' \"%z\" unit tests." 739and is called by some low-level `time-stamp' \"%z\" unit tests."
@@ -765,20 +765,20 @@ and is called by some low-level `time-stamp' \"%z\" unit tests."
765 trailing-string))) 765 trailing-string)))
766 766
767(defun fz-make+zone (h &optional m s) 767(defun fz-make+zone (h &optional m s)
768 "Creates a non-negative offset." 768 "Create a non-negative offset."
769 (declare (pure t)) 769 (declare (pure t))
770 (let ((m (or m 0)) 770 (let ((m (or m 0))
771 (s (or s 0))) 771 (s (or s 0)))
772 (+ (* 3600 h) (* 60 m) s))) 772 (+ (* 3600 h) (* 60 m) s)))
773 773
774(defun fz-make-zone (h &optional m s) 774(defun fz-make-zone (h &optional m s)
775 "Creates a negative offset. The arguments are all non-negative." 775 "Create a negative offset. The arguments are all non-negative."
776 (declare (pure t)) 776 (declare (pure t))
777 (- (fz-make+zone h m s))) 777 (- (fz-make+zone h m s)))
778 778
779(defmacro formatz-should-equal (zone expect) 779(defmacro formatz-should-equal (zone expect)
780 "Formats ZONE and compares it to EXPECT. 780 "Format ZONE and compares it to EXPECT.
781Uses the free variables `form-string' and `pattern-mod'. 781Use the free variables `form-string' and `pattern-mod'.
782The functions in `pattern-mod' are composed left to right." 782The functions in `pattern-mod' are composed left to right."
783 (declare (debug t)) 783 (declare (debug t))
784 `(let ((result ,expect)) 784 `(let ((result ,expect))
@@ -790,7 +790,7 @@ The functions in `pattern-mod' are composed left to right."
790;; for hours, minutes, and seconds. 790;; for hours, minutes, and seconds.
791 791
792(defun formatz-hours-exact-helper (form-string pattern-mod) 792(defun formatz-hours-exact-helper (form-string pattern-mod)
793 "Tests format %z with whole hours." 793 "Test format %z with whole hours."
794 (formatz-should-equal (fz-make+zone 0) "+00") ;0 sign always +, both digits 794 (formatz-should-equal (fz-make+zone 0) "+00") ;0 sign always +, both digits
795 (formatz-should-equal (fz-make+zone 10) "+10") 795 (formatz-should-equal (fz-make+zone 10) "+10")
796 (formatz-should-equal (fz-make-zone 10) "-10") 796 (formatz-should-equal (fz-make-zone 10) "-10")
@@ -801,7 +801,7 @@ The functions in `pattern-mod' are composed left to right."
801 ) 801 )
802 802
803(defun formatz-nonzero-minutes-helper (form-string pattern-mod) 803(defun formatz-nonzero-minutes-helper (form-string pattern-mod)
804 "Tests format %z with whole minutes." 804 "Test format %z with whole minutes."
805 (formatz-should-equal (fz-make+zone 0 30) "+00:30") ;has hours even though 0 805 (formatz-should-equal (fz-make+zone 0 30) "+00:30") ;has hours even though 0
806 (formatz-should-equal (fz-make-zone 0 30) "-00:30") 806 (formatz-should-equal (fz-make-zone 0 30) "-00:30")
807 (formatz-should-equal (fz-make+zone 0 4) "+00:04") 807 (formatz-should-equal (fz-make+zone 0 4) "+00:04")
@@ -819,7 +819,7 @@ The functions in `pattern-mod' are composed left to right."
819 ) 819 )
820 820
821(defun formatz-nonzero-seconds-helper (form-string pattern-mod) 821(defun formatz-nonzero-seconds-helper (form-string pattern-mod)
822 "Tests format %z with non-0 seconds." 822 "Test format %z with non-0 seconds."
823 ;; non-0 seconds are always included 823 ;; non-0 seconds are always included
824 (formatz-should-equal (fz-make+zone 0 0 50) "+00:00:50") 824 (formatz-should-equal (fz-make+zone 0 0 50) "+00:00:50")
825 (formatz-should-equal (fz-make-zone 0 0 50) "-00:00:50") 825 (formatz-should-equal (fz-make-zone 0 0 50) "-00:00:50")
@@ -848,7 +848,7 @@ The functions in `pattern-mod' are composed left to right."
848 ) 848 )
849 849
850(defun formatz-hours-big-helper (form-string pattern-mod) 850(defun formatz-hours-big-helper (form-string pattern-mod)
851 "Tests format %z with hours that don't fit in two digits." 851 "Test format %z with hours that don't fit in two digits."
852 (formatz-should-equal (fz-make+zone 101) "+101:00") 852 (formatz-should-equal (fz-make+zone 101) "+101:00")
853 (formatz-should-equal (fz-make+zone 123 10) "+123:10") 853 (formatz-should-equal (fz-make+zone 123 10) "+123:10")
854 (formatz-should-equal (fz-make-zone 123 10) "-123:10") 854 (formatz-should-equal (fz-make-zone 123 10) "-123:10")
@@ -857,7 +857,7 @@ The functions in `pattern-mod' are composed left to right."
857 ) 857 )
858 858
859(defun formatz-seconds-big-helper (form-string pattern-mod) 859(defun formatz-seconds-big-helper (form-string pattern-mod)
860 "Tests format %z with hours greater than 99 and non-zero seconds." 860 "Test format %z with hours greater than 99 and non-zero seconds."
861 (formatz-should-equal (fz-make+zone 123 0 30) "+123:00:30") 861 (formatz-should-equal (fz-make+zone 123 0 30) "+123:00:30")
862 (formatz-should-equal (fz-make-zone 123 0 30) "-123:00:30") 862 (formatz-should-equal (fz-make-zone 123 0 30) "-123:00:30")
863 (formatz-should-equal (fz-make+zone 120 0 4) "+120:00:04") 863 (formatz-should-equal (fz-make+zone 120 0 4) "+120:00:04")
@@ -868,30 +868,30 @@ The functions in `pattern-mod' are composed left to right."
868;; use the above test cases for multiple formats. 868;; use the above test cases for multiple formats.
869 869
870(defun formatz-mod-del-colons (string) 870(defun formatz-mod-del-colons (string)
871 "Returns STRING with any colons removed." 871 "Return STRING with any colons removed."
872 (string-replace ":" "" string)) 872 (string-replace ":" "" string))
873 873
874(defun formatz-mod-add-00 (string) 874(defun formatz-mod-add-00 (string)
875 "Returns STRING with \"00\" appended." 875 "Return STRING with \"00\" appended."
876 (concat string "00")) 876 (concat string "00"))
877 877
878(defun formatz-mod-add-colon00 (string) 878(defun formatz-mod-add-colon00 (string)
879 "Returns STRING with \":00\" appended." 879 "Return STRING with \":00\" appended."
880 (concat string ":00")) 880 (concat string ":00"))
881 881
882(defun formatz-mod-pad-r10 (string) 882(defun formatz-mod-pad-r10 (string)
883 "Returns STRING padded on the right to 10 characters." 883 "Return STRING padded on the right to 10 characters."
884 (concat string (make-string (- 10 (length string)) ?\s))) 884 (concat string (make-string (- 10 (length string)) ?\s)))
885 885
886(defun formatz-mod-pad-r12 (string) 886(defun formatz-mod-pad-r12 (string)
887 "Returns STRING padded on the right to 12 characters." 887 "Return STRING padded on the right to 12 characters."
888 (concat string (make-string (- 12 (length string)) ?\s))) 888 (concat string (make-string (- 12 (length string)) ?\s)))
889 889
890;; Convenience macro for generating groups of test cases. 890;; Convenience macro for generating groups of test cases.
891 891
892(defmacro formatz-generate-tests 892(defmacro formatz-generate-tests
893 (form-strings hour-mod mins-mod secs-mod big-mod secbig-mod) 893 (form-strings hour-mod mins-mod secs-mod big-mod secbig-mod)
894 "Defines tests for time formats FORM-STRINGS. 894 "Define tests for time formats FORM-STRINGS.
895FORM-STRINGS is a list of formats, each \"%z\" or some variation thereof. 895FORM-STRINGS is a list of formats, each \"%z\" or some variation thereof.
896 896
897Each of the remaining arguments is an unquoted list of the form 897Each of the remaining arguments is an unquoted list of the form
@@ -925,7 +925,7 @@ the other expected results for hours greater than 99 with non-zero seconds."
925 ert-test-list 925 ert-test-list
926 (list 926 (list
927 `(ert-deftest ,(intern (concat "formatz-" form-string "-hhmm")) () 927 `(ert-deftest ,(intern (concat "formatz-" form-string "-hhmm")) ()
928 ,(concat "Tests time-stamp format " form-string 928 ,(concat "Test time-stamp format " form-string
929 " with whole hours or minutes.") 929 " with whole hours or minutes.")
930 (should (equal (formatz ,form-string (fz-make+zone 0)) 930 (should (equal (formatz ,form-string (fz-make+zone 0))
931 ,(car hour-mod))) 931 ,(car hour-mod)))
@@ -934,13 +934,13 @@ the other expected results for hours greater than 99 with non-zero seconds."
934 ,(car mins-mod))) 934 ,(car mins-mod)))
935 (formatz-nonzero-minutes-helper ,form-string ',(cdr mins-mod))) 935 (formatz-nonzero-minutes-helper ,form-string ',(cdr mins-mod)))
936 `(ert-deftest ,(intern (concat "formatz-" form-string "-seconds")) () 936 `(ert-deftest ,(intern (concat "formatz-" form-string "-seconds")) ()
937 ,(concat "Tests time-stamp format " form-string 937 ,(concat "Test time-stamp format " form-string
938 " with offsets that have non-zero seconds.") 938 " with offsets that have non-zero seconds.")
939 (should (equal (formatz ,form-string (fz-make+zone 0 0 30)) 939 (should (equal (formatz ,form-string (fz-make+zone 0 0 30))
940 ,(car secs-mod))) 940 ,(car secs-mod)))
941 (formatz-nonzero-seconds-helper ,form-string ',(cdr secs-mod))) 941 (formatz-nonzero-seconds-helper ,form-string ',(cdr secs-mod)))
942 `(ert-deftest ,(intern (concat "formatz-" form-string "-threedigit")) () 942 `(ert-deftest ,(intern (concat "formatz-" form-string "-threedigit")) ()
943 ,(concat "Tests time-stamp format " form-string 943 ,(concat "Test time-stamp format " form-string
944 " with offsets that are 100 hours or greater.") 944 " with offsets that are 100 hours or greater.")
945 (should (equal (formatz ,form-string (fz-make+zone 100)) 945 (should (equal (formatz ,form-string (fz-make+zone 100))
946 ,(car big-mod))) 946 ,(car big-mod)))
@@ -981,7 +981,7 @@ the other expected results for hours greater than 99 with non-zero seconds."
981;; The legacy exception for %z in time-stamp will need to remain 981;; The legacy exception for %z in time-stamp will need to remain
982;; through at least 2024 and Emacs 28. 982;; through at least 2024 and Emacs 28.
983(ert-deftest formatz-%z-spotcheck () 983(ert-deftest formatz-%z-spotcheck ()
984 "Spot-checks internal implementation of time-stamp format %z." 984 "Spot-check internal implementation of time-stamp format %z."
985 (should (equal (format-time-offset "%z" (fz-make+zone 0)) "+0000")) 985 (should (equal (format-time-offset "%z" (fz-make+zone 0)) "+0000"))
986 (should (equal (format-time-offset "%z" (fz-make+zone 0 30)) "+0030")) 986 (should (equal (format-time-offset "%z" (fz-make+zone 0 30)) "+0030"))
987 (should (equal (format-time-offset "%z" (fz-make+zone 0 0 30)) "+000030")) 987 (should (equal (format-time-offset "%z" (fz-make+zone 0 0 30)) "+000030"))
@@ -1104,7 +1104,7 @@ the other expected results for hours greater than 99 with non-zero seconds."
1104;;; Illegal %z formats 1104;;; Illegal %z formats
1105 1105
1106(ert-deftest formatz-illegal-options () 1106(ert-deftest formatz-illegal-options ()
1107 "Tests that illegal/nonsensical/ambiguous %z formats don't produce output." 1107 "Test that illegal/nonsensical/ambiguous %z formats don't produce output."
1108 ;; multiple options 1108 ;; multiple options
1109 (should (equal "" (formatz "%_-z" 0))) 1109 (should (equal "" (formatz "%_-z" 0)))
1110 (should (equal "" (formatz "%-_z" 0))) 1110 (should (equal "" (formatz "%-_z" 0)))