]> git.madduck.net Git - etc/vim.git/blob - test/python-folding.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:

91fc9e270eabf6d12d88ebdc97e1440eaf0330f9
[etc/vim.git] / test / python-folding.vader
1 Before:
2   let g:vim_markdown_folding_style_pythonic = 1
3   source ../after/ftplugin/markdown.vim
4
5 After:
6   setlocal foldexpr=0
7   setlocal foldmethod=manual
8
9 Given markdown;
10 # Title
11
12 ## Chapter 1
13
14 ```
15 This is code block
16 # This is just a comment
17 ```
18
19 ## Chapter 2
20
21 foobar
22
23 Execute (fold level # in code block):
24   AssertEqual foldlevel(1), 0, '# Title'
25   AssertEqual foldlevel(3), 1, '## Chapter 1'
26   AssertEqual foldlevel(7), 1, '# This is just a comment'
27   AssertEqual foldlevel(8), 1, '```'
28   AssertEqual foldlevel(10), 1, '## Chapter 2'
29   AssertEqual foldlevel(12), 1, 'foobar'
30
31 Execute (fold text of chapters):
32   let b:width = winwidth(0)
33   let b:hyphen = repeat('-', b:width - 18 > 2 ? b:width - 18 : b:width - 9 > 0 ? 3 : 2)
34   AssertEqual foldtextresult(3), strpart('## Chapter 1', 0, b:width - 9) . ' ' . b:hyphen . ' 6'
35   AssertEqual foldtextresult(10), strpart('## Chapter 2', 0, b:width - 9) . ' ' . b:hyphen . ' 2'
36
37 Given markdown;
38 Fold text 1
39 ===========
40 Fold text 2
41 -----------
42
43 Execute (fold level ==, --):
44   AssertEqual foldlevel(2), 0, '=='
45   AssertEqual foldlevel(4), 1, '--'
46
47 Execute (fold text of ==, --):
48   let b:width = winwidth(0)
49   let b:hyphen = repeat('-', b:width - 17 > 2 ? b:width - 17 : b:width - 9 > 0 ? 3 : 2)
50   AssertEqual foldtextresult(3), strpart('Fold text 2', 0, b:width - 9) . ' ' . b:hyphen . ' 1'
51
52 Given markdown;
53 Headline
54
55 foobar
56
57 # Title
58
59 Execute (fold any preamble):
60   AssertEqual foldlevel(1), 1, 'Headline'
61   AssertEqual foldlevel(3), 1, 'foobar'
62   AssertEqual foldlevel(5), 0, '# Title'
63
64 Given markdown;
65 ---
66 layout: article
67 title: A test of the heading folding when there is YAML frontmatter
68 tags: markdown yaml vim-markdown
69 ---
70 body
71
72 heading
73 -------
74
75 Execute (fold level of yaml front matter):
76   let g:vim_markdown_frontmatter = 1
77   source ../after/ftplugin/markdown.vim
78   AssertEqual foldlevel(1), 1, '---'
79   AssertEqual foldlevel(2), 1, 'layout: article'
80   AssertEqual foldlevel(4), 1, 'tags: markdown yaml vim-markdown'
81   AssertEqual foldlevel(5), 1, '---'
82   AssertEqual foldlevel(6), 1, 'body'
83   AssertEqual foldlevel(8), 1, 'heading'
84   AssertEqual foldlevel(9), 1, '-------'
85   unlet g:vim_markdown_frontmatter