blob: 58537f33dbe30646201ae67bee34ff1e03f125fc [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001Tests for folding. vim: set ft=vim :
2
3STARTTEST
4:so small.vim
5:" We also need the +syntax feature here.
6:if !has("syntax")
7 e! test.ok
8 w! test.out
9 qa!
10:endif
11:" basic test if a fold can be created, opened, moving to the end and closed
12/^1
13zf2j:call append("$", "manual " . getline(foldclosed(".")))
14zo:call append("$", foldclosed("."))
15]z:call append("$", getline("."))
16zc:call append("$", getline(foldclosed(".")))
17:" test folding with markers.
18:set fdm=marker fdl=1 fdc=3
19/^5
20:call append("$", "marker " . foldlevel("."))
21[z:call append("$", foldlevel("."))
22jo{{ r{jj:call append("$", foldlevel("."))
23kYpj:call append("$", foldlevel("."))
24:" test folding with indent
25:set fdm=indent sw=2
26/^2 b
27i jI :call append("$", "indent " . foldlevel("."))
28k:call append("$", foldlevel("."))
29:" test syntax folding
30:set fdm=syntax fdl=0
31:syn region Hup start="dd" end="hh" fold
32Gzk:call append("$", "folding " . getline("."))
33k:call append("$", getline("."))
34:" test expression folding
35:fun Flvl()
36 let l = getline(v:lnum)
37 if l =~ "bb$"
38 return 2
39 elseif l =~ "gg$"
40 return "s1"
41 elseif l =~ "ii$"
42 return ">2"
43 elseif l =~ "kk$"
44 return "0"
45 endif
46 return "="
47endfun
48:set fdm=expr fde=Flvl()
49/bb$
50:call append("$", "expr " . foldlevel("."))
51/hh$
52:call append("$", foldlevel("."))
53/ii$
54:call append("$", foldlevel("."))
55/kk$
56:call append("$", foldlevel("."))
57:/^last/+1,$w! test.out
58:qa!
59ENDTEST
60
611 aa
622 bb
633 cc
644 dd {{{
655 ee {{{ }}}
666 ff }}}
677 gg
688 hh
699 ii
70a jj
71b kk
72last