diff options
| author | Paul Eggert | 2018-10-03 09:10:00 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-10-06 23:31:03 -0700 |
| commit | b5d08da1e9ea7ee1334d810348c656babe6a15d2 (patch) | |
| tree | e42a93a11f341db5cde167332790ebf9ad717525 /test/src/editfns-tests.el | |
| parent | 44bf4a6b012f65327718b8c8334bfac1aee26370 (diff) | |
| download | emacs-b5d08da1e9ea7ee1334d810348c656babe6a15d2.tar.gz emacs-b5d08da1e9ea7ee1334d810348c656babe6a15d2.zip | |
Move timestamp-related stuff to timefns.c
This does not change behavior; it’s just long-overdue
refactoring (Bug#32902).
* src/emacs.c (main): Call init_timefns, syms_of_timefns.
* src/timefns.c: New file, containing timestamp-related stuff
from editfns.c and sysdep.c.
* src/Makefile.in (base_obj): Add timefns.o.
* src/editfns.c: Simplify by moving a big chunk to timefns.c.
Do not include systime.h, sys/resource.h, sys/param.h,
strftime.h, coding.h.
(HAVE_TZALLOC_BUG, TM_YEAR_BASE, HAVE_TM_GMTOFF, tzeqlen)
(local_tz, utc_tz, emacs_localtime_rz, emacs_mktime_z)
(invalid_time_zone_specification, xtzfree, tzlookup)
(TIME_T_MIN, TIME_T_MAX, time_overflow, invalid_time)
(check_time_validity, hi_time, lo_time, Fcurrent_time)
(time_add, time_subtract, time_arith, Ftime_add)
(Ftime_subtract, Ftime_less_p, Fget_internal_run_time)
(make_lisp_time, disassemble_lisp_time, decode_float_time)
(lisp_to_timespec, lisp_time_struct, lisp_time_argument)
(lisp_seconds_argument, Ffloat_time, emacs_nmemftime)
(Fformat_time_string, format_time_string, Fdecode_time)
(check_tm_member, Fencode_time, Fcurrent_time_string)
(tm_gmtoff, Fcurrent_time_zone, Fset_time_zone_rule)
(emacs_getenv_TZ, emacs_setenv_TZ): Move to timefns.c.
* src/emacs.c (main): Adjust to initialization changes.
* src/sysdep.c: Include <sys/resource.h> if it's present.
Regularize includes a bit.
(Fget_internal_run_time): Move here from editfns.c.
(init_timefns, syms_of_timefns): New functions.
* src/w32.h (w32_get_internal_run_time): Move decl here
so that it need not be cloned.
* test/src/editfns-tests.el:
* test/src/editfns-tests.el (format-time-string-with-zone)
(format-time-string-with-outlandish-zone)
(editfns-tests--have-leap-seconds)
(format-time-string-with-bignum-on-32-bit):
Move to ...
* test/src/timefns-tests.el: ... this new file.
Diffstat (limited to 'test/src/editfns-tests.el')
| -rw-r--r-- | test/src/editfns-tests.el | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index 4a840c8d7d1..17b2c510734 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el | |||
| @@ -204,65 +204,6 @@ | |||
| 204 | (should (string-equal (format "%d" 0.9) "0")) | 204 | (should (string-equal (format "%d" 0.9) "0")) |
| 205 | (should (string-equal (format "%d" 1.1) "1"))) | 205 | (should (string-equal (format "%d" 1.1) "1"))) |
| 206 | 206 | ||
| 207 | ;;; Check format-time-string with various TZ settings. | ||
| 208 | ;;; Use only POSIX-compatible TZ values, since the tests should work | ||
| 209 | ;;; even if tzdb is not in use. | ||
| 210 | (ert-deftest format-time-string-with-zone () | ||
| 211 | ;; Don’t use (0 0 0 0) as the test case, as there are too many bugs | ||
| 212 | ;; in MS-Windows (and presumably other) C libraries when formatting | ||
| 213 | ;; time stamps near the Epoch of 1970-01-01 00:00:00 UTC, and this | ||
| 214 | ;; test is for GNU Emacs, not for C runtimes. Instead, look before | ||
| 215 | ;; you leap: "look" is the timestamp just before the first leap | ||
| 216 | ;; second on 1972-06-30 23:59:60 UTC, so it should format to the | ||
| 217 | ;; same string regardless of whether the underlying C library | ||
| 218 | ;; ignores leap seconds, while avoiding circa-1970 glitches. | ||
| 219 | ;; | ||
| 220 | ;; Similarly, stick to the limited set of time zones that are | ||
| 221 | ;; supported by both POSIX and MS-Windows: exactly 3 ASCII letters | ||
| 222 | ;; in the abbreviation, and no DST. | ||
| 223 | (let ((look '(1202 22527 999999 999999)) | ||
| 224 | (format "%Y-%m-%d %H:%M:%S.%3N %z (%Z)")) | ||
| 225 | ;; UTC. | ||
| 226 | (should (string-equal | ||
| 227 | (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" look t) | ||
| 228 | "1972-06-30 23:59:59.999 +0000")) | ||
| 229 | ;; "UTC0". | ||
| 230 | (should (string-equal | ||
| 231 | (format-time-string format look "UTC0") | ||
| 232 | "1972-06-30 23:59:59.999 +0000 (UTC)")) | ||
| 233 | ;; Negative UTC offset, as a Lisp list. | ||
| 234 | (should (string-equal | ||
| 235 | (format-time-string format look '(-28800 "PST")) | ||
| 236 | "1972-06-30 15:59:59.999 -0800 (PST)")) | ||
| 237 | ;; Negative UTC offset, as a Lisp integer. | ||
| 238 | (should (string-equal | ||
| 239 | (format-time-string format look -28800) | ||
| 240 | ;; MS-Windows build replaces unrecognizable TZ values, | ||
| 241 | ;; such as "-08", with "ZZZ". | ||
| 242 | (if (eq system-type 'windows-nt) | ||
| 243 | "1972-06-30 15:59:59.999 -0800 (ZZZ)" | ||
| 244 | "1972-06-30 15:59:59.999 -0800 (-08)"))) | ||
| 245 | ;; Positive UTC offset that is not an hour multiple, as a string. | ||
| 246 | (should (string-equal | ||
| 247 | (format-time-string format look "IST-5:30") | ||
| 248 | "1972-07-01 05:29:59.999 +0530 (IST)")))) | ||
| 249 | |||
| 250 | ;;; This should not dump core. | ||
| 251 | (ert-deftest format-time-string-with-outlandish-zone () | ||
| 252 | (should (stringp | ||
| 253 | (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" nil | ||
| 254 | (concat (make-string 2048 ?X) "0"))))) | ||
| 255 | |||
| 256 | (defun editfns-tests--have-leap-seconds () | ||
| 257 | (string-equal (format-time-string "%Y-%m-%d %H:%M:%S" 78796800 t) | ||
| 258 | "1972-06-30 23:59:60")) | ||
| 259 | |||
| 260 | (ert-deftest format-time-string-with-bignum-on-32-bit () | ||
| 261 | (should (or (string-equal | ||
| 262 | (format-time-string "%Y-%m-%d %H:%M:%S" (- (ash 1 31) 3600) t) | ||
| 263 | "2038-01-19 02:14:08") | ||
| 264 | (editfns-tests--have-leap-seconds)))) | ||
| 265 | |||
| 266 | (ert-deftest format-with-field () | 207 | (ert-deftest format-with-field () |
| 267 | (should (equal (format "First argument %2$s, then %3$s, then %1$s" 1 2 3) | 208 | (should (equal (format "First argument %2$s, then %3$s, then %1$s" 1 2 3) |
| 268 | "First argument 2, then 3, then 1")) | 209 | "First argument 2, then 3, then 1")) |