@@ -83,3 +83,136 @@ function! s:suite.distance() abort
83
83
call s: assert .compare (r .distance (l ), ' <' , 3 , r .as_rgb_hex () . ' distance ' . l .as_rgb_hex ())
84
84
endfor
85
85
endfunction
86
+
87
+ function ! s: suite .error_parse ()
88
+ for l: V in [
89
+ \ 0 ,
90
+ \ function (' function' ),
91
+ \ [],
92
+ \ {},
93
+ \ 0.0 ,
94
+ \ v: false ,
95
+ \ v: null ,
96
+ \ test_null_job (),
97
+ \ test_null_channel (),
98
+ \ test_null_blob (),
99
+ \ ' ' ,
100
+ \ ' #' ,
101
+ \ ' #d' ,
102
+ \ ' #de' ,
103
+ \ ' #dead' ,
104
+ \ ' #deadb' ,
105
+ \ ' #deadbee' ,
106
+ \ ' #deadbeef' ,
107
+ \ ' d' ,
108
+ \ ' de' ,
109
+ \ ' dea' ,
110
+ \ ' dead' ,
111
+ \ ' deadb' ,
112
+ \ ' deadbe' ,
113
+ \ ' deadbee' ,
114
+ \ ' deadbeef' ,
115
+ \ ' 0xc0ffee' ,
116
+ \ ' rgb(0,0%,0%)' ,
117
+ \ ' hsl(0,0,0)' ,
118
+ \ ' rgb(0,0,0);' ,
119
+ \ ' hsl(0,0%,0%);' ,
120
+ \ ' unknown_color_name' ,
121
+ \]
122
+ try
123
+ call s: C .parse (l: V )
124
+ catch /vital: Color: parse():/
125
+ call s: assert .true (1 , string (l: V ) . ' should not be parsed' )
126
+ endtry
127
+ endfor
128
+ endfunction
129
+
130
+ function ! s: suite .error_rgb ()
131
+ for rgb in [
132
+ \ repeat ([0 ], 3 ),
133
+ \ repeat ([function (' function' )], 3 ),
134
+ \ repeat ([[]], 3 ),
135
+ \ repeat ([{}], 3 ),
136
+ \ repeat ([0.0 ], 3 ),
137
+ \ repeat ([v: false ], 3 ),
138
+ \ repeat ([v: null ], 3 ),
139
+ \ repeat ([test_null_job ()], 3 ),
140
+ \ repeat ([test_null_channel ()], 3 ),
141
+ \ repeat ([test_null_blob ()], 3 ),
142
+ \ [-1 , 0 , 0 ],
143
+ \ [-2 , 0 , 0 ],
144
+ \ [0 , -1 , 0 ],
145
+ \ [0 , -2 , 0 ],
146
+ \ [0 , 0 , -1 ],
147
+ \ [0 , 0 , -2 ],
148
+ \ [256 , 0 , 0 ],
149
+ \ [257 , 0 , 0 ],
150
+ \ [0 , 256 , 0 ],
151
+ \ [0 , 257 , 0 ],
152
+ \ [0 , 0 , 256 ],
153
+ \ [0 , 0 , 257 ],
154
+ \]
155
+ try
156
+ call s: C .rgb (rgb[0 ], rgb[1 ], rgb[2 ])
157
+ catch /vital: Color: rgb():/
158
+ call s: assert .true (1 , ' rgb() disallow ' . string (rgb))
159
+ endtry
160
+ endfor
161
+ endfunction
162
+
163
+ function ! s: suite .error_hsl ()
164
+ for hsl in [
165
+ \ repeat ([0 ], 3 ),
166
+ \ repeat ([function (' function' )], 3 ),
167
+ \ repeat ([[]], 3 ),
168
+ \ repeat ([{}], 3 ),
169
+ \ repeat ([0.0 ], 3 ),
170
+ \ repeat ([v: false ], 3 ),
171
+ \ repeat ([v: null ], 3 ),
172
+ \ repeat ([test_null_job ()], 3 ),
173
+ \ repeat ([test_null_channel ()], 3 ),
174
+ \ repeat ([test_null_blob ()], 3 ),
175
+ \ [-1 , 0 , 0 ],
176
+ \ [-2 , 0 , 0 ],
177
+ \ [0 , -1 , 0 ],
178
+ \ [0 , -2 , 0 ],
179
+ \ [0 , 0 , -1 ],
180
+ \ [0 , 0 , -2 ],
181
+ \ [361 , 0 , 0 ],
182
+ \ [362 , 0 , 0 ],
183
+ \ [0 , 101 , 0 ],
184
+ \ [0 , 102 , 0 ],
185
+ \ [0 , 0 , 101 ],
186
+ \ [0 , 0 , 102 ],
187
+ \]
188
+ try
189
+ call s: C .hsl (hsl[0 ], hsl[1 ], hsl[2 ])
190
+ catch /vital: Color: hsl():/
191
+ call s: assert .true (1 , ' hsl() disallow ' . string (hsl))
192
+ endtry
193
+ endfor
194
+ endfunction
195
+
196
+ function ! s: suite .error_xterm ()
197
+ for l: Value in [
198
+ \ function (' function' ),
199
+ \ [],
200
+ \ {},
201
+ \ 0.0 ,
202
+ \ v: false ,
203
+ \ v: null ,
204
+ \ test_null_job (),
205
+ \ test_null_channel (),
206
+ \ test_null_blob (),
207
+ \ -2 ,
208
+ \ -1 ,
209
+ \ 256 ,
210
+ \ 257 ,
211
+ \]
212
+ try
213
+ call s: C .xterm (l: Value )
214
+ catch /vital: Color: xterm():/
215
+ call s: assert .true (1 , ' xterm() disallow ' . string (l: Value ))
216
+ endtry
217
+ endfor
218
+ endfunction
0 commit comments