Mercurial > vim
changeset 7761:db5864658024 v7.4.1178
commit https://github.com/vim/vim/commit/767d8c1a1ae762ecf47297c168b8c23caf05d30a
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 25 20:22:54 2016 +0100
patch 7.4.1178
Problem: empty() doesn't work for the new special variables.
Solution: Make empty() work. (Damien)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 25 Jan 2016 20:30:05 +0100 |
parents | 999cdc9f6010 |
children | faf07cb27904 |
files | src/eval.c src/testdir/test_viml.vim src/version.c |
diffstat | 3 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -10578,6 +10578,10 @@ f_empty(argvars, rettv) n = argvars[0].vval.v_dict == NULL || argvars[0].vval.v_dict->dv_hashtab.ht_used == 0; break; + case VAR_SPECIAL: + n = argvars[0].vval.v_number != VVAL_TRUE; + break; + default: EMSG2(_(e_intern2), "f_empty()"); n = 0;
--- a/src/testdir/test_viml.vim +++ b/src/testdir/test_viml.vim @@ -987,6 +987,11 @@ func Test_type() call assert_equal(v:true, eval(string(v:true))) call assert_equal(v:none, eval(string(v:none))) call assert_equal(v:null, eval(string(v:null))) + + call assert_true(empty(v:false)) + call assert_false(empty(v:true)) + call assert_true(empty(v:null)) + call assert_true(empty(v:none)) endfunc "-------------------------------------------------------------------------------