-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathtests.el
229 lines (209 loc) · 10 KB
/
tests.el
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
(ert-deftest spaceline-literal-segments-l ()
"Tests literal segments (left side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-install '("a" "b" 1.23 nil "longer" -2) nil)
(should (string= " a > b > 1.23 > longer > -2 > "
(spaceline-ml-main)))))
(ert-deftest spaceline-list-segments-l ()
"Tests list segments (left side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-install '(("a" "b" "c") ("def" "ghj")) nil)
(should (string= " a b c > def ghj > "
(spaceline-ml-main)))))
(ert-deftest spaceline-nested-list-segments-l ()
"Tests nested list segments (left side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-install '(("a" "b" "c") ("def" ("rofl" "mao" "sup") "ghj")) nil)
(should (string= " a b c > def rofl mao sup ghj > "
(spaceline-ml-main)))))
(ert-deftest spaceline-symbol-l ()
"Tests symbols (left side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-define-segment a "" "a")
(spaceline-define-segment b "" nil)
(spaceline-define-segment c "" var)
(spaceline-install '(a b) nil)
(should (string= " a > " (spaceline-ml-main)))
(spaceline-install '(a b c) nil)
(let ((var "alpha"))
(should (string= " a > alpha > " (spaceline-ml-main))))
(let ((var "beta"))
(should (string= " a > beta > " (spaceline-ml-main))))))
(ert-deftest spaceline-list-separators-l ()
"Tests the :separator property of lists (left side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-install '((("a" "b" "c") :separator "~~")) nil)
(should (string= " a~~b~~c > " (spaceline-ml-main)))))
(ert-deftest spaceline-nested-list-separators-l ()
"Tests the :separator property of nested lists (left side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-install '((("a" (("b" "c" "d") :separator "$$") "e") :separator "~~")) nil)
(should (string= " a~~b$$c$$d~~e > " (spaceline-ml-main)))))
(ert-deftest spaceline-symbol-list-l ()
"Tests symbols returning lists, with the :separator property (left side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-define-segment a "" '("a" "b" "c"))
(spaceline-define-segment b "" '("a" "b" "c") :separator "^")
(spaceline-install '(a) nil)
(should (string= " a b c > " (spaceline-ml-main)))
(spaceline-install '((a :separator ".")) nil)
(should (string= " a.b.c > " (spaceline-ml-main)))
(spaceline-install '(b) nil)
(should (string= " a^b^c > " (spaceline-ml-main)))
(spaceline-install '((b :separator "!")) nil)
(should (string= " a!b!c > " (spaceline-ml-main)))))
(ert-deftest spaceline-fallback-literal-l ()
"Tests the :fallback property for literals (left side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-install '((nil :fallback "b")) nil)
(should (string= " b > " (spaceline-ml-main)))
(spaceline-install '(("a" :fallback "b")) nil)
(should (string= " a > " (spaceline-ml-main)))))
(ert-deftest spaceline-fallback-symbol-l ()
"Tests the :fallback property for symbols (left side)."
(spaceline-define-segment success "" "success")
(spaceline-define-segment failure "" nil)
(spaceline-define-segment fallback "" nil :fallback success)
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-install '((failure :fallback "b")) nil)
(should (string= " b > " (spaceline-ml-main)))
(spaceline-install '((success :fallback "b")) nil)
(should (string= " success > " (spaceline-ml-main)))
(spaceline-install '(fallback) nil)
(should (string= " success > " (spaceline-ml-main)))))
(ert-deftest spaceline-tight-l ()
"Tests the :tight properties (left side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-install '("a" ("b" :tight t) "c") nil)
(should (string= " a b c > " (spaceline-ml-main)))
(spaceline-install '("a" ("b" :tight-left t) "c") nil)
(should (string= " a b > c > " (spaceline-ml-main)))
(spaceline-install '("a" ("b" :tight-right t) "c") nil)
(should (string= " a > b c > " (spaceline-ml-main)))
(spaceline-define-segment tight "" "tight" :tight t)
(spaceline-install '("a" tight "c") nil)
(should (string= " a tight c > " (spaceline-ml-main)))))
(ert-deftest spaceline-literal-segments-r ()
"Tests literal segments (right side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-right ?<))
(spaceline-install nil '("a" "b" 1.23 nil "longer" -2))
(should (string= " < a < b < 1.23 < longer < -2 "
(spaceline-ml-main)))))
(ert-deftest spaceline-list-segments-r ()
"Tests list segments (right side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-right ?<))
(spaceline-install nil '(("a" "b" "c") ("def" "ghj")))
(should (string= " < a b c < def ghj "
(spaceline-ml-main)))))
(ert-deftest spaceline-nested-list-segments-r ()
"Tests nested list segments (right side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-right ?<))
(spaceline-install nil '(("a" "b" "c") ("def" ("rofl" "mao" "sup") "ghj")))
(should (string= " < a b c < def rofl mao sup ghj "
(spaceline-ml-main)))))
(ert-deftest spaceline-symbol-r ()
"Tests symbols (right side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-right ?<))
(spaceline-define-segment a "" "a")
(spaceline-define-segment b "" nil)
(spaceline-define-segment c "" var)
(spaceline-install nil '(a b))
(should (string= " < a " (spaceline-ml-main)))
(spaceline-install nil '(a b c))
(let ((var "alpha"))
(should (string= " < a < alpha " (spaceline-ml-main))))
(let ((var "beta"))
(should (string= " < a < beta " (spaceline-ml-main))))))
(ert-deftest spaceline-list-separators-r ()
"Tests the :separator property of lists (right side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-right ?<))
(spaceline-install nil '((("a" "b" "c") :separator "~~")))
(should (string= " < a~~b~~c " (spaceline-ml-main)))))
(ert-deftest spaceline-nested-list-separators-r ()
"Tests the :separator property of nested lists (right side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-right ?<))
(spaceline-install nil '((("a" (("b" "c" "d") :separator "$$") "e") :separator "~~")))
(should (string= " < a~~b$$c$$d~~e " (spaceline-ml-main)))))
(ert-deftest spaceline-symbol-list-r ()
"Tests symbols returning lists, with the :separator property (right side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-right ?<))
(spaceline-define-segment a "" '("a" "b" "c"))
(spaceline-define-segment b "" '("a" "b" "c") :separator "^")
(spaceline-install nil '(a))
(should (string= " < a b c " (spaceline-ml-main)))
(spaceline-install nil '((a :separator ".")))
(should (string= " < a.b.c " (spaceline-ml-main)))
(spaceline-install nil '(b))
(should (string= " < a^b^c " (spaceline-ml-main)))
(spaceline-install nil '((b :separator "!")))
(should (string= " < a!b!c " (spaceline-ml-main)))))
(ert-deftest spaceline-fallback-literal-r ()
"Tests the :fallback property for literals (right side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-right ?<))
(spaceline-install nil '((nil :fallback "b")))
(should (string= " < b " (spaceline-ml-main)))
(spaceline-install nil '(("a" :fallback "b")))
(should (string= " < a " (spaceline-ml-main)))))
(ert-deftest spaceline-fallback-symbol-r ()
"Tests the :fallback property for symbols (right side)."
(spaceline-define-segment success "" "success")
(spaceline-define-segment failure "" nil)
(spaceline-define-segment fallback "" nil :fallback success)
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-right ?<))
(spaceline-install nil '((failure :fallback "b")))
(should (string= " < b " (spaceline-ml-main)))
(spaceline-install nil '((success :fallback "b")))
(should (string= " < success " (spaceline-ml-main)))
(spaceline-install nil '(fallback))
(should (string= " < success " (spaceline-ml-main)))))
(ert-deftest spaceline-tight-r ()
"Tests the :tight properties (right side)."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-right ?<))
(spaceline-install nil '("a" ("b" :tight t) "c"))
(should (string= " < a b c " (spaceline-ml-main)))
(spaceline-install nil '("a" ("b" :tight-left t) "c"))
(should (string= " < a b < c " (spaceline-ml-main)))
(spaceline-install nil '("a" ("b" :tight-right t) "c"))
(should (string= " < a < b c " (spaceline-ml-main)))
(spaceline-define-segment tight "" "tight" :tight t)
(spaceline-install nil '("a" tight "c"))
(should (string= " < a tight c " (spaceline-ml-main)))))
(ert-deftest spaceline-recompile ()
"Tests recompilation."
(let ((powerline-default-separator 'utf-8)
(powerline-utf-8-separator-left ?>))
(spaceline-define-segment a "" "a")
(spaceline-install '(a) nil)
(should (string= " a > " (spaceline-ml-main)))
(spaceline-define-segment a "" "b")
(should (string= " a > " (spaceline-ml-main)))
(spaceline-install)
(should (string= " b > " (spaceline-ml-main)))
(spaceline-define-segment a "" "a" :tight t)
(should (string= " b > " (spaceline-ml-main)))
(spaceline-install)
(should (string= "a " (spaceline-ml-main)))
(spaceline-define-segment a "" "c")
(should (string= "a " (spaceline-ml-main)))
(spaceline-install)
(should (string= " c > " (spaceline-ml-main)))))