-
Notifications
You must be signed in to change notification settings - Fork 1
/
function-check.vim
64 lines (47 loc) · 1.68 KB
/
function-check.vim
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
" Check if basic functionality works
" what is the name of the directory containing this file?
let s:portable = expand('<sfile>:p:h')
" add to 'runtimepath' the directory of the software under test.
let &runtimepath = printf('%s/vim,%s,%s/after', s:portable, &runtimepath, s:portable)
echo 'New runtimepath = ' . &runtimepath
" Force-load this *before* loading a file.
source vim/ftdetect/metamath.vim
edit test.mm
echo 'Starting test'
function SpecificSyntaxName()
return synIDattr(synID(line('.'),col('.'),0),'name')
endfunction
function MappedSyntaxName()
return synIDattr(synIDtrans(synID(line('.'),col('.'),1)),'name')
endfunction
function MyMoveTo(line,column)
let junk = cursor(a:line, a:column)
endfunction
function MyMoveToPattern(text)
let junk = search(a:text)
endfunction
function! RunATest(actual, expected, testid) abort
if a:actual != a:expected
echo 'Test failure: ' . a:testid
echo 'Expected: ' . a:expected
echo 'Actual: ' . a:actual
cq
endif
endfunction
" Did we detect the filetype correctly?
call RunATest(&filetype, 'metamath', 'Filetype')
" Did we detect a comment?
call MyMoveTo(1,4)
call RunATest(SpecificSyntaxName(), 'metamathComment', 'Comment1')
call RunATest(MappedSyntaxName(), 'Comment', 'Comment2')
" In: wo $a wff ( ph \/ ps ) $.
" Move to "wo"
normal 1G
call MyMoveToPattern('\m\C\<wo\>')
call RunATest(SpecificSyntaxName(), 'metamathLabel', 'Statement1')
call RunATest(MappedSyntaxName(), 'Statement', 'Statement2')
call MyMoveToPattern('\m\C\<$a\>')
call RunATest(SpecificSyntaxName(), 'metamathAxiom', 'Axiom1')
call MyMoveToPattern('\m\C\<\\\/\>')
call RunATest(SpecificSyntaxName(), 'metamathBasicOperator', 'BasicOperator1')
quit