patch 8.2.2949: tests failing because no error for float to string conversion
Problem: Tests failing because there is no error for float to string
conversion.
Solution: Change the check for failure to check for correct result. Make
some conversions strict in Vim9 script.
diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim
index 4549f48..0c1e75d 100644
--- a/src/testdir/test_eval_stuff.vim
+++ b/src/testdir/test_eval_stuff.vim
@@ -144,7 +144,7 @@
if has('float')
let a = 'A'
let b = 1.234
- call assert_fails('echo a .. b', 'E806:')
+ call assert_equal('A1.234', a .. b)
endif
endfunc
diff --git a/src/testdir/test_execute_func.vim b/src/testdir/test_execute_func.vim
index 0363717..c08b239 100644
--- a/src/testdir/test_execute_func.vim
+++ b/src/testdir/test_execute_func.vim
@@ -2,6 +2,7 @@
source view_util.vim
source check.vim
+source vim9.vim
func NestedEval()
let nested = execute('echo "nested\nlines"')
@@ -37,8 +38,9 @@
call assert_equal("\nsomething", execute('echo "something"', 'silent!'))
call assert_equal("", execute('burp', 'silent!'))
if has('float')
- call assert_fails('call execute(3.4)', 'E806:')
- call assert_fails('call execute("echo \"x\"", 3.4)', 'E806:')
+ call assert_fails('call execute(3.4)', 'E492:')
+ call assert_equal("\nx", execute("echo \"x\"", 3.4))
+ call CheckDefExecAndScriptFailure(['execute("echo \"x\"", 3.4)'], 'E806:')
endif
endfunc
diff --git a/src/testdir/test_float_func.vim b/src/testdir/test_float_func.vim
index 17b5cda..b10bffd 100644
--- a/src/testdir/test_float_func.vim
+++ b/src/testdir/test_float_func.vim
@@ -2,6 +2,7 @@
source check.vim
CheckFeature float
+source vim9.vim
func Test_abs()
call assert_equal('1.23', string(abs(1.23)))
@@ -238,7 +239,9 @@
call assert_equal('nan', string(str2float('NaN')))
call assert_equal('nan', string(str2float(' nan ')))
- call assert_fails("call str2float(1.2)", 'E806:')
+ call assert_equal(1.2, str2float(1.2))
+ call CheckDefExecFailure(['str2float(1.2)'], 'E1013:')
+ call CheckScriptFailure(['vim9script', 'str2float(1.2)'], 'E806:')
call assert_fails("call str2float([])", 'E730:')
call assert_fails("call str2float({})", 'E731:')
call assert_fails("call str2float(function('string'))", 'E729:')
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index bc96491..023da66 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -165,11 +165,13 @@
call assert_fails('call strwidth({->0})', 'E729:')
call assert_fails('call strwidth([])', 'E730:')
call assert_fails('call strwidth({})', 'E731:')
- if has('float')
- call assert_fails('call strwidth(1.2)', 'E806:')
- endif
endfor
+ if has('float')
+ call assert_equal(3, strwidth(1.2))
+ call CheckDefExecAndScriptFailure(['echo strwidth(1.2)'], 'E806:')
+ endif
+
set ambiwidth&
endfunc
@@ -233,7 +235,9 @@
call assert_fails('call str2nr([])', 'E730:')
call assert_fails('call str2nr({->2})', 'E729:')
if has('float')
- call assert_fails('call str2nr(1.2)', 'E806:')
+ call assert_equal(1, str2nr(1.2))
+ call CheckDefExecFailure(['echo str2nr(1.2)'], 'E1013:')
+ call CheckScriptFailure(['vim9script', 'echo str2nr(1.2)'], 'E806:')
endif
call assert_fails('call str2nr(10, [])', 'E745:')
endfunc
@@ -494,7 +498,8 @@
call assert_fails('call simplify([])', 'E730:')
call assert_fails('call simplify({})', 'E731:')
if has('float')
- call assert_fails('call simplify(1.2)', 'E806:')
+ call assert_equal('1.2', simplify(1.2))
+ call CheckDefExecAndScriptFailure(['echo simplify(1.2)'], 'E806:')
endif
endfunc
diff --git a/src/testdir/test_glob2regpat.vim b/src/testdir/test_glob2regpat.vim
index 2907b28..ab459bb 100644
--- a/src/testdir/test_glob2regpat.vim
+++ b/src/testdir/test_glob2regpat.vim
@@ -1,8 +1,11 @@
" Test glob2regpat()
+source vim9.vim
+
func Test_glob2regpat_invalid()
if has('float')
- call assert_fails('call glob2regpat(1.33)', 'E806:')
+ call assert_equal('^1\.33$', glob2regpat(1.33))
+ call CheckDefExecAndScriptFailure(['echo glob2regpat(1.33)'], 'E806:')
endif
call assert_fails('call glob2regpat("}")', 'E219:')
call assert_fails('call glob2regpat("{")', 'E220:')
diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim
index 46b030b..8351acb 100644
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -859,7 +859,7 @@
call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:')
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)", 'E806:')
+ call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E475:')
endif
call assert_equal({'a': 'A', 'b': 'B'}, d)
@@ -1022,9 +1022,9 @@
call assert_fails("let l = insert([1,2,3], 4, [])", 'E745:')
let l = [1, 2, 3]
call assert_fails("let l[i] = 3", 'E121:')
- call assert_fails("let l[1.1] = 4", 'E806:')
+ call assert_fails("let l[1.1] = 4", 'E805:')
call assert_fails("let l[:i] = [4, 5]", 'E121:')
- call assert_fails("let l[:3.2] = [4, 5]", 'E806:')
+ call assert_fails("let l[:3.2] = [4, 5]", 'E805:')
let t = test_unknown()
call assert_fails("echo t[0]", 'E685:')
endfunc