/*
* Lists of functions that check the argument types of a builtin function.
*/
+argcheck_T arg1_string[] = {arg_string};
argcheck_T arg3_string_nr_bool[] = {arg_string, arg_number, arg_bool};
argcheck_T arg1_float_or_nr[] = {arg_float_or_nr};
argcheck_T arg2_listblob_item[] = {arg_list_or_blob, arg_item_of_prev};
ret_list_number, f_srand},
{"state", 0, 1, FEARG_1, NULL,
ret_string, f_state},
- {"str2float", 1, 1, FEARG_1, NULL,
+ {"str2float", 1, 1, FEARG_1, arg1_string,
ret_float, FLOAT_FUNC(f_str2float)},
{"str2list", 1, 2, FEARG_1, NULL,
ret_list_number, f_str2list},
split(' aa bb ', '\W\+', true)->assert_equal(['', 'aa', 'bb', ''])
enddef
+def Run_str2float()
+ if !has('float')
+ MissingFeature 'float'
+ endif
+ str2float("1.00")->assert_equal(1.00)
+ str2float("2e-2")->assert_equal(0.02)
+
+ CheckDefFailure(['echo str2float(123)'], 'E1013:')
+ CheckScriptFailure(['vim9script', 'echo str2float(123)'], 'E1024:')
+ endif
+enddef
+
def Test_str2nr()
str2nr("1'000'000", 10, true)->assert_equal(1000000)