Mercurial > vim
annotate src/testdir/test_modeline.vim @ 15603:639b8318472c v8.1.0809
patch 8.1.0809: too many #ifdefs
commit https://github.com/vim/vim/commit/a12a161b8ce09d024ed71c2134149fa323f8ee8e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 24 16:39:02 2019 +0100
patch 8.1.0809: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 3.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Jan 2019 16:45:06 +0100 |
parents | e52034f8b457 |
children | e55c26aaf484 |
rev | line source |
---|---|
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for parsing the modeline. |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
14383
8846b8344430
patch 8.1.0206: duplicate test function name
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
3 func Test_modeline_invalid() |
14989
85467d180844
patch 8.1.0506: modeline test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents:
14387
diff
changeset
|
4 " This was reading allocated memory in the past. |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 call writefile(['vi:0', 'nothing'], 'Xmodeline') |
14989
85467d180844
patch 8.1.0506: modeline test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents:
14387
diff
changeset
|
6 let modeline = &modeline |
85467d180844
patch 8.1.0506: modeline test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents:
14387
diff
changeset
|
7 set modeline |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 call assert_fails('split Xmodeline', 'E518:') |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
9 |
14989
85467d180844
patch 8.1.0506: modeline test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents:
14387
diff
changeset
|
10 let &modeline = modeline |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 bwipe! |
14387
68722ba52971
patch 8.1.0208: file left behind after running individual test
Christian Brabandt <cb@256bit.org>
parents:
14383
diff
changeset
|
12 call delete('Xmodeline') |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 endfunc |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
14 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
15 func Test_modeline_filetype() |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
16 call writefile(['vim: set ft=c :', 'nothing'], 'Xmodeline_filetype') |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
17 let modeline = &modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
18 set modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
19 filetype plugin on |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
20 split Xmodeline_filetype |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
21 call assert_equal("c", &filetype) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
22 call assert_equal(1, b:did_ftplugin) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
23 call assert_equal("ccomplete#Complete", &ofu) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
24 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
25 bwipe! |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
26 call delete('Xmodeline_filetype') |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
27 let &modeline = modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
28 filetype plugin off |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
29 endfunc |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
30 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
31 func Test_modeline_syntax() |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
32 call writefile(['vim: set syn=c :', 'nothing'], 'Xmodeline_syntax') |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
33 let modeline = &modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
34 set modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
35 syntax enable |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
36 split Xmodeline_syntax |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
37 call assert_equal("c", &syntax) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
38 call assert_equal("c", b:current_syntax) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
39 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
40 bwipe! |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
41 call delete('Xmodeline_syntax') |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
42 let &modeline = modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
43 syntax off |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
44 endfunc |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
45 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
46 func Test_modeline_keymap() |
15071
aabaf1499d05
patch 8.1.0546: modeline test with keymap fails
Bram Moolenaar <Bram@vim.org>
parents:
15066
diff
changeset
|
47 if !has('keymap') |
aabaf1499d05
patch 8.1.0546: modeline test with keymap fails
Bram Moolenaar <Bram@vim.org>
parents:
15066
diff
changeset
|
48 return |
aabaf1499d05
patch 8.1.0546: modeline test with keymap fails
Bram Moolenaar <Bram@vim.org>
parents:
15066
diff
changeset
|
49 endif |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
50 call writefile(['vim: set keymap=greek :', 'nothing'], 'Xmodeline_keymap') |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
51 let modeline = &modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
52 set modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
53 split Xmodeline_keymap |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
54 call assert_equal("greek", &keymap) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
55 call assert_match('greek\|grk', b:keymap_name) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
56 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
57 bwipe! |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
58 call delete('Xmodeline_keymap') |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
59 let &modeline = modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
60 set keymap= iminsert=0 imsearch=-1 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
61 endfunc |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
62 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
63 func s:modeline_fails(what, text) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
64 let fname = "Xmodeline_fails_" . a:what |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
65 call writefile(['vim: set ' . a:text . ' :', 'nothing'], fname) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
66 let modeline = &modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
67 set modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
68 filetype plugin on |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
69 syntax enable |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
70 call assert_fails('split ' . fname, 'E474:') |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
71 call assert_equal("", &filetype) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
72 call assert_equal("", &syntax) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
73 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
74 bwipe! |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
75 call delete(fname) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
76 let &modeline = modeline |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
77 filetype plugin off |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
78 syntax off |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
79 endfunc |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
80 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
81 func Test_modeline_filetype_fails() |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
82 call s:modeline_fails('filetype', 'ft=evil$CMD') |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
83 endfunc |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
84 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
85 func Test_modeline_syntax_fails() |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
86 call s:modeline_fails('syntax', 'syn=evil$CMD') |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
87 endfunc |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
88 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
89 func Test_modeline_keymap_fails() |
15073
e52034f8b457
patch 8.1.0547: modeline test with keymap still fails
Bram Moolenaar <Bram@vim.org>
parents:
15071
diff
changeset
|
90 if !has('keymap') |
e52034f8b457
patch 8.1.0547: modeline test with keymap still fails
Bram Moolenaar <Bram@vim.org>
parents:
15071
diff
changeset
|
91 return |
e52034f8b457
patch 8.1.0547: modeline test with keymap still fails
Bram Moolenaar <Bram@vim.org>
parents:
15071
diff
changeset
|
92 endif |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
93 call s:modeline_fails('keymap', 'keymap=evil$CMD') |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
14989
diff
changeset
|
94 endfunc |