]> 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:

Add test for folding and :Toc
[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 cd foo
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(25), 2, '### chap 1.1.1'
78   AssertEqual foldlevel(27), 3, '- dragons'
79   AssertEqual foldlevel(30), 1, '# chap 2'
80   AssertEqual foldlevel(32), 1, 'another'
81   AssertEqual foldlevel(34), 1, '# chap 2.1'
82   AssertEqual foldlevel(37), 2, '- japan'
83   AssertEqual foldlevel(41), 1, '# chap 3'
84   AssertEqual foldlevel(45), 1, 'chap 4\n======'
85   AssertEqual foldlevel(48), 1, 'setext are evil'
86   AssertEqual foldlevel(50), 2, 'chap 4.1\n------'
87 " BUG: for lines 30, 41, 45, the foldlevel should be 0.
88 " The folding behavior itself is correct, but the level number isn't.
89
90 Execute (fold text result):
91   AssertEqual foldtextresult(2), '+-- 28 lines: hello'
92   AssertEqual foldtextresult(31), '+-- 10 lines: another'
93   AssertEqual foldtextresult(42), '+--  3 lines: nothing here'
94   AssertEqual foldtextresult(45), '+-- 14 lines: chap 4'
95 " BUG: for line 45, vim shows and calling foldtextresult even echoes 15 lines.
96
97 Execute (check TOC):
98   :Toc
99   let res = getloclist(0)
100   let elem = res[0]
101   AssertEqual elem.lnum, 1
102   AssertEqual elem.text, '# chap 1'
103   let elem = res[1]
104   AssertEqual elem.lnum, 15
105   AssertEqual elem.text, '## chap 1.1'
106   let elem = res[2]
107   AssertEqual elem.lnum, 25
108   AssertEqual elem.text, '### chap 1.1.1'
109   let elem = res[3]
110   AssertEqual elem.lnum, 30
111   AssertEqual elem.text, '# chap 2'
112   let elem = res[4]
113   AssertEqual elem.lnum, 34
114   AssertEqual elem.text, '## chap 2.1'
115   let elem = res[5]
116   AssertEqual elem.lnum, 41
117   AssertEqual elem.text, '# chap 3'
118   let elem = res[6]
119   AssertEqual elem.lnum, 45
120   AssertEqual elem.text, 'chap 4'
121   let elem = res[7]
122   AssertEqual elem.lnum, 50
123   AssertEqual elem.text, 'chap 4.1'
124