blob: 1b52e92a0215161c6de694afdbf357700e0d6e22 [file] [log] [blame]
Bram Moolenaarded27822017-01-02 14:27:34 +01001" Test for folding
2
3function! Test_address_fold()
4 new
5 call setline(1, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/',
6 \ 'after fold 1', 'after fold 2', 'after fold 3'])
7 setl fen fdm=marker
8 " The next ccommands should all copy the same part of the buffer,
9 " regardless of the adressing type, since the part to be copied
10 " is folded away
11 :1y
12 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
13 :.y
14 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
15 :.+y
16 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
17 :.,.y
18 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
19 :sil .1,.y
20 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
21 " use silent to make E493 go away
22 :sil .+,.y
23 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
24 :,y
25 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
26 :,+y
27 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/','after fold 1'], getreg(0,1,1))
28 " using .+3 as second address should copy the whole folded line + the next 3
29 " lines
30 :.,+3y
31 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/',
32 \ 'after fold 1', 'after fold 2', 'after fold 3'], getreg(0,1,1))
33 :sil .,-2y
34 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
35
36 " now test again with folding disabled
37 set nofoldenable
38 :1y
39 call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1))
40 :.y
41 call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1))
42 :.+y
43 call assert_equal(['1'], getreg(0,1,1))
44 :.,.y
45 call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1))
46 " use silent to make E493 go away
47 :sil .1,.y
48 call assert_equal(['int FuncName() {/*{{{*/', '1'], getreg(0,1,1))
49 " use silent to make E493 go away
50 :sil .+,.y
51 call assert_equal(['int FuncName() {/*{{{*/', '1'], getreg(0,1,1))
52 :,y
53 call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1))
54 :,+y
55 call assert_equal(['int FuncName() {/*{{{*/', '1'], getreg(0,1,1))
56 " using .+3 as second address should copy the whole folded line + the next 3
57 " lines
58 :.,+3y
59 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3'], getreg(0,1,1))
60 :7
61 :sil .,-2y
62 call assert_equal(['4', '5', '}/*}}}*/'], getreg(0,1,1))
63
64 quit!
65endfunction