aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_autocmd_option.ok
blob: 230f53a6f5c6c07a340867f63aa3181bca5c6d8b (plain) (blame)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Test for option autocommand

STARTTEST
:so small.vim
:if !has("eval") || !has("autocmd") | e! test.ok | w! test.out | qa! | endif
:fu! AutoCommand(match)
:	let c=g:testcase
:       let item=remove(g:options, 0)
:       let c.=printf("Expected: Name: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\n", item[0], item[1], item[2], item[3])
:       let c.=printf("Autocmd Option: <%s>,", a:match)
:       let c.=printf(" OldVal: <%s>,", v:option_old)
:       let c.=printf(" NewVal: <%s>,", v:option_new)
:       let c.=printf(" Scope: <%s>\n", v:option_type)
:       call setreg('r', printf("%s\n%s", getreg('r'), c))
:endfu
:au OptionSet * :call AutoCommand(expand("<amatch>"))
:let g:testcase="1: Setting number option\n"
:let g:options=[['number', 0, 1, 'global']]
:set nu
:let g:testcase="2: Setting local number option\n"
:let g:options=[['number', 1, 0, 'local']]
:setlocal nonu
:let g:testcase="3: Setting global number option\n"
:let g:options=[['number', 1, 0, 'global']]
:setglobal nonu
:let g:testcase="4: Setting local autoindent option\n"
:let g:options=[['autoindent', 0, 1, 'local']]
:setlocal ai
:let g:testcase="5: Setting global autoindent option\n"
:let g:options=[['autoindent', 0, 1, 'global']]
:setglobal ai
:let g:testcase="6: Setting global autoindent option\n"
:let g:options=[['autoindent', 1, 0, 'global']]
:set ai!
: Should not print anything, use :noa
:noa :set nonu
:let g:testcase="7: Setting several global list and number option\n"
:let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]
:set list nu
:noa set nolist nonu
:let g:testcase="8: Setting global acd\n"
:let g:options=[['autochdir', 0, 1, 'global']]
:setlocal acd
:let g:testcase="9: Setting global autoread\n"
:let g:options=[['autoread', 0, 1, 'global']]
:set ar
:let g:testcase="10: Setting local autoread\n"
:let g:options=[['autoread', 0, 1, 'local']]
:setlocal ar
:let g:testcase="11: Setting global autoread\n"
:let g:options=[['autoread', 1, 0, 'global']]
:setglobal invar
:let g:testcase="12: Setting option backspace through :let\n"
:let g:options=[['backspace', '', 'eol,indent,start', 'global']]
:let &bs="eol,indent,start"
:let g:testcase="13: Setting option backspace through setbufvar()\n"
:let g:options=[['backup', '', '1', 'local']]
: "try twice, first time, shouldn't trigger because option name is invalid, second time, it should trigger
:call setbufvar(1, '&l:bk', 1)
: "should trigger, use correct option name
:call setbufvar(1, '&backup', 1)
:" Write register now, because next test shouldn't output anything.
:$put r
:let @r=''
:let g:testcase="\n14: Setting key option, shouldn't trigger\n"
:let g:options=[['key', 'invalid', 'invalid1', 'invalid']]
:setlocal key=blah
:setlocal key=
:$put =g:testcase
:%w! test.out
:qa!
ENDTEST
dummy text

1: Setting number option
Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <global>
Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <global>

2: Setting local number option
Expected: Name: <number>, Oldval: <1>, NewVal: <0>, Scope: <local>
Autocmd Option: <number>, OldVal: <1>, NewVal: <0>, Scope: <local>

3: Setting global number option
Expected: Name: <number>, Oldval: <1>, NewVal: <0>, Scope: <global>
Autocmd Option: <number>, OldVal: <1>, NewVal: <0>, Scope: <global>

4: Setting local autoindent option
Expected: Name: <autoindent>, Oldval: <1>, NewVal: <0>, Scope: <local>
Autocmd Option: <autoindent>, OldVal: <1>, NewVal: <0>, Scope: <local>

5: Setting global autoindent option
Expected: Name: <autoindent>, Oldval: <1>, NewVal: <0>, Scope: <global>
Autocmd Option: <autoindent>, OldVal: <1>, NewVal: <0>, Scope: <global>

6: Setting global autoindent option
Expected: Name: <autoindent>, Oldval: <0>, NewVal: <1>, Scope: <global>
Autocmd Option: <autoindent>, OldVal: <0>, NewVal: <1>, Scope: <global>

7: Setting several global list and number option
Expected: Name: <list>, Oldval: <0>, NewVal: <1>, Scope: <global>
Autocmd Option: <list>, OldVal: <0>, NewVal: <1>, Scope: <global>

7: Setting several global list and number option
Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <global>
Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <global>

8: Setting global acd
Expected: Name: <autochdir>, Oldval: <0>, NewVal: <1>, Scope: <global>
Autocmd Option: <autochdir>, OldVal: <0>, NewVal: <1>, Scope: <local>

9: Setting global autoread
Expected: Name: <autoread>, Oldval: <1>, NewVal: <0>, Scope: <global>
Autocmd Option: <autoread>, OldVal: <1>, NewVal: <0>, Scope: <global>

10: Setting local autoread
Expected: Name: <autoread>, Oldval: <1>, NewVal: <0>, Scope: <local>
Autocmd Option: <autoread>, OldVal: <1>, NewVal: <0>, Scope: <local>

11: Setting global autoread
Expected: Name: <autoread>, Oldval: <0>, NewVal: <1>, Scope: <global>
Autocmd Option: <autoread>, OldVal: <0>, NewVal: <1>, Scope: <global>

12: Setting option backspace through :let
Expected: Name: <backspace>, Oldval: <indent,eol,start>, NewVal: <>, Scope: <global>
Autocmd Option: <backspace>, OldVal: <indent,eol,start>, NewVal: <>, Scope: <global>

13: Setting option backspace through setbufvar()
Expected: Name: <backup>, Oldval: <>, NewVal: <1>, Scope: <local>
Autocmd Option: <backup>, OldVal: <0>, NewVal: <1>, Scope: <local>