]> git.madduck.net Git - etc/vim.git/blob - test/folding-toc.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Escape `~` in regexp with folding
[etc/vim.git] / test / folding-toc.vader
1 " Tests atx and setext folding, and :Toc.
2
3 Before:
4   source ../after/ftplugin/markdown.vim
5
6 After:
7   setlocal foldexpr=0
8   setlocal foldmethod=manual
9
10 Given markdown;
11 # chap 1
12
13 hello
14 world
15
16 ```bash
17 # some bash scripting
18 pwd
19
20 # this is another comment
21 # other
22 echo "foo"
23 ```
24
25 ## chap 1.1
26
27 - dog
28 - cat
29
30 ~~~~bash
31 mkdir foo
32 # comment in ~
33 ~~~~
34
35 ### chap 1.1.1
36
37 - dragons
38 - fenixs
39
40 # chap 2
41
42 another
43
44 ## chap 2.1
45
46 - uk
47 - japan
48 - china
49
50
51 # chap 3
52
53 nothing here
54
55 chap 4
56 ======
57
58 setext are evil
59
60 chap 4.1
61 --------
62
63 evil indeed
64
65 ````bash
66 # get system info
67 uname -a
68 ````
69
70 Execute (fold level):
71   AssertEqual foldlevel(1), 0, '# chap 1'
72   AssertEqual foldlevel(3), 1, 'hello'
73   AssertEqual foldlevel(6), 1, '```bash'
74   AssertEqual foldlevel(7), 1, '# some bash scripting'
75   AssertEqual foldlevel(15), 1, '## chap 1.1'
76   AssertEqual foldlevel(21), 2, 'mkdir foo'
77   AssertEqual foldlevel(22), 2, 'comment in ~'
78   AssertEqual foldlevel(25), 2, '### chap 1.1.1'
79   AssertEqual foldlevel(27), 3, '- dragons'
80   AssertEqual foldlevel(30), 1, '# chap 2'
81   AssertEqual foldlevel(32), 1, 'another'
82   AssertEqual foldlevel(34), 1, '# chap 2.1'
83   AssertEqual foldlevel(37), 2, '- japan'
84   AssertEqual foldlevel(41), 1, '# chap 3'
85   AssertEqual foldlevel(45), 1, 'chap 4\n======'
86   AssertEqual foldlevel(48), 1, 'setext are evil'
87   AssertEqual foldlevel(50), 2, 'chap 4.1\n------'
88 " BUG: for lines 30, 41, 45, the foldlevel should be 0.
89 " The folding behavior itself is correct, but the level number isn't.
90
91 Execute (fold text result):
92   AssertEqual foldtextresult(2), '+-- 28 lines: hello'
93   AssertEqual foldtextresult(31), '+-- 10 lines: another'
94   AssertEqual foldtextresult(42), '+--  3 lines: nothing here'
95   AssertEqual foldtextresult(45), '+-- 14 lines: chap 4'
96 " BUG: for line 45, vim shows and calling foldtextresult even echoes 15 lines.
97
98 Execute (check TOC):
99   :Toc
100   :lclose
101   let res = getloclist(0)
102   let elem = res[0]
103   AssertEqual elem.lnum, 1
104   AssertEqual elem.text, '# chap 1'
105   let elem = res[1]
106   AssertEqual elem.lnum, 15
107   AssertEqual elem.text, '## chap 1.1'
108   let elem = res[2]
109   AssertEqual elem.lnum, 25
110   AssertEqual elem.text, '### chap 1.1.1'
111   let elem = res[3]
112   AssertEqual elem.lnum, 30
113   AssertEqual elem.text, '# chap 2'
114   let elem = res[4]
115   AssertEqual elem.lnum, 34
116   AssertEqual elem.text, '## chap 2.1'
117   let elem = res[5]
118   AssertEqual elem.lnum, 41
119   AssertEqual elem.text, '# chap 3'
120   let elem = res[6]
121   AssertEqual elem.lnum, 45
122   AssertEqual elem.text, 'chap 4'
123   let elem = res[7]
124   AssertEqual elem.lnum, 50
125   AssertEqual elem.text, 'chap 4.1'
126