Mercurial > vim
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 |
rev | line source |
---|---|
6935 | 1 Test for option autocommand |
2 | |
3 STARTTEST | |
4 :so small.vim | |
6943 | 5 :if !has("eval") || !has("autocmd") || !exists("+autochdir") | e! test.ok | w! test.out | qa! | endif |
6935 | 6 :fu! AutoCommand(match) |
7 : let c=g:testcase | |
8 : let item=remove(g:options, 0) | |
9 : let c.=printf("Expected: Name: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\n", item[0], item[1], item[2], item[3]) | |
10 : let c.=printf("Autocmd Option: <%s>,", a:match) | |
11 : let c.=printf(" OldVal: <%s>,", v:option_old) | |
12 : let c.=printf(" NewVal: <%s>,", v:option_new) | |
13 : let c.=printf(" Scope: <%s>\n", v:option_type) | |
14 : call setreg('r', printf("%s\n%s", getreg('r'), c)) | |
15 :endfu | |
16 :au OptionSet * :call AutoCommand(expand("<amatch>")) | |
17 :let g:testcase="1: Setting number option\n" | |
18 :let g:options=[['number', 0, 1, 'global']] | |
19 :set nu | |
20 :let g:testcase="2: Setting local number option\n" | |
21 :let g:options=[['number', 1, 0, 'local']] | |
22 :setlocal nonu | |
23 :let g:testcase="3: Setting global number option\n" | |
24 :let g:options=[['number', 1, 0, 'global']] | |
25 :setglobal nonu | |
26 :let g:testcase="4: Setting local autoindent option\n" | |
27 :let g:options=[['autoindent', 0, 1, 'local']] | |
28 :setlocal ai | |
29 :let g:testcase="5: Setting global autoindent option\n" | |
30 :let g:options=[['autoindent', 0, 1, 'global']] | |
31 :setglobal ai | |
32 :let g:testcase="6: Setting global autoindent option\n" | |
33 :let g:options=[['autoindent', 1, 0, 'global']] | |
34 :set ai! | |
35 : Should not print anything, use :noa | |
36 :noa :set nonu | |
37 :let g:testcase="7: Setting several global list and number option\n" | |
38 :let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']] | |
39 :set list nu | |
40 :noa set nolist nonu | |
41 :let g:testcase="8: Setting global acd\n" | |
42 :let g:options=[['autochdir', 0, 1, 'global']] | |
43 :setlocal acd | |
44 :let g:testcase="9: Setting global autoread\n" | |
45 :let g:options=[['autoread', 0, 1, 'global']] | |
46 :set ar | |
47 :let g:testcase="10: Setting local autoread\n" | |
48 :let g:options=[['autoread', 0, 1, 'local']] | |
49 :setlocal ar | |
50 :let g:testcase="11: Setting global autoread\n" | |
51 :let g:options=[['autoread', 1, 0, 'global']] | |
52 :setglobal invar | |
53 :let g:testcase="12: Setting option backspace through :let\n" | |
54 :let g:options=[['backspace', '', 'eol,indent,start', 'global']] | |
55 :let &bs="eol,indent,start" | |
56 :let g:testcase="13: Setting option backspace through setbufvar()\n" | |
57 :let g:options=[['backup', '', '1', 'local']] | |
58 : "try twice, first time, shouldn't trigger because option name is invalid, second time, it should trigger | |
59 :call setbufvar(1, '&l:bk', 1) | |
60 : "should trigger, use correct option name | |
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 | 65 :" Write register now, because next test shouldn't output anything. |
66 :$put r | |
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 | 69 :let g:options=[['key', 'invalid', 'invalid1', 'invalid']] |
70 :setlocal key=blah | |
71 :setlocal key= | |
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 | 74 :/^dummy text/,$w! test.out |
6935 | 75 :qa! |
76 ENDTEST | |
77 dummy text |