emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c359782: Reorganize time-stamp tests


From: Stephen Gildea
Subject: [Emacs-diffs] master c359782: Reorganize time-stamp tests
Date: Sat, 28 Sep 2019 18:49:44 -0400 (EDT)

branch: master
commit c359782ae6441bba2fad2b6d53bcbcd5a8be7057
Author: Stephen Gildea <address@hidden>
Commit: Stephen Gildea <address@hidden>

    Reorganize time-stamp tests
    
    * time-stamp-tests.el: Group tests by when the format was or will be
    documented.  Add tests for a few more undocumented, volatile formats.
    Change AM hours test time to be a different hour from PM test time.
    (Making these changes to the tests now will minimize test changes
    needed later with anticipated code changes.)
---
 test/lisp/time-stamp-tests.el | 215 ++++++++++++++++++++++--------------------
 1 file changed, 112 insertions(+), 103 deletions(-)

diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el
index 165b4f1..452d83d 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -31,7 +31,7 @@
          (mail-host-address "test-mail-host-name")
          (ref-time '(17337 16613))     ;Monday, Jan 2, 2006, 3:04:05 PM
          (ref-time2 '(22574 61591))    ;Friday, Nov 18, 2016, 12:14:15 PM
-         (ref-time3 '(21377 23973 123456)) ;Sun, May 25, 2014, 
03:04:05.123456am
+         (ref-time3 '(21377 34956))    ;Sunday, May 25, 2014, 06:07:08 AM
          (time-stamp-time-zone t))     ;use UTC
      (cl-letf (((symbol-function 'time-stamp-conv-warn)
                 (lambda (old-format _new)
@@ -57,181 +57,187 @@
 
 ;;; Tests:
 
-(ert-deftest time-stamp-test-day-of-week-documented ()
-  "Test documented time-stamp formats for day of week."
+(ert-deftest time-stamp-test-day-of-week ()
+  "Test time-stamp formats for named day of week."
   (with-time-stamp-test-env
+    ;; implemented and documented since 1997
     (should (equal (time-stamp-string "%3a" ref-time) "Mon"))
+    (should (equal (time-stamp-string "%#A" ref-time) "MONDAY"))
     (should (equal (time-stamp-string "%3A" ref-time) "MON"))
     (should (equal (time-stamp-string "%:a" ref-time) "Monday"))
-    (should (equal (time-stamp-string "%#A" ref-time) "MONDAY"))
-    (should (equal (time-stamp-string "%3a" ref-time2) "Fri"))
-    (should (equal (time-stamp-string "%3A" ref-time2) "FRI"))
-    (should (equal (time-stamp-string "%:a" ref-time2) "Friday"))
-    (should (equal (time-stamp-string "%#A" ref-time2) "FRIDAY"))))
-
-(ert-deftest time-stamp-test-day-of-week-future ()
-  "Test implemented but as yet undocumented time-stamp formats for day of 
week."
-  (with-time-stamp-test-env
+    ;; implemented since 2001, undocumented future formats
     (should (equal (time-stamp-string "%#a" ref-time) "MON"))
     (should (equal (time-stamp-string "%:A" ref-time) "Monday"))
-    (should (equal (time-stamp-string "%#a" ref-time2) "FRI"))
-    (should (equal (time-stamp-string "%:A" ref-time2) "Friday"))))
-
-(ert-deftest time-stamp-test-day-of-week-volatile-warns ()
-  "Test time-stamp formats for day of week that will change.
-Test that each generates a warning."
-  (with-time-stamp-test-env
+    ;; warned since 1997, will change
+    (time-stamp-should-warn (equal
+                             (time-stamp-string "%a" ref-time) "Monday"))
     (time-stamp-should-warn (equal
-                            (time-stamp-string "%a" ref-time) "Monday"))
+                             (time-stamp-string "%^a" ref-time) "Monday"))
     (time-stamp-should-warn (equal
                              (time-stamp-string "%A" ref-time) "MONDAY"))))
 
-(ert-deftest time-stamp-test-month-name-documented ()
-  "Test documented time-stamp formats for month name."
+(ert-deftest time-stamp-test-month-name ()
+  "Test time-stamp formats for month name."
   (with-time-stamp-test-env
+    ;; implemented and documented since 1997
     (should (equal (time-stamp-string "%3b" ref-time) "Jan"))
+    (should (equal (time-stamp-string "%#B" ref-time) "JANUARY"))
     (should (equal (time-stamp-string "%3B" ref-time) "JAN"))
     (should (equal (time-stamp-string "%:b" ref-time) "January"))
-    (should (equal (time-stamp-string "%#B" ref-time) "JANUARY"))))
-
-(ert-deftest time-stamp-test-month-name-future ()
-  "Test implemented but as yet undocumented time-stamp formats for month name."
-  (with-time-stamp-test-env
+    ;; implemented since 2001, undocumented future formats
     (should (equal (time-stamp-string "%#b" ref-time) "JAN"))
-    (should (equal (time-stamp-string "%:B" ref-time) "January"))))
-
-(ert-deftest time-stamp-test-month-name-volatile-warns ()
-  "Test time-stamp formats for month name that will change.
-Test that each generates a warning."
-  (with-time-stamp-test-env
+    (should (equal (time-stamp-string "%:B" ref-time) "January"))
+    ;; warned since 1997, will change
     (time-stamp-should-warn (equal
                              (time-stamp-string "%b" ref-time) "January"))
     (time-stamp-should-warn (equal
+                             (time-stamp-string "%^b" ref-time) "January"))
+    (time-stamp-should-warn (equal
                              (time-stamp-string "%B" ref-time) "JANUARY"))))
 
 (ert-deftest time-stamp-test-day-of-month ()
   "Test time-stamp formats for day of month."
   (with-time-stamp-test-env
-    ;; documented 1-digit
-    (should (equal (time-stamp-string "%:d" ref-time) "2"))
+    ;; implemented and documented since 1995
     (should (equal (time-stamp-string "%2d" ref-time) " 2"))
-    (should (equal (time-stamp-string "%02d" ref-time) "02"))
-    ;; documented 2-digit
-    (should (equal (time-stamp-string "%:d" ref-time2) "18"))
     (should (equal (time-stamp-string "%2d" ref-time2) "18"))
+    (should (equal (time-stamp-string "%02d" ref-time) "02"))
     (should (equal (time-stamp-string "%02d" ref-time2) "18"))
-    ;; undocumented future formats
+    ;; implemented and documented since 1997
+    (should (equal (time-stamp-string "%:d" ref-time) "2"))
+    (should (equal (time-stamp-string "%:d" ref-time2) "18"))
+    ;; implemented since 1997, undocumented future format
     (should (equal (time-stamp-string "%1d" ref-time) "2"))
     (should (equal (time-stamp-string "%1d" ref-time2) "18"))
-    ;; changing formats
+    ;; warned since 1997, will change
+    (time-stamp-should-warn (equal (time-stamp-string "%_d" ref-time) "2"))
+    (time-stamp-should-warn (equal (time-stamp-string "%_d" ref-time2) "18"))
     (time-stamp-should-warn (equal (time-stamp-string "%d" ref-time) "2"))
-    (time-stamp-should-warn (equal (time-stamp-string "%_d" ref-time) "2"))))
+    (time-stamp-should-warn (equal (time-stamp-string "%d" ref-time2) "18"))))
 
 (ert-deftest time-stamp-test-hours-24 ()
   "Test time-stamp formats for hour on a 24-hour clock."
   (with-time-stamp-test-env
-    ;; documented PM
-    (should (equal (time-stamp-string "%:H" ref-time) "15"))
+    ;; implemented and documented since 1995
     (should (equal (time-stamp-string "%2H" ref-time) "15"))
-    (should (equal (time-stamp-string "%02H" ref-time) "15"))
-    ;; documented AM
-    (should (equal (time-stamp-string "%:H" ref-time2) "12"))
     (should (equal (time-stamp-string "%2H" ref-time2) "12"))
+    (should (equal (time-stamp-string "%2H" ref-time3) " 6"))
+    (should (equal (time-stamp-string "%02H" ref-time) "15"))
     (should (equal (time-stamp-string "%02H" ref-time2) "12"))
-    ;; documented 1-digit
-    (should (equal (time-stamp-string "%:H" ref-time3) "3"))
-    (should (equal (time-stamp-string "%2H" ref-time3) " 3"))
-    (should (equal (time-stamp-string "%02H" ref-time3) "03"))
-    ;; undocumented future formats
+    (should (equal (time-stamp-string "%02H" ref-time3) "06"))
+    ;; implemented and documented since 1997
+    (should (equal (time-stamp-string "%:H" ref-time) "15"))
+    (should (equal (time-stamp-string "%:H" ref-time2) "12"))
+    (should (equal (time-stamp-string "%:H" ref-time3) "6"))
+    ;; implemented since 1997, undocumented future format
     (should (equal (time-stamp-string "%1H" ref-time) "15"))
     (should (equal (time-stamp-string "%1H" ref-time2) "12"))
-    (should (equal (time-stamp-string "%1H" ref-time3) "3"))
-    ;; changing formats
+    (should (equal (time-stamp-string "%1H" ref-time3) "6"))
+    ;; warned since 1997, will change
+    (time-stamp-should-warn (equal (time-stamp-string "%_H" ref-time) "15"))
+    (time-stamp-should-warn (equal (time-stamp-string "%_H" ref-time2) "12"))
+    (time-stamp-should-warn (equal (time-stamp-string "%_H" ref-time3) "6"))
     (time-stamp-should-warn (equal (time-stamp-string "%H" ref-time) "15"))
-    (time-stamp-should-warn (equal (time-stamp-string "%_H" ref-time) "15"))))
+    (time-stamp-should-warn (equal (time-stamp-string "%H" ref-time2) "12"))
+    (time-stamp-should-warn (equal (time-stamp-string "%H" ref-time3) "6"))))
 
 (ert-deftest time-stamp-test-hours-12 ()
   "Test time-stamp formats for hour on a 12-hour clock."
   (with-time-stamp-test-env
-    ;; documented 1-digit, PM
-    (should (equal (time-stamp-string "%:I" ref-time) "3"))
+    ;; implemented and documented since 1995
     (should (equal (time-stamp-string "%2I" ref-time) " 3"))
-    (should (equal (time-stamp-string "%02I" ref-time) "03"))
-    ;; documented 2-digit
-    (should (equal (time-stamp-string "%:I" ref-time2) "12"))
     (should (equal (time-stamp-string "%2I" ref-time2) "12"))
+    (should (equal (time-stamp-string "%2I" ref-time3) " 6"))
+    (should (equal (time-stamp-string "%02I" ref-time) "03"))
     (should (equal (time-stamp-string "%02I" ref-time2) "12"))
-    ;; undocumented future formats
+    (should (equal (time-stamp-string "%02I" ref-time3) "06"))
+    ;; implemented and documented since 1997
+    (should (equal (time-stamp-string "%:I" ref-time) "3")) ;PM
+    (should (equal (time-stamp-string "%:I" ref-time2) "12")) ;PM
+    (should (equal (time-stamp-string "%:I" ref-time3) "6")) ;AM
+    ;; implemented since 1997, undocumented future format
     (should (equal (time-stamp-string "%1I" ref-time) "3"))
     (should (equal (time-stamp-string "%1I" ref-time2) "12"))
-    ;; changing formats
+    (should (equal (time-stamp-string "%1I" ref-time3) "6"))
+    ;; warned since 1997, will change
+    (time-stamp-should-warn (equal (time-stamp-string "%_I" ref-time) "3"))
+    (time-stamp-should-warn (equal (time-stamp-string "%_I" ref-time2) "12"))
+    (time-stamp-should-warn (equal (time-stamp-string "%_I" ref-time3) "6"))
     (time-stamp-should-warn (equal (time-stamp-string "%I" ref-time) "3"))
-    (time-stamp-should-warn (equal (time-stamp-string "%_I" ref-time) "3"))))
+    (time-stamp-should-warn (equal (time-stamp-string "%I" ref-time2) "12"))
+    (time-stamp-should-warn (equal (time-stamp-string "%I" ref-time3) "6"))))
 
 (ert-deftest time-stamp-test-month-number ()
   "Test time-stamp formats for month number."
   (with-time-stamp-test-env
-    ;; documented 1-digit
-    (should (equal (time-stamp-string "%:m" ref-time) "1"))
+    ;; implemented and documented since 1995
     (should (equal (time-stamp-string "%2m" ref-time) " 1"))
-    (should (equal (time-stamp-string "%02m" ref-time) "01"))
-    ;; documented 2-digit
-    (should (equal (time-stamp-string "%:m" ref-time2) "11"))
     (should (equal (time-stamp-string "%2m" ref-time2) "11"))
+    (should (equal (time-stamp-string "%02m" ref-time) "01"))
     (should (equal (time-stamp-string "%02m" ref-time2) "11"))
-    ;; undocumented future formats
+    ;; implemented and documented since 1997
+    (should (equal (time-stamp-string "%:m" ref-time) "1"))
+    (should (equal (time-stamp-string "%:m" ref-time2) "11"))
+    ;; implemented since 1997, undocumented future format
     (should (equal (time-stamp-string "%1m" ref-time) "1"))
     (should (equal (time-stamp-string "%1m" ref-time2) "11"))
-    ;; changing formats
+    ;; warned since 1997, will change
+    (time-stamp-should-warn (equal (time-stamp-string "%_m" ref-time) "1"))
+    (time-stamp-should-warn (equal (time-stamp-string "%_m" ref-time2) "11"))
     (time-stamp-should-warn (equal (time-stamp-string "%m" ref-time) "1"))
-    (time-stamp-should-warn (equal (time-stamp-string "%_m" ref-time) "1"))))
+    (time-stamp-should-warn (equal (time-stamp-string "%m" ref-time2) "11"))))
 
 (ert-deftest time-stamp-test-minute ()
   "Test time-stamp formats for minute."
   (with-time-stamp-test-env
-    ;; documented 1-digit
-    (should (equal (time-stamp-string "%:M" ref-time) "4"))
+    ;; implemented and documented since 1995
     (should (equal (time-stamp-string "%2M" ref-time) " 4"))
-    (should (equal (time-stamp-string "%02M" ref-time) "04"))
-    ;; documented 2-digit
-    (should (equal (time-stamp-string "%:M" ref-time2) "14"))
     (should (equal (time-stamp-string "%2M" ref-time2) "14"))
+    (should (equal (time-stamp-string "%02M" ref-time) "04"))
     (should (equal (time-stamp-string "%02M" ref-time2) "14"))
-    ;; undocumented future formats
+    ;; implemented and documented since 1997
+    (should (equal (time-stamp-string "%:M" ref-time) "4"))
+    (should (equal (time-stamp-string "%:M" ref-time2) "14"))
+    ;; implemented since 1997, undocumented future format
     (should (equal (time-stamp-string "%1M" ref-time) "4"))
     (should (equal (time-stamp-string "%1M" ref-time2) "14"))
-    ;; changing formats
+    ;; warned since 1997, will change
+    (time-stamp-should-warn (equal (time-stamp-string "%_M" ref-time) "4"))
+    (time-stamp-should-warn (equal (time-stamp-string "%_M" ref-time2) "14"))
     (time-stamp-should-warn (equal (time-stamp-string "%M" ref-time) "4"))
-    (time-stamp-should-warn (equal (time-stamp-string "%_M" ref-time) "4"))))
+    (time-stamp-should-warn (equal (time-stamp-string "%M" ref-time2) "14"))))
 
 (ert-deftest time-stamp-test-second ()
   "Test time-stamp formats for second."
   (with-time-stamp-test-env
-    ;; documented 1-digit
-    (should (equal (time-stamp-string "%:S" ref-time) "5"))
+    ;; implemented and documented since 1995
     (should (equal (time-stamp-string "%2S" ref-time) " 5"))
-    (should (equal (time-stamp-string "%02S" ref-time) "05"))
-    ;; documented 2-digit
-    (should (equal (time-stamp-string "%:S" ref-time2) "15"))
     (should (equal (time-stamp-string "%2S" ref-time2) "15"))
+    (should (equal (time-stamp-string "%02S" ref-time) "05"))
     (should (equal (time-stamp-string "%02S" ref-time2) "15"))
-    ;; undocumented future formats
+    ;; implemented and documented since 1997
+    (should (equal (time-stamp-string "%:S" ref-time) "5"))
+    (should (equal (time-stamp-string "%:S" ref-time2) "15"))
+    ;; implemented since 1997, undocumented future format
     (should (equal (time-stamp-string "%1S" ref-time) "5"))
     (should (equal (time-stamp-string "%1S" ref-time2) "15"))
-    ;; changing formats
+    ;; warned since 1997, will change
+    (time-stamp-should-warn (equal (time-stamp-string "%_S" ref-time) "5"))
+    (time-stamp-should-warn (equal (time-stamp-string "%_S" ref-time2) "15"))
     (time-stamp-should-warn (equal (time-stamp-string "%S" ref-time) "5"))
-    (time-stamp-should-warn (equal (time-stamp-string "%_S" ref-time) "5"))))
+    (time-stamp-should-warn (equal (time-stamp-string "%S" ref-time2) "15"))))
 
 (ert-deftest time-stamp-test-am-pm ()
   "Test time-stamp formats for AM and PM strings."
   (with-time-stamp-test-env
-    ;; documented
+    ;; implemented and documented since 1997
     (should (equal (time-stamp-string "%#p" ref-time) "pm"))
-    (should (equal (time-stamp-string "%P" ref-time) "PM"))
     (should (equal (time-stamp-string "%#p" ref-time3) "am"))
+    (should (equal (time-stamp-string "%P" ref-time) "PM"))
     (should (equal (time-stamp-string "%P" ref-time3) "AM"))
-    ;; changing
-    (time-stamp-should-warn (equal (time-stamp-string "%p" ref-time) "pm"))))
+    ;; warned since 1997, will change
+    (time-stamp-should-warn (equal (time-stamp-string "%p" ref-time) "pm"))
+    (time-stamp-should-warn (equal (time-stamp-string "%p" ref-time3) "am"))))
 
 (ert-deftest time-stamp-test-day-number-in-week ()
   "Test time-stamp formats for day number in week."
@@ -243,40 +249,42 @@ Test that each generates a warning."
 (ert-deftest time-stamp-test-year ()
   "Test time-stamp formats for year."
   (with-time-stamp-test-env
-    ;; documented
+    ;; implemented and documented since 1995
     (should (equal (time-stamp-string "%02y" ref-time) "06"))
+    ;; implemented and documented since 1997
     (should (equal (time-stamp-string "%:y" ref-time) "2006"))
-    ;; undocumented future formats
+    ;; implemented since 1997, undocumented future format
     (should (equal (time-stamp-string "%Y" ref-time) "2006"))
-    ;; changing
+    ;; warned since 1997, will change
     (time-stamp-should-warn (equal (time-stamp-string "%y" ref-time) "2006"))))
 
 (ert-deftest time-stamp-test-time-zone ()
   "Test time-stamp formats for time zone."
   (with-time-stamp-test-env
-    ;; documented
-    (should (equal (time-stamp-string "%z" ref-time) "gmt"))
+    ;; implemented and documented since 1995
     (should (equal (time-stamp-string "%Z" ref-time) "GMT"))
-    ;; undocumented future formats
+    (should (equal (time-stamp-string "%z" ref-time) "gmt"))
+    ;; implemented since 1997, undocumented future format
     (should (equal (time-stamp-string "%#Z" ref-time) "gmt"))))
 
 (ert-deftest time-stamp-test-non-date-conversions ()
   "Test time-stamp formats for non-date items."
   (with-time-stamp-test-env
-    ;; documented
+    ;; implemented and documented since 1995
     (should (equal (time-stamp-string "%%" ref-time) "%")) ;% last char
     (should (equal (time-stamp-string "%%P" ref-time) "%P")) ;% not last char
     (should (equal (time-stamp-string "%f" ref-time) "time-stamped-file"))
     (should (equal
              (time-stamp-string "%F" ref-time) 
"/emacs/test/time-stamped-file"))
-    (should
-     (equal (time-stamp-string "%s" ref-time) "test-system-name.example.org"))
-    (should (equal (time-stamp-string "%u" ref-time) "test-logname"))
-    (should (equal (time-stamp-string "%U" ref-time) "Time Stamp Tester"))
     (should (equal (time-stamp-string "%h" ref-time) "test-mail-host-name"))
-    ;; undocumented
+    (should (equal
+             (time-stamp-string "%s" ref-time) "test-system-name.example.org"))
+    (should (equal (time-stamp-string "%U" ref-time) "Time Stamp Tester"))
+    (should (equal (time-stamp-string "%u" ref-time) "test-logname"))
+    ;; implemented since 2001, undocumented future formats
     (should (equal (time-stamp-string "%L" ref-time) "Time Stamp Tester"))
     (should (equal (time-stamp-string "%l" ref-time) "test-logname"))
+    ;; implemented since 2007, undocumented future formats
     (should (equal
              (time-stamp-string "%Q" ref-time) "test-system-name.example.org"))
     (should (equal
@@ -306,6 +314,7 @@ Test that each generates a warning."
     (should (equal (time-stamp-string "%0%" ref-time3) ""))
     (should (equal (time-stamp-string "%1%" ref-time3) "%"))
     (should (equal (time-stamp-string "%2%" ref-time3) " %"))
-    (should (equal (time-stamp-string "%#3a" ref-time3) "SUN"))))
+    (should (equal (time-stamp-string "%#3a" ref-time3) "SUN"))
+    (should (equal (time-stamp-string "%#3b" ref-time2) "NOV"))))
 
 ;;; time-stamp-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]