blob: 5d4dea756a0c6f157e07b7326b99c0981122d4f5 (
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
|
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @Website: https://github.com/tomtom
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Last Change: 2015-12-04
" @Revision: 41
" Enable tracing via |:Tlibassert|.
function! tlib#assert#Enable() abort "{{{3
" :nodoc:
command! -nargs=+ -bang Tlibassert call tlib#assert#Assert(expand('<sfile>'), <q-args>, [<args>])
endf
" Disable tracing via |:Tlibassert|.
function! tlib#assert#Disable() abort "{{{3
" :nodoc:
command! -nargs=+ -bang Tlibassert :
endf
function! tlib#assert#Assert(caller, check, vals) abort "{{{3
for val in a:vals
" TLogVAR val
if type(val) == 3
call tlib#assert#Assert(a:caller, a:check, val)
elseif !val
throw 'Tlibassert: '. tlib#trace#Backtrace(a:caller) .': '. a:check
endif
endfor
endf
function! tlib#assert#Map(vals, expr) abort "{{{3
return tlib#assert#All(map(a:vals, a:expr))
endf
function! tlib#assert#All(vals) abort "{{{3
" TLogVAR a:vals, empty(filter(a:vals, '!v:val'))
return empty(filter(a:vals, '!v:val'))
endf
|