blob: cc991497767c561d7d37b22f67ab91c766746755 [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
Bram Moolenaar9d2c8c12007-09-25 16:00:00 +000058:delfun Flvl
Bram Moolenaar071d4272004-06-13 20:20:40 +000059:qa!
60ENDTEST
61
621 aa
632 bb
643 cc
654 dd {{{
665 ee {{{ }}}
676 ff }}}
687 gg
698 hh
709 ii
71a jj
72b kk
73last