Merge pull request #10841 from janlazo/vim-7.4.1407

vim-patch:7.4.1407,8.1.1111
This commit is contained in:
Daniel Hahler 2019-08-25 21:04:17 +02:00 committed by GitHub
commit e3e0574cb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 8 deletions

View File

@ -2196,7 +2196,10 @@ insert({list}, {item} [, {idx}])
List insert {item} in {list} [before {idx}]
invert({expr}) Number bitwise invert
isdirectory({directory}) Number |TRUE| if {directory} is a directory
isinf({expr}) Number determine if {expr} is infinity value
(positive or negative)
islocked({expr}) Number |TRUE| if {expr} is locked
isnan({expr}) Number |TRUE| if {expr} is NaN
id({expr}) String identifier of the container
items({dict}) List key-value pairs in {dict}
jobpid({id}) Number Returns pid of a job.
@ -5292,6 +5295,14 @@ isdirectory({directory}) *isdirectory()*
exist, or isn't a directory, the result is |FALSE|. {directory}
is any expression, which is used as a String.
isinf({expr}) *isinf()*
Return 1 if {expr} is a positive infinity, or -1 a negative
infinity, otherwise 0. >
:echo isinf(1.0 / 0.0)
< 1 >
:echo isinf(-1.0 / 0.0)
< -1
islocked({expr}) *islocked()* *E786*
The result is a Number, which is |TRUE| when {expr} is the
name of a locked variable.
@ -5327,6 +5338,10 @@ items({dict}) *items()*
entry and the value of this entry. The |List| is in arbitrary
order.
isnan({expr}) *isnan()*
Return |TRUE| if {expr} is a float with value NaN. >
echo isnan(0.0 / 0.0)
< 1
jobpid({job}) *jobpid()*
Return the PID (process id) of |job-id| {job}.

View File

@ -47,6 +47,7 @@
#include "nvim/indent_c.h"
#include "nvim/indent.h"
#include "nvim/mark.h"
#include "nvim/math.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
@ -11289,7 +11290,6 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr)
#endif
"tablineat",
"tag_binary",
"tag_old_static",
"termguicolors",
"termresponse",
"textobjects",
@ -12042,6 +12042,21 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, FunPtr fptr)
clear_lval(&lv);
}
// "isinf()" function
static void f_isinf(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
if (argvars[0].v_type == VAR_FLOAT
&& xisinf(argvars[0].vval.v_float)) {
rettv->vval.v_number = argvars[0].vval.v_float > 0.0 ? 1 : -1;
}
}
// "isnan()" function
static void f_isnan(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->vval.v_number = argvars[0].v_type == VAR_FLOAT
&& xisnan(argvars[0].vval.v_float);
}
/// Turn a dictionary into a list
///

View File

@ -189,7 +189,9 @@ return {
insert={args={2, 3}},
invert={args=1},
isdirectory={args=1},
isinf={args=1},
islocked={args=1},
isnan={args=1},
id={args=1},
items={args=1},
jobclose={args={1, 2}, func="f_chanclose"},

View File

@ -288,14 +288,24 @@ func Test_trunc()
call assert_fails("call trunc('')", 'E808:')
endfunc
func Test_isinf()
call assert_equal(1, isinf(1.0/0.0))
call assert_equal(-1, isinf(-1.0/0.0))
call assert_false(isinf(1.0))
call assert_false(isinf(0.0/0.0))
call assert_false(isinf('a'))
call assert_false(isinf([]))
call assert_false(isinf({}))
endfunc
func Test_isnan()
throw 'skipped: Nvim does not support isnan()'
call assert_equal(0, isnan(1.0))
call assert_equal(1, isnan(0.0/0.0))
call assert_equal(0, isnan(1.0/0.0))
call assert_equal(0, isnan('a'))
call assert_equal(0, isnan([]))
call assert_equal(0, isnan({}))
call assert_true(isnan(0.0/0.0))
call assert_false(isnan(1.0))
call assert_false(isnan(1.0/0.0))
call assert_false(isnan(-1.0/0.0))
call assert_false(isnan('a'))
call assert_false(isnan([]))
call assert_false(isnan({}))
endfunc
" This was converted from test65