Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b3bbad

Browse files
committed
greatly expanded tests
1 parent8d7405e commit0b3bbad

File tree

12 files changed

+699
-12
lines changed

12 files changed

+699
-12
lines changed

‎.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
branches:
33
only:
44
-develop
5+
-dev_unstable
56
before_install:
67
-export ORIGINAL_FOLDER=$PWD
78
-sudo apt install libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev python3-dev lua5.1 lua5.1-dev libperl-dev git

‎ftplugin/python/pymode.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ if g:pymode_debug
228228
" Get a system independent temporary filename. The 'marker' variable is
229229
" used to get rid of a null character getting inserted at position.
230230
" substitute() was not able to remove it.
231+
" TODO: see https://superuser.com/questions/935574/get-rid-of-null-character-in-vim-variable
231232
letg:pymode_debug_tempfile=matchstr(
232233
\execute(
233234
\g:pymode_python

‎readme.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ help packages` in vim for details.
9898
cd ~/.vim
9999
mkdir -p bundle && cd bundle
100100
git clone https://github.com/python-mode/python-mode.git
101-
cd python-mode
102-
git submodule update --init --recursive
103101

104102
Enable[pathogen](https://github.com/tpope/vim-pathogen) in your`~/.vimrc`:
105103

@@ -116,7 +114,6 @@ Enable [pathogen](https://github.com/tpope/vim-pathogen) in your `~/.vimrc`:
116114

117115
% git clone https://github.com/python-mode/python-mode.git
118116
% cd python-mode
119-
% git submodule update --init --recursive
120117
% cp -R * ~/.vim
121118

122119
Then rebuild**helptags** in vim:

‎tests/test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
set -e
55
which vim1>/dev/null2>/dev/null
66

7+
cd$(dirname$0)
8+
79
# Source common variables.
810
source ./test_helpers_bash/test_variables.sh
911

‎tests/test_bash/test_folding.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22

33
# Source file.
44
set +e
5-
RETURN_CODE=$(vim -i NONE -u$VIM_TEST_VIMRC -c"source ./test_procedures_vimscript/folding1.vim"$VIM_DISPOSABLE_PYFILE> /dev/null2>&1)
5+
source ./test_helpers_bash/test_prepare_between_tests.sh
6+
vim -i NONE -u$VIM_TEST_VIMRC -c"source ./test_procedures_vimscript/folding1.vim"$VIM_DISPOSABLE_PYFILE> /dev/null
67
R1=$?
7-
bash ./test_helpers_bash/test_prepare_between_tests.sh
8-
RETURN_CODE=$(vim -i NONE -u$VIM_TEST_VIMRC -c"source ./test_procedures_vimscript/folding2.vim"$VIM_DISPOSABLE_PYFILE> /dev/null2>&1)
8+
source ./test_helpers_bash/test_prepare_between_tests.sh
9+
vim -i NONE -u$VIM_TEST_VIMRC -c"source ./test_procedures_vimscript/folding2.vim"$VIM_DISPOSABLE_PYFILE> /dev/null
910
R2=$?
11+
source ./test_helpers_bash/test_prepare_between_tests.sh
12+
vim -i NONE -u$VIM_TEST_VIMRC -c"source ./test_procedures_vimscript/folding3.vim"$VIM_DISPOSABLE_PYFILE> /dev/null
13+
R3=$?
1014
set -e
15+
1116
if [["$R1"-ne 0 ]]
1217
then
1318
exit 1
1419
elif [["$R2"-ne 0 ]]
1520
then
1621
exit 2
22+
elif [["$R3"-ne 0 ]]
23+
then
24+
exit 3
1725
fi
1826

19-
exit 0
20-
2127
# vim: set fileformat=unix filetype=sh wrap tw=0 :
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
#! /bin/bash
22

33
# Create minimal vimrc.
4+
echo -e"syntax on\nfiletype plugin indent on\nset nocompatible">>$VIM_TEST_VIMRC
45
echo"call has('python3')">>$VIM_TEST_VIMRC
5-
echo"set noswapfile">>$VIM_TEST_VIMRC
6-
echo"set shell=bash">>$VIM_TEST_VIMRC
6+
echo"set paste">>$VIM_TEST_VIMRC
7+
echo"set shortmess=at">>$VIM_TEST_VIMRC
8+
echo"set cmdheight=10">>$VIM_TEST_VIMRC
79
echo"set ft=python">>$VIM_TEST_VIMRC
8-
echo -e"syntax on\nfiletype plugin indent on\nset nocompatible">>$VIM_TEST_VIMRC
10+
echo"set shell=bash">>$VIM_TEST_VIMRC
11+
echo"set noswapfile">>$VIM_TEST_VIMRC
12+
echo"set backupdir=">>$VIM_TEST_VIMRC
13+
echo"set undodir=">>$VIM_TEST_VIMRC
14+
echo"set viewdir=">>$VIM_TEST_VIMRC
15+
echo"set directory=">>$VIM_TEST_VIMRC
16+
echo -e"set runtimepath=">>$VIM_TEST_VIMRC
917
echo -e"set runtimepath+=$(dirname$PWD)\n">>$VIM_TEST_VIMRC
18+
# echo -e "redir! >> $VIM_OUTPUT_FILE\n" >> $VIM_TEST_VIMRC
1019
echo -e"set verbosefile=$VIM_OUTPUT_FILE\n">>$VIM_TEST_VIMRC
20+
echo -e"let g:pymode_debug = 1">>$VIM_TEST_VIMRC
21+
22+
echo"set nomore">>$VIM_TEST_VIMRC
23+
1124

1225
# vim: set fileformat=unix filetype=sh wrap tw=0 :

‎tests/test_helpers_bash/test_prepare_between_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
# Prepare tests.
44
set +e
5-
rm$VIM_DISPOSABLE_PYFILE 2&>/dev/null
5+
rm$VIM_DISPOSABLE_PYFILE
6+
export VIM_DISPOSABLE_PYFILE=`mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py`
67
set -e
78
touch$VIM_DISPOSABLE_PYFILE
89

‎tests/test_helpers_bash/test_prepare_once.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Prepare tests.
44
set +e
55
rm$VIM_OUTPUT_FILE$VIM_TEST_VIMRC$VIM_TEST_PYMODECOMMANDS$VIM_DISPOSABLE_PYFILE 2&>/dev/null
6+
rm /tmp/*pymode* 2&>/dev/null
67
set -e
78

89
# vim: set fileformat=unix filetype=sh wrap tw=0 :
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
function!InsertRandomText(low_range, high_range)" {{{
2+
" Insert random ascii visible table text at cursor position.
3+
" Return the number of characters inserted.
4+
5+
python3 << EOF
6+
import random,string,vim
7+
# Texthasto large froma larger samplein orderto avoid errors.
8+
text= random.sample(
9+
(10*string.ascii_lowercase+string.digits+''),
10+
random.randint(int(vim.eval('a:low_range')),int(vim.eval('a:high_range'))))
11+
vim.current.buffer.vars['random_text']=''.join(text)
12+
EOF
13+
letl:textwidth= &tw
14+
settw=0
15+
execute"normal! i" .b:random_text
16+
let &tw=l:textwidth
17+
18+
returnlen(b:random_text)
19+
20+
endfunction" }}}
21+
22+
function!DeleteChars(nchars)" {{{
23+
" Delete n chars at cursor position.
24+
" It is the inverse of InsertRandomText().
25+
26+
letl:textwidth= &tw
27+
settw=0
28+
execute"normal!" . (repeat('h',a:nchars-1))
29+
execute"normal!" .repeat('x',a:nchars)
30+
let &tw=l:textwidth
31+
32+
endfunction" }}}
33+
34+
function!JumpToRandomPosition()" {{{
35+
" Jump cursor to a random position in current buffer.
36+
37+
python3 << EOF
38+
import random,vim
39+
cw=vim.current.window
40+
cb=vim.current.buffer
41+
rand_line= random.randint(1,len(cb)-1)
42+
rand_line_len=len(cb[rand_line])
43+
rand_col= random.randint(0, rand_line_len)if rand_line_len >0else0
44+
cw.cursor= (rand_line, rand_col)
45+
EOF
46+
endfunction" }}}
47+
48+
function!DeleteRandomLines(low_range, high_range)" {{{
49+
" Delete random lines between low_range and high_range.
50+
" Return the number of lines deleted.
51+
52+
python3 << EOF
53+
import random,vim
54+
del_lines= random.randint(
55+
int(vim.eval('a:low_range')),int(vim.eval('a:high_range')))
56+
vim.current.buffer.vars['del_lines']= del_lines
57+
EOF
58+
59+
execute"normal!" .b:del_lines ."dd"
60+
61+
returnb:del_lines
62+
63+
endfunction"}}}
64+
65+
function!InsertTextAtRandomPositions(ntimes)" {{{
66+
" Insert text at random positions. May either insert in insert mode or in
67+
" normal mode.
68+
69+
letl:total_lines=line('$')
70+
foriinrange(a:ntimes)
71+
72+
python3 << EOF
73+
import random,vim
74+
del_method= random.randint(0,1)
75+
vim.current.buffer.vars['del_method']= del_method
76+
EOF
77+
78+
callJumpToRandomPosition()
79+
" b:del_method is set to either change the buffer via insert mode or
80+
" via normal mode.
81+
ifb:del_method
82+
" This uses insert mode.
83+
letl:inserted_chars=InsertRandomText(3,100)
84+
callDeleteChars(l:inserted_chars)
85+
else
86+
" This uses normal mode.
87+
letl:current_line=getpos('.')[1]
88+
letl:deleted_lines=DeleteRandomLines(1,5)
89+
ifl:current_line+l:deleted_lines<=l:total_lines
90+
execute"normal! P"
91+
else
92+
execute"normal! p"
93+
endif
94+
endif
95+
96+
endfor
97+
98+
endfunction" }}}

‎tests/test_helpers_vimscript/moving_around.vim

Whitespace-only changes.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
" Test that doing (reversible) changes in insert mode or normal mode to a
2+
" buffer do not alter their folding.
3+
4+
" Load sample python file.
5+
read ./test_python_sample_code/algorithms.py
6+
7+
" Delete the first line (which is not present in the original file) and save
8+
" loaded file.
9+
execute"normal! gg"
10+
execute"normal! dd"
11+
noautocmdwrite!
12+
13+
" Load auxiliary code.
14+
source ./test_helpers_vimscript/inserting_text.vim
15+
source ./test_helpers_vimscript/md5sum.vim
16+
17+
" Get original md5sum for script.
18+
noautocmdwrite!
19+
callMd5()
20+
lets:md5orig=b:calculated_md5
21+
unletb:calculated_md5
22+
23+
" Define a convenient function to map line numbers to their folding values.
24+
functionPymodefoldingfuncref(key, val)
25+
letl:retval=pymode#folding#expr(a:val)
26+
returnl:retval
27+
endfunction!
28+
29+
30+
" Force recomputation of all foldings.
31+
" TODO: inspect why causes trouble.
32+
" set fdm=expr
33+
" set fdm=marker
34+
" set fdm=expr
35+
letb:old_fold_vals=map(range(1,line('$')),function('Pymodefoldingfuncref'))
36+
37+
" Change folding in numerous ways.
38+
callInsertTextAtRandomPositions(10)
39+
40+
" Force recomputation of all foldings.
41+
" set fdm=expr
42+
" set fdm=marker
43+
" set fdm=expr
44+
letb:new_fold_vals=map(range(1,line('$')),function('Pymodefoldingfuncref'))
45+
46+
" Get original md5sum for script.
47+
noautocmdwrite!
48+
callMd5()
49+
lets:md5mod=b:calculated_md5
50+
unletb:calculated_md5
51+
52+
" echom s:md5orig == s:md5mod
53+
" echom b:new_fold_vals == b:old_fold_vals
54+
55+
" set fdm=expr
56+
" set fdm=marker
57+
" set fdm=expr
58+
59+
" Assert changes.
60+
callassert_equal(s:md5orig,s:md5mod)
61+
callassert_equal(b:new_fold_vals,b:old_fold_vals)
62+
iflen(v:errors) >0
63+
cquit!
64+
else
65+
quit!
66+
endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp