Mercurial > vim
annotate src/testdir/test_cindent.vim @ 12251:9b6c3d136e7f
Added tag v8.0.1005 for changeset ac8b2f9c14094f2685c6a596339cdbe84ba7d5aa
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 27 Aug 2017 15:00:05 +0200 |
parents | 0066a7e178bc |
children | 4dba3e4f3b01 |
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 bwipe! |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
11069
diff
changeset
|
72 endfunc |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
11069
diff
changeset
|
73 |
12238
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
74 func! Test_cindent_rawstring() |
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
75 new |
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
76 setl cindent |
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
77 call feedkeys("i" . |
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
78 \ "int main() {\<CR>" . |
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
79 \ "R\"(\<CR>" . |
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
80 \ ")\";\<CR>" . |
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
81 \ "statement;\<Esc>", "x") |
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
82 call assert_equal("\tstatement;", getline(line('.'))) |
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
83 bw! |
0066a7e178bc
patch 8.0.0999: indenting raw C++ strings is wrong
Christian Brabandt <cb@256bit.org>
parents:
11087
diff
changeset
|
84 endfunction |
11087
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
11069
diff
changeset
|
85 " vim: shiftwidth=2 sts=2 expandtab |