annotate src/testdir/test_autocmd_option.in @ 7443:357b7bd8d612 v7.4.1025

commit https://github.com/vim/vim/commit/6c7b44472f7055c78d996e1b626bd2932502212f Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 2 15:44:32 2016 +0100 patch 7.4.1025 Problem: Version in installer needs to be updated manually. Solution: Generate a file with the version number. (Guopeng Wen)
author Christian Brabandt <cb@256bit.org>
date Sat, 02 Jan 2016 15:45:03 +0100
parents 0b4e65cf84fb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6935
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 Test for option autocommand
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3 STARTTEST
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4 :so small.vim
6943
d37e168dee20 patch 7.4.790
Bram Moolenaar <bram@vim.org>
parents: 6935
diff changeset
5 :if !has("eval") || !has("autocmd") || !exists("+autochdir") | e! test.ok | w! test.out | qa! | endif
6935
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 :fu! AutoCommand(match)
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7 : let c=g:testcase
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 : let item=remove(g:options, 0)
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9 : let c.=printf("Expected: Name: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\n", item[0], item[1], item[2], item[3])
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 : let c.=printf("Autocmd Option: <%s>,", a:match)
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 : let c.=printf(" OldVal: <%s>,", v:option_old)
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 : let c.=printf(" NewVal: <%s>,", v:option_new)
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 : let c.=printf(" Scope: <%s>\n", v:option_type)
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 : call setreg('r', printf("%s\n%s", getreg('r'), c))
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 :endfu
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 :au OptionSet * :call AutoCommand(expand("<amatch>"))
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 :let g:testcase="1: Setting number option\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 :let g:options=[['number', 0, 1, 'global']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 :set nu
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20 :let g:testcase="2: Setting local number option\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21 :let g:options=[['number', 1, 0, 'local']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 :setlocal nonu
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 :let g:testcase="3: Setting global number option\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 :let g:options=[['number', 1, 0, 'global']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 :setglobal nonu
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26 :let g:testcase="4: Setting local autoindent option\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 :let g:options=[['autoindent', 0, 1, 'local']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28 :setlocal ai
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
29 :let g:testcase="5: Setting global autoindent option\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 :let g:options=[['autoindent', 0, 1, 'global']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31 :setglobal ai
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
32 :let g:testcase="6: Setting global autoindent option\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
33 :let g:options=[['autoindent', 1, 0, 'global']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
34 :set ai!
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35 : Should not print anything, use :noa
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36 :noa :set nonu
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37 :let g:testcase="7: Setting several global list and number option\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38 :let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
39 :set list nu
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
40 :noa set nolist nonu
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
41 :let g:testcase="8: Setting global acd\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
42 :let g:options=[['autochdir', 0, 1, 'global']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
43 :setlocal acd
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
44 :let g:testcase="9: Setting global autoread\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
45 :let g:options=[['autoread', 0, 1, 'global']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46 :set ar
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47 :let g:testcase="10: Setting local autoread\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 :let g:options=[['autoread', 0, 1, 'local']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
49 :setlocal ar
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50 :let g:testcase="11: Setting global autoread\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
51 :let g:options=[['autoread', 1, 0, 'global']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
52 :setglobal invar
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53 :let g:testcase="12: Setting option backspace through :let\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
54 :let g:options=[['backspace', '', 'eol,indent,start', 'global']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
55 :let &bs="eol,indent,start"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
56 :let g:testcase="13: Setting option backspace through setbufvar()\n"
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
57 :let g:options=[['backup', '', '1', 'local']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
58 : "try twice, first time, shouldn't trigger because option name is invalid, second time, it should trigger
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
59 :call setbufvar(1, '&l:bk', 1)
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
60 : "should trigger, use correct option name
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
61 :call setbufvar(1, '&backup', 1)
7156
0b4e65cf84fb commit https://github.com/vim/vim/commit/74b738d414b2895b3365e26ae3b7792eb82ccf47
Christian Brabandt <cb@256bit.org>
parents: 6943
diff changeset
62 :let g:testcase="14: Setting number option using setwinvar\n"
0b4e65cf84fb commit https://github.com/vim/vim/commit/74b738d414b2895b3365e26ae3b7792eb82ccf47
Christian Brabandt <cb@256bit.org>
parents: 6943
diff changeset
63 :let g:options=[['number', 0, 1, 'local']]
0b4e65cf84fb commit https://github.com/vim/vim/commit/74b738d414b2895b3365e26ae3b7792eb82ccf47
Christian Brabandt <cb@256bit.org>
parents: 6943
diff changeset
64 :call setwinvar(0, '&number', 1)
6935
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
65 :" Write register now, because next test shouldn't output anything.
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
66 :$put r
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
67 :let @r=''
7156
0b4e65cf84fb commit https://github.com/vim/vim/commit/74b738d414b2895b3365e26ae3b7792eb82ccf47
Christian Brabandt <cb@256bit.org>
parents: 6943
diff changeset
68 :let g:testcase="\n15: Setting key option, shouldn't trigger\n"
6935
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
69 :let g:options=[['key', 'invalid', 'invalid1', 'invalid']]
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
70 :setlocal key=blah
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
71 :setlocal key=
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
72 :$put =g:testcase
7156
0b4e65cf84fb commit https://github.com/vim/vim/commit/74b738d414b2895b3365e26ae3b7792eb82ccf47
Christian Brabandt <cb@256bit.org>
parents: 6943
diff changeset
73 :$put r
6943
d37e168dee20 patch 7.4.790
Bram Moolenaar <bram@vim.org>
parents: 6935
diff changeset
74 :/^dummy text/,$w! test.out
6935
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
75 :qa!
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
76 ENDTEST
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
77 dummy text