summaryrefslogtreecommitdiff
path: root/src/testdir/test60.in
blob: 4435343ac3ffccffbc6bd975e50f497a3067b338 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Tests for the exists() function.  vim: set ft=vim :

STARTTEST
:so small.vim
:function! RunTest(str, result)
    if exists(a:str) == a:result
	echo "OK"
    else
	echo "FAILED: Checking for " . a:str
    endif
endfunction
:function! TestExists()
    augroup myagroup
	autocmd! BufEnter *.my echo 'myfile edited'
    augroup END

    let test_cases = []

    " valid autocmd group
    let test_cases += [['#myagroup', 1]]
    " Valid autocmd group and event
    let test_cases += [['#myagroup#BufEnter', 1]]
    " Valid autocmd group, event and pattern
    let test_cases += [['#myagroup#BufEnter#*.my', 1]]
    " Valid autocmd event
    let test_cases += [['#BufEnter', 1]]
    " Valid autocmd event and pattern
    let test_cases += [['#BufEnter#*.my', 1]]
    " Non-existing autocmd group or event
    let test_cases += [['#xyzagroup', 0]]
    " Non-existing autocmd group and valid autocmd event
    let test_cases += [['#xyzagroup#BufEnter', 0]]
    " Valid autocmd group and event with no matching pattern
    let test_cases += [['#myagroup#CmdwinEnter', 0]]
    " Valid autocmd group and non-existing autocmd event
    let test_cases += [['#myagroup#xyzacmd', 0]]
    " Valid autocmd group and event and non-matching pattern
    let test_cases += [['#myagroup#BufEnter#xyzpat', 0]]
    " Valid autocmd event and non-matching pattern
    let test_cases += [['#BufEnter#xyzpat', 0]]
    " Empty autocmd group, event and pattern
    let test_cases += [['###', 0]]
    " Empty autocmd group and event or empty event and pattern
    let test_cases += [['##', 0]]
    " Valid autocmd event
    let test_cases += [['##FileReadCmd', 1]]
    " Non-existing autocmd event
    let test_cases += [['##MySpecialCmd', 0]]

    redir! > test.out

    for [test_case, result] in test_cases
      	echo test_case . ": " . result
        call RunTest(test_case, result)
    endfor

    redir END
endfunction
:call TestExists()
:edit! test.out
:set ff=unix
:w
:qa!
ENDTEST