Mercurial > vim
comparison src/testdir/test_indent.vim @ 19603:6d3c683466f4 v8.2.0358
patch 8.2.0358: insufficient testing for indent.c
Commit: https://github.com/vim/vim/commit/bd7206e02c957f0619e68e1628e2a3e91dd41e06
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 6 20:36:04 2020 +0100
patch 8.2.0358: insufficient testing for indent.c
Problem: Insufficient testing for indent.c.
Solution: Add indent tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5736)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 06 Mar 2020 20:45:04 +0100 |
parents | |
children | 9c15be376631 |
comparison
equal
deleted
inserted
replaced
19602:03c12433ae36 | 19603:6d3c683466f4 |
---|---|
1 " Test for various indent options | |
2 | |
3 func Test_preserveindent() | |
4 new | |
5 " Test for autoindent copying indent from the previous line | |
6 setlocal autoindent | |
7 call setline(1, [repeat(' ', 16) .. 'line1']) | |
8 call feedkeys("A\nline2", 'xt') | |
9 call assert_equal("\t\tline2", getline(2)) | |
10 setlocal autoindent& | |
11 | |
12 " Test for using CTRL-T with and without 'preserveindent' | |
13 set shiftwidth=4 | |
14 call cursor(1, 1) | |
15 call setline(1, " \t ") | |
16 call feedkeys("Al\<C-T>", 'xt') | |
17 call assert_equal("\t\tl", getline(1)) | |
18 set preserveindent | |
19 call setline(1, " \t ") | |
20 call feedkeys("Al\<C-T>", 'xt') | |
21 call assert_equal(" \t \tl", getline(1)) | |
22 set pi& sw& | |
23 | |
24 " Test for using CTRL-T with 'expandtab' and 'preserveindent' | |
25 call cursor(1, 1) | |
26 call setline(1, "\t \t") | |
27 set shiftwidth=4 expandtab preserveindent | |
28 call feedkeys("Al\<C-T>", 'xt') | |
29 call assert_equal("\t \t l", getline(1)) | |
30 set sw& et& pi& | |
31 | |
32 close! | |
33 endfunc | |
34 | |
35 " Test for indent() | |
36 func Test_indent_func() | |
37 call assert_equal(-1, indent(-1)) | |
38 new | |
39 call setline(1, "\tabc") | |
40 call assert_equal(8, indent(1)) | |
41 call setline(1, " abc") | |
42 call assert_equal(4, indent(1)) | |
43 call setline(1, " \t abc") | |
44 call assert_equal(12, indent(1)) | |
45 close! | |
46 endfunc | |
47 | |
48 " Test for reindenting a line using the '=' operator | |
49 func Test_reindent() | |
50 new | |
51 call setline(1, 'abc') | |
52 set nomodifiable | |
53 call assert_fails('normal ==', 'E21:') | |
54 set modifiable | |
55 | |
56 call setline(1, ['foo', 'bar']) | |
57 call feedkeys('ggVG=', 'xt') | |
58 call assert_equal(['foo', 'bar'], getline(1, 2)) | |
59 close! | |
60 endfunc | |
61 | |
62 " Test for shifting a line with a preprocessor directive ('#') | |
63 func Test_preproc_indent() | |
64 new | |
65 set sw=4 | |
66 call setline(1, '#define FOO 1') | |
67 normal >> | |
68 call assert_equal(' #define FOO 1', getline(1)) | |
69 | |
70 " with 'smartindent' | |
71 call setline(1, '#define FOO 1') | |
72 set smartindent | |
73 normal >> | |
74 call assert_equal('#define FOO 1', getline(1)) | |
75 set smartindent& | |
76 | |
77 " with 'cindent' | |
78 set cindent | |
79 normal >> | |
80 call assert_equal('#define FOO 1', getline(1)) | |
81 set cindent& | |
82 | |
83 close! | |
84 endfunc | |
85 | |
86 " Test for 'copyindent' | |
87 func Test_copyindent() | |
88 new | |
89 set shiftwidth=4 autoindent expandtab copyindent | |
90 call setline(1, " \t abc") | |
91 call feedkeys("ol", 'xt') | |
92 call assert_equal(" \t l", getline(2)) | |
93 set noexpandtab | |
94 call setline(1, " \t abc") | |
95 call feedkeys("ol", 'xt') | |
96 call assert_equal(" \t l", getline(2)) | |
97 set sw& ai& et& ci& | |
98 close! | |
99 endfunc | |
100 | |
101 " vim: shiftwidth=2 sts=2 expandtab |