patch 9.0.0491: no good reason to build without the float feature

Problem:    No good reason to build without the float feature.
Solution:   Remove configure check for float and "#ifdef FEAT_FLOAT".
This commit is contained in:
Bram Moolenaar
2022-09-17 21:08:33 +01:00
parent 1c3dd8ddcb
commit 73e28dcc61
74 changed files with 589 additions and 1152 deletions
+1 -52
View File
@@ -753,8 +753,6 @@ abs({expr}) *abs()*
Can also be used as a |method|: >
Compute()->abs()
< {only available when compiled with the |+float| feature}
acos({expr}) *acos()*
Return the arc cosine of {expr} measured in radians, as a
@@ -770,8 +768,6 @@ acos({expr}) *acos()*
Can also be used as a |method|: >
Compute()->acos()
< {only available when compiled with the |+float| feature}
add({object}, {expr}) *add()*
Append the item {expr} to |List| or |Blob| {object}. Returns
@@ -904,8 +900,6 @@ asin({expr}) *asin()*
Can also be used as a |method|: >
Compute()->asin()
<
{only available when compiled with the |+float| feature}
assert_ functions are documented here: |assert-functions-details|
@@ -925,8 +919,6 @@ atan({expr}) *atan()*
Can also be used as a |method|: >
Compute()->atan()
<
{only available when compiled with the |+float| feature}
atan2({expr1}, {expr2}) *atan2()*
@@ -943,8 +935,6 @@ atan2({expr1}, {expr2}) *atan2()*
Can also be used as a |method|: >
Compute()->atan2(1)
<
{only available when compiled with the |+float| feature}
autocmd_add({acmds}) *autocmd_add()*
@@ -1428,8 +1418,6 @@ ceil({expr}) *ceil()*
Can also be used as a |method|: >
Compute()->ceil()
<
{only available when compiled with the |+float| feature}
ch_ functions are documented here: |channel-functions-details|
@@ -1801,8 +1789,6 @@ cos({expr}) *cos()*
Can also be used as a |method|: >
Compute()->cos()
<
{only available when compiled with the |+float| feature}
cosh({expr}) *cosh()*
@@ -1818,8 +1804,6 @@ cosh({expr}) *cosh()*
Can also be used as a |method|: >
Compute()->cosh()
<
{only available when compiled with the |+float| feature}
count({comp}, {expr} [, {ic} [, {start}]]) *count()*
@@ -2405,8 +2389,6 @@ exp({expr}) *exp()*
Can also be used as a |method|: >
Compute()->exp()
<
{only available when compiled with the |+float| feature}
expand({string} [, {nosuf} [, {list}]]) *expand()*
@@ -2807,8 +2789,6 @@ float2nr({expr}) *float2nr()*
Can also be used as a |method|: >
Compute()->float2nr()
<
{only available when compiled with the |+float| feature}
floor({expr}) *floor()*
@@ -2826,8 +2806,6 @@ floor({expr}) *floor()*
Can also be used as a |method|: >
Compute()->floor()
<
{only available when compiled with the |+float| feature}
fmod({expr1}, {expr2}) *fmod()*
@@ -2848,8 +2826,6 @@ fmod({expr1}, {expr2}) *fmod()*
Can also be used as a |method|: >
Compute()->fmod(1.22)
<
{only available when compiled with |+float| feature}
fnameescape({string}) *fnameescape()*
@@ -5050,8 +5026,6 @@ isinf({expr}) *isinf()*
Can also be used as a |method|: >
Compute()->isinf()
<
{only available when compiled with the |+float| feature}
islocked({expr}) *islocked()* *E786*
The result is a Number, which is |TRUE| when {expr} is the
@@ -5080,8 +5054,6 @@ isnan({expr}) *isnan()*
Can also be used as a |method|: >
Compute()->isnan()
<
{only available when compiled with the |+float| feature}
items({dict}) *items()*
Return a |List| with all the key-value pairs of {dict}. Each
@@ -5510,8 +5482,6 @@ log({expr}) *log()*
Can also be used as a |method|: >
Compute()->log()
<
{only available when compiled with the |+float| feature}
log10({expr}) *log10()*
@@ -5526,8 +5496,6 @@ log10({expr}) *log10()*
Can also be used as a |method|: >
Compute()->log10()
<
{only available when compiled with the |+float| feature}
luaeval({expr} [, {expr}]) *luaeval()*
Evaluate Lua expression {expr} and return its result converted
@@ -5535,8 +5503,7 @@ luaeval({expr} [, {expr}]) *luaeval()*
argument accessible as _A inside first {expr}.
Strings are returned as they are.
Boolean objects are converted to numbers.
Numbers are converted to |Float| values if vim was compiled
with |+float| and to numbers otherwise.
Numbers are converted to |Float| values.
Dictionaries and lists obtained by vim.eval() are returned
as-is.
Other objects are returned as zero without any errors.
@@ -6483,8 +6450,6 @@ pow({x}, {y}) *pow()*
Can also be used as a |method|: >
Compute()->pow(3)
<
{only available when compiled with the |+float| feature}
prevnonblank({lnum}) *prevnonblank()*
Return the line number of the first line at or above {lnum}
@@ -7366,8 +7331,6 @@ round({expr}) *round()*
Can also be used as a |method|: >
Compute()->round()
<
{only available when compiled with the |+float| feature}
rubyeval({expr}) *rubyeval()*
Evaluate Ruby expression {expr} and return its result
@@ -8536,8 +8499,6 @@ sin({expr}) *sin()*
Can also be used as a |method|: >
Compute()->sin()
<
{only available when compiled with the |+float| feature}
sinh({expr}) *sinh()*
@@ -8553,8 +8514,6 @@ sinh({expr}) *sinh()*
Can also be used as a |method|: >
Compute()->sinh()
<
{only available when compiled with the |+float| feature}
slice({expr}, {start} [, {end}]) *slice()*
@@ -8821,8 +8780,6 @@ sqrt({expr}) *sqrt()*
Can also be used as a |method|: >
Compute()->sqrt()
<
{only available when compiled with the |+float| feature}
srand([{expr}]) *srand()*
@@ -8896,8 +8853,6 @@ str2float({string} [, {quoted}]) *str2float()*
Can also be used as a |method|: >
let f = text->substitute(',', '', 'g')->str2float()
<
{only available when compiled with the |+float| feature}
str2list({string} [, {utf8}]) *str2list()*
Return a list containing the number values which represent
@@ -9643,8 +9598,6 @@ tan({expr}) *tan()*
Can also be used as a |method|: >
Compute()->tan()
<
{only available when compiled with the |+float| feature}
tanh({expr}) *tanh()*
@@ -9660,8 +9613,6 @@ tanh({expr}) *tanh()*
Can also be used as a |method|: >
Compute()->tanh()
<
{only available when compiled with the |+float| feature}
tempname() *tempname()* *temp-file-name*
@@ -9897,8 +9848,6 @@ trunc({expr}) *trunc()*
Can also be used as a |method|: >
Compute()->trunc()
<
{only available when compiled with the |+float| feature}
*type()*
type({expr}) The result is a Number representing the type of {expr}.
Instead of using the number directly, it is better to use the
-2
View File
@@ -54,7 +54,6 @@ Number A 32 or 64 bit signed number. |expr-number|
Examples: -123 0x10 0177 0o177 0b1011
Float A floating point number. |floating-point-format| *Float*
{only when compiled with the |+float| feature} *E1076*
Examples: 123.456 1.15e-6 -1.1e3
String A NUL terminated string of 8-bit unsigned characters (bytes).
@@ -1441,7 +1440,6 @@ digits are ignored.
{exp} is the exponent, power of 10.
Only a decimal point is accepted, not a comma. No matter what the current
locale is.
{only when compiled with the |+float| feature}
Examples:
123.456
+3 -3
View File
@@ -82,9 +82,9 @@ use of "-" and "_".
characters. This sets $LC_COLLATE.
Without an argument all are set, and additionally
$LANG is set.
When compiled with the |+float| feature the LC_NUMERIC
value will always be set to "C", so that floating
point numbers use '.' as the decimal point.
If available the LC_NUMERIC value will always be set
to "C", so that floating point numbers use '.' as the
decimal point.
This will make a difference for items that depend on
the language (some messages, time and date format).
Not fully supported on all systems
+1 -1
View File
@@ -381,7 +381,7 @@ N *+find_in_path* include file searches: |[I|, |:isearch|,
N *+folding* |folding|
*+footer* |gui-footer|
*+fork* Unix only: |fork| shell commands
*+float* Floating point support
T *+float* Floating point support Always enabled since 9.0.0491
N *+gettext* message translations |multi-lang|
- *+GUI_Athena* Unix only: Athena |GUI|
*+GUI_neXtaw* Unix only: neXtaw |GUI|
-42
View File
@@ -13379,48 +13379,6 @@ _ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strtod() and other floating point functions" >&5
$as_echo_n "checking for strtod() and other floating point functions... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef HAVE_MATH_H
# include <math.h>
#endif
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#endif
int
main ()
{
char *s; double d;
d = strtod("1.1", &s);
d = fabs(1.11);
d = ceil(1.11);
d = floor(1.11);
d = log10(1.11);
d = pow(1.11, 2.22);
d = sqrt(1.11);
d = sin(1.11);
d = cos(1.11);
d = atan(1.11);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }; $as_echo "#define HAVE_FLOAT_FUNCS 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isinf()" >&5
$as_echo_n "checking for isinf()... " >&6; }
-1
View File
@@ -157,7 +157,6 @@
#undef HAVE_FCHDIR
#undef HAVE_FCHOWN
#undef HAVE_FCHMOD
#undef HAVE_FLOAT_FUNCS
#undef HAVE_FSEEKO
#undef HAVE_FSYNC
#undef HAVE_FTRUNCATE
+1 -25
View File
@@ -3952,32 +3952,8 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([
AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
AC_MSG_RESULT(no))
dnl Need various functions for floating point support. Only enable
dnl floating point when they are all present.
dnl Floating point support may require the "m" library
AC_CHECK_LIB(m, strtod)
AC_MSG_CHECKING([for strtod() and other floating point functions])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#ifdef HAVE_MATH_H
# include <math.h>
#endif
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#endif
], [char *s; double d;
d = strtod("1.1", &s);
d = fabs(1.11);
d = ceil(1.11);
d = floor(1.11);
d = log10(1.11);
d = pow(1.11, 2.22);
d = sqrt(1.11);
d = sin(1.11);
d = cos(1.11);
d = atan(1.11);
])],
AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
AC_MSG_RESULT(no))
dnl isinf() and isnan() need to include header files and may need -lm.
AC_MSG_CHECKING([for isinf()])
-2
View File
@@ -984,13 +984,11 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
}
if (evaluate)
{
#ifdef FEAT_FLOAT
if (tvkey.v_type == VAR_FLOAT)
{
tvkey.vval.v_string = typval_tostring(&tvkey, TRUE);
tvkey.v_type = VAR_STRING;
}
#endif
key = tv_get_string_buf_chk(&tvkey, buf);
if (key == NULL)
{
+3 -16
View File
@@ -895,7 +895,7 @@ EXTERN char e_cannot_execute_shell_with_f_option[]
INIT(= N_("E360: Cannot execute shell with -f option"));
#endif
// E361 unused
#if defined(FEAT_EVAL) && defined(FEAT_FLOAT)
#if defined(FEAT_EVAL)
EXTERN char e_using_boolean_value_as_float[]
INIT(= N_("E362: Using a boolean value as a Float"));
#endif
@@ -2044,17 +2044,13 @@ EXTERN char e_cannot_use_percent_with_float[]
// xgettext:no-c-format
INIT(= N_("E804: Cannot use '%' with Float"));
#endif
#ifdef FEAT_FLOAT
EXTERN char e_using_float_as_number[]
INIT(= N_("E805: Using a Float as a Number"));
EXTERN char e_using_float_as_string[]
INIT(= N_("E806: Using a Float as a String"));
#endif
#ifdef FEAT_FLOAT
EXTERN char e_expected_float_argument_for_printf[]
INIT(= N_("E807: Expected Float argument for printf()"));
#endif
#if defined(FEAT_EVAL) && defined(FEAT_FLOAT)
#if defined(FEAT_EVAL)
EXTERN char e_number_or_float_required[]
INIT(= N_("E808: Number or Float required"));
#endif
@@ -2290,7 +2286,6 @@ EXTERN char e_number_required[]
EXTERN char e_trailing_char_after_rsb_str_str[]
INIT(= N_("E890: Trailing char after ']': %s]%s"));
#endif
#ifdef FEAT_FLOAT
EXTERN char e_using_funcref_as_float[]
INIT(= N_("E891: Using a Funcref as a Float"));
EXTERN char e_using_string_as_float[]
@@ -2299,7 +2294,6 @@ EXTERN char e_using_list_as_float[]
INIT(= N_("E893: Using a List as a Float"));
EXTERN char e_using_dictionary_as_float[]
INIT(= N_("E894: Using a Dictionary as a Float"));
#endif
#ifdef FEAT_MZSCHEME
EXTERN char e_sorry_this_command_is_disabled_the_mzscheme_racket_base_module_could_not_be_loaded[]
INIT(= N_("E895: Sorry, this command is disabled, the MzScheme's racket/base module could not be loaded."));
@@ -2340,10 +2334,8 @@ EXTERN char e_received_unknown_command_str[]
EXTERN char e_not_an_open_channel[]
INIT(= N_("E906: Not an open channel"));
#endif
#ifdef FEAT_FLOAT
EXTERN char e_using_special_value_as_float[]
INIT(= N_("E907: Using a special value as a Float"));
#endif
#ifdef FEAT_EVAL
EXTERN char e_using_invalid_value_as_string_str[]
INIT(= N_("E908: Using an invalid value as a String: %s"));
@@ -2537,10 +2529,8 @@ EXTERN char e_blob_literal_should_have_an_even_number_of_hex_characters[]
INIT(= N_("E973: Blob literal should have an even number of hex characters"));
EXTERN char e_using_blob_as_number[]
INIT(= N_("E974: Using a Blob as a Number"));
# ifdef FEAT_FLOAT
EXTERN char e_using_blob_as_float[]
INIT(= N_("E975: Using a Blob as a Float"));
# endif
EXTERN char e_using_blob_as_string[]
INIT(= N_("E976: Using a Blob as a String"));
EXTERN char e_can_only_compare_blob_with_blob[]
@@ -2775,10 +2765,7 @@ EXTERN char e_no_white_space_allowed_after_dot[]
INIT(= N_("E1074: No white space allowed after dot"));
EXTERN char e_namespace_not_supported_str[]
INIT(= N_("E1075: Namespace not supported: %s"));
# ifndef FEAT_FLOAT
EXTERN char e_this_vim_is_not_compiled_with_float_support[]
INIT(= N_("E1076: This Vim is not compiled with float support"));
# endif
// E1076 was deleted
EXTERN char e_missing_argument_type_for_str[]
INIT(= N_("E1077: Missing argument type for %s"));
#endif
+6 -59
View File
@@ -525,9 +525,7 @@ typval2string(typval_T *tv, int convert)
{
garray_T ga;
char_u *retval;
#ifdef FEAT_FLOAT
char_u numbuf[NUMBUFLEN];
#endif
if (convert && tv->v_type == VAR_LIST)
{
@@ -541,13 +539,11 @@ typval2string(typval_T *tv, int convert)
ga_append(&ga, NUL);
retval = (char_u *)ga.ga_data;
}
#ifdef FEAT_FLOAT
else if (convert && tv->v_type == VAR_FLOAT)
{
vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv->vval.v_float);
retval = vim_strsave(numbuf);
}
#endif
else
retval = vim_strsave(tv_get_string(tv));
return retval;
@@ -1683,7 +1679,6 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op)
{
// nr += nr , nr -= nr , nr *=nr , nr /= nr , nr %= nr
n = tv_get_number(tv1);
#ifdef FEAT_FLOAT
if (tv2->v_type == VAR_FLOAT)
{
float_T f = n;
@@ -1702,7 +1697,6 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op)
tv1->vval.v_float = f;
}
else
#endif
{
switch (*op)
{
@@ -1734,7 +1728,6 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op)
return failed ? FAIL : OK;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
{
float_T f;
@@ -1755,7 +1748,6 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op)
case '/': tv1->vval.v_float /= f; break;
}
}
#endif
return OK;
}
}
@@ -3238,9 +3230,7 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
}
if ((op != '+' || (rettv->v_type != VAR_LIST
&& rettv->v_type != VAR_BLOB))
#ifdef FEAT_FLOAT
&& (op == '.' || rettv->v_type != VAR_FLOAT)
#endif
&& evaluate)
{
int error = FALSE;
@@ -3293,14 +3283,12 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|| var2.v_type == VAR_JOB))
semsg(_(e_using_invalid_value_as_string_str),
vartype_name(var2.v_type));
#ifdef FEAT_FLOAT
else if (vim9script && var2.v_type == VAR_FLOAT)
{
vim_snprintf((char *)buf2, NUMBUFLEN, "%g",
var2.vval.v_float);
s2 = buf2;
}
#endif
else
s2 = tv_get_string_buf_chk(&var2, buf2);
if (s2 == NULL) // type error ?
@@ -3327,8 +3315,7 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
{
int error = FALSE;
varnumber_T n1, n2;
#ifdef FEAT_FLOAT
float_T f1 = 0, f2 = 0;
float_T f1 = 0, f2 = 0;
if (rettv->v_type == VAR_FLOAT)
{
@@ -3336,7 +3323,6 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
n1 = 0;
}
else
#endif
{
n1 = tv_get_number_chk(rettv, &error);
if (error)
@@ -3349,19 +3335,15 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
clear_tv(&var2);
return FAIL;
}
#ifdef FEAT_FLOAT
if (var2.v_type == VAR_FLOAT)
f1 = n1;
#endif
}
#ifdef FEAT_FLOAT
if (var2.v_type == VAR_FLOAT)
{
f2 = var2.vval.v_float;
n2 = 0;
}
else
#endif
{
n2 = tv_get_number_chk(&var2, &error);
if (error)
@@ -3370,14 +3352,11 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
clear_tv(&var2);
return FAIL;
}
#ifdef FEAT_FLOAT
if (rettv->v_type == VAR_FLOAT)
f2 = n2;
#endif
}
clear_tv(rettv);
#ifdef FEAT_FLOAT
// If there is a float on either side the result is a float.
if (rettv->v_type == VAR_FLOAT || var2.v_type == VAR_FLOAT)
{
@@ -3389,7 +3368,6 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
rettv->vval.v_float = f1;
}
else
#endif
{
if (op == '+')
n1 = n1 + n2;
@@ -3423,9 +3401,7 @@ eval7(
evalarg_T *evalarg,
int want_string) // after "." operator
{
#ifdef FEAT_FLOAT
int use_float = FALSE;
#endif
/*
* Get the first expression.
@@ -3444,9 +3420,7 @@ eval7(
char_u *p;
int op;
varnumber_T n1, n2;
#ifdef FEAT_FLOAT
float_T f1, f2;
#endif
int error;
// "*=", "/=" and "%=" are assignments
@@ -3469,14 +3443,11 @@ eval7(
*arg = p;
}
#ifdef FEAT_FLOAT
f1 = 0;
f2 = 0;
#endif
error = FALSE;
if (evaluate)
{
#ifdef FEAT_FLOAT
if (rettv->v_type == VAR_FLOAT)
{
f1 = rettv->vval.v_float;
@@ -3484,7 +3455,6 @@ eval7(
n1 = 0;
}
else
#endif
n1 = tv_get_number_chk(rettv, &error);
clear_tv(rettv);
if (error)
@@ -3508,7 +3478,6 @@ eval7(
if (evaluate)
{
#ifdef FEAT_FLOAT
if (var2.v_type == VAR_FLOAT)
{
if (!use_float)
@@ -3520,30 +3489,26 @@ eval7(
n2 = 0;
}
else
#endif
{
n2 = tv_get_number_chk(&var2, &error);
clear_tv(&var2);
if (error)
return FAIL;
#ifdef FEAT_FLOAT
if (use_float)
f2 = n2;
#endif
}
/*
* Compute the result.
* When either side is a float the result is a float.
*/
#ifdef FEAT_FLOAT
if (use_float)
{
if (op == '*')
f1 = f1 * f2;
else if (op == '/')
{
# ifdef VMS
#ifdef VMS
// VMS crashes on divide by zero, work around it
if (f2 == 0.0)
{
@@ -3556,11 +3521,11 @@ eval7(
}
else
f1 = f1 / f2;
# else
#else
// We rely on the floating point library to handle divide
// by zero to result in "inf" and not a crash.
f1 = f1 / f2;
# endif
#endif
}
else
{
@@ -3571,7 +3536,6 @@ eval7(
rettv->vval.v_float = f1;
}
else
#endif
{
int failed = FALSE;
@@ -3858,11 +3822,7 @@ eval9(
return FAIL;
end_leader = *arg;
if (**arg == '.' && (!isdigit(*(*arg + 1))
#ifdef FEAT_FLOAT
|| in_old_script(2)
#endif
))
if (**arg == '.' && (!isdigit(*(*arg + 1)) || in_old_script(2)))
{
semsg(_(e_invalid_expression_str), *arg);
++*arg;
@@ -4129,13 +4089,11 @@ eval9_leader(
varnumber_T val = 0;
vartype_T type = rettv->v_type;
int vim9script = in_vim9script();
#ifdef FEAT_FLOAT
float_T f = 0.0;
if (rettv->v_type == VAR_FLOAT)
f = rettv->vval.v_float;
else
#endif
{
while (VIM_ISWHITE(end_leader[-1]))
--end_leader;
@@ -4161,7 +4119,6 @@ eval9_leader(
++end_leader;
break;
}
#ifdef FEAT_FLOAT
if (rettv->v_type == VAR_FLOAT)
{
if (vim9script)
@@ -4173,7 +4130,6 @@ eval9_leader(
f = !f;
}
else
#endif
{
val = !val;
type = VAR_BOOL;
@@ -4181,25 +4137,21 @@ eval9_leader(
}
else if (*end_leader == '-')
{
#ifdef FEAT_FLOAT
if (rettv->v_type == VAR_FLOAT)
f = -f;
else
#endif
{
val = -val;
type = VAR_NUMBER;
}
}
}
#ifdef FEAT_FLOAT
if (rettv->v_type == VAR_FLOAT)
{
clear_tv(rettv);
rettv->vval.v_float = f;
}
else
#endif
{
clear_tv(rettv);
if (vim9script)
@@ -4500,7 +4452,6 @@ eval_index(
{
int error = FALSE;
#ifdef FEAT_FLOAT
// allow for indexing with float
if (vim9script && rettv->v_type == VAR_DICT
&& var1.v_type == VAR_FLOAT)
@@ -4508,7 +4459,7 @@ eval_index(
var1.vval.v_string = typval_tostring(&var1, TRUE);
var1.v_type = VAR_STRING;
}
#endif
if (vim9script && rettv->v_type == VAR_LIST)
tv_get_number_chk(&var1, &error);
else
@@ -4599,11 +4550,9 @@ check_can_index(typval_T *rettv, int evaluate, int verbose)
emsg(_(e_cannot_index_a_funcref));
return FAIL;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
if (verbose)
emsg(_(e_using_float_as_string));
return FAIL;
#endif
case VAR_BOOL:
case VAR_SPECIAL:
case VAR_JOB:
@@ -5696,12 +5645,10 @@ echo_string_core(
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
*tofree = NULL;
vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv->vval.v_float);
r = numbuf;
break;
#endif
case VAR_BOOL:
case VAR_SPECIAL:
+26 -39
View File
@@ -1512,12 +1512,7 @@ typedef struct
#define FEARG_3 3 // base is the third argument
#define FEARG_4 4 // base is the fourth argument
#ifdef FEAT_FLOAT
# define FLOAT_FUNC(name) name
#else
# define FLOAT_FUNC(name) NULL
#endif
#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
#if defined(HAVE_MATH_H)
# define MATH_FUNC(name) name
#else
# define MATH_FUNC(name) NULL
@@ -1556,9 +1551,9 @@ typedef struct
static funcentry_T global_functions[] =
{
{"abs", 1, 1, FEARG_1, arg1_float_or_nr,
ret_any, FLOAT_FUNC(f_abs)},
ret_any, f_abs},
{"acos", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_acos)},
ret_float, f_acos},
{"add", 2, 2, FEARG_1, arg2_listblob_item,
ret_first_arg, f_add},
{"and", 2, 2, FEARG_1, arg2_number,
@@ -1576,7 +1571,7 @@ static funcentry_T global_functions[] =
{"argv", 0, 2, 0, arg2_number,
ret_argv, f_argv},
{"asin", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_asin)},
ret_float, f_asin},
{"assert_beeps", 1, 1, FEARG_1, arg1_string,
ret_number_bool, f_assert_beeps},
{"assert_equal", 2, 3, FEARG_2, NULL,
@@ -1604,9 +1599,9 @@ static funcentry_T global_functions[] =
{"assert_true", 1, 2, FEARG_1, NULL,
ret_number_bool, f_assert_true},
{"atan", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_atan)},
ret_float, f_atan},
{"atan2", 2, 2, FEARG_1, arg2_float_or_nr,
ret_float, FLOAT_FUNC(f_atan2)},
ret_float, f_atan2},
{"autocmd_add", 1, 1, FEARG_1, arg1_list_any,
ret_number_bool, f_autocmd_add},
{"autocmd_delete", 1, 1, FEARG_1, arg1_list_any,
@@ -1676,7 +1671,7 @@ static funcentry_T global_functions[] =
{"call", 2, 3, FEARG_1, arg3_any_list_dict,
ret_any, f_call},
{"ceil", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_ceil)},
ret_float, f_ceil},
{"ch_canread", 1, 1, FEARG_1, arg1_chan_or_job,
ret_number_bool, JOB_FUNC(f_ch_canread)},
{"ch_close", 1, 1, FEARG_1, arg1_chan_or_job,
@@ -1744,9 +1739,9 @@ static funcentry_T global_functions[] =
{"copy", 1, 1, FEARG_1, NULL,
ret_copy, f_copy},
{"cos", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_cos)},
ret_float, f_cos},
{"cosh", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_cosh)},
ret_float, f_cosh},
{"count", 2, 4, FEARG_1, arg24_count,
ret_number, f_count},
{"cscope_connection",0,3, 0, arg3_number_string_string,
@@ -1804,7 +1799,7 @@ static funcentry_T global_functions[] =
{"exists_compiled", 1, 1, FEARG_1, arg1_string,
ret_number_bool, f_exists_compiled},
{"exp", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_exp)},
ret_float, f_exp},
{"expand", 1, 3, FEARG_1, arg3_string_bool_bool,
ret_any, f_expand},
{"expandcmd", 1, 2, FEARG_1, arg2_string_dict,
@@ -1832,11 +1827,11 @@ static funcentry_T global_functions[] =
{"flattennew", 1, 2, FEARG_1, arg2_list_any_number,
ret_list_any, f_flattennew},
{"float2nr", 1, 1, FEARG_1, arg1_float_or_nr,
ret_number, FLOAT_FUNC(f_float2nr)},
ret_number, f_float2nr},
{"floor", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_floor)},
ret_float, f_floor},
{"fmod", 2, 2, FEARG_1, arg2_float_or_nr,
ret_float, FLOAT_FUNC(f_fmod)},
ret_float, f_fmod},
{"fnameescape", 1, 1, FEARG_1, arg1_string,
ret_string, f_fnameescape},
{"fnamemodify", 2, 2, FEARG_1, arg2_string,
@@ -2088,9 +2083,9 @@ static funcentry_T global_functions[] =
{"localtime", 0, 0, 0, NULL,
ret_number, f_localtime},
{"log", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_log)},
ret_float, f_log},
{"log10", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_log10)},
ret_float, f_log10},
{"luaeval", 1, 2, FEARG_1, arg2_string_any,
ret_any,
#ifdef FEAT_LUA
@@ -2216,7 +2211,7 @@ static funcentry_T global_functions[] =
{"popup_show", 1, 1, FEARG_1, arg1_number,
ret_void, PROP_FUNC(f_popup_show)},
{"pow", 2, 2, FEARG_1, arg2_float_or_nr,
ret_float, FLOAT_FUNC(f_pow)},
ret_float, f_pow},
{"prevnonblank", 1, 1, FEARG_1, arg1_lnum,
ret_number, f_prevnonblank},
{"printf", 1, 19, FEARG_2, arg119_printf,
@@ -2300,7 +2295,7 @@ static funcentry_T global_functions[] =
{"reltime", 0, 2, FEARG_1, arg2_list_number,
ret_list_any, f_reltime},
{"reltimefloat", 1, 1, FEARG_1, arg1_list_number,
ret_float, FLOAT_FUNC(f_reltimefloat)},
ret_float, f_reltimefloat},
{"reltimestr", 1, 1, FEARG_1, arg1_list_number,
ret_string, f_reltimestr},
{"remote_expr", 2, 4, FEARG_1, arg24_remote_expr,
@@ -2326,7 +2321,7 @@ static funcentry_T global_functions[] =
{"reverse", 1, 1, FEARG_1, arg1_list_or_blob,
ret_first_arg, f_reverse},
{"round", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_round)},
ret_float, f_round},
{"rubyeval", 1, 1, FEARG_1, arg1_string,
ret_any,
#ifdef FEAT_RUBY
@@ -2438,9 +2433,9 @@ static funcentry_T global_functions[] =
{"simplify", 1, 1, FEARG_1, arg1_string,
ret_string, f_simplify},
{"sin", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_sin)},
ret_float, f_sin},
{"sinh", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_sinh)},
ret_float, f_sinh},
{"slice", 2, 3, FEARG_1, arg23_slice,
ret_slice, f_slice},
{"sort", 1, 3, FEARG_1, arg13_sortuniq,
@@ -2462,13 +2457,13 @@ static funcentry_T global_functions[] =
{"split", 1, 3, FEARG_1, arg3_string_string_bool,
ret_list_string, f_split},
{"sqrt", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_sqrt)},
ret_float, f_sqrt},
{"srand", 0, 1, FEARG_1, arg1_number,
ret_list_number, f_srand},
{"state", 0, 1, FEARG_1, arg1_string,
ret_string, f_state},
{"str2float", 1, 2, FEARG_1, arg2_string_bool,
ret_float, FLOAT_FUNC(f_str2float)},
ret_float, f_str2float},
{"str2list", 1, 2, FEARG_1, arg2_string_bool,
ret_list_number, f_str2list},
{"str2nr", 1, 3, FEARG_1, arg3_string_number_bool,
@@ -2546,9 +2541,9 @@ static funcentry_T global_functions[] =
{"taglist", 1, 2, FEARG_1, arg2_string,
ret_list_dict_any, f_taglist},
{"tan", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_tan)},
ret_float, f_tan},
{"tanh", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_tanh)},
ret_float, f_tanh},
{"tempname", 0, 0, 0, NULL,
ret_string, f_tempname},
{"term_dumpdiff", 2, 3, FEARG_1, arg3_string_string_dict,
@@ -2680,7 +2675,7 @@ static funcentry_T global_functions[] =
{"trim", 1, 3, FEARG_1, arg3_string_string_number,
ret_string, f_trim},
{"trunc", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_trunc)},
ret_float, f_trunc},
{"type", 1, 1, FEARG_1, NULL,
ret_number, f_type},
{"typename", 1, 1, FEARG_1, NULL,
@@ -3670,10 +3665,8 @@ f_empty(typval_T *argvars, typval_T *rettv)
n = argvars[0].vval.v_number == 0;
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
n = argvars[0].vval.v_float == 0.0;
break;
#endif
case VAR_LIST:
n = argvars[0].vval.v_list == NULL
|| argvars[0].vval.v_list->lv_len == 0;
@@ -5644,13 +5637,7 @@ f_has(typval_T *argvars, typval_T *rettv)
0
#endif
},
{"float",
#ifdef FEAT_FLOAT
1
#else
0
#endif
},
{"float", 1},
{"folding",
#ifdef FEAT_FOLDING
1
+2 -20
View File
@@ -14,9 +14,7 @@
#include "vim.h"
#include "version.h"
#ifdef FEAT_FLOAT
# include <float.h>
#endif
#include <float.h>
static int linelen(int *has_tab);
static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd, int do_in, int do_out);
@@ -275,9 +273,7 @@ static int sort_lc; // sort using locale
static int sort_ic; // ignore case
static int sort_nr; // sort on number
static int sort_rx; // sort on regex instead of skipping it
#ifdef FEAT_FLOAT
static int sort_flt; // sort on floating number
#endif
static int sort_abort; // flag to indicate if sorting has been interrupted
@@ -296,9 +292,7 @@ typedef struct
varnumber_T value; // value if sorting by integer
int is_number; // TRUE when line contains a number
} num;
#ifdef FEAT_FLOAT
float_T value_flt; // value if sorting by float
#endif
} st_u;
} sorti_T;
@@ -334,11 +328,9 @@ sort_compare(const void *s1, const void *s2)
result = l1.st_u.num.value == l2.st_u.num.value ? 0
: l1.st_u.num.value > l2.st_u.num.value ? 1 : -1;
}
#ifdef FEAT_FLOAT
else if (sort_flt)
result = l1.st_u.value_flt == l2.st_u.value_flt ? 0
: l1.st_u.value_flt > l2.st_u.value_flt ? 1 : -1;
#endif
else
{
// We need to copy one line into "sortbuf1", because there is no
@@ -399,9 +391,7 @@ ex_sort(exarg_T *eap)
goto sortend;
sort_abort = sort_ic = sort_lc = sort_rx = sort_nr = 0;
#ifdef FEAT_FLOAT
sort_flt = 0;
#endif
for (p = eap->arg; *p != NUL; ++p)
{
@@ -418,13 +408,11 @@ ex_sort(exarg_T *eap)
sort_nr = 1;
++format_found;
}
#ifdef FEAT_FLOAT
else if (*p == 'f')
{
sort_flt = 1;
++format_found;
}
#endif
else if (*p == 'b')
{
sort_what = STR2NR_BIN + STR2NR_FORCE;
@@ -521,11 +509,7 @@ ex_sort(exarg_T *eap)
if (regmatch.regprog != NULL)
end_col = 0;
if (sort_nr
#ifdef FEAT_FLOAT
|| sort_flt
#endif
)
if (sort_nr || sort_flt)
{
// Make sure vim_str2nr doesn't read any digits past the end
// of the match, by temporarily terminating the string there
@@ -558,7 +542,6 @@ ex_sort(exarg_T *eap)
NULL, 0, FALSE);
}
}
#ifdef FEAT_FLOAT
else
{
s = skipwhite(p);
@@ -572,7 +555,6 @@ ex_sort(exarg_T *eap)
nrs[lnum - eap->line1].st_u.value_flt =
strtod((char *)s, NULL);
}
#endif
*s2 = c;
}
else
+1 -4
View File
@@ -121,6 +121,7 @@
* +wildignore 'wildignore' and 'backupskip' options
* +wildmenu 'wildmenu' option
* +builtin_terms all builtin termcap entries included
* +float Floating point variables.
*
* Obsolete:
* +tag_old_static Old style static tags: "file:tag file ..".
@@ -251,13 +252,9 @@
/*
* +eval Built-in script language and expression evaluation,
* ":let", ":if", etc.
* +float Floating point variables.
*/
#ifdef FEAT_NORMAL
# define FEAT_EVAL
# if defined(HAVE_FLOAT_FUNCS) || defined(MSWIN) || defined(MACOS_X)
# define FEAT_FLOAT
# endif
#endif
#ifdef FEAT_EVAL
+1 -1
View File
@@ -14,7 +14,7 @@
#include "vim.h"
#if (defined(FEAT_EVAL) && defined(FEAT_FLOAT)) || defined(PROTO)
#if defined(FEAT_EVAL) || defined(PROTO)
#ifdef VMS
# include <float.h>
+1 -1
View File
@@ -3598,7 +3598,7 @@ gui_mch_init(void)
{
gnome_program_init(VIMPACKAGE, VIM_VERSION_SHORT,
LIBGNOMEUI_MODULE, gui_argc, gui_argv, NULL);
# if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
# if defined(LC_NUMERIC)
{
char *p = setlocale(LC_NUMERIC, NULL);
+1 -1
View File
@@ -1184,7 +1184,7 @@ gui_mch_init_check(void)
cmdline_options, XtNumber(cmdline_options),
CARDINAL &gui_argc, gui_argv);
# if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
# if defined(LC_NUMERIC)
{
// The call to XtOpenDisplay() may have set the locale from the
// environment. Set LC_NUMERIC to "C" to make sure that strtod() uses a
-7
View File
@@ -559,11 +559,9 @@ luaV_pushtypval(lua_State *L, typval_T *tv)
case VAR_NUMBER:
lua_pushinteger(L, (int) tv->vval.v_number);
break;
#ifdef FEAT_FLOAT
case VAR_FLOAT:
lua_pushnumber(L, (lua_Number) tv->vval.v_float);
break;
#endif
case VAR_LIST:
luaV_pushlist(L, tv->vval.v_list);
break;
@@ -619,7 +617,6 @@ luaV_totypval(lua_State *L, int pos, typval_T *tv)
tv->vval.v_string = vim_strsave((char_u *) lua_tostring(L, pos));
break;
case LUA_TNUMBER:
#ifdef FEAT_FLOAT
{
const lua_Number n = lua_tonumber(L, pos);
@@ -635,10 +632,6 @@ luaV_totypval(lua_State *L, int pos, typval_T *tv)
tv->vval.v_number = (varnumber_T)n;
}
}
#else
tv->v_type = VAR_NUMBER;
tv->vval.v_number = (varnumber_T) lua_tointeger(L, pos);
#endif
break;
case LUA_TFUNCTION:
{
-4
View File
@@ -3009,13 +3009,11 @@ vim_to_mzscheme_impl(typval_T *vim_value, int depth, Scheme_Hash_Table *visited)
result = scheme_make_integer((long)vim_value->vval.v_number);
MZ_GC_CHECK();
}
# ifdef FEAT_FLOAT
else if (vim_value->v_type == VAR_FLOAT)
{
result = scheme_make_double((double)vim_value->vval.v_float);
MZ_GC_CHECK();
}
# endif
else if (vim_value->v_type == VAR_LIST)
{
list_T *list = vim_value->vval.v_list;
@@ -3208,13 +3206,11 @@ mzscheme_to_vim_impl(Scheme_Object *obj, typval_T *tv, int depth,
tv->v_type = VAR_BOOL;
tv->vval.v_number = SCHEME_TRUEP(obj);
}
# ifdef FEAT_FLOAT
else if (SCHEME_DBLP(obj))
{
tv->v_type = VAR_FLOAT;
tv->vval.v_float = SCHEME_DBL_VAL(obj);
}
# endif
else if (SCHEME_BYTE_STRINGP(obj))
{
tv->v_type = VAR_STRING;
-6
View File
@@ -761,7 +761,6 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookup_dict)
sprintf(buf, "%ld", (long)our_tv->vval.v_number);
ret = PyString_FromString((char *)buf);
}
#ifdef FEAT_FLOAT
else if (our_tv->v_type == VAR_FLOAT)
{
char buf[NUMBUFLEN];
@@ -769,7 +768,6 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookup_dict)
sprintf(buf, "%f", our_tv->vval.v_float);
ret = PyString_FromString((char *)buf);
}
#endif
else if (our_tv->v_type == VAR_LIST)
{
list_T *list = our_tv->vval.v_list;
@@ -6329,13 +6327,11 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookup_dict)
}
else if (PyDict_Check(obj))
return convert_dl(obj, tv, pydict_to_tv, lookup_dict);
#ifdef FEAT_FLOAT
else if (PyFloat_Check(obj))
{
tv->v_type = VAR_FLOAT;
tv->vval.v_float = (float_T) PyFloat_AsDouble(obj);
}
#endif
else if (PyObject_HasAttrString(obj, "keys"))
return convert_dl(obj, tv, pymap_to_tv, lookup_dict);
// PyObject_GetIter can create built-in iterator for any sequence object
@@ -6388,9 +6384,7 @@ ConvertToPyObject(typval_T *tv)
case VAR_NUMBER:
return PyLong_FromLong((long) tv->vval.v_number);
case VAR_FLOAT:
#ifdef FEAT_FLOAT
return PyFloat_FromDouble((double) tv->vval.v_float);
#endif
case VAR_LIST:
return NEW_LIST(tv->vval.v_list);
case VAR_DICT:
-4
View File
@@ -1221,12 +1221,10 @@ vim_to_ruby(typval_T *tv)
{
result = INT2NUM(tv->vval.v_number);
}
# ifdef FEAT_FLOAT
else if (tv->v_type == VAR_FLOAT)
{
result = rb_float_new(tv->vval.v_float);
}
# endif
else if (tv->v_type == VAR_LIST)
{
list_T *list = tv->vval.v_list;
@@ -1932,12 +1930,10 @@ ruby_convert_to_vim_value(VALUE val, typval_T *rettv)
rettv->v_type = VAR_NUMBER;
rettv->vval.v_number = (varnumber_T)NUM2LONG(val);
break;
#ifdef FEAT_FLOAT
case T_FLOAT:
rettv->v_type = VAR_FLOAT;
rettv->vval.v_float = (float_T)NUM2DBL(val);
break;
#endif
default:
val = rb_obj_as_string(val);
// FALLTHROUGH
+9 -16
View File
@@ -409,8 +409,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
# if defined(HAVE_MATH_H)
#if defined(HAVE_MATH_H)
if (isnan(val->vval.v_float))
ga_concat(gap, (char_u *)"NaN");
else if (isinf(val->vval.v_float))
@@ -421,14 +420,13 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
ga_concat(gap, (char_u *)"Infinity");
}
else
# endif
#endif
{
vim_snprintf((char *)numbuf, NUMBUFLEN, "%g",
val->vval.v_float);
ga_concat(gap, numbuf);
}
break;
#endif
case VAR_UNKNOWN:
case VAR_ANY:
case VAR_VOID:
@@ -861,7 +859,6 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
}
}
sp = skipdigits(sp);
#ifdef FEAT_FLOAT
if (*sp == '.' || *sp == 'e' || *sp == 'E')
{
if (cur_item == NULL)
@@ -878,7 +875,6 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
}
}
else
#endif
{
varnumber_T nr;
@@ -934,7 +930,6 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
retval = OK;
break;
}
#ifdef FEAT_FLOAT
if (STRNICMP((char *)p, "NaN", 3) == 0)
{
reader->js_used += 3;
@@ -968,19 +963,19 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
retval = OK;
break;
}
#endif
// check for truncated name
len = (int)(reader->js_end
- (reader->js_buf + reader->js_used));
if (
(len < 5 && STRNICMP((char *)p, "false", len) == 0)
#ifdef FEAT_FLOAT
|| (len < 9 && STRNICMP((char *)p, "-Infinity", len) == 0)
|| (len < 8 && STRNICMP((char *)p, "Infinity", len) == 0)
|| (len < 9
&& STRNICMP((char *)p, "-Infinity", len) == 0)
|| (len < 8
&& STRNICMP((char *)p, "Infinity", len) == 0)
|| (len < 3 && STRNICMP((char *)p, "NaN", len) == 0)
#endif
|| (len < 4 && (STRNICMP((char *)p, "true", len) == 0
|| STRNICMP((char *)p, "null", len) == 0)))
|| (len < 4
&& (STRNICMP((char *)p, "true", len) == 0
|| STRNICMP((char *)p, "null", len) == 0)))
retval = MAYBE;
else
@@ -998,7 +993,6 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
if (top_item != NULL && top_item->jd_type == JSON_OBJECT_KEY
&& cur_item != NULL)
{
#ifdef FEAT_FLOAT
if (cur_item->v_type == VAR_FLOAT)
{
// cannot use a float as a key
@@ -1006,7 +1000,6 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
retval = FAIL;
goto theend;
}
#endif
top_item->jd_key = tv_get_string_buf_chk(cur_item, key_buf);
if (top_item->jd_key == NULL)
{
-8
View File
@@ -1876,9 +1876,7 @@ typedef struct
int item_compare_lc;
int item_compare_numeric;
int item_compare_numbers;
#ifdef FEAT_FLOAT
int item_compare_float;
#endif
char_u *item_compare_func;
partial_T *item_compare_partial;
dict_T *item_compare_selfdict;
@@ -1915,7 +1913,6 @@ item_compare(const void *s1, const void *s2)
return v1 == v2 ? 0 : v1 > v2 ? 1 : -1;
}
#ifdef FEAT_FLOAT
if (sortinfo->item_compare_float)
{
float_T v1 = tv_get_float(tv1);
@@ -1923,7 +1920,6 @@ item_compare(const void *s1, const void *s2)
return v1 == v2 ? 0 : v1 > v2 ? 1 : -1;
}
#endif
// tv2string() puts quotes around a string and allocates memory. Don't do
// that for string variables. Use a single quote when comparing with a
@@ -2160,9 +2156,7 @@ parse_sort_uniq_args(typval_T *argvars, sortinfo_T *info)
info->item_compare_lc = FALSE;
info->item_compare_numeric = FALSE;
info->item_compare_numbers = FALSE;
#ifdef FEAT_FLOAT
info->item_compare_float = FALSE;
#endif
info->item_compare_func = NULL;
info->item_compare_partial = NULL;
info->item_compare_selfdict = NULL;
@@ -2215,13 +2209,11 @@ parse_sort_uniq_args(typval_T *argvars, sortinfo_T *info)
info->item_compare_func = NULL;
info->item_compare_numbers = TRUE;
}
#ifdef FEAT_FLOAT
else if (STRCMP(info->item_compare_func, "f") == 0)
{
info->item_compare_func = NULL;
info->item_compare_float = TRUE;
}
#endif
else if (STRCMP(info->item_compare_func, "i") == 0)
{
info->item_compare_func = NULL;
+2 -2
View File
@@ -225,7 +225,7 @@ init_locale(void)
// Tell Gtk not to change our locale settings.
gtk_disable_setlocale();
# endif
# if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
# if defined(LC_NUMERIC)
// Make sure strtod() uses a decimal point, not a comma.
setlocale(LC_NUMERIC, "C");
# endif
@@ -333,7 +333,7 @@ ex_language(exarg_T *eap)
# endif
{
loc = setlocale(what, (char *)name);
# if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
# if defined(LC_NUMERIC)
// Make sure strtod() uses a decimal point, not a comma.
setlocale(LC_NUMERIC, "C");
# endif
+1 -1
View File
@@ -261,7 +261,7 @@
# define MESSAGE_QUEUE
#endif
#if defined(FEAT_EVAL) && defined(FEAT_FLOAT)
#if defined(FEAT_EVAL)
# include <float.h>
# if defined(HAVE_MATH_H)
// for isnan() and isinf()
-2
View File
@@ -211,7 +211,6 @@ test_vim_snprintf(void)
assert(bsize == 0 || STRNCMP(buf, "001100", bsize_int) == 0);
assert(bsize == 0 || buf[MIN(n, bsize_int)] == '\0');
#ifdef FEAT_FLOAT
n = vim_snprintf(buf, bsize, "%f", 1.234);
assert(n == 8);
assert(bsize == 0 || STRNCMP(buf, "1.234000", bsize_int) == 0);
@@ -241,7 +240,6 @@ test_vim_snprintf(void)
assert(n == 9);
assert(bsize == 0 || STRNCMP(buf, "-0.000000", bsize_int) == 0);
assert(bsize == 0 || buf[MIN(n, bsize_int)] == '\0');
#endif
n = vim_snprintf(buf, bsize, "%s", "漢語");
assert(n == 6);
+1 -1
View File
@@ -585,7 +585,7 @@ mac_lang_init(void)
# ifdef HAVE_LOCALE_H
setlocale(LC_ALL, "");
# endif
# if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
# if defined(LC_NUMERIC)
// Make sure strtod() uses a decimal point, not a comma.
setlocale(LC_NUMERIC, "C");
# endif
-1
View File
@@ -110,7 +110,6 @@
#define HAVE_SETENV
#define HAVE_SETJMP_H
#define HAVE_MATH_H
#define HAVE_FLOAT_FUNCS
#define HAVE_GETTIMEOFDAY
#define HAVE_PWD_H
#define HAVE_NETDB_H
+4 -6
View File
@@ -90,23 +90,21 @@ profile_msg(proftime_T *tm)
return buf;
}
# if defined(FEAT_FLOAT) || defined(PROTO)
/*
* Return a float that represents the time in "tm".
*/
float_T
profile_float(proftime_T *tm)
{
# ifdef MSWIN
# ifdef MSWIN
LARGE_INTEGER fr;
QueryPerformanceFrequency(&fr);
return (float_T)tm->QuadPart / (float_T)fr.QuadPart;
# else
# else
return (float_T)tm->tv_sec + (float_T)tm->tv_usec / 1000000.0;
# endif
}
# endif
}
/*
* Put the time "msec" past now in "tm".
@@ -173,7 +171,7 @@ profile_zero(proftime_T *tm)
# endif // FEAT_PROFILE || FEAT_RELTIME
#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) && defined(FEAT_FLOAT) && defined(FEAT_PROFILE)
#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) && defined(FEAT_PROFILE)
# if defined(HAVE_MATH_H)
# include <math.h>
# endif
-2
View File
@@ -577,7 +577,6 @@ store_session_globals(FILE *fd)
}
vim_free(p);
}
#ifdef FEAT_FLOAT
else if (this_var->di_tv.v_type == VAR_FLOAT
&& var_flavour(this_var->di_key) == VAR_FLAVOUR_SESSION)
{
@@ -594,7 +593,6 @@ store_session_globals(FILE *fd)
|| put_eol(fd) == FAIL)
return FAIL;
}
#endif
}
}
return OK;
+6 -16
View File
@@ -1895,7 +1895,6 @@ tv_str(typval_T *tvs, int *idxp, char_u **tofree)
return s;
}
# ifdef FEAT_FLOAT
/*
* Get float argument from "idxp" entry in "tvs". First entry is 1.
*/
@@ -1919,11 +1918,9 @@ tv_float(typval_T *tvs, int *idxp)
}
return f;
}
# endif
#endif
#ifdef FEAT_FLOAT
/*
* Return the representation of infinity for printf() function:
* "-inf", "inf", "+inf", " inf", "-INF", "INF", "+INF" or " INF".
@@ -1945,7 +1942,6 @@ infinity_str(int positive,
idx += 4;
return table[idx];
}
#endif
/*
* This code was included to provide a portable vsnprintf() and snprintf().
@@ -2079,13 +2075,9 @@ vim_vsnprintf_typval(
char length_modifier = '\0';
// temporary buffer for simple numeric->string conversion
# if defined(FEAT_FLOAT)
# define TMP_LEN 350 // On my system 1e308 is the biggest number possible.
# define TMP_LEN 350 // On my system 1e308 is the biggest number possible.
// That sounds reasonable to use as the maximum
// printable.
# else
# define TMP_LEN 66
# endif
char tmp[TMP_LEN];
// string address in case of string argument
@@ -2637,7 +2629,6 @@ vim_vsnprintf_typval(
break;
}
# ifdef FEAT_FLOAT
case 'f':
case 'F':
case 'e':
@@ -2653,9 +2644,9 @@ vim_vsnprintf_typval(
int remove_trailing_zeroes = FALSE;
f =
# if defined(FEAT_EVAL)
# if defined(FEAT_EVAL)
tvs != NULL ? tv_float(tvs, &arg_idx) :
# endif
# endif
va_arg(ap, double);
abs_f = f < 0 ? -f : f;
@@ -2672,11 +2663,11 @@ vim_vsnprintf_typval(
}
if ((fmt_spec == 'f' || fmt_spec == 'F') &&
# ifdef VAX
# ifdef VAX
abs_f > 1.0e38
# else
# else
abs_f > 1.0e307
# endif
# endif
)
{
// Avoid a buffer overflow
@@ -2801,7 +2792,6 @@ vim_vsnprintf_typval(
str_arg = tmp;
break;
}
# endif
default:
// unrecognized conversion specifier, keep format string
-2
View File
@@ -1460,9 +1460,7 @@ typedef struct
union
{
varnumber_T v_number; // number value
#ifdef FEAT_FLOAT
float_T v_float; // floating number value
#endif
char_u *v_string; // string value (can be NULL!)
list_T *v_list; // list value (can be NULL!)
dict_T *v_dict; // dict value (can be NULL!)
+2 -4
View File
@@ -6694,7 +6694,7 @@ syntime_report(void)
{
int idx;
synpat_T *spp;
# if defined(FEAT_RELTIME) && defined(FEAT_FLOAT)
# if defined(FEAT_RELTIME)
proftime_T tm;
# endif
int len;
@@ -6724,7 +6724,7 @@ syntime_report(void)
p->match = spp->sp_time.match;
total_count += spp->sp_time.count;
p->slowest = spp->sp_time.slowest;
# if defined(FEAT_RELTIME) && defined(FEAT_FLOAT)
# if defined(FEAT_RELTIME)
profile_divide(&spp->sp_time.total, spp->sp_time.count, &tm);
p->average = tm;
# endif
@@ -6758,10 +6758,8 @@ syntime_report(void)
msg_puts(profile_msg(&p->slowest));
msg_puts(" ");
msg_advance(38);
# ifdef FEAT_FLOAT
msg_puts(profile_msg(&p->average));
msg_puts(" ");
# endif
msg_advance(50);
msg_outtrans(highlight_group_name(p->id - 1));
msg_puts(" ");
+2 -2
View File
@@ -283,11 +283,11 @@ func RunTheTest(test)
if has('reltime')
let message ..= repeat(' ', 50 - len(message))
let time = reltime(func_start)
if has('float') && reltimefloat(time) > 0.1
if reltimefloat(time) > 0.1
let message = s:t_bold .. message
endif
let message ..= ' in ' .. reltimestr(time) .. ' seconds'
if has('float') && reltimefloat(time) > 0.1
if reltimefloat(time) > 0.1
let message ..= s:t_normal
endif
endif
+12 -14
View File
@@ -352,21 +352,19 @@ func Test_assert_inrange()
call assert_fails('call assert_inrange(1, 1)', 'E119:')
if has('float')
call assert_equal(0, assert_inrange(7.0, 7, 7))
call assert_equal(0, assert_inrange(7, 7.0, 7))
call assert_equal(0, assert_inrange(7, 7, 7.0))
call assert_equal(0, assert_inrange(5, 7, 5.0))
call assert_equal(0, assert_inrange(5, 7, 6.0))
call assert_equal(0, assert_inrange(5, 7, 7.0))
call assert_equal(0, assert_inrange(7.0, 7, 7))
call assert_equal(0, assert_inrange(7, 7.0, 7))
call assert_equal(0, assert_inrange(7, 7, 7.0))
call assert_equal(0, assert_inrange(5, 7, 5.0))
call assert_equal(0, assert_inrange(5, 7, 6.0))
call assert_equal(0, assert_inrange(5, 7, 7.0))
call assert_equal(1, assert_inrange(5, 7, 4.0))
call assert_match("Expected range 5.0 - 7.0, but got 4.0", v:errors[0])
call remove(v:errors, 0)
call assert_equal(1, assert_inrange(5, 7, 8.0))
call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0])
call remove(v:errors, 0)
endif
call assert_equal(1, assert_inrange(5, 7, 4.0))
call assert_match("Expected range 5.0 - 7.0, but got 4.0", v:errors[0])
call remove(v:errors, 0)
call assert_equal(1, assert_inrange(5, 7, 8.0))
call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0])
call remove(v:errors, 0)
endfunc
func Test_assert_with_msg()
+1 -3
View File
@@ -669,9 +669,7 @@ func Test_blob_lock()
endfunc
func Test_blob_sort()
if has('float')
call v9.CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:')
endif
call v9.CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:')
call v9.CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:')
endfunc
+17 -19
View File
@@ -122,25 +122,23 @@ func Test_cscopeWithCscopeConnections()
call assert_fails('cs find', 'E560:')
call assert_fails('cs find x', 'E560:')
if has('float')
" Test: Find places where this symbol is assigned a value
" this needs a cscope >= 15.8
" unfortunately, Travis has cscope version 15.7
let cscope_version = systemlist('cscope --version')[0]
let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
if cs_version >= 15.8
for cmd in ['cs find a item', 'cs find 9 item']
let a = execute(cmd)
call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = LALLOC_CLEAR_ONE(mf_hashitem_T);'], split(a, '\n', 1))
call assert_equal(' item = LALLOC_CLEAR_ONE(mf_hashitem_T);', getline('.'))
cnext
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
cnext
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
cnext
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
endfor
endif
" Test: Find places where this symbol is assigned a value
" this needs a cscope >= 15.8
" unfortunately, Travis has cscope version 15.7
let cscope_version = systemlist('cscope --version')[0]
let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
if cs_version >= 15.8
for cmd in ['cs find a item', 'cs find 9 item']
let a = execute(cmd)
call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = LALLOC_CLEAR_ONE(mf_hashitem_T);'], split(a, '\n', 1))
call assert_equal(' item = LALLOC_CLEAR_ONE(mf_hashitem_T);', getline('.'))
cnext
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
cnext
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
cnext
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
endfor
endif
" Test: leading whitespace is not removed for cscope find text
+6 -12
View File
@@ -240,11 +240,9 @@ func Test_string_concatenation()
let a..=b
call assert_equal('ab', a)
if has('float')
let a = 'A'
let b = 1.234
call assert_equal('A1.234', a .. b)
endif
let a = 'A'
let b = 1.234
call assert_equal('A1.234', a .. b)
endfunc
" Test fix for issue #4507
@@ -266,10 +264,8 @@ func Test_string_concat_scriptversion2()
call assert_fails('let a .= b', 'E985:')
call assert_fails('let vers = 1.2.3', 'E488:')
if has('float')
let f = .5
call assert_equal(0.5, f)
endif
let f = .5
call assert_equal(0.5, f)
endfunc
scriptversion 1
@@ -283,9 +279,7 @@ func Test_string_concat_scriptversion1()
let vers = 1.2.3
call assert_equal('123', vers)
if has('float')
call assert_fails('let f = .5', 'E15:')
endif
call assert_fails('let f = .5', 'E15:')
endfunc
scriptversion 3
+3 -5
View File
@@ -38,11 +38,9 @@ func Test_execute_string()
call assert_equal("\nsomething", execute('echo "something"', 'silent'))
call assert_equal("\nsomething", execute('echo "something"', 'silent!'))
call assert_equal("", execute('burp', 'silent!'))
if has('float')
call assert_fails('call execute(3.4)', 'E492:')
call assert_equal("\nx", execute("echo \"x\"", 3.4))
call v9.CheckDefExecAndScriptFailure(['execute("echo \"x\"", 3.4)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1174:'])
endif
call assert_fails('call execute(3.4)', 'E492:')
call assert_equal("\nx", execute("echo \"x\"", 3.4))
call v9.CheckDefExecAndScriptFailure(['execute("echo \"x\"", 3.4)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1174:'])
endfunc
func Test_execute_list()
+109 -123
View File
@@ -77,9 +77,7 @@ func Test_op_falsy()
call assert_equal(0z00, 0z00 ?? 456)
call assert_equal([1], [1] ?? 456)
call assert_equal({'one': 1}, {'one': 1} ?? 456)
if has('float')
call assert_equal(0.1, 0.1 ?? 456)
endif
call assert_equal(0.1, 0.1 ?? 456)
call assert_equal(456, v:false ?? 456)
call assert_equal(456, 0 ?? 456)
@@ -87,9 +85,7 @@ func Test_op_falsy()
call assert_equal(456, 0z ?? 456)
call assert_equal(456, [] ?? 456)
call assert_equal(456, {} ?? 456)
if has('float')
call assert_equal(456, 0.0 ?? 456)
endif
call assert_equal(456, 0.0 ?? 456)
END
call v9.CheckLegacyAndVim9Success(lines)
endfunc
@@ -200,10 +196,8 @@ func Test_compare_with_null()
call assert_false(s:value == v:null)
let s:value = 0
call assert_true(s:value == v:null)
if has('float')
let s:value = 0.0
call assert_true(s:value == v:null)
endif
let s:value = 0.0
call assert_true(s:value == v:null)
let s:value = ''
call assert_false(s:value == v:null)
let s:value = 0z
@@ -467,116 +461,114 @@ func Test_printf_misc()
endfunc
func Test_printf_float()
if has('float')
let lines =<< trim END
call assert_equal('1.000000', printf('%f', 1))
call assert_equal('1.230000', printf('%f', 1.23))
call assert_equal('1.230000', printf('%F', 1.23))
call assert_equal('9999999.9', printf('%g', 9999999.9))
call assert_equal('9999999.9', printf('%G', 9999999.9))
call assert_equal('1.00000001e7', printf('%.8g', 10000000.1))
call assert_equal('1.00000001E7', printf('%.8G', 10000000.1))
call assert_equal('1.230000e+00', printf('%e', 1.23))
call assert_equal('1.230000E+00', printf('%E', 1.23))
call assert_equal('1.200000e-02', printf('%e', 0.012))
call assert_equal('-1.200000e-02', printf('%e', -0.012))
call assert_equal('0.33', printf('%.2f', 1.0 / 3.0))
call assert_equal(' 0.33', printf('%6.2f', 1.0 / 3.0))
call assert_equal(' -0.33', printf('%6.2f', -1.0 / 3.0))
call assert_equal('000.33', printf('%06.2f', 1.0 / 3.0))
call assert_equal('-00.33', printf('%06.2f', -1.0 / 3.0))
call assert_equal('-00.33', printf('%+06.2f', -1.0 / 3.0))
call assert_equal('+00.33', printf('%+06.2f', 1.0 / 3.0))
call assert_equal(' 00.33', printf('% 06.2f', 1.0 / 3.0))
call assert_equal('000.33', printf('%06.2g', 1.0 / 3.0))
call assert_equal('-00.33', printf('%06.2g', -1.0 / 3.0))
call assert_equal('0.33', printf('%3.2f', 1.0 / 3.0))
call assert_equal('003.33e-01', printf('%010.2e', 1.0 / 3.0))
call assert_equal(' 03.33e-01', printf('% 010.2e', 1.0 / 3.0))
call assert_equal('+03.33e-01', printf('%+010.2e', 1.0 / 3.0))
call assert_equal('-03.33e-01', printf('%010.2e', -1.0 / 3.0))
let lines =<< trim END
call assert_equal('1.000000', printf('%f', 1))
call assert_equal('1.230000', printf('%f', 1.23))
call assert_equal('1.230000', printf('%F', 1.23))
call assert_equal('9999999.9', printf('%g', 9999999.9))
call assert_equal('9999999.9', printf('%G', 9999999.9))
call assert_equal('1.00000001e7', printf('%.8g', 10000000.1))
call assert_equal('1.00000001E7', printf('%.8G', 10000000.1))
call assert_equal('1.230000e+00', printf('%e', 1.23))
call assert_equal('1.230000E+00', printf('%E', 1.23))
call assert_equal('1.200000e-02', printf('%e', 0.012))
call assert_equal('-1.200000e-02', printf('%e', -0.012))
call assert_equal('0.33', printf('%.2f', 1.0 / 3.0))
call assert_equal(' 0.33', printf('%6.2f', 1.0 / 3.0))
call assert_equal(' -0.33', printf('%6.2f', -1.0 / 3.0))
call assert_equal('000.33', printf('%06.2f', 1.0 / 3.0))
call assert_equal('-00.33', printf('%06.2f', -1.0 / 3.0))
call assert_equal('-00.33', printf('%+06.2f', -1.0 / 3.0))
call assert_equal('+00.33', printf('%+06.2f', 1.0 / 3.0))
call assert_equal(' 00.33', printf('% 06.2f', 1.0 / 3.0))
call assert_equal('000.33', printf('%06.2g', 1.0 / 3.0))
call assert_equal('-00.33', printf('%06.2g', -1.0 / 3.0))
call assert_equal('0.33', printf('%3.2f', 1.0 / 3.0))
call assert_equal('003.33e-01', printf('%010.2e', 1.0 / 3.0))
call assert_equal(' 03.33e-01', printf('% 010.2e', 1.0 / 3.0))
call assert_equal('+03.33e-01', printf('%+010.2e', 1.0 / 3.0))
call assert_equal('-03.33e-01', printf('%010.2e', -1.0 / 3.0))
#" When precision is 0, the dot should be omitted.
call assert_equal(' 2', printf('%3.f', 7.0 / 3.0))
call assert_equal(' 2', printf('%3.g', 7.0 / 3.0))
call assert_equal(' 2e+00', printf('%7.e', 7.0 / 3.0))
#" When precision is 0, the dot should be omitted.
call assert_equal(' 2', printf('%3.f', 7.0 / 3.0))
call assert_equal(' 2', printf('%3.g', 7.0 / 3.0))
call assert_equal(' 2e+00', printf('%7.e', 7.0 / 3.0))
#" Float zero can be signed.
call assert_equal('+0.000000', printf('%+f', 0.0))
call assert_equal('0.000000', printf('%f', 1.0 / (1.0 / 0.0)))
call assert_equal('-0.000000', printf('%f', 1.0 / (-1.0 / 0.0)))
call assert_equal('0.0', printf('%s', 1.0 / (1.0 / 0.0)))
call assert_equal('-0.0', printf('%s', 1.0 / (-1.0 / 0.0)))
call assert_equal('0.0', printf('%S', 1.0 / (1.0 / 0.0)))
call assert_equal('-0.0', printf('%S', 1.0 / (-1.0 / 0.0)))
#" Float zero can be signed.
call assert_equal('+0.000000', printf('%+f', 0.0))
call assert_equal('0.000000', printf('%f', 1.0 / (1.0 / 0.0)))
call assert_equal('-0.000000', printf('%f', 1.0 / (-1.0 / 0.0)))
call assert_equal('0.0', printf('%s', 1.0 / (1.0 / 0.0)))
call assert_equal('-0.0', printf('%s', 1.0 / (-1.0 / 0.0)))
call assert_equal('0.0', printf('%S', 1.0 / (1.0 / 0.0)))
call assert_equal('-0.0', printf('%S', 1.0 / (-1.0 / 0.0)))
#" Float infinity can be signed.
call assert_equal('inf', printf('%f', 1.0 / 0.0))
call assert_equal('-inf', printf('%f', -1.0 / 0.0))
call assert_equal('inf', printf('%g', 1.0 / 0.0))
call assert_equal('-inf', printf('%g', -1.0 / 0.0))
call assert_equal('inf', printf('%e', 1.0 / 0.0))
call assert_equal('-inf', printf('%e', -1.0 / 0.0))
call assert_equal('INF', printf('%F', 1.0 / 0.0))
call assert_equal('-INF', printf('%F', -1.0 / 0.0))
call assert_equal('INF', printf('%E', 1.0 / 0.0))
call assert_equal('-INF', printf('%E', -1.0 / 0.0))
call assert_equal('INF', printf('%E', 1.0 / 0.0))
call assert_equal('-INF', printf('%G', -1.0 / 0.0))
call assert_equal('+inf', printf('%+f', 1.0 / 0.0))
call assert_equal('-inf', printf('%+f', -1.0 / 0.0))
call assert_equal(' inf', printf('% f', 1.0 / 0.0))
call assert_equal(' inf', printf('%6f', 1.0 / 0.0))
call assert_equal(' -inf', printf('%6f', -1.0 / 0.0))
call assert_equal(' inf', printf('%6g', 1.0 / 0.0))
call assert_equal(' -inf', printf('%6g', -1.0 / 0.0))
call assert_equal(' +inf', printf('%+6f', 1.0 / 0.0))
call assert_equal(' inf', printf('% 6f', 1.0 / 0.0))
call assert_equal(' +inf', printf('%+06f', 1.0 / 0.0))
call assert_equal('inf ', printf('%-6f', 1.0 / 0.0))
call assert_equal('-inf ', printf('%-6f', -1.0 / 0.0))
call assert_equal('+inf ', printf('%-+6f', 1.0 / 0.0))
call assert_equal(' inf ', printf('%- 6f', 1.0 / 0.0))
call assert_equal('-INF ', printf('%-6F', -1.0 / 0.0))
call assert_equal('+INF ', printf('%-+6F', 1.0 / 0.0))
call assert_equal(' INF ', printf('%- 6F', 1.0 / 0.0))
call assert_equal('INF ', printf('%-6G', 1.0 / 0.0))
call assert_equal('-INF ', printf('%-6G', -1.0 / 0.0))
call assert_equal('INF ', printf('%-6E', 1.0 / 0.0))
call assert_equal('-INF ', printf('%-6E', -1.0 / 0.0))
call assert_equal('inf', printf('%s', 1.0 / 0.0))
call assert_equal('-inf', printf('%s', -1.0 / 0.0))
#" Float infinity can be signed.
call assert_equal('inf', printf('%f', 1.0 / 0.0))
call assert_equal('-inf', printf('%f', -1.0 / 0.0))
call assert_equal('inf', printf('%g', 1.0 / 0.0))
call assert_equal('-inf', printf('%g', -1.0 / 0.0))
call assert_equal('inf', printf('%e', 1.0 / 0.0))
call assert_equal('-inf', printf('%e', -1.0 / 0.0))
call assert_equal('INF', printf('%F', 1.0 / 0.0))
call assert_equal('-INF', printf('%F', -1.0 / 0.0))
call assert_equal('INF', printf('%E', 1.0 / 0.0))
call assert_equal('-INF', printf('%E', -1.0 / 0.0))
call assert_equal('INF', printf('%E', 1.0 / 0.0))
call assert_equal('-INF', printf('%G', -1.0 / 0.0))
call assert_equal('+inf', printf('%+f', 1.0 / 0.0))
call assert_equal('-inf', printf('%+f', -1.0 / 0.0))
call assert_equal(' inf', printf('% f', 1.0 / 0.0))
call assert_equal(' inf', printf('%6f', 1.0 / 0.0))
call assert_equal(' -inf', printf('%6f', -1.0 / 0.0))
call assert_equal(' inf', printf('%6g', 1.0 / 0.0))
call assert_equal(' -inf', printf('%6g', -1.0 / 0.0))
call assert_equal(' +inf', printf('%+6f', 1.0 / 0.0))
call assert_equal(' inf', printf('% 6f', 1.0 / 0.0))
call assert_equal(' +inf', printf('%+06f', 1.0 / 0.0))
call assert_equal('inf ', printf('%-6f', 1.0 / 0.0))
call assert_equal('-inf ', printf('%-6f', -1.0 / 0.0))
call assert_equal('+inf ', printf('%-+6f', 1.0 / 0.0))
call assert_equal(' inf ', printf('%- 6f', 1.0 / 0.0))
call assert_equal('-INF ', printf('%-6F', -1.0 / 0.0))
call assert_equal('+INF ', printf('%-+6F', 1.0 / 0.0))
call assert_equal(' INF ', printf('%- 6F', 1.0 / 0.0))
call assert_equal('INF ', printf('%-6G', 1.0 / 0.0))
call assert_equal('-INF ', printf('%-6G', -1.0 / 0.0))
call assert_equal('INF ', printf('%-6E', 1.0 / 0.0))
call assert_equal('-INF ', printf('%-6E', -1.0 / 0.0))
call assert_equal('inf', printf('%s', 1.0 / 0.0))
call assert_equal('-inf', printf('%s', -1.0 / 0.0))
#" Test special case where max precision is truncated at 340.
call assert_equal('1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.330f', 1.0))
call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.340f', 1.0))
call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.350f', 1.0))
#" Test special case where max precision is truncated at 340.
call assert_equal('1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.330f', 1.0))
call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.340f', 1.0))
call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.350f', 1.0))
#" Float nan (not a number) has no sign.
call assert_equal('nan', printf('%f', sqrt(-1.0)))
call assert_equal('nan', printf('%f', 0.0 / 0.0))
call assert_equal('nan', printf('%f', -0.0 / 0.0))
call assert_equal('nan', printf('%g', 0.0 / 0.0))
call assert_equal('nan', printf('%e', 0.0 / 0.0))
call assert_equal('NAN', printf('%F', 0.0 / 0.0))
call assert_equal('NAN', printf('%G', 0.0 / 0.0))
call assert_equal('NAN', printf('%E', 0.0 / 0.0))
call assert_equal('NAN', printf('%F', -0.0 / 0.0))
call assert_equal('NAN', printf('%G', -0.0 / 0.0))
call assert_equal('NAN', printf('%E', -0.0 / 0.0))
call assert_equal(' nan', printf('%6f', 0.0 / 0.0))
call assert_equal(' nan', printf('%06f', 0.0 / 0.0))
call assert_equal('nan ', printf('%-6f', 0.0 / 0.0))
call assert_equal('nan ', printf('%- 6f', 0.0 / 0.0))
call assert_equal('nan', printf('%s', 0.0 / 0.0))
call assert_equal('nan', printf('%s', -0.0 / 0.0))
call assert_equal('nan', printf('%S', 0.0 / 0.0))
call assert_equal('nan', printf('%S', -0.0 / 0.0))
END
call v9.CheckLegacyAndVim9Success(lines)
#" Float nan (not a number) has no sign.
call assert_equal('nan', printf('%f', sqrt(-1.0)))
call assert_equal('nan', printf('%f', 0.0 / 0.0))
call assert_equal('nan', printf('%f', -0.0 / 0.0))
call assert_equal('nan', printf('%g', 0.0 / 0.0))
call assert_equal('nan', printf('%e', 0.0 / 0.0))
call assert_equal('NAN', printf('%F', 0.0 / 0.0))
call assert_equal('NAN', printf('%G', 0.0 / 0.0))
call assert_equal('NAN', printf('%E', 0.0 / 0.0))
call assert_equal('NAN', printf('%F', -0.0 / 0.0))
call assert_equal('NAN', printf('%G', -0.0 / 0.0))
call assert_equal('NAN', printf('%E', -0.0 / 0.0))
call assert_equal(' nan', printf('%6f', 0.0 / 0.0))
call assert_equal(' nan', printf('%06f', 0.0 / 0.0))
call assert_equal('nan ', printf('%-6f', 0.0 / 0.0))
call assert_equal('nan ', printf('%- 6f', 0.0 / 0.0))
call assert_equal('nan', printf('%s', 0.0 / 0.0))
call assert_equal('nan', printf('%s', -0.0 / 0.0))
call assert_equal('nan', printf('%S', 0.0 / 0.0))
call assert_equal('nan', printf('%S', -0.0 / 0.0))
END
call v9.CheckLegacyAndVim9Success(lines)
call v9.CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:')
endif
call v9.CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:')
endfunc
func Test_printf_errors()
@@ -585,10 +577,8 @@ func Test_printf_errors()
call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1, 2)'], 'E767:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%s")'], 'E766:')
if has('float')
call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1.2)'], 'E805:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%f")'], 'E766:')
endif
call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1.2)'], 'E805:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%f")'], 'E766:')
endfunc
func Test_printf_64bit()
@@ -607,9 +597,7 @@ func Test_printf_spec_s()
call assert_equal("abcdefgi", printf('%s', "abcdefgi"))
#" float
if has('float')
call assert_equal("1.23", printf('%s', 1.23))
endif
call assert_equal("1.23", printf('%s', 1.23))
#" list
VAR lvalue = [1, 'two', ['three', 4]]
@@ -878,8 +866,6 @@ endfunc
" Test for float value comparison
func Test_float_compare()
CheckFeature float
let lines =<< trim END
call assert_true(1.2 == 1.2)
call assert_true(1.0 != 1.2)
-1
View File
@@ -1,7 +1,6 @@
" test float functions
source check.vim
CheckFeature float
import './vim9.vim' as v9
func Test_abs()
+13 -23
View File
@@ -54,14 +54,12 @@ func Test_empty()
call assert_equal(0, empty(1))
call assert_equal(0, empty(-1))
if has('float')
call assert_equal(1, empty(0.0))
call assert_equal(1, empty(-0.0))
call assert_equal(0, empty(1.0))
call assert_equal(0, empty(-1.0))
call assert_equal(0, empty(1.0/0.0))
call assert_equal(0, empty(0.0/0.0))
endif
call assert_equal(1, empty(0.0))
call assert_equal(1, empty(-0.0))
call assert_equal(0, empty(1.0))
call assert_equal(0, empty(-1.0))
call assert_equal(0, empty(1.0/0.0))
call assert_equal(0, empty(0.0/0.0))
call assert_equal(1, empty([]))
call assert_equal(0, empty(['a']))
@@ -90,9 +88,7 @@ endfunc
func Test_test_void()
call assert_fails('echo 1 == test_void()', 'E1031:')
if has('float')
call assert_fails('echo 1.0 == test_void()', 'E1031:')
endif
call assert_fails('echo 1.0 == test_void()', 'E1031:')
call assert_fails('let x = json_encode(test_void())', 'E685:')
call assert_fails('let x = copy(test_void())', 'E685:')
call assert_fails('let x = copy([test_void()])', 'E1031:')
@@ -175,10 +171,8 @@ func Test_strwidth()
call assert_fails('call strwidth({})', 'E731:')
endfor
if has('float')
call assert_equal(3, strwidth(1.2))
call v9.CheckDefAndScriptFailure(['echo strwidth(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
endif
call assert_equal(3, strwidth(1.2))
call v9.CheckDefAndScriptFailure(['echo strwidth(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
set ambiwidth&
endfunc
@@ -242,10 +236,8 @@ func Test_str2nr()
call assert_fails('call str2nr([])', 'E730:')
call assert_fails('call str2nr({->2})', 'E729:')
if has('float')
call assert_equal(1, str2nr(1.2))
call v9.CheckDefAndScriptFailure(['echo str2nr(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
endif
call assert_equal(1, str2nr(1.2))
call v9.CheckDefAndScriptFailure(['echo str2nr(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
call assert_fails('call str2nr(10, [])', 'E745:')
endfunc
@@ -504,10 +496,8 @@ func Test_simplify()
call assert_fails('call simplify({->0})', 'E729:')
call assert_fails('call simplify([])', 'E730:')
call assert_fails('call simplify({})', 'E731:')
if has('float')
call assert_equal('1.2', simplify(1.2))
call v9.CheckDefAndScriptFailure(['echo simplify(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
endif
call assert_equal('1.2', simplify(1.2))
call v9.CheckDefAndScriptFailure(['echo simplify(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
endfunc
func Test_pathshorten()
+2 -4
View File
@@ -3,10 +3,8 @@
import './vim9.vim' as v9
func Test_glob2regpat_invalid()
if has('float')
call assert_equal('^1\.33$', glob2regpat(1.33))
call v9.CheckDefAndScriptFailure(['echo glob2regpat(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
endif
call assert_equal('^1\.33$', glob2regpat(1.33))
call v9.CheckDefAndScriptFailure(['echo glob2regpat(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
call assert_fails('call glob2regpat("}")', 'E219:')
call assert_fails('call glob2regpat("{")', 'E220:')
endfunc
+22 -34
View File
@@ -21,16 +21,14 @@ let s:jsonmb = '"s¢cĴgё"'
let s:varmb = "s¢cĴgё"
let s:jsonnr = '1234'
let s:varnr = 1234
if has('float')
let s:jsonfl = '12.34'
let s:varfl = 12.34
let s:jsonneginf = '-Infinity'
let s:jsonposinf = 'Infinity'
let s:varneginf = -1.0 / 0.0
let s:varposinf = 1.0 / 0.0
let s:jsonnan = 'NaN'
let s:varnan = 0.0 / 0.0
endif
let s:jsonfl = '12.34'
let s:varfl = 12.34
let s:jsonneginf = '-Infinity'
let s:jsonposinf = 'Infinity'
let s:varneginf = -1.0 / 0.0
let s:varposinf = 1.0 / 0.0
let s:jsonnan = 'NaN'
let s:varnan = 0.0 / 0.0
let s:jsonl1 = '[1,"a",3]'
let s:varl1 = [1, "a", 3]
@@ -82,12 +80,10 @@ func Test_json_encode()
" no test for surrogate pair, json_encode() doesn't create them.
call assert_equal(s:jsonnr, json_encode(s:varnr))
if has('float')
call assert_equal(s:jsonfl, json_encode(s:varfl))
call assert_equal(s:jsonneginf, json_encode(s:varneginf))
call assert_equal(s:jsonposinf, json_encode(s:varposinf))
call assert_equal(s:jsonnan, json_encode(s:varnan))
endif
call assert_equal(s:jsonfl, json_encode(s:varfl))
call assert_equal(s:jsonneginf, json_encode(s:varneginf))
call assert_equal(s:jsonposinf, json_encode(s:varposinf))
call assert_equal(s:jsonnan, json_encode(s:varnan))
call assert_equal(s:jsonl1, json_encode(s:varl1))
call assert_equal(s:jsonl2, json_encode(s:varl2))
@@ -133,9 +129,7 @@ func Test_json_decode()
call assert_equal(s:varsp2, json_decode(s:jsonsp2))
call assert_equal(s:varnr, json_decode(s:jsonnr))
if has('float')
call assert_equal(s:varfl, json_decode(s:jsonfl))
endif
call assert_equal(s:varfl, json_decode(s:jsonfl))
call assert_equal(s:varl1, json_decode(s:jsonl1))
call assert_equal(s:varl2x, json_decode(s:jsonl2))
@@ -189,9 +183,7 @@ func Test_json_decode()
call assert_fails('call json_decode("{\"n\":1,")', "E491:")
call assert_fails('call json_decode("{\"n\",1}")', "E491:")
call assert_fails('call json_decode("{-}")', "E491:")
if has('float')
call assert_fails('call json_decode("{3.14:1}")', "E806:")
endif
call assert_fails('call json_decode("{3.14:1}")', "E806:")
call assert_fails('call json_decode("[foobar]")', "E491:")
call assert_fails('call json_decode("[")', "E491:")
@@ -230,12 +222,10 @@ func Test_js_encode()
" no test for surrogate pair, js_encode() doesn't create them.
call assert_equal(s:jsonnr, js_encode(s:varnr))
if has('float')
call assert_equal(s:jsonfl, js_encode(s:varfl))
call assert_equal(s:jsonneginf, js_encode(s:varneginf))
call assert_equal(s:jsonposinf, js_encode(s:varposinf))
call assert_equal(s:jsonnan, js_encode(s:varnan))
endif
call assert_equal(s:jsonfl, js_encode(s:varfl))
call assert_equal(s:jsonneginf, js_encode(s:varneginf))
call assert_equal(s:jsonposinf, js_encode(s:varposinf))
call assert_equal(s:jsonnan, js_encode(s:varnan))
call assert_equal(s:jsonl1, js_encode(s:varl1))
call assert_equal(s:jsonl2, js_encode(s:varl2))
@@ -270,12 +260,10 @@ func Test_js_decode()
call assert_equal(s:varsp2, js_decode(s:jsonsp2))
call assert_equal(s:varnr, js_decode(s:jsonnr))
if has('float')
call assert_equal(s:varfl, js_decode(s:jsonfl))
call assert_equal(s:varneginf, js_decode(s:jsonneginf))
call assert_equal(s:varposinf, js_decode(s:jsonposinf))
call assert_true(isnan(js_decode(s:jsonnan)))
endif
call assert_equal(s:varfl, js_decode(s:jsonfl))
call assert_equal(s:varneginf, js_decode(s:jsonneginf))
call assert_equal(s:varposinf, js_decode(s:jsonposinf))
call assert_true(isnan(js_decode(s:jsonnan)))
call assert_equal(s:varl1, js_decode(s:jsonl1))
call assert_equal(s:varl2x, js_decode(s:jsonl2))
+12 -18
View File
@@ -966,20 +966,18 @@ func Test_reverse_sort_uniq()
call assert_equal(['-0', 'A11', 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5], uniq(copy(l)))
call assert_equal([1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'], reverse(l))
call assert_equal([1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'], reverse(reverse(l)))
if has('float')
call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(l))
call assert_equal([[0, 1, 2], [0, 1, 2], 4, 2, 2, 1.5, 'xaaa', 'x8', 'foo6', 'foo', 'foo', 'A11', '-0'], reverse(sort(l)))
call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(reverse(sort(l))))
call assert_equal(['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 4, [0, 1, 2]], uniq(sort(l)))
call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(l))
call assert_equal([[0, 1, 2], [0, 1, 2], 4, 2, 2, 1.5, 'xaaa', 'x8', 'foo6', 'foo', 'foo', 'A11', '-0'], reverse(sort(l)))
call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(reverse(sort(l))))
call assert_equal(['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 4, [0, 1, 2]], uniq(sort(l)))
LET l = [7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff, 0.22, 'four']
call assert_equal([-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255], sort(copy(l), 'n'))
LET l = [7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff, 0.22, 'four']
call assert_equal([-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255], sort(copy(l), 'n'))
LET l = [7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []]
call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i'))
call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i'))
call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l)))
endif
LET l = [7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []]
call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i'))
call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i'))
call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l)))
END
call v9.CheckLegacyAndVim9Success(lines)
@@ -1173,9 +1171,7 @@ func Test_listdict_extend()
let l = [1, 2, 3]
call assert_fails("call extend(l, [4, 5, 6], 4)", 'E684:')
call assert_fails("call extend(l, [4, 5, 6], -4)", 'E684:')
if has('float')
call assert_fails("call extend(l, [4, 5, 6], 1.2)", 'E805:')
endif
call assert_fails("call extend(l, [4, 5, 6], 1.2)", 'E805:')
" Test extend() with dictionaries.
@@ -1203,9 +1199,7 @@ func Test_listdict_extend()
call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:')
call assert_fails("call extend(d, {'b': 0}, [])", 'E730:')
call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'xxx')", 'E475:')
if has('float')
call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E475:')
endif
call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E475:')
call assert_equal({'a': 'A', 'b': 'B'}, d)
call assert_fails("call extend([1, 2], 1)", 'E712:')
-1
View File
@@ -10,7 +10,6 @@ func Test_skip_lua()
endfunc
CheckFeature lua
CheckFeature float
" Depending on the lua version, the error messages are different.
let [s:major, s:minor, s:patch] = luaeval('vim.lua_version')->split('\.')->map({-> str2nr(v:val)})
+2 -6
View File
@@ -74,9 +74,7 @@ func Test_echomsg()
call assert_equal("\n[1, 2, []]", execute(':echomsg [1, 2, test_null_list()]'))
call assert_equal("\n{}", execute(':echomsg {}'))
call assert_equal("\n{'a': 1, 'b': 2}", execute(':echomsg {"a": 1, "b": 2}'))
if has('float')
call assert_equal("\n1.23", execute(':echomsg 1.23'))
endif
call assert_equal("\n1.23", execute(':echomsg 1.23'))
call assert_match("function('<lambda>\\d*')", execute(':echomsg {-> 1234}'))
endfunc
@@ -86,9 +84,7 @@ func Test_echoerr()
call assert_equal("\n12345 IgNoRe", execute(':echoerr 12345 "IgNoRe"'))
call assert_equal("\n[1, 2, 'IgNoRe']", execute(':echoerr [1, 2, "IgNoRe"]'))
call assert_equal("\n{'IgNoRe': 2, 'a': 1}", execute(':echoerr {"a": 1, "IgNoRe": 2}'))
if has('float')
call assert_equal("\n1.23 IgNoRe", execute(':echoerr 1.23 "IgNoRe"'))
endif
call assert_equal("\n1.23 IgNoRe", execute(':echoerr 1.23 "IgNoRe"'))
eval '<lambda>'->test_ignore_error()
call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}'))
call test_ignore_error('RESET')
-1
View File
@@ -121,7 +121,6 @@ func Test_method_funcref()
endfunc
func Test_method_float()
CheckFeature float
eval 1.234->string()->assert_equal('1.234')
eval -1.234->string()->assert_equal('-1.234')
endfunc
+1 -5
View File
@@ -163,11 +163,7 @@ func Test_perleval()
call assert_equal(0, perleval('0'))
call assert_equal(2, perleval('2'))
call assert_equal(-2, perleval('-2'))
if has('float')
call assert_equal(2.5, perleval('2.5'))
else
call assert_equal(2, perleval('2.5'))
end
call assert_equal(2.5, perleval('2.5'))
sandbox call assert_equal(2, perleval('2'))
+1 -4
View File
@@ -686,7 +686,6 @@ func Test_python_function_call()
endfunc
func Test_python_float()
CheckFeature float
let l = [0.0]
py l = vim.bindeval('l')
py l.extend([0.0])
@@ -785,9 +784,7 @@ func Test_python_pyeval()
py v = vim.eval('test_null_function()')
call assert_equal(v:none, pyeval('v'))
if has('float')
call assert_equal(0.0, pyeval('0.0'))
endif
call assert_equal(0.0, pyeval('0.0'))
" Evaluate an invalid values
call AssertException(['let v = pyeval(''"\0"'')'], 'E859:')
+9 -14
View File
@@ -286,16 +286,14 @@ 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("\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"))'))
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}"))'))
@@ -879,7 +877,6 @@ func Test_python3_function_call()
endfunc
func Test_python3_float()
CheckFeature float
let l = [0.0]
py3 l = vim.bindeval('l')
py3 l.extend([0.0])
@@ -982,9 +979,7 @@ func Test_python3_pyeval()
py3 v = vim.eval('test_null_function()')
call assert_equal(v:none, py3eval('v'))
if has('float')
call assert_equal(0.0, py3eval('0.0'))
endif
call assert_equal(0.0, py3eval('0.0'))
" Evaluate an invalid values
call AssertException(['let v = py3eval(''"\0"'')'], 'E859:')
+1 -3
View File
@@ -26,9 +26,7 @@ func Test_Rand()
call assert_equal(1001954530, rand())
call test_srand_seed()
if has('float')
call assert_fails('echo srand(1.2)', 'E805:')
endif
call assert_fails('echo srand(1.2)', 'E805:')
call assert_fails('echo srand([1])', 'E745:')
call assert_fails('echo rand("burp")', 'E475:')
call assert_fails('echo rand([1, 2, 3])', 'E730:')
-1
View File
@@ -2,7 +2,6 @@
source check.vim
CheckFeature reltime
CheckFeature float
func Test_reltime()
let g:test_is_flaky = 1
+2 -4
View File
@@ -304,10 +304,8 @@ func Test_ruby_Vim_evaluate()
" on versions of Ruby.
call assert_match('^Integer\|Fixnum$', rubyeval('Vim::evaluate("123").class'))
if has('float')
call assert_equal(1.23, rubyeval('Vim::evaluate("1.23")'))
call assert_equal('Float', rubyeval('Vim::evaluate("1.23").class'))
endif
call assert_equal(1.23, rubyeval('Vim::evaluate("1.23")'))
call assert_equal('Float', rubyeval('Vim::evaluate("1.23").class'))
call assert_equal('foo', rubyeval('Vim::evaluate("\"foo\"")'))
call assert_equal('String', rubyeval('Vim::evaluate("\"foo\"").class'))
+26 -31
View File
@@ -62,7 +62,6 @@ func Test_sort_numbers()
endfunc
func Test_sort_float()
CheckFeature float
call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f'))
endfunc
@@ -72,8 +71,6 @@ func Test_sort_nested()
endfunc
func Test_sort_default()
CheckFeature float
" docs say omitted, empty or zero argument sorts on string representation.
call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"]))
call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"], ''))
@@ -1336,34 +1333,32 @@ func Test_sort_cmd()
\ ]
endif
endif
if has('float')
let tests += [
\ {
\ 'name' : 'float',
\ 'cmd' : 'sort f',
\ 'input' : [
\ '1.234',
\ '0.88',
\ ' + 123.456',
\ '1.15e-6',
\ '-1.1e3',
\ '-1.01e3',
\ '',
\ ''
\ ],
\ 'expected' : [
\ '',
\ '',
\ '-1.1e3',
\ '-1.01e3',
\ '1.15e-6',
\ '0.88',
\ '1.234',
\ ' + 123.456'
\ ]
\ },
\ ]
endif
let tests += [
\ {
\ 'name' : 'float',
\ 'cmd' : 'sort f',
\ 'input' : [
\ '1.234',
\ '0.88',
\ ' + 123.456',
\ '1.15e-6',
\ '-1.1e3',
\ '-1.01e3',
\ '',
\ ''
\ ],
\ 'expected' : [
\ '',
\ '',
\ '-1.1e3',
\ '-1.01e3',
\ '1.15e-6',
\ '0.88',
\ '1.234',
\ ' + 123.456'
\ ]
\ },
\ ]
for t in tests
enew!
-2
View File
@@ -464,8 +464,6 @@ func Test_substitute_partial()
endfunc
func Test_substitute_float()
CheckFeature float
call assert_equal('number 1.23', substitute('number ', '$', { -> 1.23 }, ''))
vim9 assert_equal('number 1.23', substitute('number ', '$', () => 1.23, ''))
endfunc
+1 -3
View File
@@ -478,9 +478,7 @@ func Test_terminal_size()
call assert_fails("call term_start(cmd, {'term_rows': -1})", 'E475:')
call assert_fails("call term_start(cmd, {'term_rows': 1001})", 'E475:')
if has('float')
call assert_fails("call term_start(cmd, {'term_rows': 10.0})", 'E805:')
endif
call assert_fails("call term_start(cmd, {'term_rows': 10.0})", 'E805:')
call delete('Xtext')
endfunc
+1 -4
View File
@@ -43,9 +43,7 @@ func Test_if()
call assert_fails('if [1]', 'E745:')
call assert_fails('if {1: 1}', 'E728:')
call assert_fails('if function("string")', 'E703:')
if has('float')
call assert_fails('if 1.3")', 'E805:')
endif
call assert_fails('if 1.3")', 'E805:')
endfunc
function Try_arg_true_false(expr, false_val, true_val)
@@ -117,7 +115,6 @@ func Test_true_false_arg()
endfunc
function Try_arg_non_zero(expr, false_val, true_val)
CheckFeature float
for v in ['v:false', '0', '[1]', '{2:3}', '3.4']
let r = eval(substitute(a:expr, '%v%', v, ''))
call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . a:false_val . ' but ' . r)
+3 -5
View File
@@ -129,11 +129,9 @@ func MakeBadFunc()
endfunc
func Test_default_arg()
if has('float')
call assert_equal(1.0, Log(10))
call assert_equal(log(10), Log(10, exp(1)))
call assert_fails("call Log(1,2,3)", 'E118:')
endif
call assert_equal(1.0, Log(10))
call assert_equal(log(10), Log(10, exp(1)))
call assert_fails("call Log(1,2,3)", 'E118:')
let res = Args(1)
call assert_equal(res.mandatory, 1)
+23 -35
View File
@@ -96,9 +96,7 @@ def Test_assignment()
# calling job_start() is in test_vim9_fails.vim, it causes leak reports
endif
if has('float')
var float1: float = 3.4
endif
var float1: float = 3.4
var Funky1: func
var Funky2: func = function('len')
var Party2: func = funcref('g:Test_syntax')
@@ -147,17 +145,15 @@ def Test_assignment()
&ts %= 4
assert_equal(2, &ts)
if has('float')
var f100: float = 100.0
f100 /= 5
assert_equal(20.0, f100)
var f100: float = 100.0
f100 /= 5
assert_equal(20.0, f100)
var f200: float = 200.0
f200 /= 5.0
assert_equal(40.0, f200)
var f200: float = 200.0
f200 /= 5.0
assert_equal(40.0, f200)
v9.CheckDefFailure(['var nr: number = 200', 'nr /= 5.0'], 'E1012:')
endif
v9.CheckDefFailure(['var nr: number = 200', 'nr /= 5.0'], 'E1012:')
lines =<< trim END
&ts = 6
@@ -227,11 +223,9 @@ def Test_assignment()
g:inc_counter += 1
assert_equal(2, g:inc_counter)
if has('float')
var f: float
f += 1
assert_equal(1.0, f)
endif
var f: float
f += 1
assert_equal(1.0, f)
$SOME_ENV_VAR ..= 'more'
assert_equal('somemore', $SOME_ENV_VAR)
@@ -250,20 +244,16 @@ def Test_assignment()
enddef
def Test_float_and_number()
if !has('float')
MissingFeature float
else
var lines =<< trim END
var f: float
f += 2
f -= 1
assert_equal(1.0, f)
++f
--f
assert_equal(1.0, f)
END
v9.CheckDefAndScriptSuccess(lines)
endif
var lines =<< trim END
var f: float
f += 2
f -= 1
assert_equal(1.0, f)
++f
--f
assert_equal(1.0, f)
END
v9.CheckDefAndScriptSuccess(lines)
enddef
let g:someNumber = 43
@@ -1314,10 +1304,8 @@ def Test_assignment_default()
var thenumber: number
assert_equal(0, thenumber)
if has('float')
var thefloat: float
assert_equal(0.0, thefloat)
endif
var thefloat: float
assert_equal(0.0, thefloat)
var thestring: string
assert_equal('', thestring)
+8 -18
View File
@@ -69,11 +69,9 @@ def Test_abs()
assert_equal(2, abs(-2))
assert_equal(3, abs(3))
v9.CheckDefAndScriptFailure(['abs("text")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
if has('float')
assert_equal(0, abs(0))
assert_equal(2.0, abs(-2.0))
assert_equal(3.0, abs(3.0))
endif
assert_equal(0, abs(0))
assert_equal(2.0, abs(-2.0))
assert_equal(3.0, abs(3.0))
enddef
def Test_add()
@@ -1283,8 +1281,6 @@ enddef
" Test for float functions argument type
def Test_float_funcs_args()
CheckFeature float
# acos()
v9.CheckDefAndScriptFailure(['acos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('1.570796', string(acos(0.0)))
@@ -4064,15 +4060,11 @@ def Test_state()
enddef
def Test_str2float()
if !has('float')
CheckFeature float
else
str2float("1.00")->assert_equal(1.00)
str2float("2e-2")->assert_equal(0.02)
str2float('')->assert_equal(0.0)
str2float("1.00")->assert_equal(1.00)
str2float("2e-2")->assert_equal(0.02)
str2float('')->assert_equal(0.0)
v9.CheckDefAndScriptFailure(['str2float(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
endif
v9.CheckDefAndScriptFailure(['str2float(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
enddef
def Test_str2list()
@@ -4585,9 +4577,7 @@ def Test_trim()
enddef
def Test_typename()
if has('float')
assert_equal('func([unknown], [unknown]): float', typename(function('pow')))
endif
assert_equal('func([unknown], [unknown]): float', typename(function('pow')))
assert_equal('func(...): unknown', test_null_partial()->typename())
assert_equal('list<unknown>', test_null_list()->typename())
assert_equal('dict<unknown>', test_null_dict()->typename())
+33 -41
View File
@@ -309,9 +309,7 @@ def s:ScriptFuncPush()
var localbool = true
var localspec = v:none
var localblob = 0z1234
if has('float')
var localfloat = 1.234
endif
var localfloat = 1.234
enddef
def Test_disassemble_push()
@@ -1742,13 +1740,11 @@ def s:Computing()
anyres = g:number / 7
anyres = g:number % 7
if has('float')
var fl = 3.0
var flres = fl + 7.0
flres = fl - 7.0
flres = fl * 7.0
flres = fl / 7.0
endif
var fl = 3.0
var flres = fl + 7.0
flres = fl - 7.0
flres = fl * 7.0
flres = fl / 7.0
enddef
def Test_disassemble_computing()
@@ -1783,24 +1779,22 @@ def Test_disassemble_computing()
'anyres = g:number % 7.*' ..
'\d OPANY %.*',
instr)
if has('float')
assert_match('Computing.*' ..
'var fl = 3.0.*' ..
'\d PUSHF 3.0.*' ..
'\d STORE $3.*' ..
'var flres = fl + 7.0.*' ..
'\d LOAD $3.*' ..
'\d PUSHF 7.0.*' ..
'\d OPFLOAT +.*' ..
'\d STORE $4.*' ..
'flres = fl - 7.0.*' ..
'\d OPFLOAT -.*' ..
'flres = fl \* 7.0.*' ..
'\d OPFLOAT \*.*' ..
'flres = fl / 7.0.*' ..
'\d OPFLOAT /.*',
instr)
endif
assert_match('Computing.*' ..
'var fl = 3.0.*' ..
'\d PUSHF 3.0.*' ..
'\d STORE $3.*' ..
'var flres = fl + 7.0.*' ..
'\d LOAD $3.*' ..
'\d PUSHF 7.0.*' ..
'\d OPFLOAT +.*' ..
'\d STORE $4.*' ..
'flres = fl - 7.0.*' ..
'\d OPFLOAT -.*' ..
'flres = fl \* 7.0.*' ..
'\d OPFLOAT \*.*' ..
'flres = fl / 7.0.*' ..
'\d OPFLOAT /.*',
instr)
enddef
def s:AddListBlob()
@@ -2178,19 +2172,17 @@ def Test_disassemble_compare()
['77 isnot g:xx', 'COMPAREANY isnot'],
]
var floatDecl = ''
if has('float')
cases->extend([
['1.1 == aFloat', 'COMPAREFLOAT =='],
['1.1 != aFloat', 'COMPAREFLOAT !='],
['1.1 > aFloat', 'COMPAREFLOAT >'],
['1.1 < aFloat', 'COMPAREFLOAT <'],
['1.1 >= aFloat', 'COMPAREFLOAT >='],
['1.1 <= aFloat', 'COMPAREFLOAT <='],
['1.1 =~ aFloat', 'COMPAREFLOAT =\~'],
['1.1 !~ aFloat', 'COMPAREFLOAT !\~'],
])
floatDecl = 'var aFloat = 2.2'
endif
cases->extend([
['1.1 == aFloat', 'COMPAREFLOAT =='],
['1.1 != aFloat', 'COMPAREFLOAT !='],
['1.1 > aFloat', 'COMPAREFLOAT >'],
['1.1 < aFloat', 'COMPAREFLOAT <'],
['1.1 >= aFloat', 'COMPAREFLOAT >='],
['1.1 <= aFloat', 'COMPAREFLOAT <='],
['1.1 =~ aFloat', 'COMPAREFLOAT =\~'],
['1.1 !~ aFloat', 'COMPAREFLOAT !\~'],
])
floatDecl = 'var aFloat = 2.2'
var nr = 1
for case in cases
+138 -192
View File
@@ -18,9 +18,7 @@ def Test_expr1_ternary()
assert_equal('one', 1 ?
'one' :
'two')
if has('float')
assert_equal('one', !!0.1 ? 'one' : 'two')
endif
assert_equal('one', !!0.1 ? 'one' : 'two')
assert_equal('one', !!'x' ? 'one' : 'two')
assert_equal('one', !!'x'
? 'one'
@@ -33,9 +31,7 @@ def Test_expr1_ternary()
assert_equal('two', false ? 'one' : 'two')
assert_equal('two', 0 ? 'one' : 'two')
if has('float')
assert_equal('two', !!0.0 ? 'one' : 'two')
endif
assert_equal('two', !!0.0 ? 'one' : 'two')
assert_equal('two', !!'' ? 'one' : 'two')
assert_equal('two', !!0z ? 'one' : 'two')
assert_equal('two', !![] ? 'one' : 'two')
@@ -208,9 +204,7 @@ func Test_expr1_ternary_fails()
call v9.CheckDefExecAndScriptFailure(["var x = true ? xxx : 'foo'"], ['E1001:', 'E121:'], 1)
call v9.CheckDefExecAndScriptFailure(["var x = false ? 'foo' : xxx"], ['E1001:', 'E121:'], 1)
if has('float')
call v9.CheckDefAndScriptFailure(["var x = 0.1 ? 'one' : 'two'"], 'E805:', 1)
endif
call v9.CheckDefAndScriptFailure(["var x = 0.1 ? 'one' : 'two'"], 'E805:', 1)
" missing argument detected even when common type is used
call v9.CheckDefAndScriptFailure([
@@ -227,18 +221,14 @@ def Test_expr1_falsy()
assert_equal('yes', 'yes' ?? 456)
assert_equal([1], [1] ?? 456)
assert_equal({one: 1}, {one: 1} ?? 456)
if has('float')
assert_equal(0.1, 0.1 ?? 456)
endif
assert_equal(0.1, 0.1 ?? 456)
assert_equal(456, v:false ?? 456)
assert_equal(456, 0 ?? 456)
assert_equal(456, '' ?? 456)
assert_equal(456, [] ?? 456)
assert_equal(456, {} ?? 456)
if has('float')
assert_equal(456, 0.0 ?? 456)
endif
assert_equal(456, 0.0 ?? 456)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -567,9 +557,7 @@ let anull = v:null
let anint = 10
let theone = 1
let thefour = 4
if has('float')
let afloat = 0.1
endif
let afloat = 0.1
let astring = 'asdf'
let ablob = 0z01ab
let alist = [2, 3, 4]
@@ -605,20 +593,18 @@ def Test_expr4_equal()
assert_equal(true, g:anint == 10)
assert_equal(false, 61 == g:anint)
if has('float')
var ff = 0.3
assert_equal(true, ff == 0.3)
assert_equal(false, 0.4 == ff)
assert_equal(true, 0.1 == g:afloat)
assert_equal(false, g:afloat == 0.3)
var ff = 0.3
assert_equal(true, ff == 0.3)
assert_equal(false, 0.4 == ff)
assert_equal(true, 0.1 == g:afloat)
assert_equal(false, g:afloat == 0.3)
ff = 3.0
assert_equal(true, ff == 3)
assert_equal(true, 3 == ff)
ff = 3.1
assert_equal(false, ff == 3)
assert_equal(false, 3 == ff)
endif
ff = 3.0
assert_equal(true, ff == 3)
assert_equal(true, 3 == ff)
ff = 3.1
assert_equal(false, ff == 3)
assert_equal(false, 3 == ff)
assert_equal(true, 'abc' == 'abc')
assert_equal(false, 'xyz' == 'abc')
@@ -706,20 +692,18 @@ def Test_expr4_equal()
v9.CheckScriptFailure(lines, 'E1030: Using a String as a Number: "3"')
assert_true(g:notReached)
if has('float')
lines =<< trim END
vim9script
var n: any = 2.2
def Compare()
eval n == '3'
g:notReached = false
enddef
g:notReached = true
Compare()
END
v9.CheckScriptFailure(lines, 'E892: Using a String as a Float')
assert_true(g:notReached)
endif
lines =<< trim END
vim9script
var n: any = 2.2
def Compare()
eval n == '3'
g:notReached = false
enddef
g:notReached = true
Compare()
END
v9.CheckScriptFailure(lines, 'E892: Using a String as a Float')
assert_true(g:notReached)
unlet g:notReached
enddef
@@ -746,16 +730,14 @@ def Test_expr4_compare_null()
assert_true(null != 123)
assert_true(null != 0)
if has('float')
assert_false(12.3 == null)
assert_false(0.0 == null)
assert_false(null == 12.3)
assert_false(null == 0.0)
assert_true(12.3 != null)
assert_true(0.0 != null)
assert_true(null != 12.3)
assert_true(null != 0.0)
endif
assert_false(12.3 == null)
assert_false(0.0 == null)
assert_false(null == 12.3)
assert_false(null == 0.0)
assert_true(12.3 != null)
assert_true(0.0 != null)
assert_true(null != 12.3)
assert_true(null != 0.0)
assert_true(test_null_blob() == v:null)
assert_true(null_blob == null)
@@ -1077,20 +1059,18 @@ def Test_expr4_notequal()
assert_equal(false, g:anint != 10)
assert_equal(true, 61 != g:anint)
if has('float')
var ff = 0.3
assert_equal(false, 0.3 != ff)
assert_equal(true, 0.4 != ff)
assert_equal(false, 0.1 != g:afloat)
assert_equal(true, g:afloat != 0.3)
var ff = 0.3
assert_equal(false, 0.3 != ff)
assert_equal(true, 0.4 != ff)
assert_equal(false, 0.1 != g:afloat)
assert_equal(true, g:afloat != 0.3)
ff = 3.0
assert_equal(false, ff != 3)
assert_equal(false, 3 != ff)
ff = 3.1
assert_equal(true, ff != 3)
assert_equal(true, 3 != ff)
endif
ff = 3.0
assert_equal(false, ff != 3)
assert_equal(false, 3 != ff)
ff = 3.1
assert_equal(true, ff != 3)
assert_equal(true, 3 != ff)
assert_equal(false, 'abc' != 'abc')
assert_equal(true, 'xyz' != 'abc')
@@ -1149,13 +1129,11 @@ def Test_expr4_greater()
assert_false(nr2 > 2)
assert_false(nr2
> 3)
if has('float')
var ff = 2.0
assert_true(ff > 0.0)
assert_true(ff > 1.0)
assert_false(ff > 2.0)
assert_false(ff > 3.0)
endif
var ff = 2.0
assert_true(ff > 0.0)
assert_true(ff > 1.0)
assert_false(ff > 2.0)
assert_false(ff > 3.0)
END
v9.CheckDefAndScriptSuccess(lines)
enddef
@@ -1171,12 +1149,10 @@ def Test_expr4_greaterequal()
assert_true(nr2 >= 0)
assert_true(nr2 >= 2)
assert_false(nr2 >= 3)
if has('float')
var ff = 2.0
assert_true(ff >= 0.0)
assert_true(ff >= 2.0)
assert_false(ff >= 3.0)
endif
var ff = 2.0
assert_true(ff >= 0.0)
assert_true(ff >= 2.0)
assert_false(ff >= 3.0)
END
v9.CheckDefAndScriptSuccess(lines)
enddef
@@ -1193,12 +1169,10 @@ def Test_expr4_smaller()
assert_false(nr2 < 0)
assert_false(nr2 < 2)
assert_true(nr2 < 3)
if has('float')
var ff = 2.0
assert_false(ff < 0.0)
assert_false(ff < 2.0)
assert_true(ff < 3.0)
endif
var ff = 2.0
assert_false(ff < 0.0)
assert_false(ff < 2.0)
assert_true(ff < 3.0)
END
v9.CheckDefAndScriptSuccess(lines)
enddef
@@ -1217,13 +1191,11 @@ def Test_expr4_smallerequal()
assert_false(nr2 <= 1)
assert_true(nr2 <= 2)
assert_true(nr2 <= 3)
if has('float')
var ff = 2.0
assert_false(ff <= 0.0)
assert_false(ff <= 1.0)
assert_true(ff <= 2.0)
assert_true(ff <= 3.0)
endif
var ff = 2.0
assert_false(ff <= 0.0)
assert_false(ff <= 1.0)
assert_true(ff <= 2.0)
assert_true(ff <= 3.0)
END
v9.CheckDefAndScriptSuccess(lines)
enddef
@@ -1456,10 +1428,8 @@ func Test_expr4_fails()
call v9.CheckDefAndScriptFailure(["var x = v:none isnot v:null"], 'Cannot use "isnot" with special', 1)
call v9.CheckDefAndScriptFailure(["var x = 123 is 123"], 'Cannot use "is" with number', 1)
call v9.CheckDefAndScriptFailure(["var x = 123 isnot 123"], 'Cannot use "isnot" with number', 1)
if has('float')
call v9.CheckDefAndScriptFailure(["var x = 1.3 is 1.3"], 'Cannot use "is" with float', 1)
call v9.CheckDefAndScriptFailure(["var x = 1.3 isnot 1.3"], 'Cannot use "isnot" with float', 1)
endif
call v9.CheckDefAndScriptFailure(["var x = 1.3 is 1.3"], 'Cannot use "is" with float', 1)
call v9.CheckDefAndScriptFailure(["var x = 1.3 isnot 1.3"], 'Cannot use "isnot" with float', 1)
call v9.CheckDefAndScriptFailure(["var x = 0za1 > 0z34"], 'Cannot compare blob with blob', 1)
call v9.CheckDefAndScriptFailure(["var x = 0za1 >= 0z34"], 'Cannot compare blob with blob', 1)
@@ -1518,9 +1488,7 @@ def Test_expr6()
assert_equal('afalse', 'a' .. false)
assert_equal('anull', 'a' .. v:null)
assert_equal('av:none', 'a' .. v:none)
if has('float')
assert_equal('a0.123', 'a' .. 0.123)
endif
assert_equal('a0.123', 'a' .. 0.123)
assert_equal(3, 1 + [2, 3, 4][0])
assert_equal(5, 2 + {key: 3}['key'])
@@ -1719,31 +1687,27 @@ def Test_expr6_vim9script_channel()
enddef
def Test_expr6_float()
if !has('float')
MissingFeature 'float'
else
var lines =<< trim END
assert_equal(66.0, 60.0 + 6.0)
assert_equal(66.0, 60.0 + 6)
assert_equal(66.0, 60 +
6.0)
assert_equal(5.1, g:afloat
+ 5)
assert_equal(8.1, 8 + g:afloat)
assert_equal(10.1, g:anint + g:afloat)
assert_equal(10.1, g:afloat + g:anint)
var lines =<< trim END
assert_equal(66.0, 60.0 + 6.0)
assert_equal(66.0, 60.0 + 6)
assert_equal(66.0, 60 +
6.0)
assert_equal(5.1, g:afloat
+ 5)
assert_equal(8.1, 8 + g:afloat)
assert_equal(10.1, g:anint + g:afloat)
assert_equal(10.1, g:afloat + g:anint)
assert_equal(54.0, 60.0 - 6.0)
assert_equal(54.0, 60.0
- 6)
assert_equal(54.0, 60 - 6.0)
assert_equal(-4.9, g:afloat - 5)
assert_equal(7.9, 8 - g:afloat)
assert_equal(9.9, g:anint - g:afloat)
assert_equal(-9.9, g:afloat - g:anint)
END
v9.CheckDefAndScriptSuccess(lines)
endif
assert_equal(54.0, 60.0 - 6.0)
assert_equal(54.0, 60.0
- 6)
assert_equal(54.0, 60 - 6.0)
assert_equal(-4.9, g:afloat - 5)
assert_equal(7.9, 8 - g:afloat)
assert_equal(9.9, g:anint - g:afloat)
assert_equal(-9.9, g:afloat - g:anint)
END
v9.CheckDefAndScriptSuccess(lines)
enddef
func Test_expr6_fails()
@@ -1852,14 +1816,12 @@ def Test_expr7()
var y = [3]
assert_equal(5, x[0] + y[0])
assert_equal(6, x[0] * y[0])
if has('float')
var xf = [2.0]
var yf = [3.0]
assert_equal(5.0, xf[0]
+ yf[0])
assert_equal(6.0, xf[0]
* yf[0])
endif
var xf = [2.0]
var yf = [3.0]
assert_equal(5.0, xf[0]
+ yf[0])
assert_equal(6.0, xf[0]
* yf[0])
END
v9.CheckDefAndScriptSuccess(lines)
@@ -1874,13 +1836,11 @@ def Test_expr7()
v9.CheckDefExecFailure(['echo 123 / g:zero'], 'E1154: Divide by zero')
v9.CheckDefExecFailure(['echo 123 % g:zero'], 'E1154: Divide by zero')
if has('float')
v9.CheckDefExecAndScriptFailure([
'g:one = 1.0',
'g:two = 2.0',
'echo g:one % g:two',
], 'E804', 3)
endif
v9.CheckDefExecAndScriptFailure([
'g:one = 1.0',
'g:two = 2.0',
'echo g:one % g:two',
], 'E804', 3)
lines =<< trim END
var n = 0
@@ -1948,36 +1908,32 @@ def Test_expr7_vim9script()
enddef
def Test_expr7_float()
if !has('float')
MissingFeature 'float'
else
var lines =<< trim END
assert_equal(36.0, 6.0 * 6)
assert_equal(36.0, 6 *
6.0)
assert_equal(36.0, 6.0 * 6.0)
assert_equal(1.0, g:afloat * g:anint)
var lines =<< trim END
assert_equal(36.0, 6.0 * 6)
assert_equal(36.0, 6 *
6.0)
assert_equal(36.0, 6.0 * 6.0)
assert_equal(1.0, g:afloat * g:anint)
assert_equal(10.0, 60 / 6.0)
assert_equal(10.0, 60.0 /
6)
assert_equal(10.0, 60.0 / 6.0)
assert_equal(0.01, g:afloat / g:anint)
assert_equal(10.0, 60 / 6.0)
assert_equal(10.0, 60.0 /
6)
assert_equal(10.0, 60.0 / 6.0)
assert_equal(0.01, g:afloat / g:anint)
assert_equal(4.0, 6.0 * 4 / 6)
assert_equal(4.0, 6 *
4.0 /
6)
assert_equal(4.0, 6 * 4 / 6.0)
assert_equal(4.0, 6.0 * 4.0 / 6)
assert_equal(4.0, 6 * 4.0 / 6.0)
assert_equal(4.0, 6.0 * 4 / 6.0)
assert_equal(4.0, 6.0 * 4.0 / 6.0)
assert_equal(4.0, 6.0 * 4 / 6)
assert_equal(4.0, 6 *
4.0 /
6)
assert_equal(4.0, 6 * 4 / 6.0)
assert_equal(4.0, 6.0 * 4.0 / 6)
assert_equal(4.0, 6 * 4.0 / 6.0)
assert_equal(4.0, 6.0 * 4 / 6.0)
assert_equal(4.0, 6.0 * 4.0 / 6.0)
assert_equal(4.0, 6.0 * 4.0 / 6.0)
END
v9.CheckDefAndScriptSuccess(lines)
endif
assert_equal(4.0, 6.0 * 4.0 / 6.0)
END
v9.CheckDefAndScriptSuccess(lines)
enddef
func Test_expr7_fails()
@@ -2013,9 +1969,7 @@ func Test_expr7_fails()
call v9.CheckDefAndScriptFailure(["var x = {one: 1} % {two: 2}"], ['E1035:', 'E728:'], 1)
call v9.CheckDefAndScriptFailure(["var x = 0xff[1]"], ['E1107:', 'E1062:'], 1)
if has('float')
call v9.CheckDefAndScriptFailure(["var x = 0.7[1]"], ['E1107:', 'E806:'], 1)
endif
call v9.CheckDefAndScriptFailure(["var x = 0.7[1]"], ['E1107:', 'E806:'], 1)
for op in ['*', '/', '%']
let lines = ['var x = 1', op .. '2', '# comment']
@@ -2025,16 +1979,14 @@ func Test_expr7_fails()
endfunc
func Test_expr7_float_fails()
CheckFeature float
call v9.CheckDefAndScriptFailure(["var x = 1.0 % 2"], ['E1035:', 'E804:'], 1)
endfunc
" define here to use old style parsing
if has('float')
let g:float_zero = 0.0
let g:float_neg = -9.8
let g:float_big = 9.9e99
endif
let g:float_zero = 0.0
let g:float_neg = -9.8
let g:float_big = 9.9e99
let g:blob_empty = 0z
let g:blob_one = 0z01
let g:blob_long = 0z0102.0304
@@ -2099,17 +2051,13 @@ enddef
def Test_expr9_float()
# float constant
if !has('float')
MissingFeature 'float'
else
var lines =<< trim END
assert_equal(g:float_zero, .0)
assert_equal(g:float_zero, 0.0)
assert_equal(g:float_neg, -9.8)
assert_equal(g:float_big, 9.9e99)
END
v9.CheckDefAndScriptSuccess(lines)
endif
var lines =<< trim END
assert_equal(g:float_zero, .0)
assert_equal(g:float_zero, 0.0)
assert_equal(g:float_neg, -9.8)
assert_equal(g:float_big, 9.9e99)
END
v9.CheckDefAndScriptSuccess(lines)
enddef
def Test_expr9_blob()
@@ -2797,11 +2745,9 @@ def Test_expr9_dict()
assert_equal('numberexpr', dkeys[12])
assert_equal('number', dkeys[34])
assert_equal('bool', dkeys[true])
if has('float')
dkeys = {[1.2]: 'floatexpr', [3.4]: 'float'}
assert_equal('floatexpr', dkeys[1.2])
assert_equal('float', dkeys[3.4])
endif
dkeys = {[1.2]: 'floatexpr', [3.4]: 'float'}
assert_equal('floatexpr', dkeys[1.2])
assert_equal('float', dkeys[3.4])
# automatic conversion from number to string
var n = 123
+62 -88
View File
@@ -6490,9 +6490,7 @@ func Test_type()
call assert_equal(2, type(function("tr", [8])))
call assert_equal(3, type([]))
call assert_equal(4, type({}))
if has('float')
call assert_equal(5, type(0.0))
endif
call assert_equal(5, type(0.0))
call assert_equal(6, type(v:false))
call assert_equal(6, type(v:true))
call assert_equal(7, type(v:none))
@@ -6505,9 +6503,7 @@ func Test_type()
call assert_equal(v:t_func, type(function("tr", [8])))
call assert_equal(v:t_list, type([]))
call assert_equal(v:t_dict, type({}))
if has('float')
call assert_equal(v:t_float, type(0.0))
endif
call assert_equal(v:t_float, type(0.0))
call assert_equal(v:t_bool, type(v:false))
call assert_equal(v:t_bool, type(v:true))
call assert_equal(v:t_none, type(v:none))
@@ -6551,11 +6547,9 @@ func Test_type()
call assert_true(v:none == 0)
call assert_false(v:none == 1)
call assert_false(v:none != 0)
if has('float')
call assert_true(v:null == 0.0)
call assert_false(v:null == 0.1)
call assert_false(v:null != 0.0)
endif
call assert_true(v:null == 0.0)
call assert_false(v:null == 0.1)
call assert_false(v:null != 0.0)
call assert_true(v:false is v:false)
call assert_true(v:true is v:true)
@@ -6670,16 +6664,14 @@ func Test_echo_and_string()
\ "'foo bar'"], l)
" Float
if has('float')
let a = -1.2e0
redir => result
echo a
echo string(a)
redir END
let l = split(result, "\n")
call assert_equal(["-1.2",
\ "-1.2"], l)
endif
let a = -1.2e0
redir => result
echo a
echo string(a)
redir END
let l = split(result, "\n")
call assert_equal(["-1.2",
\ "-1.2"], l)
" Funcref
redir => result
@@ -6816,10 +6808,8 @@ func Test_num64()
call assert_equal(-9223372036854775807, -1 / 0)
call assert_equal(-9223372036854775807 - 1, 0 / 0)
if has('float')
call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150))
call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))
endif
call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150))
call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))
let rng = range(0xFFFFffff, 0x100000001)
call assert_equal([0xFFFFffff, 0x100000000, 0x100000001], rng)
@@ -6921,10 +6911,8 @@ func Test_bitwise_functions()
call assert_equal(0, and(127, 128))
call assert_fails("call and([], 1)", 'E745:')
call assert_fails("call and({}, 1)", 'E728:')
if has('float')
call assert_fails("call and(1.0, 1)", 'E805:')
call assert_fails("call and(1, 1.0)", 'E805:')
endif
call assert_fails("call and(1.0, 1)", 'E805:')
call assert_fails("call and(1, 1.0)", 'E805:')
call assert_fails("call and(1, [])", 'E745:')
call assert_fails("call and(1, {})", 'E728:')
" or
@@ -6934,10 +6922,8 @@ func Test_bitwise_functions()
call assert_equal(123, or(0, 123))
call assert_fails("call or([], 1)", 'E745:')
call assert_fails("call or({}, 1)", 'E728:')
if has('float')
call assert_fails("call or(1.0, 1)", 'E805:')
call assert_fails("call or(1, 1.0)", 'E805:')
endif
call assert_fails("call or(1.0, 1)", 'E805:')
call assert_fails("call or(1, 1.0)", 'E805:')
call assert_fails("call or(1, [])", 'E745:')
call assert_fails("call or(1, {})", 'E728:')
" xor
@@ -6945,10 +6931,8 @@ func Test_bitwise_functions()
call assert_equal(111, xor(127, 16))
eval 127->xor(16)->assert_equal(111)
call assert_equal(255, xor(127, 128))
if has('float')
call assert_fails("call xor(1.0, 1)", 'E805:')
call assert_fails("call xor(1, 1.0)", 'E805:')
endif
call assert_fails("call xor(1.0, 1)", 'E805:')
call assert_fails("call xor(1, 1.0)", 'E805:')
call assert_fails("call xor([], 1)", 'E745:')
call assert_fails("call xor({}, 1)", 'E728:')
call assert_fails("call xor(1, [])", 'E745:')
@@ -6958,9 +6942,7 @@ func Test_bitwise_functions()
eval 127->invert()->and(65535)->assert_equal(65408)
call assert_equal(65519, and(invert(16), 65535))
call assert_equal(65407, and(invert(128), 65535))
if has('float')
call assert_fails("call invert(1.0)", 'E805:')
endif
call assert_fails("call invert(1.0)", 'E805:')
call assert_fails("call invert([])", 'E745:')
call assert_fails("call invert({})", 'E728:')
endfunc
@@ -7039,38 +7021,36 @@ func Test_compound_assignment_operators()
let x += 1
call assert_equal(1, x)
if has('float')
" Test for float
let x -= 1.5
call assert_equal(-0.5, x)
let x = 0.5
let x += 4.5
call assert_equal(5.0, x)
let x -= 1.5
call assert_equal(3.5, x)
let x *= 3.0
call assert_equal(10.5, x)
let x /= 2.5
call assert_equal(4.2, x)
call assert_fails('let x %= 0.5', 'E734:')
call assert_fails('let x .= "f"', 'E734:')
let x = !3.14
call assert_equal(0.0, x)
" Test for float
let x -= 1.5
call assert_equal(-0.5, x)
let x = 0.5
let x += 4.5
call assert_equal(5.0, x)
let x -= 1.5
call assert_equal(3.5, x)
let x *= 3.0
call assert_equal(10.5, x)
let x /= 2.5
call assert_equal(4.2, x)
call assert_fails('let x %= 0.5', 'E734:')
call assert_fails('let x .= "f"', 'E734:')
let x = !3.14
call assert_equal(0.0, x)
" integer and float operations
let x = 1
let x *= 2.1
call assert_equal(2.1, x)
let x = 1
let x /= 0.25
call assert_equal(4.0, x)
let x = 1
call assert_fails('let x %= 0.25', 'E734:')
let x = 1
call assert_fails('let x .= 0.25', 'E734:')
let x = 1.0
call assert_fails('let x += [1.1]', 'E734:')
endif
" integer and float operations
let x = 1
let x *= 2.1
call assert_equal(2.1, x)
let x = 1
let x /= 0.25
call assert_equal(4.0, x)
let x = 1
call assert_fails('let x %= 0.25', 'E734:')
let x = 1
call assert_fails('let x .= 0.25', 'E734:')
let x = 1.0
call assert_fails('let x += [1.1]', 'E734:')
" Test for environment variable
let $FOO = 1
@@ -7142,9 +7122,7 @@ func Test_refcount()
call assert_equal(0, test_refcount({}))
call assert_equal(0, test_refcount(0zff))
call assert_equal(0, test_refcount({-> line('.')}))
if has('float')
call assert_equal(-1, test_refcount(0.1))
endif
call assert_equal(-1, test_refcount(0.1))
if has('job')
call assert_equal(0, test_refcount(job_start([&shell, &shellcmdflag, 'echo .'])))
endif
@@ -7156,10 +7134,8 @@ func Test_refcount()
call assert_equal(-1, test_refcount(x))
let x = v:true
call assert_equal(-1, test_refcount(x))
if has('float')
let x = 0.1
call assert_equal(-1, test_refcount(x))
endif
let x = 0.1
call assert_equal(-1, test_refcount(x))
" Check refcount
let x = []
@@ -7377,16 +7353,14 @@ endfunc
" Test for errors in converting to float from various types {{{1
func Test_float_conversion_errors()
if has('float')
call assert_fails('let x = 4.0 % 2.0', 'E804:')
call assert_fails('echo 1.1[0]', 'E806:')
call assert_fails('echo sort([function("min"), 1], "f")', 'E891:')
call assert_fails('echo 3.2 == "vim"', 'E892:')
call assert_fails('echo sort([[], 1], "f")', 'E893:')
call assert_fails('echo sort([{}, 1], "f")', 'E894:')
call assert_fails('echo 3.2 == v:true', 'E362:')
call assert_fails('echo 3.2 == v:none', 'E907:')
endif
call assert_fails('let x = 4.0 % 2.0', 'E804:')
call assert_fails('echo 1.1[0]', 'E806:')
call assert_fails('echo sort([function("min"), 1], "f")', 'E891:')
call assert_fails('echo 3.2 == "vim"', 'E892:')
call assert_fails('echo sort([[], 1], "f")', 'E893:')
call assert_fails('echo sort([{}, 1], "f")', 'E894:')
call assert_fails('echo 3.2 == v:true', 'E362:')
call assert_fails('echo 3.2 == v:none', 'E907:')
endfunc
" invalid function names {{{1
-2
View File
@@ -787,7 +787,6 @@ assert_inrange(typval_T *argvars)
char msg[200];
char_u numbuf[NUMBUFLEN];
#ifdef FEAT_FLOAT
if (argvars[0].v_type == VAR_FLOAT
|| argvars[1].v_type == VAR_FLOAT
|| argvars[2].v_type == VAR_FLOAT)
@@ -816,7 +815,6 @@ assert_inrange(typval_T *argvars)
}
}
else
#endif
{
varnumber_T lower = tv_get_number_chk(&argvars[0], &error);
varnumber_T upper = tv_get_number_chk(&argvars[1], &error);
+4 -6
View File
@@ -221,20 +221,19 @@ f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
# endif
}
# ifdef FEAT_FLOAT
/*
* "reltimefloat()" function
*/
void
f_reltimefloat(typval_T *argvars UNUSED, typval_T *rettv)
{
# ifdef FEAT_RELTIME
# ifdef FEAT_RELTIME
proftime_T tm;
# endif
# endif
rettv->v_type = VAR_FLOAT;
rettv->vval.v_float = 0;
# ifdef FEAT_RELTIME
# ifdef FEAT_RELTIME
if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
return;
@@ -242,9 +241,8 @@ f_reltimefloat(typval_T *argvars UNUSED, typval_T *rettv)
rettv->vval.v_float = profile_float(&tm);
else if (in_vim9script())
emsg(_(e_invalid_argument));
# endif
}
# endif
}
/*
* "reltimestr()" function
-18
View File
@@ -136,10 +136,8 @@ clear_tv(typval_T *varp)
varp->vval.v_number = 0;
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
varp->vval.v_float = 0.0;
break;
#endif
case VAR_JOB:
#ifdef FEAT_JOB_CHANNEL
job_unref(varp->vval.v_job);
@@ -190,10 +188,8 @@ tv_get_bool_or_number_chk(typval_T *varp, int *denote, int want_bool)
}
return varp->vval.v_number;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
emsg(_(e_using_float_as_number));
break;
#endif
case VAR_FUNC:
case VAR_PARTIAL:
emsg(_(e_using_funcref_as_number));
@@ -296,7 +292,6 @@ tv_get_bool_chk(typval_T *varp, int *denote)
return tv_get_bool_or_number_chk(varp, denote, TRUE);
}
#if defined(FEAT_FLOAT) || defined(PROTO)
static float_T
tv_get_float_chk(typval_T *varp, int *error)
{
@@ -357,7 +352,6 @@ tv_get_float(typval_T *varp)
{
return tv_get_float_chk(varp, NULL);
}
#endif
/*
* Give an error and return FAIL unless "args[idx]" is unknown
@@ -1007,7 +1001,6 @@ tv_get_string_buf_chk_strict(typval_T *varp, char_u *buf, int strict)
emsg(_(e_using_dictionary_as_string));
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
if (strict)
{
emsg(_(e_using_float_as_string));
@@ -1015,7 +1008,6 @@ tv_get_string_buf_chk_strict(typval_T *varp, char_u *buf, int strict)
}
vim_snprintf((char *)buf, NUMBUFLEN, "%g", varp->vval.v_float);
return buf;
#endif
case VAR_STRING:
if (varp->vval.v_string != NULL)
return varp->vval.v_string;
@@ -1136,10 +1128,8 @@ copy_tv(typval_T *from, typval_T *to)
to->vval.v_number = from->vval.v_number;
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
to->vval.v_float = from->vval.v_float;
break;
#endif
case VAR_JOB:
#ifdef FEAT_JOB_CHANNEL
to->vval.v_job = from->vval.v_job;
@@ -1289,7 +1279,6 @@ typval_compare(
n1 = res;
}
#ifdef FEAT_FLOAT
// If one of the two variables is a float, compare as a float.
// When using "=~" or "!~", always compare as string.
else if ((tv1->v_type == VAR_FLOAT || tv2->v_type == VAR_FLOAT)
@@ -1322,7 +1311,6 @@ typval_compare(
default: break; // avoid gcc warning
}
}
#endif
// If one of the two variables is a number, compare as a number.
// When using "=~" or "!~", always compare as string.
@@ -1489,11 +1477,9 @@ typval_compare_null(typval_T *tv1, typval_T *tv2)
case VAR_NUMBER: if (!in_vim9script())
return tv->vval.v_number == 0;
break;
#ifdef FEAT_FLOAT
case VAR_FLOAT: if (!in_vim9script())
return tv->vval.v_float == 0.0;
break;
#endif
default: break;
}
}
@@ -1870,9 +1856,7 @@ tv_equal(
return ((ic ? MB_STRICMP(s1, s2) : STRCMP(s1, s2)) == 0);
case VAR_FLOAT:
#ifdef FEAT_FLOAT
return tv1->vval.v_float == tv2->vval.v_float;
#endif
case VAR_JOB:
#ifdef FEAT_JOB_CHANNEL
return tv1->vval.v_job == tv2->vval.v_job;
@@ -2005,7 +1989,6 @@ eval_number(
{
int len;
int skip_quotes = !in_old_script(4);
#ifdef FEAT_FLOAT
char_u *p;
int get_float = FALSE;
@@ -2062,7 +2045,6 @@ eval_number(
}
}
else
#endif
if (**arg == '0' && ((*arg)[1] == 'z' || (*arg)[1] == 'Z'))
{
char_u *bp;
+2 -4
View File
@@ -244,11 +244,7 @@ static char *(features[]) =
#else
"-find_in_path",
#endif
#ifdef FEAT_FLOAT
"+float",
#else
"-float",
#endif
#ifdef FEAT_FOLDING
"+folding",
#else
@@ -703,6 +699,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
491,
/**/
490,
/**/
-2
View File
@@ -469,9 +469,7 @@ struct isn_S {
varnumber_T number;
blob_T *blob;
vartype_T vartype;
#ifdef FEAT_FLOAT
float_T fnumber;
#endif
channel_T *channel;
job_T *job;
partial_T *partial;
-4
View File
@@ -2384,9 +2384,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
r = generate_PUSHBOOL(cctx, VVAL_FALSE);
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
r = generate_PUSHF(cctx, 0.0);
#endif
break;
case VAR_STRING:
r = generate_PUSHS(cctx, NULL);
@@ -2455,11 +2453,9 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
expected = lhs.lhs_member_type;
stacktype = get_type_on_stack(cctx, 0);
if (
#ifdef FEAT_FLOAT
// If variable is float operation with number is OK.
!(expected == &t_float && (stacktype == &t_number
|| stacktype == &t_number_bool)) &&
#endif
need_type(stacktype, expected, -1, 0, cctx,
FALSE, FALSE) == FAIL)
goto theend;
-24
View File
@@ -3872,12 +3872,10 @@ exec_instructions(ectx_T *ectx)
tv->v_type = VAR_SPECIAL;
tv->vval.v_number = iptr->isn_arg.number;
break;
#ifdef FEAT_FLOAT
case ISN_PUSHF:
tv->v_type = VAR_FLOAT;
tv->vval.v_float = iptr->isn_arg.fnumber;
break;
#endif
case ISN_PUSHBLOB:
blob_copy(iptr->isn_arg.blob, tv);
break;
@@ -4569,7 +4567,6 @@ exec_instructions(ectx_T *ectx)
// Computation with two float arguments
case ISN_OPFLOAT:
case ISN_COMPAREFLOAT:
#ifdef FEAT_FLOAT
{
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
@@ -4602,7 +4599,6 @@ exec_instructions(ectx_T *ectx)
else
tv1->vval.v_float = res;
}
#endif
break;
case ISN_COMPARELIST:
@@ -4744,9 +4740,7 @@ exec_instructions(ectx_T *ectx)
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
varnumber_T n1, n2;
#ifdef FEAT_FLOAT
float_T f1 = 0, f2 = 0;
#endif
int error = FALSE;
if (iptr->isn_arg.op.op_type == EXPR_ADD)
@@ -4767,42 +4761,33 @@ exec_instructions(ectx_T *ectx)
break;
}
}
#ifdef FEAT_FLOAT
if (tv1->v_type == VAR_FLOAT)
{
f1 = tv1->vval.v_float;
n1 = 0;
}
else
#endif
{
SOURCING_LNUM = iptr->isn_lnum;
n1 = tv_get_number_chk(tv1, &error);
if (error)
goto on_error;
#ifdef FEAT_FLOAT
if (tv2->v_type == VAR_FLOAT)
f1 = n1;
#endif
}
#ifdef FEAT_FLOAT
if (tv2->v_type == VAR_FLOAT)
{
f2 = tv2->vval.v_float;
n2 = 0;
}
else
#endif
{
n2 = tv_get_number_chk(tv2, &error);
if (error)
goto on_error;
#ifdef FEAT_FLOAT
if (tv1->v_type == VAR_FLOAT)
f2 = n2;
#endif
}
#ifdef FEAT_FLOAT
// if there is a float on either side the result is a float
if (tv1->v_type == VAR_FLOAT || tv2->v_type == VAR_FLOAT)
{
@@ -4823,7 +4808,6 @@ exec_instructions(ectx_T *ectx)
--ectx->ec_stack.ga_len;
}
else
#endif
{
int failed = FALSE;
@@ -5110,11 +5094,9 @@ exec_instructions(ectx_T *ectx)
case ISN_NEGATENR:
tv = STACK_TV_BOT(-1);
// CHECKTYPE should have checked the variable type
#ifdef FEAT_FLOAT
if (tv->v_type == VAR_FLOAT)
tv->vval.v_float = -tv->vval.v_float;
else
#endif
tv->vval.v_number = -tv->vval.v_number;
break;
@@ -6279,9 +6261,7 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
get_var_special_name(iptr->isn_arg.number));
break;
case ISN_PUSHF:
#ifdef FEAT_FLOAT
smsg("%s%4d PUSHF %g", pfx, current, iptr->isn_arg.fnumber);
#endif
break;
case ISN_PUSHS:
smsg("%s%4d PUSHS \"%s\"", pfx, current, iptr->isn_arg.string);
@@ -6896,11 +6876,7 @@ tv2bool(typval_T *tv)
case VAR_NUMBER:
return tv->vval.v_number != 0;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
return tv->vval.v_float != 0.0;
#else
break;
#endif
case VAR_PARTIAL:
return tv->vval.v_partial != NULL;
case VAR_FUNC:
-2
View File
@@ -1488,14 +1488,12 @@ apply_leader(typval_T *rettv, int numeric_only, char_u *start, char_u **end)
if (*p == '-' || *p == '+')
{
// only '-' has an effect, for '+' we only check the type
#ifdef FEAT_FLOAT
if (rettv->v_type == VAR_FLOAT)
{
if (*p == '-')
rettv->vval.v_float = -rettv->vval.v_float;
}
else
#endif
{
varnumber_T val;
int error = FALSE;
+1 -13
View File
@@ -208,9 +208,7 @@ generate_add_instr(
vartype == VAR_NUMBER ? ISN_OPNR
: vartype == VAR_LIST ? ISN_ADDLIST
: vartype == VAR_BLOB ? ISN_ADDBLOB
#ifdef FEAT_FLOAT
: vartype == VAR_FLOAT ? ISN_OPFLOAT
#endif
: ISN_OPANY, 1);
if (vartype != VAR_LIST && vartype != VAR_BLOB
@@ -251,9 +249,7 @@ operator_type(type_T *type1, type_T *type2)
if (type1->tt_type == type2->tt_type
&& (type1->tt_type == VAR_NUMBER
|| type1->tt_type == VAR_LIST
#ifdef FEAT_FLOAT
|| type1->tt_type == VAR_FLOAT
#endif
|| type1->tt_type == VAR_BLOB))
return type1->tt_type;
return VAR_ANY;
@@ -293,10 +289,8 @@ generate_two_op(cctx_T *cctx, char_u *op)
return FAIL;
if (vartype == VAR_NUMBER)
isn = generate_instr_drop(cctx, ISN_OPNR, 1);
#ifdef FEAT_FLOAT
else if (vartype == VAR_FLOAT)
isn = generate_instr_drop(cctx, ISN_OPFLOAT, 1);
#endif
else
isn = generate_instr_drop(cctx, ISN_OPANY, 1);
if (isn != NULL)
@@ -326,12 +320,10 @@ generate_two_op(cctx_T *cctx, char_u *op)
{
type_T *type = &t_any;
#ifdef FEAT_FLOAT
// float+number and number+float results in float
if ((type1->tt_type == VAR_NUMBER || type1->tt_type == VAR_FLOAT)
&& (type2->tt_type == VAR_NUMBER || type2->tt_type == VAR_FLOAT))
&& (type2->tt_type == VAR_NUMBER || type2->tt_type == VAR_FLOAT))
type = &t_float;
#endif
set_type_on_stack(cctx, type, 0);
}
@@ -580,11 +572,9 @@ generate_tv_PUSH(cctx_T *cctx, typval_T *tv)
case VAR_NUMBER:
generate_PUSHNR(cctx, tv->vval.v_number);
break;
#ifdef FEAT_FLOAT
case VAR_FLOAT:
generate_PUSHF(cctx, tv->vval.v_float);
break;
#endif
case VAR_BLOB:
generate_PUSHBLOB(cctx, tv->vval.v_blob);
tv->vval.v_blob = NULL;
@@ -688,7 +678,6 @@ generate_PUSHSPEC(cctx_T *cctx, varnumber_T number)
return OK;
}
#if defined(FEAT_FLOAT) || defined(PROTO)
/*
* Generate an ISN_PUSHF instruction.
*/
@@ -704,7 +693,6 @@ generate_PUSHF(cctx_T *cctx, float_T fnumber)
return OK;
}
#endif
/*
* Generate an ISN_PUSHS instruction.
-6
View File
@@ -985,14 +985,8 @@ parse_type(char_u **arg, garray_T *type_gap, int give_error)
case 'f':
if (len == 5 && STRNCMP(*arg, "float", len) == 0)
{
#ifdef FEAT_FLOAT
*arg += len;
return &t_float;
#else
if (give_error)
emsg(_(e_this_vim_is_not_compiled_with_float_support));
return NULL;
#endif
}
if (len == 4 && STRNCMP(*arg, "func", len) == 0)
{
-4
View File
@@ -1225,9 +1225,7 @@ read_viminfo_varlist(vir_T *virp, int writing)
switch (*tab)
{
case 'S': type = VAR_STRING; break;
#ifdef FEAT_FLOAT
case 'F': type = VAR_FLOAT; break;
#endif
case 'D': type = VAR_DICT; break;
case 'L': type = VAR_LIST; break;
case 'B': type = VAR_BLOB; break;
@@ -1242,10 +1240,8 @@ read_viminfo_varlist(vir_T *virp, int writing)
|| type == VAR_LIST || type == VAR_BLOB)
tv.vval.v_string = viminfo_readstring(virp,
(int)(tab - virp->vir_line + 1), TRUE);
#ifdef FEAT_FLOAT
else if (type == VAR_FLOAT)
(void)string2float(tab + 1, &tv.vval.v_float, FALSE);
#endif
else
{
tv.vval.v_number = atol((char *)tab + 1);