aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStephen Leake2019-09-10 03:37:51 -0700
committerStephen Leake2019-09-10 03:37:51 -0700
commit3d442312889ef2d14c07282d0aff6199d00cc165 (patch)
tree74034ca2dded6ed233d0701b4cb5c10a0b5e9034 /test/src
parentac1a2e260e8ece34500b5879f766b4e54ee57b94 (diff)
parent74e9799bd89484b8d15bdd6597c68fc00d07e7f7 (diff)
downloademacs-3d442312889ef2d14c07282d0aff6199d00cc165.tar.gz
emacs-3d442312889ef2d14c07282d0aff6199d00cc165.zip
Merge commit '74e9799bd89484b8d15bdd6597c68fc00d07e7f7'
Diffstat (limited to 'test/src')
-rw-r--r--test/src/data-tests.el7
-rw-r--r--test/src/lread-tests.el3
-rw-r--r--test/src/process-tests.el63
-rw-r--r--test/src/timefns-tests.el50
4 files changed, 91 insertions, 32 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index a9d48e29a8a..3a7462b6ada 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -653,6 +653,13 @@ comparing the subr with a much slower lisp implementation."
653 (data-tests-check-sign (% -1 -3) (% nb1 nb3)) 653 (data-tests-check-sign (% -1 -3) (% nb1 nb3))
654 (data-tests-check-sign (mod -1 -3) (mod nb1 nb3)))) 654 (data-tests-check-sign (mod -1 -3) (mod nb1 nb3))))
655 655
656(ert-deftest data-tests-mod-0 ()
657 (dolist (num (list (1- most-negative-fixnum) -1 0 1
658 (1+ most-positive-fixnum)))
659 (should-error (mod num 0)))
660 (when (ignore-errors (/ 0.0 0))
661 (should (equal (abs (mod 0.0 0)) (abs (- 0.0 (/ 0.0 0)))))))
662
656(ert-deftest data-tests-ash-lsh () 663(ert-deftest data-tests-ash-lsh ()
657 (should (= (ash most-negative-fixnum 1) 664 (should (= (ash most-negative-fixnum 1)
658 (* most-negative-fixnum 2))) 665 (* most-negative-fixnum 2)))
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el
index 82b75b195ca..ba5bfe0145d 100644
--- a/test/src/lread-tests.el
+++ b/test/src/lread-tests.el
@@ -220,4 +220,7 @@ literals (Bug#20852)."
220 (* most-positive-fixnum most-positive-fixnum))) 220 (* most-positive-fixnum most-positive-fixnum)))
221 (should (= n (string-to-number (format "%d." n)))))) 221 (should (= n (string-to-number (format "%d." n))))))
222 222
223(ert-deftest lread-circular-hash ()
224 (should-error (read "#s(hash-table data #0=(#0# . #0#))")))
225
223;;; lread-tests.el ends here 226;;; lread-tests.el ends here
diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index 7745fccaf9d..158c036aaa7 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -22,6 +22,7 @@
22;;; Code: 22;;; Code:
23 23
24(require 'ert) 24(require 'ert)
25(require 'puny)
25 26
26;; Timeout in seconds; the test fails if the timeout is reached. 27;; Timeout in seconds; the test fails if the timeout is reached.
27(defvar process-test-sentinel-wait-timeout 2.0) 28(defvar process-test-sentinel-wait-timeout 2.0)
@@ -154,24 +155,30 @@
154 (concat invocation-directory invocation-name) 155 (concat invocation-directory invocation-name)
155 "-Q" "--batch" "--eval" 156 "-Q" "--batch" "--eval"
156 (prin1-to-string 157 (prin1-to-string
157 '(let (s) 158 '(let ((s nil) (count 0))
158 (while (setq s (read-from-minibuffer "$ ")) 159 (while (setq s (read-from-minibuffer
160 (format "%d> " count)))
159 (princ s) 161 (princ s)
160 (princ "\n"))))))) 162 (princ "\n")
163 (setq count (1+ count))))))))
161 (set-process-query-on-exit-flag proc nil) 164 (set-process-query-on-exit-flag proc nil)
162 (send-string proc "one\n") 165 (send-string proc "one\n")
163 (should 166 (while (not (equal (buffer-substring
164 (accept-process-output proc 1)) ; Read "one". 167 (line-beginning-position) (point-max))
165 (should (equal (buffer-string) "$ one\n$ ")) 168 "1> "))
169 (accept-process-output proc)) ; Read "one".
170 (should (equal (buffer-string) "0> one\n1> "))
166 (set-process-filter proc t) ; Stop reading from proc. 171 (set-process-filter proc t) ; Stop reading from proc.
167 (send-string proc "two\n") 172 (send-string proc "two\n")
168 (should-not 173 (should-not
169 (accept-process-output proc 1)) ; Can't read "two" yet. 174 (accept-process-output proc 1)) ; Can't read "two" yet.
170 (should (equal (buffer-string) "$ one\n$ ")) 175 (should (equal (buffer-string) "0> one\n1> "))
171 (set-process-filter proc nil) ; Resume reading from proc. 176 (set-process-filter proc nil) ; Resume reading from proc.
172 (should 177 (while (not (equal (buffer-substring
173 (accept-process-output proc 1)) ; Read "two" from proc. 178 (line-beginning-position) (point-max))
174 (should (equal (buffer-string) "$ one\n$ two\n$ "))))) 179 "2> "))
180 (accept-process-output proc)) ; Read "Two".
181 (should (equal (buffer-string) "0> one\n1> two\n2> ")))))
175 182
176(ert-deftest start-process-should-not-modify-arguments () 183(ert-deftest start-process-should-not-modify-arguments ()
177 "`start-process' must not modify its arguments in-place." 184 "`start-process' must not modify its arguments in-place."
@@ -322,5 +329,41 @@ See Bug#30460."
322 invocation-directory)) 329 invocation-directory))
323 :stop t))) 330 :stop t)))
324 331
332;; All the following tests require working DNS, which appears not to
333;; be the case for hydra.nixos.org, so disable them there for now.
334
335(ert-deftest lookup-family-specification ()
336 "network-lookup-address-info should only accept valid family symbols."
337 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
338 (should-error (network-lookup-address-info "google.com" 'both))
339 (should (network-lookup-address-info "google.com" 'ipv4))
340 (should (network-lookup-address-info "google.com" 'ipv6)))
341
342(ert-deftest lookup-unicode-domains ()
343 "Unicode domains should fail"
344 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
345 (should-error (network-lookup-address-info "faß.de"))
346 (should (network-lookup-address-info (puny-encode-domain "faß.de"))))
347
348(ert-deftest unibyte-domain-name ()
349 "Unibyte domain names should work"
350 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
351 (should (network-lookup-address-info (string-to-unibyte "google.com"))))
352
353(ert-deftest lookup-google ()
354 "Check that we can look up google IP addresses"
355 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
356 (let ((addresses-both (network-lookup-address-info "google.com"))
357 (addresses-v4 (network-lookup-address-info "google.com" 'ipv4))
358 (addresses-v6 (network-lookup-address-info "google.com" 'ipv6)))
359 (should addresses-both)
360 (should addresses-v4)
361 (should addresses-v6)))
362
363(ert-deftest non-existent-lookup-failure ()
364 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
365 "Check that looking up non-existent domain returns nil"
366 (should (eq nil (network-lookup-address-info "emacs.invalid"))))
367
325(provide 'process-tests) 368(provide 'process-tests)
326;; process-tests.el ends here. 369;; process-tests.el ends here.
diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el
index a30b2de3a5b..3a18a4a24dd 100644
--- a/test/src/timefns-tests.el
+++ b/test/src/timefns-tests.el
@@ -19,6 +19,12 @@
19 19
20(require 'ert) 20(require 'ert)
21 21
22(defun timefns-tests--decode-time (look zone decoded-time)
23 (should (equal (decode-time look zone t) decoded-time))
24 (should (equal (decode-time look zone 'integer)
25 (cons (time-convert (car decoded-time) 'integer)
26 (cdr decoded-time)))))
27
22;;; Check format-time-string and decode-time with various TZ settings. 28;;; Check format-time-string and decode-time with various TZ settings.
23;;; Use only POSIX-compatible TZ values, since the tests should work 29;;; Use only POSIX-compatible TZ values, since the tests should work
24;;; even if tzdb is not in use. 30;;; even if tzdb is not in use.
@@ -40,31 +46,29 @@
40 (7879679999900 . 100000) 46 (7879679999900 . 100000)
41 (78796799999999999999 . 1000000000000))) 47 (78796799999999999999 . 1000000000000)))
42 ;; UTC. 48 ;; UTC.
43 (let ((sec (time-add 59 (time-subtract (time-convert look t) 49 (let* ((look-ticks-hz (time-convert look t))
44 (time-convert look 'integer))))) 50 (hz (cdr look-ticks-hz))
51 (look-integer (time-convert look 'integer))
52 (sec (time-add (time-convert 59 hz)
53 (time-subtract look-ticks-hz
54 (time-convert look-integer hz)))))
45 (should (string-equal 55 (should (string-equal
46 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" look t) 56 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" look t)
47 "1972-06-30 23:59:59.999 +0000")) 57 "1972-06-30 23:59:59.999 +0000"))
48 (should (equal (decode-time look t 'integer) 58 (timefns-tests--decode-time look t
49 '(59 59 23 30 6 1972 5 nil 0))) 59 (list sec 59 23 30 6 1972 5 nil 0))
50 (should (equal (decode-time look t t)
51 (list sec 59 23 30 6 1972 5 nil 0)))
52 ;; "UTC0". 60 ;; "UTC0".
53 (should (string-equal 61 (should (string-equal
54 (format-time-string format look "UTC0") 62 (format-time-string format look "UTC0")
55 "1972-06-30 23:59:59.999 +0000 (UTC)")) 63 "1972-06-30 23:59:59.999 +0000 (UTC)"))
56 (should (equal (decode-time look "UTC0" 'integer) 64 (timefns-tests--decode-time look "UTC0"
57 '(59 59 23 30 6 1972 5 nil 0))) 65 (list sec 59 23 30 6 1972 5 nil 0))
58 (should (equal (decode-time look "UTC0" t)
59 (list sec 59 23 30 6 1972 5 nil 0)))
60 ;; Negative UTC offset, as a Lisp list. 66 ;; Negative UTC offset, as a Lisp list.
61 (should (string-equal 67 (should (string-equal
62 (format-time-string format look '(-28800 "PST")) 68 (format-time-string format look '(-28800 "PST"))
63 "1972-06-30 15:59:59.999 -0800 (PST)")) 69 "1972-06-30 15:59:59.999 -0800 (PST)"))
64 (should (equal (decode-time look '(-28800 "PST") 'integer) 70 (timefns-tests--decode-time look '(-28800 "PST")
65 '(59 59 15 30 6 1972 5 nil -28800))) 71 (list sec 59 15 30 6 1972 5 nil -28800))
66 (should (equal (decode-time look '(-28800 "PST") t)
67 (list sec 59 15 30 6 1972 5 nil -28800)))
68 ;; Negative UTC offset, as a Lisp integer. 72 ;; Negative UTC offset, as a Lisp integer.
69 (should (string-equal 73 (should (string-equal
70 (format-time-string format look -28800) 74 (format-time-string format look -28800)
@@ -73,18 +77,14 @@
73 (if (eq system-type 'windows-nt) 77 (if (eq system-type 'windows-nt)
74 "1972-06-30 15:59:59.999 -0800 (ZZZ)" 78 "1972-06-30 15:59:59.999 -0800 (ZZZ)"
75 "1972-06-30 15:59:59.999 -0800 (-08)"))) 79 "1972-06-30 15:59:59.999 -0800 (-08)")))
76 (should (equal (decode-time look -28800 'integer) 80 (timefns-tests--decode-time look -28800
77 '(59 59 15 30 6 1972 5 nil -28800))) 81 (list sec 59 15 30 6 1972 5 nil -28800))
78 (should (equal (decode-time look -28800 t)
79 (list sec 59 15 30 6 1972 5 nil -28800)))
80 ;; Positive UTC offset that is not an hour multiple, as a string. 82 ;; Positive UTC offset that is not an hour multiple, as a string.
81 (should (string-equal 83 (should (string-equal
82 (format-time-string format look "IST-5:30") 84 (format-time-string format look "IST-5:30")
83 "1972-07-01 05:29:59.999 +0530 (IST)")) 85 "1972-07-01 05:29:59.999 +0530 (IST)"))
84 (should (equal (decode-time look "IST-5:30" 'integer) 86 (timefns-tests--decode-time look "IST-5:30"
85 '(59 29 5 1 7 1972 6 nil 19800))) 87 (list sec 29 5 1 7 1972 6 nil 19800))))))
86 (should (equal (decode-time look "IST-5:30" t)
87 (list sec 29 5 1 7 1972 6 nil 19800)))))))
88 88
89(ert-deftest decode-then-encode-time () 89(ert-deftest decode-then-encode-time ()
90 (let ((time-values (list 0 -2 1 0.0 -0.0 -2.0 1.0 90 (let ((time-values (list 0 -2 1 0.0 -0.0 -2.0 1.0
@@ -129,6 +129,12 @@
129 most-negative-fixnum most-positive-fixnum 129 most-negative-fixnum most-positive-fixnum
130 (1- most-negative-fixnum) 130 (1- most-negative-fixnum)
131 (1+ most-positive-fixnum) 131 (1+ most-positive-fixnum)
132 1e1 -1e1 1e-1 -1e-1
133 1e8 -1e8 1e-8 -1e-8
134 1e9 -1e9 1e-9 -1e-9
135 1e10 -1e10 1e-10 -1e-10
136 1e16 -1e16 1e-16 -1e-16
137 1e37 -1e37 1e-37 -1e-37
132 1e+INF -1e+INF 1e+NaN -1e+NaN 138 1e+INF -1e+INF 1e+NaN -1e+NaN
133 '(0 0 0 1) '(0 0 1 0) '(0 1 0 0) '(1 0 0 0) 139 '(0 0 0 1) '(0 0 1 0) '(0 1 0 0) '(1 0 0 0)
134 '(-1 0 0 0) '(1 2 3 4) '(-1 2 3 4) 140 '(-1 0 0 0) '(1 2 3 4) '(-1 2 3 4)