blob: 3430a93944dcaf6a0ca63a5ffddcdbc78cfee785 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
;;; test-host-environment--platform-predicates.el --- Tests for env-linux/bsd/macos/windows-p -*- lexical-binding: t; -*-
;;; Commentary:
;; Tests for the platform predicates in host-environment.el. Each is a
;; thin wrapper around `system-type'. Tests rely on `system-type'
;; being a special variable (so a `let'-binding shadows the global
;; value) and walk every supported platform to confirm the right
;; predicate returns t.
;;; Code:
(require 'ert)
(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
(require 'host-environment)
(ert-deftest test-host-environment-linux-p-true-on-gnu-linux ()
"Normal: env-linux-p returns t when system-type is gnu/linux."
(let ((system-type 'gnu/linux))
(should (env-linux-p))))
(ert-deftest test-host-environment-linux-p-false-on-other-platforms ()
"Boundary: env-linux-p returns nil on every non-Linux platform."
(dolist (other '(darwin berkeley-unix windows-nt cygwin ms-dos))
(let ((system-type other))
(should-not (env-linux-p)))))
(ert-deftest test-host-environment-bsd-p-true-on-berkeley-unix ()
"Normal: env-bsd-p returns t when system-type is berkeley-unix."
(let ((system-type 'berkeley-unix))
(should (env-bsd-p))))
(ert-deftest test-host-environment-bsd-p-false-on-other-platforms ()
"Boundary: env-bsd-p returns nil on every non-BSD platform."
(dolist (other '(gnu/linux darwin windows-nt cygwin ms-dos))
(let ((system-type other))
(should-not (env-bsd-p)))))
(ert-deftest test-host-environment-macos-p-true-on-darwin ()
"Normal: env-macos-p returns t when system-type is darwin."
(let ((system-type 'darwin))
(should (env-macos-p))))
(ert-deftest test-host-environment-macos-p-false-on-other-platforms ()
"Boundary: env-macos-p returns nil on every non-Darwin platform."
(dolist (other '(gnu/linux berkeley-unix windows-nt cygwin ms-dos))
(let ((system-type other))
(should-not (env-macos-p)))))
(ert-deftest test-host-environment-windows-p-true-on-each-windows-variant ()
"Normal: env-windows-p returns t on cygwin, windows-nt, and ms-dos."
(dolist (win '(cygwin windows-nt ms-dos))
(let ((system-type win))
(should (env-windows-p)))))
(ert-deftest test-host-environment-windows-p-false-on-unix-platforms ()
"Boundary: env-windows-p returns nil on Unix-family platforms."
(dolist (other '(gnu/linux darwin berkeley-unix))
(let ((system-type other))
(should-not (env-windows-p)))))
(provide 'test-host-environment--platform-predicates)
;;; test-host-environment--platform-predicates.el ends here
|