summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-02-23 15:10:16 +0100
committerBram Moolenaar <Bram@vim.org>2020-02-23 15:10:16 +0100
commit026270c01d8ae4425b2afe289d464451718cb9ab (patch)
tree211d354fc5c7c51a2d06980caf95061cb9bfad2b /src
parent83f37b91426b419a913aa4f42d041b2111b57864 (diff)
patch 8.2.0307: Python 3 vim.eval not well testedv8.2.0307
Problem: Python 3 vim.eval not well tested. Solution: Add a test. (Dominique Pelle, closes #5680)
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_python3.vim25
-rw-r--r--src/version.c2
2 files changed, 27 insertions, 0 deletions
diff --git a/src/testdir/test_python3.vim b/src/testdir/test_python3.vim
index 2f5e0571aa..61be9a1e9f 100644
--- a/src/testdir/test_python3.vim
+++ b/src/testdir/test_python3.vim
@@ -188,6 +188,31 @@ func Test_unicode()
set encoding=utf8
endfunc
+" Test vim.eval() with various types.
+func Test_python3_vim_val()
+ call assert_equal("\n8", execute('py3 print(vim.eval("3+5"))'))
+ if has('float')
+ call assert_equal("\n3.140000", execute('py3 print(vim.eval("1.01+2.13"))'))
+ call assert_equal("\n0.000000", execute('py3 print(vim.eval("0.0/(1.0/0.0)"))'))
+ call assert_equal("\n0.000000", execute('py3 print(vim.eval("0.0/(1.0/0.0)"))'))
+ call assert_equal("\n-0.000000", execute('py3 print(vim.eval("0.0/(-1.0/0.0)"))'))
+ " Commented out: output of infinity and nan depend on platforms.
+ " call assert_equal("\ninf", execute('py3 print(vim.eval("1.0/0.0"))'))
+ " call assert_equal("\n-inf", execute('py3 print(vim.eval("-1.0/0.0"))'))
+ " call assert_equal("\n-nan", execute('py3 print(vim.eval("0.0/0.0"))'))
+ endif
+ call assert_equal("\nabc", execute('py3 print(vim.eval("\"abc\""))'))
+ call assert_equal("\n['1', '2']", execute('py3 print(vim.eval("[1, 2]"))'))
+ call assert_equal("\n{'1': '2'}", execute('py3 print(vim.eval("{1:2}"))'))
+ call assert_equal("\nTrue", execute('py3 print(vim.eval("v:true"))'))
+ call assert_equal("\nFalse", execute('py3 print(vim.eval("v:false"))'))
+ call assert_equal("\nNone", execute('py3 print(vim.eval("v:null"))'))
+ call assert_equal("\nNone", execute('py3 print(vim.eval("v:none"))'))
+ call assert_equal("\nb'\\xab\\x12'", execute('py3 print(vim.eval("0zab12"))'))
+
+ call assert_fails('py3 vim.eval("1+")', 'vim.error: invalid expression')
+endfunc
+
" Test range objects, see :help python-range
func Test_python3_range()
new
diff --git a/src/version.c b/src/version.c
index 49cdcc5da7..373eb163cb 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 307,
+/**/
306,
/**/
305,