11" Code folding tests for vim-solidity
22
33Before:
4- set rtp+ =.
4+ set rtp^ =.
55 filetype plugin indent on
66 syntax enable
77 set foldmethod=syntax
88 set foldlevel=0
99
10- After:
11- %bwipeout!
12- set foldmethod=manual
13-
1410# ==============================================================================
1511# Function Folding
1612# ==============================================================================
1713
1814Given solidity (function with body):
19- function test() public {
20- uint256 x = 1;
21- uint256 y = 2;
22- return x + y;
15+ contract Test {
16+ function test() public {
17+ uint256 x = 1;
18+ uint256 y = 2;
19+ return x + y;
20+ }
2321 }
2422
2523Execute (function body should be foldable):
2624 normal! gg
27- " Check that fold exists
28- let l:foldlevel = foldlevel(1)
29- AssertNotEqual 0, l:foldlevel
25+ " Find the function keyword
26+ normal! /function
27+ " Find the opening brace line
28+ normal! /{
29+ let g:func_line = line('.')
30+ " Function body should have a fold
31+ let g:fold_level = foldlevel(g:func_line + 1)
32+ " If function folding is working, there should be a fold level
33+ AssertNotEqual 0, g:fold_level
3034
3135# ==============================================================================
3236# Contract Folding (Issue #11)
@@ -45,11 +49,11 @@ Execute (contract body should be foldable):
4549 normal! gg
4650 " Find the opening brace line
4751 normal! /{
48- let l :contract_line = line('.')
52+ let g :contract_line = line('.')
4953 " Contract body should have a fold
50- let l:foldlevel = foldlevel(l :contract_line + 1)
54+ let g:fold_level = foldlevel(g :contract_line + 1)
5155 " If contract folding is working, there should be a fold level
52- AssertNotEqual 0, l:foldlevel
56+ AssertNotEqual 0, g:fold_level
5357
5458# ==============================================================================
5559# Assembly Folding
@@ -66,9 +70,9 @@ Given solidity (assembly block):
6670Execute (assembly block should be foldable):
6771 normal! /assembly
6872 normal! /{
69- let l :asm_line = line('.')
70- let l:foldlevel = foldlevel(l :asm_line + 1)
71- AssertNotEqual 0, l:foldlevel
73+ let g :asm_line = line('.')
74+ let g:fold_level = foldlevel(g :asm_line + 1)
75+ AssertNotEqual 0, g:fold_level
7276
7377# ==============================================================================
7478# Multi-line Comment Folding
@@ -82,6 +86,6 @@ Given solidity (multi-line comment):
8286
8387Execute (multi-line comment should be foldable):
8488 normal! gg
85- let l:foldlevel = foldlevel(1)
89+ let g:fold_level = foldlevel(1)
8690 " Comments should have fold support
87- AssertNotEqual 0, l:foldlevel
91+ AssertNotEqual 0, g:fold_level
0 commit comments