1
1
let s: helper = themis#suite (' helper' )
2
2
let s: expect = themis#helper (' expect' )
3
3
4
- function ! s: helper .__expect__ () abort
4
+ function s: helper .__expect__ () abort
5
5
let expect = themis#suite (' expect' )
6
6
7
- function ! expect.__to_be_true__ () abort
7
+ function expect.__to_be_true__ () abort
8
8
let to_be_true = themis#suite (' .to_be_true()' )
9
- function ! to_be_true.checks_value_is_true () abort
9
+ function to_be_true.checks_value_is_true () abort
10
10
call s: expect (1 ).to_be_true ()
11
11
endfunction
12
- function ! to_be_true.checks_value_strictly () abort
12
+ function to_be_true.checks_value_strictly () abort
13
13
call s: check_throw (' to_be_true' , 100 )
14
14
call s: check_throw (' to_be_true' , ' 1' )
15
15
call s: check_throw (' to_be_true' , 1.0 )
@@ -18,231 +18,231 @@ function! s:helper.__expect__() abort
18
18
endfunction
19
19
endfunction
20
20
21
- function ! expect.__to_be_false__ () abort
21
+ function expect.__to_be_false__ () abort
22
22
let to_be_false = themis#suite (' .to_be_false()' )
23
- function ! to_be_false.checks_value_is_false () abort
23
+ function to_be_false.checks_value_is_false () abort
24
24
call s: expect (0 ).to_be_false ()
25
25
endfunction
26
- function ! to_be_false.checks_value_strictly () abort
26
+ function to_be_false.checks_value_strictly () abort
27
27
call s: check_throw (' to_be_false' , ' ' )
28
28
call s: check_throw (' to_be_false' , 0.0 )
29
29
call s: check_throw (' to_be_false' , [])
30
30
call s: check_throw (' to_be_false' , ' to_be_false' )
31
31
endfunction
32
32
endfunction
33
33
34
- function ! expect.__to_be_truthy__ () abort
34
+ function expect.__to_be_truthy__ () abort
35
35
let to_be_truthy = themis#suite (' .to_be_truthy()' )
36
- function ! to_be_truthy.checks_value_is_not_zero () abort
36
+ function to_be_truthy.checks_value_is_not_zero () abort
37
37
call s: expect (1 ).to_be_truthy ()
38
38
call s: expect (100 ).to_be_truthy ()
39
39
call s: expect (' 1' ).to_be_truthy ()
40
40
endfunction
41
- function ! to_be_truthy.throws_a_report_when_value_is_zero_or_not_a_number () abort
41
+ function to_be_truthy.throws_a_report_when_value_is_zero_or_not_a_number () abort
42
42
call s: check_throw (' to_be_truthy' , 0 )
43
43
call s: check_throw (' to_be_truthy' , 1.0 )
44
44
call s: check_throw (' to_be_truthy' , ' to_be_truthy' )
45
45
call s: check_throw (' to_be_truthy' , ' 0' )
46
46
endfunction
47
47
endfunction
48
48
49
- function ! expect.__to_equal__ () abort
49
+ function expect.__to_equal__ () abort
50
50
let to_equal = themis#suite (' .to_equal()' )
51
- function ! to_equal.checks_values_are_equal () abort
51
+ function to_equal.checks_values_are_equal () abort
52
52
call s: expect (1 ).to_equal (1 )
53
53
call s: expect (' foo' ).to_equal (' foo' )
54
54
call s: expect ([1 , 2 , 3 ]).to_equal ([1 , 2 , 3 ])
55
55
call s: expect ({' foo' : ' x' }).to_equal ({' foo' : ' x' })
56
56
endfunction
57
- function ! to_equal.throws_a_report_when_values_are_different () abort
57
+ function to_equal.throws_a_report_when_values_are_different () abort
58
58
call s: check_throw (' to_equal' , 1 , [0 ])
59
59
call s: check_throw (' to_equal' , ' foo' , [' bar' ])
60
60
call s: check_throw (' to_equal' , [1 , 2 , 3 ], [[1 , 2 ]])
61
61
call s: check_throw (' to_equal' , {' foo' : ' x' }, [{' foo' : ' y' }])
62
62
endfunction
63
63
endfunction
64
64
65
- function ! expect.__to_be_same__ () abort
65
+ function expect.__to_be_same__ () abort
66
66
let to_be_same = themis#suite (' .to_be_same()' )
67
- function ! to_be_same.checks_values_have_same_instance () abort
67
+ function to_be_same.checks_values_have_same_instance () abort
68
68
call s: expect (1 ).to_be_same (1 )
69
69
let one_list = [1 , 2 , 3 ]
70
70
let ref_list = one_list
71
71
call s: expect (one_list).to_be_same (ref_list)
72
72
endfunction
73
- function ! to_be_same.throws_a_report_when_values_are_different_instances () abort
73
+ function to_be_same.throws_a_report_when_values_are_different_instances () abort
74
74
call s: check_throw (' to_be_same' , 1 , [0 ])
75
75
call s: check_throw (' to_be_same' , [1 , 2 , 3 ], [[1 , 2 , 3 ]])
76
76
endfunction
77
77
endfunction
78
78
79
- function ! expect.__to_match__ () abort
79
+ function expect.__to_match__ () abort
80
80
let to_match = themis#suite (' .to_match()' )
81
- function ! to_match.checks_value_matches_with_regex () abort
81
+ function to_match.checks_value_matches_with_regex () abort
82
82
call s: expect (' foo_bar' ).to_match (' oo' )
83
83
endfunction
84
- function ! to_match.throws_a_report_when_value_is_not_string () abort
84
+ function to_match.throws_a_report_when_value_is_not_string () abort
85
85
call s: check_throw (' to_match' , 1 , [' x' ])
86
86
endfunction
87
- function ! to_match.throws_a_report_when_value_does_not_match () abort
87
+ function to_match.throws_a_report_when_value_does_not_match () abort
88
88
call s: check_throw (' to_match' , ' foo_bar' , [' ^oo' ])
89
89
endfunction
90
90
endfunction
91
91
92
- function ! expect.__to_have_length__ () abort
92
+ function expect.__to_have_length__ () abort
93
93
let to_have_length = themis#suite (' .to_have_length()' )
94
- function ! to_have_length.checks_length_of_string () abort
94
+ function to_have_length.checks_length_of_string () abort
95
95
call s: expect (' 12345' ).to_have_length (5 )
96
96
endfunction
97
- function ! to_have_length.checks_length_of_list () abort
97
+ function to_have_length.checks_length_of_list () abort
98
98
call s: expect ([1 , 2 , 3 ]).to_have_length (3 )
99
99
endfunction
100
- function ! to_have_length.checks_length_of_dict () abort
100
+ function to_have_length.checks_length_of_dict () abort
101
101
call s: expect ({' elem' : 1 }).to_have_length (1 )
102
102
endfunction
103
- function ! to_have_length.throws_a_report_when_length_is_mismatch () abort
103
+ function to_have_length.throws_a_report_when_length_is_mismatch () abort
104
104
call s: check_throw (' to_have_length' , ' ' , [1 ])
105
105
call s: check_throw (' to_have_length' , [], [1 ])
106
106
call s: check_throw (' to_have_length' , {}, [1 ])
107
107
endfunction
108
- function ! to_have_length.throws_a_report_when_first_argument_is_not_valid () abort
108
+ function to_have_length.throws_a_report_when_first_argument_is_not_valid () abort
109
109
call s: check_throw (' to_have_length' , 0 , [1 ])
110
110
endfunction
111
111
endfunction
112
112
113
- function ! expect.__have_key__ () abort
113
+ function expect.__have_key__ () abort
114
114
let to_have_key = themis#suite (' .to_have_key()' )
115
- function ! to_have_key.checks_key_exists_in_dict () abort
115
+ function to_have_key.checks_key_exists_in_dict () abort
116
116
call s: expect ({' foo' : 0 }).to_have_key (' foo' )
117
117
endfunction
118
- function ! to_have_key.checks_index_exists_in_array () abort
118
+ function to_have_key.checks_index_exists_in_array () abort
119
119
call s: expect ([10 , 20 , 30 ]).to_have_key (2 )
120
120
endfunction
121
- function ! to_have_key.throws_a_report_when_key_is_not_exist_in_dict () abort
121
+ function to_have_key.throws_a_report_when_key_is_not_exist_in_dict () abort
122
122
call s: check_throw (' to_have_key' , {}, [' foo' ])
123
123
endfunction
124
- function ! to_have_key.throws_a_report_when_index_is_not_exist_in_array () abort
124
+ function to_have_key.throws_a_report_when_index_is_not_exist_in_array () abort
125
125
call s: check_throw (' to_have_key' , [], [0 ])
126
126
endfunction
127
127
endfunction
128
128
129
- function ! expect.__to_exist__ () abort
129
+ function expect.__to_exist__ () abort
130
130
let to_exist = themis#suite (' .to_exist()' )
131
- function ! to_exist.before () abort
131
+ function to_exist.before () abort
132
132
let g: existing_variable = 1
133
133
endfunction
134
- function ! to_exist.after () abort
134
+ function to_exist.after () abort
135
135
unlet g: existing_variable
136
136
endfunction
137
- function ! to_exist.checks_existence () abort
137
+ function to_exist.checks_existence () abort
138
138
call s: expect (' :w' ).to_exist ()
139
139
call s: expect (' *function' ).to_exist ()
140
140
call s: expect (' g:existing_variable' ).to_exist ()
141
141
endfunction
142
- function ! to_exist.throws_report_when_the_value_does_not_to_exist () abort
142
+ function to_exist.throws_report_when_the_value_does_not_to_exist () abort
143
143
call s: check_throw (' to_exist' , ' g:the_value_which_does_not_exist' )
144
144
endfunction
145
145
endfunction
146
146
147
- function ! expect.__to_be_empty__ () abort
147
+ function expect.__to_be_empty__ () abort
148
148
let to_be_empty = themis#suite (' .to_be_empty()' )
149
- function ! to_be_empty.checks_empty () abort
149
+ function to_be_empty.checks_empty () abort
150
150
call s: expect ([]).to_be_empty ()
151
151
call s: expect ({}).to_be_empty ()
152
152
call s: expect (' ' ).to_be_empty ()
153
153
endfunction
154
- function ! to_be_empty.throws_report_when_the_value_is_not_empty () abort
154
+ function to_be_empty.throws_report_when_the_value_is_not_empty () abort
155
155
call s: check_throw (' to_be_empty' , [1 , 2 , 3 ])
156
156
endfunction
157
157
endfunction
158
158
159
- function ! expect.__comparison__ () abort
159
+ function expect.__comparison__ () abort
160
160
let comparison = themis#suite (' .to_be_greater_than(_or_equal)/.to_be_less_than(_or_equal)' )
161
- function ! comparison.checks_value_compared_with_the_other () abort
161
+ function comparison.checks_value_compared_with_the_other () abort
162
162
call s: expect (1 ).to_be_greater_than (0 )
163
163
call s: expect (' Z' ).to_be_greater_than (' A' )
164
164
call s: expect (1 ).to_be_greater_than_or_equal (' 1' )
165
165
call s: expect (0 ).to_be_less_than (1 )
166
166
call s: expect (' 0' ).to_be_less_than (' A' )
167
167
call s: expect (' Z' ).to_be_less_than_or_equal (0 )
168
168
endfunction
169
- function ! comparison.throws_a_report_when_comparison_result_is_false () abort
169
+ function comparison.throws_a_report_when_comparison_result_is_false () abort
170
170
call s: check_throw (' to_be_greater_than' , 0 , [1 ])
171
171
call s: check_throw (' to_be_less_than' , 1 , [0 ])
172
172
call s: check_throw (' to_be_greater_than_or_equal' , ' a' , [' z' ])
173
173
call s: check_throw (' to_be_less_than_or_equal' , ' 1' , [' 0' ])
174
174
endfunction
175
175
endfunction
176
176
177
- function ! expect.__to_be_number__ () abort
177
+ function expect.__to_be_number__ () abort
178
178
let to_be_number = themis#suite (' .to_be_number()' )
179
- function ! to_be_number.checks_type_of_value () abort
179
+ function to_be_number.checks_type_of_value () abort
180
180
call s: expect (0 ).to_be_number ()
181
181
endfunction
182
- function ! to_be_number.throws_a_report_when_type_is_mismatch () abort
182
+ function to_be_number.throws_a_report_when_type_is_mismatch () abort
183
183
call s: check_throw (' to_be_number' , 0.0 )
184
184
endfunction
185
185
endfunction
186
186
187
- function ! expect.__to_be_string__ () abort
187
+ function expect.__to_be_string__ () abort
188
188
let to_be_string = themis#suite (' .to_be_string()' )
189
- function ! to_be_string.checks_type_of_value () abort
189
+ function to_be_string.checks_type_of_value () abort
190
190
call s: expect (' ' ).to_be_string ()
191
191
endfunction
192
- function ! to_be_string.throws_a_report_when_type_is_mismatch () abort
192
+ function to_be_string.throws_a_report_when_type_is_mismatch () abort
193
193
call s: check_throw (' to_be_string' , 0 )
194
194
endfunction
195
195
endfunction
196
196
197
- function ! expect.__to_be_list__ () abort
197
+ function expect.__to_be_list__ () abort
198
198
let to_be_list = themis#suite (' .to_be_list()' )
199
- function ! to_be_list.checks_type_of_value () abort
199
+ function to_be_list.checks_type_of_value () abort
200
200
call s: expect ([]).to_be_list ()
201
201
endfunction
202
- function ! to_be_list.throws_a_report_when_type_is_mismatch () abort
202
+ function to_be_list.throws_a_report_when_type_is_mismatch () abort
203
203
call s: check_throw (' to_be_list' , 0 )
204
204
endfunction
205
205
endfunction
206
206
207
- function ! expect.__to_be_dict__ () abort
207
+ function expect.__to_be_dict__ () abort
208
208
let to_be_dict = themis#suite (' .to_be_dict()' )
209
- function ! to_be_dict.checks_type_of_value () abort
209
+ function to_be_dict.checks_type_of_value () abort
210
210
call s: expect ({}).to_be_dict ()
211
211
endfunction
212
- function ! to_be_dict.throws_a_report_when_type_is_mismatch () abort
212
+ function to_be_dict.throws_a_report_when_type_is_mismatch () abort
213
213
call s: check_throw (' to_be_dict' , 0 )
214
214
endfunction
215
215
endfunction
216
216
217
- function ! expect.__to_be_func__ () abort
217
+ function expect.__to_be_func__ () abort
218
218
let to_be_func = themis#suite (' .to_be_func()' )
219
- function ! to_be_func.checks_type_of_value () abort
219
+ function to_be_func.checks_type_of_value () abort
220
220
call s: expect (function (' function' )).to_be_func ()
221
221
endfunction
222
- function ! to_be_func.throws_a_report_when_type_is_mismatch () abort
222
+ function to_be_func.throws_a_report_when_type_is_mismatch () abort
223
223
call s: check_throw (' to_be_func' , 0 )
224
224
endfunction
225
225
endfunction
226
226
227
- function ! expect.__to_be_float__ () abort
227
+ function expect.__to_be_float__ () abort
228
228
let to_be_float = themis#suite (' .to_be_float()' )
229
- function ! to_be_float.checks_type_of_value () abort
229
+ function to_be_float.checks_type_of_value () abort
230
230
call s: expect (0.0 ).to_be_float ()
231
231
endfunction
232
- function ! to_be_float.throws_a_report_when_type_is_mismatch () abort
232
+ function to_be_float.throws_a_report_when_type_is_mismatch () abort
233
233
call s: check_throw (' to_be_float' , 0 )
234
234
endfunction
235
235
endfunction
236
236
237
- function ! expect.__custom_matcher__ () abort
237
+ function expect.__custom_matcher__ () abort
238
238
let custom_matcher = themis#suite (' custom matcher' )
239
- function ! custom_matcher.before () abort
239
+ function custom_matcher.before () abort
240
240
call themis#helper#expect#define_matcher (' to_be_one_bigger_than' , ' a:1 ==# a:2 + 1' ,
241
241
\ ' (a:not ? "Not e" : "E") . "xpect " . string(a:1) . " to equal " . string(a:2) . "+1"' )
242
- function ! AmbigousEqual (a , b ) abort
242
+ function AmbigousEqual (a , b ) abort
243
243
return a: a == a: b
244
244
endfunction
245
- function ! MyFailureMessage (not, name, x , y ) abort
245
+ function MyFailureMessage (not, name, x , y ) abort
246
246
if a: not
247
247
return ' Not expect ' . string (a: x ) . ' == ' . string (a: y )
248
248
else
@@ -251,15 +251,15 @@ function! s:helper.__expect__() abort
251
251
endfunction
252
252
call themis#helper#expect#define_matcher (' to_be_similar' , function (' AmbigousEqual' ), function (' MyFailureMessage' ))
253
253
endfunction
254
- function ! custom_matcher.after () abort
254
+ function custom_matcher.after () abort
255
255
delfunction AmbigousEqual
256
256
delfunction MyFailureMessage
257
257
endfunction
258
- function ! custom_matcher.can_be_defined () abort
258
+ function custom_matcher.can_be_defined () abort
259
259
call s: expect (2 ).to_be_one_bigger_than (1 )
260
260
call s: expect (' 2' ).to_be_similar (2 )
261
261
endfunction
262
- function ! custom_matcher.provides_failre_message_definition () abort
262
+ function custom_matcher.provides_failre_message_definition () abort
263
263
call s: check_throw (' to_be_one_bigger_than' , 2 , [0 ], 0 , ' themis: report: failure: Expect 2 to equal 0+1' )
264
264
call s: check_throw (' to_be_one_bigger_than' , 2 , [1 ], 1 , ' themis: report: failure: Not expect 2 to equal 1+1' )
265
265
call s: check_throw (' to_be_similar' , 2 , [' 1' ], 0 , ' themis: report: failure: Expect 2 == '' 1'' ' )
@@ -269,7 +269,7 @@ function! s:helper.__expect__() abort
269
269
270
270
endfunction
271
271
272
- function ! s: check_throw (target, actual, ... ) abort
272
+ function s: check_throw (target, actual, ... ) abort
273
273
let args = a: 0 ? a: 1 : []
274
274
let not = a: 0 > 1 ? (a: 2 == # 1 ? 1 : 0 ) : 0
275
275
let expected_exception = a: 0 > 2 ? a: 3 : ' ^themis:\s*report:\s*failure:.*$'
0 commit comments