Skip to content

Commit 0116109

Browse files
committed
Fix test suite and add test runner
1 parent f0ffbaa commit 0116109

5 files changed

Lines changed: 85 additions & 29 deletions

File tree

syntax/solidity.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ syn match solModifierName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgrou
115115
syn region solModifierArgs contained matchgroup=solFuncParens start='(' end=')' contains=solFuncArgCommas nextgroup=solModifierName,solFuncReturns,solFuncBody skipwhite
116116
syn region solFuncReturns contained matchgroup=solFuncParens nextgroup=solFuncBody start='(' end=')' contains=solFuncArgCommas,solBuiltinType skipwhite
117117
syn match solFuncArgCommas contained ','
118-
syn region solFuncBody start="{" end="}" fold transparent
118+
syn region solFuncBody contained start="{" end="}" fold transparent
119119

120120
hi def link solFunction Type
121121
hi def link solFuncName Function
@@ -132,12 +132,12 @@ hi def link yulVarDeclaration Keyword
132132
hi def link yulAssemblyOp Keyword
133133

134134
" Contract
135-
syn match solContract /\<\%(contract\|library\|interface\)\>/ nextgroup=solContractName skipwhite
136-
syn match solContractName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgroup=solContractParent,solContractBody skipwhite
137-
syn region solContractParent contained start='is' end='{' contains=solContractName,solContractNoise,solContractCommas nextgroup=solContractBody skipwhite skipempty
135+
syn match solContract /\<\%(contract\|library\|interface\)\>/ nextgroup=solContractName skipwhite skipnl skipempty
136+
syn match solContractName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgroup=solContractBlock,solContractParent skipwhite skipnl skipempty
137+
syn region solContractParent contained start='is' end='{' contains=solContractName,solContractNoise,solContractCommas nextgroup=solContractBlock skipwhite skipempty
138138
syn match solContractNoise contained 'is' containedin=solContractParent
139139
syn match solContractCommas contained ','
140-
syn region solContractBody contained start='{' end='}' fold transparent
140+
syn region solContractBlock contained matchgroup=Delimiter start='{' end='}' fold transparent
141141

142142
hi def link solContract Type
143143
hi def link solContractName Function

test/run_tests.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# Run vader tests and report results
3+
4+
cd "$(dirname "$0")/.."
5+
6+
# Run all tests
7+
echo "Running vim-solidity test suite..."
8+
echo ""
9+
10+
# Track overall status
11+
FAILED=0
12+
13+
# Run syntax tests
14+
echo "=== Syntax Tests ==="
15+
if vim -Nu test/vimrc -c 'Vader! test/vader/syntax.vader' 2>&1; then
16+
echo "✓ Syntax tests passed"
17+
else
18+
echo "✗ Syntax tests failed"
19+
FAILED=1
20+
fi
21+
echo ""
22+
23+
# Run indent tests
24+
echo "=== Indentation Tests ==="
25+
if vim -Nu test/vimrc -c 'Vader! test/vader/indent.vader' 2>&1; then
26+
echo "✓ Indentation tests passed"
27+
else
28+
echo "✗ Indentation tests failed"
29+
FAILED=1
30+
fi
31+
echo ""
32+
33+
# Run folding tests
34+
echo "=== Folding Tests ==="
35+
if vim -Nu test/vimrc -c 'Vader! test/vader/folding.vader' 2>&1; then
36+
echo "✓ Folding tests passed"
37+
else
38+
echo "✗ Folding tests failed"
39+
FAILED=1
40+
fi
41+
echo ""
42+
43+
# Final summary
44+
if [ $FAILED -eq 0 ]; then
45+
echo "✓ All tests passed"
46+
exit 0
47+
else
48+
echo "✗ Some tests failed"
49+
exit 1
50+
fi

test/vader/folding.vader

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
11
" Code folding tests for vim-solidity
22

33
Before:
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

1814
Given 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

2523
Execute (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):
6670
Execute (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

8387
Execute (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

test/vader/indent.vader

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
" Indentation tests for vim-solidity
22

33
Before:
4-
set rtp+=.
4+
set rtp^=.
55
filetype plugin indent on
66
syntax enable
77

8-
After:
9-
%bwipeout!
10-
118
# ==============================================================================
129
# Basic Indentation
1310
# ==============================================================================

test/vimrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ set rtp+=test/vader.vim
77
" Add vim-solidity to runtimepath (PREPEND to override system files)
88
set rtp^=.
99

10+
" Set indent defaults (4 spaces, expand tabs)
11+
set shiftwidth=4
12+
set tabstop=4
13+
set expandtab
14+
1015
" Load filetype detection, plugins, and indent
1116
filetype plugin indent on
1217
syntax enable

0 commit comments

Comments
 (0)