Skip to content

Commit 6063a32

Browse files
committed
Add extended tests for most supported languages
1 parent f511285 commit 6063a32

4 files changed

Lines changed: 81 additions & 54 deletions

File tree

ftplugin/ruby.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,14 @@ function! s:DebugStringFun()
33
return l:debug_str
44
endfunc
55

6+
function! s:DebugStringFunExpr(expr)
7+
let l:debug_str = 'puts "'
8+
\ . a:expr . ': '
9+
\ . '#{' . a:expr . '}'
10+
\ . '"'
11+
return l:debug_str
12+
endfunc
13+
14+
615
command! -buffer -nargs=0 AddDebugString put=s:DebugStringFun()
16+
command! -buffer -nargs=1 AddDebugStringExpr put=s:DebugStringFunExpr(<args>)

test/basic.vader

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,58 @@
1-
# Test case
2-
3-
# mapleader is set in the local vimrc
4-
#
5-
# Line +Text: 3
6-
# Line -Text: 8
7-
81
Include: text_setup.vader
92
Include: env_setup.vader
103

114
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125

136
""
14-
" Standard usecase, buffer with some text
15-
Execute (C +std_debug +Text):
16-
:set filetype=c
17-
3
7+
" tests include the following
8+
" - Add Debugging string when I am in a line that has text + make sure the counter advances
9+
" - Add Debugging string when I am on an empty line
10+
" - Add a variable debugging string when I am in a line that has text
11+
After ():
12+
execute l1_text - 1
1813
AssertEqual getline('.'), 'And each in your season', "Current line contents don't match"
19-
Log join(getline(1,'$'), "\n")
2014
:normal ,ds
21-
Log join(getline(1,'$'), "\n")
2215
:normal .
23-
Log join(getline(1,'$'), "\n")
24-
25-
Then ():
26-
4
27-
AssertEqual getline('.'), 'printf("[[Vader-workbench]:4] DEBUGGING STRING ==> %d\n", 0);'
28-
5
29-
AssertEqual getline('.'), 'printf("[[Vader-workbench]:5] DEBUGGING STRING ==> %d\n", 1);'
30-
31-
================================================================================
32-
33-
""
34-
" What happens if there isn't any text in the current line? - cursor should stay
35-
" at the same line
36-
Execute (C +std_debug -Text):
37-
:set filetype=c
38-
8
16+
execute l1_notext
3917
AssertEqual getline('.'), '', "Current line is not empty"
4018
:normal ,ds
41-
42-
Then ():
43-
8
44-
AssertEqual getline('.'), 'printf("[[Vader-workbench]:8] DEBUGGING STRING ==> %d\n", 0);'
19+
execute l1_text_var - 1
20+
execute ":normal ,dSa**2 + b**2\<CR>"
21+
22+
execute l1_text
23+
AssertEqual getline('.'), FormatStrForExpectedLine(GetFileForLang(&filetype, 1), l1_text, 0)
24+
execute l2_text
25+
AssertEqual getline('.'), FormatStrForExpectedLine(GetFileForLang(&filetype, 1), l2_text, 1)
26+
execute l1_notext
27+
AssertEqual getline('.'), FormatStrForExpectedLine(GetFileForLang(&filetype, 1), l1_notext, 2)
28+
execute l1_text_var
29+
AssertEqual getline('.'), FormatStrForExpectedLine(GetFileForLang(&filetype, 2), l1_text_var, -1)
4530

4631
================================================================================
4732

48-
Execute (C +var_debug -Text TODO):
49-
:set filetype=c
50-
Then ():
51-
================================================================================
52-
Execute (C +var_debug +Text TODO):
33+
""
34+
" Test cases - one for each supported language
35+
Execute (C):
5336
:set filetype=c
54-
Then ():
55-
================================================================================
37+
Execute (C++):
38+
:set filetype=cpp
39+
Execute (CMake):
40+
:set filetype=cmake
41+
Execute (Haskell):
42+
:set filetype=haskell
43+
Execute (Java):
44+
:set filetype=java
45+
Execute (Python):
46+
:set filetype=python
47+
" Execute (Ruby):
48+
" :set filetype=rb
49+
Execute (R):
50+
:set filetype=r
51+
Execute (Shell):
52+
:set filetype=sh
53+
Execute (Vim):
54+
:set filetype=vim
5655

57-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56+
================================================================================
5857

59-
# cmake
60-
# cpp
61-
# fortran
62-
# haskell
63-
# javascript
64-
# java
65-
# php
66-
# python
67-
# ruby
68-
# r
69-
# sh
70-
# vim
7158

72-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

test/env_setup.vader

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
Before (setup):
22
ResetDebugCounter
3+
4+
let l1_text = 4
5+
let l2_text = 5
6+
let l1_notext = 10
7+
let l1_text_var = 11
8+
9+

test/vimrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,27 @@ syntax enable
1414
set nomore
1515
set noswapfile
1616
set viminfo=
17+
18+
19+
fun! GetFileLine(filename,line)
20+
return readfile(a:filename,'',a:line)[a:line-1]
21+
endfun
22+
23+
24+
fun! GetFileForLang(lang_name,line)
25+
let l:path = fnamemodify(resolve(expand('%:p')), ':h')
26+
let l:filename = l:path . '/test/ft/' . 'a.' . a:lang_name
27+
return readfile(l:filename,'',a:line)[a:line-1]
28+
endfun
29+
30+
""
31+
" Format the given str based on the expected line and the expected counter
32+
" given. Function searches for the $N$ identifiers in the string and replaces
33+
" them with the line and counter respectively.
34+
"
35+
" Returns the modified string.
36+
"
37+
fun! FormatStrForExpectedLine(str, line, cnt)
38+
let l:strTmp = substitute(a:str, '\$1\$', a:line, "")
39+
return substitute(l:strTmp, '\$2\$', a:cnt, "")
40+
endfun

0 commit comments

Comments
 (0)