To: vim_dev@googlegroups.com Subject: Patch 8.1.1879 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1879 Problem: More functions can be used as methods. Solution: Make float functions usable as a method. Files: runtime/doc/eval.txt, src/evalfunc.c, src/testdir/test_float_func.vim *** ../vim-8.1.1878/runtime/doc/eval.txt 2019-08-17 19:36:01.202907209 +0200 --- runtime/doc/eval.txt 2019-08-17 21:32:41.228739126 +0200 *************** *** 483,489 **** entry. Note that the String '04' and the Number 04 are different, since the Number will be converted to the String '4'. The empty string can also be used as a key. ! *literal-Dict* To avoid having to put quotes around every key the #{} form can be used. This does require the key to consist only of ASCII letters, digits, '-' and '_'. Example: > --- 483,489 ---- entry. Note that the String '04' and the Number 04 are different, since the Number will be converted to the String '4'. The empty string can also be used as a key. ! *literal-Dict* *#{}* To avoid having to put quotes around every key the #{} form can be used. This does require the key to consist only of ASCII letters, digits, '-' and '_'. Example: > *************** *** 1219,1225 **** expr8->name([args]) method call *method* *->* expr8->{lambda}([args]) ! For methods that are also available as global functions this is the same as: > name(expr8 [, args]) There can also be methods specifically for the type of "expr8". --- 1218,1224 ---- expr8->name([args]) method call *method* *->* expr8->{lambda}([args]) ! *E276* For methods that are also available as global functions this is the same as: > name(expr8 [, args]) There can also be methods specifically for the type of "expr8". *************** *** 1230,1236 **** < Example of using a lambda: > GetPercentage->{x -> x * 100}()->printf('%d%%') ! *E274* "->name(" must not contain white space. There can be white space before the "->" and after the "(", thus you can split the lines like this: > --- 1229,1242 ---- < Example of using a lambda: > GetPercentage->{x -> x * 100}()->printf('%d%%') ! < ! When using -> the |expr7| operators will be applied first, thus: > ! -1.234->string() ! Is equivalent to: > ! (-1.234)->string() ! And NOT: > ! -(1.234->string()) ! < *E274* "->name(" must not contain white space. There can be white space before the "->" and after the "(", thus you can split the lines like this: > *************** *** 1239,1245 **** \ ->map(mapexpr) \ ->sort() \ ->join() ! < *expr9* number --- 1245,1254 ---- \ ->map(mapexpr) \ ->sort() \ ->join() ! ! When using the lambda form there must be no white space between the } and the ! (. ! *expr9* number *************** *** 1793,1799 **** :try : throw "oops" :catch /.*/ ! : echo "caught" v:exception :endtry < Output: "caught oops". --- 1802,1808 ---- :try : throw "oops" :catch /.*/ ! : echo "caught " .. v:exception :endtry < Output: "caught oops". *************** *** 2880,2886 **** < 5.456 > echo abs(-4) < 4 ! {only available when compiled with the |+float| feature} acos({expr}) *acos()* --- 2894,2904 ---- < 5.456 > echo abs(-4) < 4 ! ! Can also be used as a |method|: > ! Compute()->abs() ! ! < {only available when compiled with the |+float| feature} acos({expr}) *acos()* *************** *** 2893,2899 **** < 1.570796 > :echo acos(-0.5) < 2.094395 ! {only available when compiled with the |+float| feature} add({object}, {expr}) *add()* --- 2911,2921 ---- < 1.570796 > :echo acos(-0.5) < 2.094395 ! ! Can also be used as a |method|: > ! Compute()->acos() ! ! < {only available when compiled with the |+float| feature} add({object}, {expr}) *add()* *************** *** 2905,2910 **** --- 2927,2933 ---- item. Use |extend()| to concatenate |Lists|. When {object} is a |Blob| then {expr} must be a number. Use |insert()| to add an item at another position. + Can also be used as a |method|: > mylist->add(val1)->add(val2) *************** *** 3006,3011 **** --- 3029,3038 ---- < 0.927295 > :echo asin(-0.5) < -0.523599 + + Can also be used as a |method|: > + Compute()->asin() + < {only available when compiled with the |+float| feature} *************** *** 3018,3023 **** --- 3045,3054 ---- < 1.560797 > :echo atan(-4.01) < -1.326405 + + Can also be used as a |method|: > + Compute()->atan() + < {only available when compiled with the |+float| feature} *************** *** 3030,3035 **** --- 3061,3070 ---- < -0.785398 > :echo atan2(1, -1) < 2.356194 + + Can also be used as a |method|: > + Compute()->atan(1) + < {only available when compiled with the |+float| feature} balloon_gettext() *balloon_gettext()* *************** *** 3288,3293 **** --- 3323,3332 ---- < -5.0 > echo ceil(4.0) < 4.0 + + Can also be used as a |method|: > + Compute()->ceil() + < {only available when compiled with the |+float| feature} *************** *** 3564,3569 **** --- 3603,3612 ---- < 0.862319 > :echo cos(-4.01) < -0.646043 + + Can also be used as a |method|: > + Compute()->cos() + < {only available when compiled with the |+float| feature} *************** *** 3576,3581 **** --- 3619,3628 ---- < 1.127626 > :echo cosh(-0.5) < -1.127626 + + Can also be used as a |method|: > + Compute()->cosh() + < {only available when compiled with the |+float| feature} *************** *** 3961,3966 **** --- 4008,4017 ---- < 7.389056 > :echo exp(-1) < 0.367879 + + Can also be used as a |method|: > + Compute()->exp() + < {only available when compiled with the |+float| feature} *************** *** 4254,4259 **** --- 4310,4319 ---- < -2147483647 (or -9223372036854775807) > echo float2nr(1.0e-100) < 0 + + Can also be used as a |method|: > + Compute()->float2nr() + < {only available when compiled with the |+float| feature} *************** *** 4268,4273 **** --- 4328,4337 ---- < -6.0 > echo floor(4.0) < 4.0 + + Can also be used as a |method|: > + Compute()->floor() + < {only available when compiled with the |+float| feature} *************** *** 4284,4289 **** --- 4348,4357 ---- < 0.13 > :echo fmod(-12.33, 1.22) < -0.13 + + Can also be used as a |method|: > + Compute()->fmod(1.22) + < {only available when compiled with |+float| feature} *************** *** 4400,4414 **** the Funcref and will be used when the Funcref is called. The arguments are passed to the function in front of other ! arguments. Example: > func Callback(arg1, arg2, name) ... ! let Func = function('Callback', ['one', 'two']) ... ! call Func('name') < Invokes the function as with: > call Callback('one', 'two', 'name') < The function() call can be nested to add more arguments to the Funcref. The extra arguments are appended to the list of arguments. Example: > --- 4468,4491 ---- the Funcref and will be used when the Funcref is called. The arguments are passed to the function in front of other ! arguments, but after any argument from |method|. Example: > func Callback(arg1, arg2, name) ... ! let Partial = function('Callback', ['one', 'two']) ... ! call Partial('name') < Invokes the function as with: > call Callback('one', 'two', 'name') + < With a |method|: > + func Callback(one, two, three) + ... + let Partial = function('Callback', ['two']) + ... + eval 'one'->Partial('three') + < Invokes the function as with: > + call Callback('one', 'two', 'three') + < The function() call can be nested to add more arguments to the Funcref. The extra arguments are appended to the list of arguments. Example: > *************** *** 5768,5773 **** --- 5849,5857 ---- :echo isinf(-1.0 / 0.0) < -1 + Can also be used as a |method|: > + Compute()->isinf() + < {only available when compiled with the |+float| feature} islocked({expr}) *islocked()* *E786* *************** *** 5788,5793 **** --- 5872,5880 ---- echo isnan(0.0 / 0.0) < 1 + Can also be used as a |method|: > + Compute()->isnan() + < {only available when compiled with the |+float| feature} items({dict}) *items()* *************** *** 6138,6143 **** --- 6225,6234 ---- < 2.302585 > :echo log(exp(5)) < 5.0 + + Can also be used as a |method|: > + Compute()->log() + < {only available when compiled with the |+float| feature} *************** *** 6149,6154 **** --- 6240,6249 ---- < 3.0 > :echo log10(0.01) < -2.0 + + Can also be used as a |method|: > + Compute()->log10() + < {only available when compiled with the |+float| feature} luaeval({expr} [, {expr}]) *luaeval()* *************** *** 6196,6201 **** --- 6291,6298 ---- call map(myDict, {key, val -> key . '-' . val}) < If you do not use "val" you can leave it out: > call map(myDict, {key -> 'item: ' . key}) + < If you do not use "key" you can use a short name: > + call map(myDict, {_, val -> 'item: ' . val}) < The operation is done in-place. If you want a |List| or |Dictionary| to remain unmodified make a copy first: > *************** *** 6706,6711 **** --- 6803,6812 ---- < 65536.0 > :echo pow(32, 0.20) < 2.0 + + Can also be used as a |method|: > + Compute()->pow(3) + < {only available when compiled with the |+float| feature} prevnonblank({lnum}) *prevnonblank()* *************** *** 7329,7334 **** --- 7431,7440 ---- < 5.0 > echo round(-4.5) < -5.0 + + Can also be used as a |method|: > + Compute()->round() + < {only available when compiled with the |+float| feature} rubyeval({expr}) *rubyeval()* *************** *** 8118,8123 **** --- 8224,8233 ---- < -0.506366 > :echo sin(-4.01) < 0.763301 + + Can also be used as a |method|: > + Compute()->sin() + < {only available when compiled with the |+float| feature} *************** *** 8130,8135 **** --- 8240,8249 ---- < 0.521095 > :echo sinh(-0.9) < -1.026517 + + Can also be used as a |method|: > + Compute()->sinh() + < {only available when compiled with the |+float| feature} *************** *** 8336,8341 **** --- 8450,8459 ---- :echo sqrt(-4.01) < nan "nan" may be different, it depends on system libraries. + + Can also be used as a |method|: > + Compute()->sqrt() + < {only available when compiled with the |+float| feature} *************** *** 8352,8358 **** 12.0. You can strip out thousands separators with |substitute()|: > let f = str2float(substitute(text, ',', '', 'g')) ! < {only available when compiled with the |+float| feature} str2list({expr} [, {utf8}]) *str2list()* Return a list containing the number values which represent --- 8470,8480 ---- 12.0. You can strip out thousands separators with |substitute()|: > let f = str2float(substitute(text, ',', '', 'g')) ! < ! Can also be used as a |method|: > ! let f = text->substitute(',', '', 'g')->str2float() ! < ! {only available when compiled with the |+float| feature} str2list({expr} [, {utf8}]) *str2list()* Return a list containing the number values which represent *************** *** 8949,8954 **** --- 9071,9080 ---- < 0.648361 > :echo tan(-4.01) < -1.181502 + + Can also be used as a |method|: > + Compute()->tan() + < {only available when compiled with the |+float| feature} *************** *** 8961,8966 **** --- 9087,9096 ---- < 0.462117 > :echo tanh(-1) < -0.761594 + + Can also be used as a |method|: > + Compute()->tanh() + < {only available when compiled with the |+float| feature} *************** *** 9114,9119 **** --- 9244,9253 ---- < -5.0 > echo trunc(4.0) < 4.0 + + Can also be used as a |method|: > + Compute()->trunc() + < {only available when compiled with the |+float| feature} *type()* *** ../vim-8.1.1878/src/evalfunc.c 2019-08-17 19:36:01.206907191 +0200 --- src/evalfunc.c 2019-08-17 21:33:06.864565121 +0200 *************** *** 418,425 **** static funcentry_T global_functions[] = { #ifdef FEAT_FLOAT ! {"abs", 1, 1, 0, f_abs}, ! {"acos", 1, 1, 0, f_acos}, // WJMc #endif {"add", 2, 2, FEARG_1, f_add}, {"and", 2, 2, 0, f_and}, --- 418,425 ---- static funcentry_T global_functions[] = { #ifdef FEAT_FLOAT ! {"abs", 1, 1, FEARG_1, f_abs}, ! {"acos", 1, 1, FEARG_1, f_acos}, // WJMc #endif {"add", 2, 2, FEARG_1, f_add}, {"and", 2, 2, 0, f_and}, *************** *** 430,436 **** {"arglistid", 0, 2, 0, f_arglistid}, {"argv", 0, 2, 0, f_argv}, #ifdef FEAT_FLOAT ! {"asin", 1, 1, 0, f_asin}, // WJMc #endif {"assert_beeps", 1, 2, FEARG_1, f_assert_beeps}, {"assert_equal", 2, 3, FEARG_2, f_assert_equal}, --- 430,436 ---- {"arglistid", 0, 2, 0, f_arglistid}, {"argv", 0, 2, 0, f_argv}, #ifdef FEAT_FLOAT ! {"asin", 1, 1, FEARG_1, f_asin}, // WJMc #endif {"assert_beeps", 1, 2, FEARG_1, f_assert_beeps}, {"assert_equal", 2, 3, FEARG_2, f_assert_equal}, *************** *** 445,452 **** {"assert_report", 1, 1, 0, f_assert_report}, {"assert_true", 1, 2, FEARG_1, f_assert_true}, #ifdef FEAT_FLOAT ! {"atan", 1, 1, 0, f_atan}, ! {"atan2", 2, 2, 0, f_atan2}, #endif #ifdef FEAT_BEVAL {"balloon_gettext", 0, 0, 0, f_balloon_gettext}, --- 445,452 ---- {"assert_report", 1, 1, 0, f_assert_report}, {"assert_true", 1, 2, FEARG_1, f_assert_true}, #ifdef FEAT_FLOAT ! {"atan", 1, 1, FEARG_1, f_atan}, ! {"atan2", 2, 2, FEARG_1, f_atan2}, #endif #ifdef FEAT_BEVAL {"balloon_gettext", 0, 0, 0, f_balloon_gettext}, *************** *** 474,480 **** {"byteidxcomp", 2, 2, 0, f_byteidxcomp}, {"call", 2, 3, 0, f_call}, #ifdef FEAT_FLOAT ! {"ceil", 1, 1, 0, f_ceil}, #endif #ifdef FEAT_JOB_CHANNEL {"ch_canread", 1, 1, 0, f_ch_canread}, --- 474,480 ---- {"byteidxcomp", 2, 2, 0, f_byteidxcomp}, {"call", 2, 3, 0, f_call}, #ifdef FEAT_FLOAT ! {"ceil", 1, 1, FEARG_1, f_ceil}, #endif #ifdef FEAT_JOB_CHANNEL {"ch_canread", 1, 1, 0, f_ch_canread}, *************** *** 511,518 **** {"confirm", 1, 4, 0, f_confirm}, {"copy", 1, 1, FEARG_1, f_copy}, #ifdef FEAT_FLOAT ! {"cos", 1, 1, 0, f_cos}, ! {"cosh", 1, 1, 0, f_cosh}, #endif {"count", 2, 4, FEARG_1, f_count}, {"cscope_connection",0,3, 0, f_cscope_connection}, --- 511,518 ---- {"confirm", 1, 4, 0, f_confirm}, {"copy", 1, 1, FEARG_1, f_copy}, #ifdef FEAT_FLOAT ! {"cos", 1, 1, FEARG_1, f_cos}, ! {"cosh", 1, 1, FEARG_1, f_cosh}, #endif {"count", 2, 4, FEARG_1, f_count}, {"cscope_connection",0,3, 0, f_cscope_connection}, *************** *** 536,542 **** {"exepath", 1, 1, 0, f_exepath}, {"exists", 1, 1, 0, f_exists}, #ifdef FEAT_FLOAT ! {"exp", 1, 1, 0, f_exp}, #endif {"expand", 1, 3, 0, f_expand}, {"expandcmd", 1, 1, 0, f_expandcmd}, --- 536,542 ---- {"exepath", 1, 1, 0, f_exepath}, {"exists", 1, 1, 0, f_exists}, #ifdef FEAT_FLOAT ! {"exp", 1, 1, FEARG_1, f_exp}, #endif {"expand", 1, 3, 0, f_expand}, {"expandcmd", 1, 1, 0, f_expandcmd}, *************** *** 549,557 **** {"finddir", 1, 3, 0, f_finddir}, {"findfile", 1, 3, 0, f_findfile}, #ifdef FEAT_FLOAT ! {"float2nr", 1, 1, 0, f_float2nr}, ! {"floor", 1, 1, 0, f_floor}, ! {"fmod", 2, 2, 0, f_fmod}, #endif {"fnameescape", 1, 1, 0, f_fnameescape}, {"fnamemodify", 2, 2, 0, f_fnamemodify}, --- 549,557 ---- {"finddir", 1, 3, 0, f_finddir}, {"findfile", 1, 3, 0, f_findfile}, #ifdef FEAT_FLOAT ! {"float2nr", 1, 1, FEARG_1, f_float2nr}, ! {"floor", 1, 1, FEARG_1, f_floor}, ! {"fmod", 2, 2, FEARG_1, f_fmod}, #endif {"fnameescape", 1, 1, 0, f_fnameescape}, {"fnamemodify", 2, 2, 0, f_fnamemodify}, *************** *** 634,644 **** {"invert", 1, 1, 0, f_invert}, {"isdirectory", 1, 1, 0, f_isdirectory}, #if defined(FEAT_FLOAT) && defined(HAVE_MATH_H) ! {"isinf", 1, 1, 0, f_isinf}, #endif {"islocked", 1, 1, 0, f_islocked}, #if defined(FEAT_FLOAT) && defined(HAVE_MATH_H) ! {"isnan", 1, 1, 0, f_isnan}, #endif {"items", 1, 1, FEARG_1, f_items}, #ifdef FEAT_JOB_CHANNEL --- 634,644 ---- {"invert", 1, 1, 0, f_invert}, {"isdirectory", 1, 1, 0, f_isdirectory}, #if defined(FEAT_FLOAT) && defined(HAVE_MATH_H) ! {"isinf", 1, 1, FEARG_1, f_isinf}, #endif {"islocked", 1, 1, 0, f_islocked}, #if defined(FEAT_FLOAT) && defined(HAVE_MATH_H) ! {"isnan", 1, 1, FEARG_1, f_isnan}, #endif {"items", 1, 1, FEARG_1, f_items}, #ifdef FEAT_JOB_CHANNEL *************** *** 668,675 **** {"listener_remove", 1, 1, 0, f_listener_remove}, {"localtime", 0, 0, 0, f_localtime}, #ifdef FEAT_FLOAT ! {"log", 1, 1, 0, f_log}, ! {"log10", 1, 1, 0, f_log10}, #endif #ifdef FEAT_LUA {"luaeval", 1, 2, 0, f_luaeval}, --- 668,675 ---- {"listener_remove", 1, 1, 0, f_listener_remove}, {"localtime", 0, 0, 0, f_localtime}, #ifdef FEAT_FLOAT ! {"log", 1, 1, FEARG_1, f_log}, ! {"log10", 1, 1, FEARG_1, f_log10}, #endif #ifdef FEAT_LUA {"luaeval", 1, 2, 0, f_luaeval}, *************** *** 722,728 **** {"popup_show", 1, 1, 0, f_popup_show}, #endif #ifdef FEAT_FLOAT ! {"pow", 2, 2, 0, f_pow}, #endif {"prevnonblank", 1, 1, 0, f_prevnonblank}, {"printf", 1, 19, FEARG_2, f_printf}, --- 722,728 ---- {"popup_show", 1, 1, 0, f_popup_show}, #endif #ifdef FEAT_FLOAT ! {"pow", 2, 2, FEARG_1, f_pow}, #endif {"prevnonblank", 1, 1, 0, f_prevnonblank}, {"printf", 1, 19, FEARG_2, f_printf}, *************** *** 775,781 **** {"resolve", 1, 1, 0, f_resolve}, {"reverse", 1, 1, FEARG_1, f_reverse}, #ifdef FEAT_FLOAT ! {"round", 1, 1, 0, f_round}, #endif #ifdef FEAT_RUBY {"rubyeval", 1, 1, 0, f_rubyeval}, --- 775,781 ---- {"resolve", 1, 1, 0, f_resolve}, {"reverse", 1, 1, FEARG_1, f_reverse}, #ifdef FEAT_FLOAT ! {"round", 1, 1, FEARG_1, f_round}, #endif #ifdef FEAT_RUBY {"rubyeval", 1, 1, 0, f_rubyeval}, *************** *** 828,835 **** #endif {"simplify", 1, 1, 0, f_simplify}, #ifdef FEAT_FLOAT ! {"sin", 1, 1, 0, f_sin}, ! {"sinh", 1, 1, 0, f_sinh}, #endif {"sort", 1, 3, FEARG_1, f_sort}, #ifdef FEAT_SOUND --- 828,835 ---- #endif {"simplify", 1, 1, 0, f_simplify}, #ifdef FEAT_FLOAT ! {"sin", 1, 1, FEARG_1, f_sin}, ! {"sinh", 1, 1, FEARG_1, f_sinh}, #endif {"sort", 1, 3, FEARG_1, f_sort}, #ifdef FEAT_SOUND *************** *** 843,850 **** {"spellsuggest", 1, 3, 0, f_spellsuggest}, {"split", 1, 3, FEARG_1, f_split}, #ifdef FEAT_FLOAT ! {"sqrt", 1, 1, 0, f_sqrt}, ! {"str2float", 1, 1, 0, f_str2float}, #endif {"str2list", 1, 2, FEARG_1, f_str2list}, {"str2nr", 1, 2, 0, f_str2nr}, --- 843,850 ---- {"spellsuggest", 1, 3, 0, f_spellsuggest}, {"split", 1, 3, FEARG_1, f_split}, #ifdef FEAT_FLOAT ! {"sqrt", 1, 1, FEARG_1, f_sqrt}, ! {"str2float", 1, 1, FEARG_1, f_str2float}, #endif {"str2list", 1, 2, FEARG_1, f_str2list}, {"str2nr", 1, 2, 0, f_str2nr}, *************** *** 879,886 **** {"tagfiles", 0, 0, 0, f_tagfiles}, {"taglist", 1, 2, 0, f_taglist}, #ifdef FEAT_FLOAT ! {"tan", 1, 1, 0, f_tan}, ! {"tanh", 1, 1, 0, f_tanh}, #endif {"tempname", 0, 0, 0, f_tempname}, #ifdef FEAT_TERMINAL --- 879,886 ---- {"tagfiles", 0, 0, 0, f_tagfiles}, {"taglist", 1, 2, 0, f_taglist}, #ifdef FEAT_FLOAT ! {"tan", 1, 1, FEARG_1, f_tan}, ! {"tanh", 1, 1, FEARG_1, f_tanh}, #endif {"tempname", 0, 0, 0, f_tempname}, #ifdef FEAT_TERMINAL *************** *** 952,958 **** {"tr", 3, 3, 0, f_tr}, {"trim", 1, 2, 0, f_trim}, #ifdef FEAT_FLOAT ! {"trunc", 1, 1, 0, f_trunc}, #endif {"type", 1, 1, FEARG_1, f_type}, {"undofile", 1, 1, 0, f_undofile}, --- 952,958 ---- {"tr", 3, 3, 0, f_tr}, {"trim", 1, 2, 0, f_trim}, #ifdef FEAT_FLOAT ! {"trunc", 1, 1, FEARG_1, f_trunc}, #endif {"type", 1, 1, FEARG_1, f_type}, {"undofile", 1, 1, 0, f_undofile}, *** ../vim-8.1.1878/src/testdir/test_float_func.vim 2019-06-15 17:57:43.968724059 +0200 --- src/testdir/test_float_func.vim 2019-08-17 21:32:59.740613352 +0200 *************** *** 6,11 **** --- 6,13 ---- func Test_abs() call assert_equal('1.23', string(abs(1.23))) call assert_equal('1.23', string(abs(-1.23))) + eval -1.23->abs()->string()->assert_equal('1.23') + call assert_equal('0.0', string(abs(0.0))) call assert_equal('0.0', string(abs(1.0/(1.0/0.0)))) call assert_equal('0.0', string(abs(-1.0/(1.0/0.0)))) *************** *** 22,27 **** --- 24,30 ---- func Test_sqrt() call assert_equal('0.0', string(sqrt(0.0))) call assert_equal('1.414214', string(sqrt(2.0))) + eval 2.0->sqrt()->string()->assert_equal('1.414214') call assert_equal('inf', string(sqrt(1.0/0.0))) call assert_equal('nan', string(sqrt(-1.0))) call assert_equal('nan', string(sqrt(0.0/0.0))) *************** *** 31,36 **** --- 34,40 ---- func Test_log() call assert_equal('0.0', string(log(1.0))) call assert_equal('-0.693147', string(log(0.5))) + eval 0.5->log()->string()->assert_equal('-0.693147') call assert_equal('-inf', string(log(0.0))) call assert_equal('nan', string(log(-1.0))) call assert_equal('inf', string(log(1.0/0.0))) *************** *** 42,47 **** --- 46,52 ---- call assert_equal('0.0', string(log10(1.0))) call assert_equal('2.0', string(log10(100.0))) call assert_equal('2.079181', string(log10(120.0))) + eval 120.0->log10()->string()->assert_equal('2.079181') call assert_equal('-inf', string(log10(0.0))) call assert_equal('nan', string(log10(-1.0))) call assert_equal('inf', string(log10(1.0/0.0))) *************** *** 53,58 **** --- 58,64 ---- call assert_equal('1.0', string(exp(0.0))) call assert_equal('7.389056', string(exp(2.0))) call assert_equal('0.367879', string(exp(-1.0))) + eval -1.0->exp()->string()->assert_equal('0.367879') call assert_equal('inf', string(exp(1.0/0.0))) call assert_equal('0.0', string(exp(-1.0/0.0))) call assert_equal('nan', string(exp(0.0/0.0))) *************** *** 63,68 **** --- 69,75 ---- call assert_equal('0.0', string(sin(0.0))) call assert_equal('0.841471', string(sin(1.0))) call assert_equal('-0.479426', string(sin(-0.5))) + eval -0.5->sin()->string()->assert_equal('-0.479426') call assert_equal('nan', string(sin(0.0/0.0))) call assert_equal('nan', string(sin(1.0/0.0))) call assert_equal('0.0', string(sin(1.0/(1.0/0.0)))) *************** *** 73,78 **** --- 80,87 ---- func Test_asin() call assert_equal('0.0', string(asin(0.0))) call assert_equal('1.570796', string(asin(1.0))) + eval 1.0->asin()->string()->assert_equal('1.570796') + call assert_equal('-0.523599', string(asin(-0.5))) call assert_equal('nan', string(asin(1.1))) call assert_equal('nan', string(asin(1.0/0.0))) *************** *** 84,89 **** --- 93,99 ---- call assert_equal('0.0', string(sinh(0.0))) call assert_equal('0.521095', string(sinh(0.5))) call assert_equal('-1.026517', string(sinh(-0.9))) + eval -0.9->sinh()->string()->assert_equal('-1.026517') call assert_equal('inf', string(sinh(1.0/0.0))) call assert_equal('-inf', string(sinh(-1.0/0.0))) call assert_equal('nan', string(sinh(0.0/0.0))) *************** *** 94,99 **** --- 104,110 ---- call assert_equal('1.0', string(cos(0.0))) call assert_equal('0.540302', string(cos(1.0))) call assert_equal('0.877583', string(cos(-0.5))) + eval -0.5->cos()->string()->assert_equal('0.877583') call assert_equal('nan', string(cos(0.0/0.0))) call assert_equal('nan', string(cos(1.0/0.0))) call assert_fails('call cos("")', 'E808:') *************** *** 103,108 **** --- 114,120 ---- call assert_equal('1.570796', string(acos(0.0))) call assert_equal('0.0', string(acos(1.0))) call assert_equal('3.141593', string(acos(-1.0))) + eval -1.0->acos()->string()->assert_equal('3.141593') call assert_equal('2.094395', string(acos(-0.5))) call assert_equal('nan', string(acos(1.1))) call assert_equal('nan', string(acos(1.0/0.0))) *************** *** 113,118 **** --- 125,131 ---- func Test_cosh() call assert_equal('1.0', string(cosh(0.0))) call assert_equal('1.127626', string(cosh(0.5))) + eval 0.5->cosh()->string()->assert_equal('1.127626') call assert_equal('inf', string(cosh(1.0/0.0))) call assert_equal('inf', string(cosh(-1.0/0.0))) call assert_equal('nan', string(cosh(0.0/0.0))) *************** *** 123,128 **** --- 136,142 ---- call assert_equal('0.0', string(tan(0.0))) call assert_equal('0.546302', string(tan(0.5))) call assert_equal('-0.546302', string(tan(-0.5))) + eval -0.5->tan()->string()->assert_equal('-0.546302') call assert_equal('nan', string(tan(1.0/0.0))) call assert_equal('nan', string(cos(0.0/0.0))) call assert_equal('0.0', string(tan(1.0/(1.0/0.0)))) *************** *** 134,139 **** --- 148,154 ---- call assert_equal('0.0', string(atan(0.0))) call assert_equal('0.463648', string(atan(0.5))) call assert_equal('-0.785398', string(atan(-1.0))) + eval -1.0->atan()->string()->assert_equal('-0.785398') call assert_equal('1.570796', string(atan(1.0/0.0))) call assert_equal('-1.570796', string(atan(-1.0/0.0))) call assert_equal('nan', string(atan(0.0/0.0))) *************** *** 144,149 **** --- 159,165 ---- call assert_equal('-2.356194', string(atan2(-1, -1))) call assert_equal('2.356194', string(atan2(1, -1))) call assert_equal('0.0', string(atan2(1.0, 1.0/0.0))) + eval 1.0->atan2(1.0/0.0)->string()->assert_equal('0.0') call assert_equal('1.570796', string(atan2(1.0/0.0, 1.0))) call assert_equal('nan', string(atan2(0.0/0.0, 1.0))) call assert_fails('call atan2("", -1)', 'E808:') *************** *** 154,159 **** --- 170,176 ---- call assert_equal('0.0', string(tanh(0.0))) call assert_equal('0.462117', string(tanh(0.5))) call assert_equal('-0.761594', string(tanh(-1.0))) + eval -1.0->tanh()->string()->assert_equal('-0.761594') call assert_equal('1.0', string(tanh(1.0/0.0))) call assert_equal('-1.0', string(tanh(-1.0/0.0))) call assert_equal('nan', string(tanh(0.0/0.0))) *************** *** 164,169 **** --- 181,187 ---- call assert_equal('0.13', string(fmod(12.33, 1.22))) call assert_equal('-0.13', string(fmod(-12.33, 1.22))) call assert_equal('nan', string(fmod(1.0/0.0, 1.0))) + eval (1.0/0.0)->fmod(1.0)->string()->assert_equal('nan') " On Windows we get "nan" instead of 1.0, accept both. let res = string(fmod(1.0, 1.0/0.0)) if res != 'nan' *************** *** 177,182 **** --- 195,201 ---- func Test_pow() call assert_equal('1.0', string(pow(0.0, 0.0))) call assert_equal('8.0', string(pow(2.0, 3.0))) + eval 2.0->pow(3.0)->string()->assert_equal('8.0') call assert_equal('nan', string(pow(2.0, 0.0/0.0))) call assert_equal('nan', string(pow(0.0/0.0, 3.0))) call assert_equal('nan', string(pow(0.0/0.0, 3.0))) *************** *** 192,197 **** --- 211,217 ---- call assert_equal('1.0', string(str2float(' 1.0 '))) call assert_equal('1.23', string(str2float('1.23'))) call assert_equal('1.23', string(str2float('1.23abc'))) + eval '1.23abc'->str2float()->string()->assert_equal('1.23') call assert_equal('1.0e40', string(str2float('1e40'))) call assert_equal('-1.23', string(str2float('-1.23'))) call assert_equal('1.23', string(str2float(' + 1.23 '))) *************** *** 228,233 **** --- 248,254 ---- call assert_equal(1, float2nr(1.234)) call assert_equal(123, float2nr(1.234e2)) call assert_equal(12, float2nr(123.4e-1)) + eval 123.4e-1->float2nr()->assert_equal(12) let max_number = 1/0 let min_number = -max_number call assert_equal(max_number/2+1, float2nr(pow(2, 62))) *************** *** 242,247 **** --- 263,269 ---- call assert_equal('2.0', string(floor(2.0))) call assert_equal('2.0', string(floor(2.11))) call assert_equal('2.0', string(floor(2.99))) + eval 2.99->floor()->string()->assert_equal('2.0') call assert_equal('-3.0', string(floor(-2.11))) call assert_equal('-3.0', string(floor(-2.99))) call assert_equal('nan', string(floor(0.0/0.0))) *************** *** 255,260 **** --- 277,283 ---- call assert_equal('3.0', string(ceil(2.11))) call assert_equal('3.0', string(ceil(2.99))) call assert_equal('-2.0', string(ceil(-2.11))) + eval -2.11->ceil()->string()->assert_equal('-2.0') call assert_equal('-2.0', string(ceil(-2.99))) call assert_equal('nan', string(ceil(0.0/0.0))) call assert_equal('inf', string(ceil(1.0/0.0))) *************** *** 266,271 **** --- 289,295 ---- call assert_equal('2.0', string(round(2.1))) call assert_equal('3.0', string(round(2.5))) call assert_equal('3.0', string(round(2.9))) + eval 2.9->round()->string()->assert_equal('3.0') call assert_equal('-2.0', string(round(-2.1))) call assert_equal('-3.0', string(round(-2.5))) call assert_equal('-3.0', string(round(-2.9))) *************** *** 279,284 **** --- 303,309 ---- call assert_equal('2.0', string(trunc(2.1))) call assert_equal('2.0', string(trunc(2.5))) call assert_equal('2.0', string(trunc(2.9))) + eval 2.9->trunc()->string()->assert_equal('2.0') call assert_equal('-2.0', string(trunc(-2.1))) call assert_equal('-2.0', string(trunc(-2.5))) call assert_equal('-2.0', string(trunc(-2.9))) *************** *** 291,296 **** --- 316,322 ---- func Test_isinf() call assert_equal(1, isinf(1.0/0.0)) call assert_equal(-1, isinf(-1.0/0.0)) + eval (-1.0/0.0)->isinf()->assert_equal(-1) call assert_false(isinf(1.0)) call assert_false(isinf(0.0/0.0)) call assert_false(isinf('a')) *************** *** 302,307 **** --- 328,334 ---- call assert_true(isnan(0.0/0.0)) call assert_false(isnan(1.0)) call assert_false(isnan(1.0/0.0)) + eval (1.0/0.0)->isnan()->assert_false() call assert_false(isnan(-1.0/0.0)) call assert_false(isnan('a')) call assert_false(isnan([])) *** ../vim-8.1.1878/src/version.c 2019-08-17 21:04:12.810190024 +0200 --- src/version.c 2019-08-17 21:05:11.061910661 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 1879, /**/ -- hundred-and-one symptoms of being an internet addict: 89. In addition to your e-mail address being on your business cards you even have your own domain. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///