annotate src/testdir/test_smartindent.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 63b02fcf1361
children 12518b40c161
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11943
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
1 " Tests for smartindent
10145
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Tests for not doing smart indenting when it isn't set.
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11943
diff changeset
4 func Test_nosmartindent()
10145
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 new
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 call append(0, [" some test text",
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11943
diff changeset
7 \ " test text",
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11943
diff changeset
8 \ "test text",
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11943
diff changeset
9 \ " test text"])
10145
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 set nocindent nosmartindent autoindent
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 exe "normal! gg/some\<CR>"
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 exe "normal! 2cc#test\<Esc>"
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_equal(" #test", getline(1))
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 enew! | close
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11943
diff changeset
15 endfunc
11943
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
16
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11943
diff changeset
17 func MyIndent()
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11943
diff changeset
18 endfunc
11943
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
19
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
20 " When 'indentexpr' is set, setting 'si' has no effect.
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11943
diff changeset
21 func Test_smartindent_has_no_effect()
11943
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
22 new
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
23 exe "normal! i\<Tab>one\<Esc>"
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
24 set noautoindent
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
25 set smartindent
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
26 set indentexpr=
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
27 exe "normal! Gotwo\<Esc>"
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
28 call assert_equal("\ttwo", getline("$"))
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
29
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
30 set indentexpr=MyIndent
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
31 exe "normal! Gothree\<Esc>"
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
32 call assert_equal("three", getline("$"))
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
33
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
34 delfunction! MyIndent
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
35 set autoindent&
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
36 set smartindent&
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
37 set indentexpr&
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
38 bwipe!
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11943
diff changeset
39 endfunc
11943
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
40
19603
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
41 " Test for inserting '{' and '} with smartindent
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
42 func Test_smartindent_braces()
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
43 new
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
44 set smartindent shiftwidth=4
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
45 call setline(1, [' if (a)', "\tif (b)", "\t return 1"])
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
46 normal 2ggO{
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
47 normal 3ggA {
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
48 normal 4ggo}
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
49 normal o}
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
50 normal 4ggO#define FOO 1
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
51 call assert_equal([
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
52 \ ' if (a)',
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
53 \ ' {',
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
54 \ "\tif (b) {",
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
55 \ '#define FOO 1',
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
56 \ "\t return 1",
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
57 \ "\t}",
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
58 \ ' }'
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
59 \ ], getline(1, '$'))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
60 set si& sw& ai&
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
61 close!
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
62 endfunc
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
63
11943
268b1036cd17 patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
64 " vim: shiftwidth=2 sts=2 expandtab