Skip to content

Commit c57eb36

Browse files
committed
Add test for textobjects selection
1 parent 1603c12 commit c57eb36

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

tests/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ declare -a TEST_ARRAY=(
2020
"./test_bash/test_autopep8.sh"
2121
"./test_bash/test_autocommands.sh"
2222
"./test_bash/test_folding.sh"
23+
"./test_bash/test_textobject.sh"
2324
)
2425
## now loop through the above array
2526
set +e

tests/test_bash/test_textobject.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#! /bin/bash
2+
3+
# Source file.
4+
set +e
5+
source ./test_helpers_bash/test_prepare_between_tests.sh
6+
vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/textobject.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
7+
R1=$?
8+
set -e
9+
10+
if [[ "$R1" -ne 0 ]]
11+
then
12+
exit 1
13+
fi
14+
15+
# vim: set fileformat=unix filetype=sh wrap tw=0 :
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
" Load sample python file.
2+
" With 'def'.
3+
execute "normal! idef func1():\<CR> a = 1\<CR>"
4+
execute "normal! idef func2():\<CR> b = 2"
5+
normal 3ggdaMggf(P
6+
7+
" Assert changes.
8+
let content=getline('^', '$')
9+
call assert_true(content == ['def func2():', ' b = 2', 'def func1():', ' a = 1'])
10+
11+
12+
" Clean file.
13+
%delete
14+
15+
" With 'class'.
16+
execute "normal! iclass Class1():\<CR> a = 1\<CR>"
17+
execute "normal! iclass Class2():\<CR> b = 2\<CR>"
18+
normal 3ggdaCggf(P
19+
20+
" Assert changes.
21+
let content=getline('^', '$')
22+
call assert_true(content == ['class Class2():', ' b = 2', '', 'class Class1():', ' a = 1'])
23+
24+
25+
if len(v:errors) > 0
26+
cquit!
27+
else
28+
quit!
29+
endif

0 commit comments

Comments
 (0)