Skip to content

Commit 4935b35

Browse files
committed
test: skip if the type is not available
1 parent 9314287 commit 4935b35

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/Validator/Args.vim

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@ scriptencoding utf-8
33
let s:suite = themis#suite('Validator.Args')
44
let s:assert = themis#helper('assert')
55

6+
function! s:assert_null_support() abort
7+
if !exists('v:null')
8+
Skip "this version of vim/neovim does not support v:null"
9+
endif
10+
endfunction
11+
12+
function! s:assert_job_support() abort
13+
if !exists('*test_null_job')
14+
Skip "this version of vim does not support job"
15+
endif
16+
endfunction
17+
18+
function! s:assert_channel_support() abort
19+
if !exists('*test_null_channel')
20+
Skip "this version of vim does not support channel"
21+
endif
22+
endfunction
23+
24+
function! s:assert_blob_support() abort
25+
if !exists('*test_null_blob')
26+
Skip "this version of vim does not support blob"
27+
endif
28+
endfunction
29+
630
function! s:suite.before()
731
let s:A = vital#vital#import('Validator.Args')
832
endfunction
@@ -25,12 +49,16 @@ function! s:suite.__of__()
2549
\ A.of(3.14)
2650
Throws /^vital: Validator.Args: of(): expected string argument but got bool/
2751
\ A.of(v:false)
52+
call s:assert_null_support()
2853
Throws /^vital: Validator.Args: of(): expected string argument but got none/
2954
\ A.of(v:null)
55+
call s:assert_job_support()
3056
Throws /^vital: Validator.Args: of(): expected string argument but got job/
3157
\ A.of(test_null_job())
58+
call s:assert_channel_support()
3259
Throws /^vital: Validator.Args: of(): expected string argument but got channel/
3360
\ A.of(test_null_channel())
61+
call s:assert_blob_support()
3462
Throws /^vital: Validator.Args: of(): expected string argument but got blob/
3563
\ A.of(test_null_blob())
3664
endfunction
@@ -79,12 +107,16 @@ function! s:suite.__of__()
79107
\ A.of('test()').type([v:t_string, v:t_func]).validate([3.14])
80108
Throws /^test(): invalid type arguments were given (expected: string or func, got: bool)/
81109
\ A.of('test()').type([v:t_string, v:t_func]).validate([v:false])
110+
call s:assert_null_support()
82111
Throws /^test(): invalid type arguments were given (expected: string or func, got: none)/
83112
\ A.of('test()').type([v:t_string, v:t_func]).validate([v:null])
113+
call s:assert_job_support()
84114
Throws /^test(): invalid type arguments were given (expected: string or func, got: job)/
85115
\ A.of('test()').type([v:t_string, v:t_func]).validate([test_null_job()])
116+
call s:assert_channel_support()
86117
Throws /^test(): invalid type arguments were given (expected: string or func, got: channel)/
87118
\ A.of('test()').type([v:t_string, v:t_func]).validate([test_null_channel()])
119+
call s:assert_blob_support()
88120
Throws /^test(): invalid type arguments were given (expected: string or func, got: blob)/
89121
\ A.of('test()').type([v:t_string, v:t_func]).validate([test_null_blob()])
90122
endfunction
@@ -97,9 +129,13 @@ function! s:suite.__of__()
97129
call s:A.of('test()').type('any').validate([{}])
98130
call s:A.of('test()').type('any').validate([3.14])
99131
call s:A.of('test()').type('any').validate([v:false])
132+
call s:assert_null_support()
100133
call s:A.of('test()').type('any').validate([v:null])
134+
call s:assert_job_support()
101135
call s:A.of('test()').type('any').validate([test_null_job()])
136+
call s:assert_channel_support()
102137
call s:A.of('test()').type('any').validate([test_null_channel()])
138+
call s:assert_blob_support()
103139
call s:A.of('test()').type('any').validate([test_null_blob()])
104140
endfunction
105141

@@ -118,12 +154,16 @@ function! s:suite.__of__()
118154
\ A.of('test()').type(v:t_string).validate([3.14])
119155
Throws /^test(): invalid type arguments were given (expected: string, got: bool)/
120156
\ A.of('test()').type(v:t_string).validate([v:false])
157+
call s:assert_null_support()
121158
Throws /^test(): invalid type arguments were given (expected: string, got: none)/
122159
\ A.of('test()').type(v:t_string).validate([v:null])
160+
call s:assert_job_support()
123161
Throws /^test(): invalid type arguments were given (expected: string, got: job)/
124162
\ A.of('test()').type(v:t_string).validate([test_null_job()])
163+
call s:assert_channel_support()
125164
Throws /^test(): invalid type arguments were given (expected: string, got: channel)/
126165
\ A.of('test()').type(v:t_string).validate([test_null_channel()])
166+
call s:assert_blob_support()
127167
Throws /^test(): invalid type arguments were given (expected: string, got: blob)/
128168
\ A.of('test()').type(v:t_string).validate([test_null_blob()])
129169
endfunction
@@ -143,12 +183,16 @@ function! s:suite.__of__()
143183
\ A.of('test()').type('any').validate(3.14)
144184
Throws /^vital: Validator.Args: Validator.validate(): expected list argument but got bool/
145185
\ A.of('test()').type('any').validate(v:false)
186+
call s:assert_null_support()
146187
Throws /^vital: Validator.Args: Validator.validate(): expected list argument but got none/
147188
\ A.of('test()').type('any').validate(v:null)
189+
call s:assert_job_support()
148190
Throws /^vital: Validator.Args: Validator.validate(): expected list argument but got job/
149191
\ A.of('test()').type('any').validate(test_null_job())
192+
call s:assert_channel_support()
150193
Throws /^vital: Validator.Args: Validator.validate(): expected list argument but got channel/
151194
\ A.of('test()').type('any').validate(test_null_channel())
195+
call s:assert_blob_support()
152196
Throws /^vital: Validator.Args: Validator.validate(): expected list argument but got blob/
153197
\ A.of('test()').type('any').validate(test_null_blob())
154198
endfunction

0 commit comments

Comments
 (0)