comparison src/testdir/test_autocmd_option.ok @ 6943:d37e168dee20 v7.4.790

patch 7.4.790 Problem: Test fails when the autochdir feature is not available. Test output contains the test script. Solution: Check for the autochdir feature. (Kazunobu Kuriyama) Only write the relevant test output.
author Bram Moolenaar <bram@vim.org>
date Tue, 21 Jul 2015 10:57:44 +0200
parents 4db70c94226b
children 0b4e65cf84fb
comparison
equal deleted inserted replaced
6942:758fe8fd4bae 6943:d37e168dee20
1 Test for option autocommand
2
3 STARTTEST
4 :so small.vim
5 :if !has("eval") || !has("autocmd") | e! test.ok | w! test.out | qa! | endif
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)
62 :" Write register now, because next test shouldn't output anything.
63 :$put r
64 :let @r=''
65 :let g:testcase="\n14: Setting key option, shouldn't trigger\n"
66 :let g:options=[['key', 'invalid', 'invalid1', 'invalid']]
67 :setlocal key=blah
68 :setlocal key=
69 :$put =g:testcase
70 :%w! test.out
71 :qa!
72 ENDTEST
73 dummy text 1 dummy text
74 2
75 1: Setting number option 3 1: Setting number option
76 Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <global> 4 Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <global>
77 Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <global> 5 Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <global>