forked from python-mode/python-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfolding3.vim
More file actions
66 lines (53 loc) · 1.58 KB
/
folding3.vim
File metadata and controls
66 lines (53 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
" Test that doing (reversible) changes in insert mode or normal mode to a
" buffer do not alter their folding.
" Load sample python file.
read ./test_python_sample_code/algorithms.py
" Delete the first line (which is not present in the original file) and save
" loaded file.
execute "normal! gg"
execute "normal! dd"
noautocmd write!
" Load auxiliary code.
source ./test_helpers_vimscript/inserting_text.vim
source ./test_helpers_vimscript/md5sum.vim
" Get original md5sum for script.
noautocmd write!
call Md5()
let s:md5orig = b:calculated_md5
unlet b:calculated_md5
" Define a convenient function to map line numbers to their folding values.
function Pymodefoldingfuncref(key, val)
let l:retval = pymode#folding#expr(a:val)
return l:retval
endfunction!
" Force recomputation of all foldings.
" TODO: inspect why causes trouble.
" set fdm=expr
" set fdm=marker
" set fdm=expr
let b:old_fold_vals = map(range(1, line('$')), function('Pymodefoldingfuncref'))
" Change folding in numerous ways.
call InsertTextAtRandomPositions(10)
" Force recomputation of all foldings.
" set fdm=expr
" set fdm=marker
" set fdm=expr
let b:new_fold_vals = map(range(1, line('$')), function('Pymodefoldingfuncref'))
" Get original md5sum for script.
noautocmd write!
call Md5()
let s:md5mod = b:calculated_md5
unlet b:calculated_md5
" echom s:md5orig == s:md5mod
" echom b:new_fold_vals == b:old_fold_vals
" set fdm=expr
" set fdm=marker
" set fdm=expr
" Assert changes.
call assert_equal(s:md5orig, s:md5mod)
call assert_equal(b:new_fold_vals, b:old_fold_vals)
if len(v:errors) > 0
cquit!
else
quit!
endif