Skip to content

Commit 026270c

Browse files
committed
patch 8.2.0307: Python 3 vim.eval not well tested
Problem: Python 3 vim.eval not well tested. Solution: Add a test. (Dominique Pelle, closes #5680)
1 parent 83f37b9 commit 026270c

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/testdir/test_python3.vim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,31 @@ func Test_unicode()
188188
set encoding=utf8
189189
endfunc
190190

191+
" Test vim.eval() with various types.
192+
func Test_python3_vim_val()
193+
call assert_equal("\n8", execute('py3 print(vim.eval("3+5"))'))
194+
if has('float')
195+
call assert_equal("\n3.140000", execute('py3 print(vim.eval("1.01+2.13"))'))
196+
call assert_equal("\n0.000000", execute('py3 print(vim.eval("0.0/(1.0/0.0)"))'))
197+
call assert_equal("\n0.000000", execute('py3 print(vim.eval("0.0/(1.0/0.0)"))'))
198+
call assert_equal("\n-0.000000", execute('py3 print(vim.eval("0.0/(-1.0/0.0)"))'))
199+
" Commented out: output of infinity and nan depend on platforms.
200+
" call assert_equal("\ninf", execute('py3 print(vim.eval("1.0/0.0"))'))
201+
" call assert_equal("\n-inf", execute('py3 print(vim.eval("-1.0/0.0"))'))
202+
" call assert_equal("\n-nan", execute('py3 print(vim.eval("0.0/0.0"))'))
203+
endif
204+
call assert_equal("\nabc", execute('py3 print(vim.eval("\"abc\""))'))
205+
call assert_equal("\n['1', '2']", execute('py3 print(vim.eval("[1, 2]"))'))
206+
call assert_equal("\n{'1': '2'}", execute('py3 print(vim.eval("{1:2}"))'))
207+
call assert_equal("\nTrue", execute('py3 print(vim.eval("v:true"))'))
208+
call assert_equal("\nFalse", execute('py3 print(vim.eval("v:false"))'))
209+
call assert_equal("\nNone", execute('py3 print(vim.eval("v:null"))'))
210+
call assert_equal("\nNone", execute('py3 print(vim.eval("v:none"))'))
211+
call assert_equal("\nb'\\xab\\x12'", execute('py3 print(vim.eval("0zab12"))'))
212+
213+
call assert_fails('py3 vim.eval("1+")', 'vim.error: invalid expression')
214+
endfunc
215+
191216
" Test range objects, see :help python-range
192217
func Test_python3_range()
193218
new

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
307,
741743
/**/
742744
306,
743745
/**/

0 commit comments

Comments
 (0)