comparison src/testdir/test_cindent.vim @ 16720:9c90cf08cfa8 v8.1.1362

patch 8.1.1362: code and data in tests can be hard to read commit https://github.com/vim/vim/commit/c79745a82faeb5a6058e915ca49a4c69fa60ea01 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 20 22:12:34 2019 +0200 patch 8.1.1362: code and data in tests can be hard to read Problem: Code and data in tests can be hard to read. Solution: Use the new heredoc style. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4400)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 May 2019 22:15:06 +0200
parents 81be817c9d9a
children d615cc95089c
comparison
equal deleted inserted replaced
16719:27f2a2799604 16720:9c90cf08cfa8
16 endfunc 16 endfunc
17 17
18 func Test_cino_extern_c() 18 func Test_cino_extern_c()
19 " Test for cino-E 19 " Test for cino-E
20 20
21 let without_ind = [ 21 let without_ind =<< trim [CODE]
22 \ '#ifdef __cplusplus', 22 #ifdef __cplusplus
23 \ 'extern "C" {', 23 extern "C" {
24 \ '#endif', 24 #endif
25 \ 'int func_a(void);', 25 int func_a(void);
26 \ '#ifdef __cplusplus', 26 #ifdef __cplusplus
27 \ '}', 27 }
28 \ '#endif' 28 #endif
29 \ ] 29 [CODE]
30 30
31 let with_ind = [ 31 let with_ind =<< trim [CODE]
32 \ '#ifdef __cplusplus', 32 #ifdef __cplusplus
33 \ 'extern "C" {', 33 extern "C" {
34 \ '#endif', 34 #endif
35 \ "\tint func_a(void);", 35 int func_a(void);
36 \ '#ifdef __cplusplus', 36 #ifdef __cplusplus
37 \ '}', 37 }
38 \ '#endif' 38 #endif
39 \ ] 39 [CODE]
40 new 40 new
41 setlocal cindent cinoptions=E0 41 setlocal cindent cinoptions=E0
42 call setline(1, without_ind) 42 call setline(1, without_ind)
43 call feedkeys("gg=G", 'tx') 43 call feedkeys("gg=G", 'tx')
44 call assert_equal(with_ind, getline(1, '$')) 44 call assert_equal(with_ind, getline(1, '$'))
87 new 87 new
88 func! MyIndentFunction() 88 func! MyIndentFunction()
89 return v:lnum == 1 ? shiftwidth() : 0 89 return v:lnum == 1 ? shiftwidth() : 0
90 endfunc 90 endfunc
91 setl expandtab sw=8 indentkeys+=; indentexpr=MyIndentFunction() 91 setl expandtab sw=8 indentkeys+=; indentexpr=MyIndentFunction()
92 call setline(1, ['var_a = something()', 'b = something()']) 92 let testinput =<< trim [CODE]
93 var_a = something()
94 b = something()
95 [CODE]
96 call setline(1, testinput)
93 call cursor(1, 1) 97 call cursor(1, 1)
94 call feedkeys("^\<c-v>j$A;\<esc>", 'tnix') 98 call feedkeys("^\<c-v>j$A;\<esc>", 'tnix')
95 call assert_equal([' var_a = something();', 'b = something();'], getline(1, '$')) 99 let expected =<< trim [CODE]
100 var_a = something();
101 b = something();
102 [CODE]
103 call assert_equal(expected, getline(1, '$'))
96 104
97 %d 105 %d
98 call setline(1, [' var_a = something()', ' b = something()']) 106 let testinput =<< trim [CODE]
107 var_a = something()
108 b = something()
109 [CODE]
110 call setline(1, testinput)
99 call cursor(1, 1) 111 call cursor(1, 1)
100 call feedkeys("^\<c-v>j$A;\<esc>", 'tnix') 112 call feedkeys("^\<c-v>j$A;\<esc>", 'tnix')
101 call assert_equal([' var_a = something();', ' b = something()'], getline(1, '$')) 113 let expected =<< trim [CODE]
114 var_a = something();
115 b = something()
116 [CODE]
117 call assert_equal(expected, getline(1, '$'))
102 bw! 118 bw!
103 endfunc 119 endfunc
104 120
105 func Test_cindent_func() 121 func Test_cindent_func()
106 new 122 new