Mercurial > vim
annotate src/testdir/test_autocmd_option.in @ 9994:ee8b8a670a5c v7.4.2270
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 27 19:21:48 2016 +0200
patch 7.4.2270
Problem: Insufficient testing for NUL bytes on a raw channel.
Solution: Add a test for writing and reading.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 27 Aug 2016 19:30:06 +0200 |
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 |