annotate src/testdir/test_cindent.vim @ 11800:5ceaecedbad2 v8.0.0782

patch 8.0.0782: using freed memory in quickfix code commit https://github.com/vim/vim/commit/d28cc3f55d4a5a980f6ac6fa682382822a223720 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jul 27 22:03:50 2017 +0200 patch 8.0.0782: using freed memory in quickfix code Problem: Using freed memory in quickfix code. (Dominique Pelle) Solution: Handle a help window differently. (Yegappan Lakshmanan)
author Christian Brabandt <cb@256bit.org>
date Thu, 27 Jul 2017 22:15:03 +0200
parents 242e0617aa51
children 0066a7e178bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11069
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for cinoptions and cindent
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 "
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " TODO: rewrite test3.in into this new style test
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_cino_hash()
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " Test that curbuf->b_ind_hash_comment is correctly reset
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 new
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 setlocal cindent cinoptions=#1
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 setlocal cinoptions=
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 call setline(1, ["#include <iostream>"])
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 call cursor(1, 1)
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 norm! o#include
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 "call feedkeys("o#include\<esc>", 't')
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call assert_equal(["#include <iostream>", "#include"], getline(1,2))
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 bwipe!
814126a34c9d patch 8.0.0423: changing 'cinoptions' does not always work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 endfunc
11087
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
17
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
18 func Test_cino_extern_c()
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
19 " Test for cino-E
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
20
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
21 let without_ind = [
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
22 \ '#ifdef __cplusplus',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
23 \ 'extern "C" {',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
24 \ '#endif',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
25 \ 'int func_a(void);',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
26 \ '#ifdef __cplusplus',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
27 \ '}',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
28 \ '#endif'
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
29 \ ]
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
30
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
31 let with_ind = [
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
32 \ '#ifdef __cplusplus',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
33 \ 'extern "C" {',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
34 \ '#endif',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
35 \ "\tint func_a(void);",
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
36 \ '#ifdef __cplusplus',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
37 \ '}',
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
38 \ '#endif'
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
39 \ ]
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
40 new
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
41 setlocal cindent cinoptions=E0
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
42 call setline(1, without_ind)
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
43 call feedkeys("gg=G", 'tx')
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
44 call assert_equal(with_ind, getline(1, '$'))
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
45
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
46 setlocal cinoptions=E-s
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
47 call setline(1, with_ind)
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
48 call feedkeys("gg=G", 'tx')
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
49 call assert_equal(without_ind, getline(1, '$'))
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
50
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
51 setlocal cinoptions=Es
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
52 let tests = [
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
53 \ ['recognized', ['extern "C" {'], "\t\t;"],
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
54 \ ['recognized', ['extern "C++" {'], "\t\t;"],
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
55 \ ['recognized', ['extern /* com */ "C"{'], "\t\t;"],
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
56 \ ['recognized', ['extern"C"{'], "\t\t;"],
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
57 \ ['recognized', ['extern "C"', '{'], "\t\t;"],
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
58 \ ['not recognized', ['extern {'], "\t;"],
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
59 \ ['not recognized', ['extern /*"C"*/{'], "\t;"],
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
60 \ ['not recognized', ['extern "C" //{'], ";"],
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
61 \ ['not recognized', ['extern "C" /*{*/'], ";"],
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
62 \ ]
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
63
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
64 for pair in tests
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
65 let lines = pair[1]
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
66 call setline(1, lines)
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
67 call feedkeys(len(lines) . "Go;", 'tx')
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
68 call assert_equal(pair[2], getline(len(lines) + 1), 'Failed for "' . string(lines) . '"')
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
69 endfor
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
70
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
71
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
72
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
73 bwipe!
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
74 endfunc
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
75
242e0617aa51 patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents: 11069
diff changeset
76 " vim: shiftwidth=2 sts=2 expandtab