From c690f1019477e4c9a63e22e7c68bf1f65cc69fc7 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 11 Sep 2021 21:40:10 +0100 Subject: vim-patch:8.2.1524: no longer get an error for string concatenation with float Problem: No longer get an error for string concatenation with float. (Tsuyoshi Cho) Solution: Only convert float for Vim9 script. (closes vim/vim#6787) https://github.com/vim/vim/commit/2e0866128b6266829a7f38733d5188bc4ec68745 Vim9script is N/A. Required for v8.2.2949. Co-authored-by: Bram Moolenaar --- test/old/testdir/test_eval_stuff.vim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/old') diff --git a/test/old/testdir/test_eval_stuff.vim b/test/old/testdir/test_eval_stuff.vim index 20eb873326..ed45eef36c 100644 --- a/test/old/testdir/test_eval_stuff.vim +++ b/test/old/testdir/test_eval_stuff.vim @@ -230,6 +230,12 @@ func Test_string_concatenation() let a = 'a' let a..=b call assert_equal('ab', a) + + if has('float') + let a = 'A' + let b = 1.234 + call assert_fails('echo a .. b', 'E806:') + endif endfunc " Test fix for issue #4507 -- cgit From 7f8c1e53a6c27ce6957b102d7b1c9ec808f61d60 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 11 Sep 2021 19:44:11 +0100 Subject: vim-patch:8.2.2948: substitute() accepts a number but not a float expression Problem: Substitute() accepts a number but not a float expression. Solution: Also accept a float. (closes vim/vim#8331) https://github.com/vim/vim/commit/7a2217bedd223df4c8bbebe731bf0b5fe8532533 Vim9script is N/A. No need to port the strict argument and tv_get_string_buf_chk_strict(), as it's only used for Vim9script. Like the patch, use vim_snprintf over snprintf, as the "%g" specifier in snprintf removes the ".0" from integer floats. This means similiar to numbers, floats are (mostly) convertable to strings. Co-authored-by: Bram Moolenaar --- test/old/testdir/test_substitute.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'test/old') diff --git a/test/old/testdir/test_substitute.vim b/test/old/testdir/test_substitute.vim index daa9426911..a6640aac30 100644 --- a/test/old/testdir/test_substitute.vim +++ b/test/old/testdir/test_substitute.vim @@ -457,7 +457,14 @@ func Test_substitute_partial() " 20 arguments plus one is too many let Replacer = function('SubReplacer20', repeat(['foo'], 20)) - call assert_fails("call substitute('123', '2', Replacer, 'g')", 'E118') + call assert_fails("call substitute('123', '2', Replacer, 'g')", 'E118:') +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 " Tests for *sub-replace-special* and *sub-replace-expression* on :substitute. -- cgit From 7abfb1f86e25efcbe6ec31c8d3f196a60d718123 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 12 Jun 2023 12:48:14 +0800 Subject: vim-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. https://github.com/vim/vim/commit/3cfa5b16b06bcc034f6de77070fa779d698ab5e9 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_eval_stuff.vim | 2 +- test/old/testdir/test_execute_func.vim | 9 +++++++-- test/old/testdir/test_float_func.vim | 5 ++++- test/old/testdir/test_functions.vim | 15 ++++++++++----- test/old/testdir/test_glob2regpat.vim | 5 ++++- test/old/testdir/test_listdict.vim | 6 +++--- test/old/testdir/vim9.vim | 4 ++++ 7 files changed, 33 insertions(+), 13 deletions(-) (limited to 'test/old') diff --git a/test/old/testdir/test_eval_stuff.vim b/test/old/testdir/test_eval_stuff.vim index ed45eef36c..45dfd57842 100644 --- a/test/old/testdir/test_eval_stuff.vim +++ b/test/old/testdir/test_eval_stuff.vim @@ -234,7 +234,7 @@ func Test_string_concatenation() 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/test/old/testdir/test_execute_func.vim b/test/old/testdir/test_execute_func.vim index cc294b7316..61971ec587 100644 --- a/test/old/testdir/test_execute_func.vim +++ b/test/old/testdir/test_execute_func.vim @@ -1,6 +1,8 @@ " test execute() source view_util.vim +source check.vim +source vim9.vim func NestedEval() let nested = execute('echo "nested\nlines"') @@ -31,7 +33,6 @@ func Test_execute_string() call assert_equal("\nthat", evaled) call assert_fails('call execute("doesnotexist")', 'E492:') - call assert_fails('call execute(3.4)', 'E806:') " Nvim supports execute('... :redir ...'), so this test is intentionally " disabled. " call assert_fails('call execute("call NestedRedir()")', 'E930:') @@ -40,7 +41,11 @@ 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!')) - call assert_fails('call execute("echo \"x\"", 3.4)', 'E806:') + if has('float') + 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 func Test_execute_list() diff --git a/test/old/testdir/test_float_func.vim b/test/old/testdir/test_float_func.vim index 902a011a9d..f9a7251d59 100644 --- a/test/old/testdir/test_float_func.vim +++ b/test/old/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 @@ func Test_str2float() call assert_equal("str2float('nan')", string(str2float('NaN'))) call assert_equal("str2float('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/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index 39d994a2df..d80004d70f 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -153,11 +153,13 @@ func Test_strwidth() 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 @@ -221,7 +223,9 @@ func Test_str2nr() 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 @@ -372,7 +376,8 @@ func Test_simplify() 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/test/old/testdir/test_glob2regpat.vim b/test/old/testdir/test_glob2regpat.vim index a423a4a9f0..b9c4c12059 100644 --- a/test/old/testdir/test_glob2regpat.vim +++ b/test/old/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/test/old/testdir/test_listdict.vim b/test/old/testdir/test_listdict.vim index 11dade18f3..3a87616a9e 100644 --- a/test/old/testdir/test_listdict.vim +++ b/test/old/testdir/test_listdict.vim @@ -882,7 +882,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, '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) @@ -1051,9 +1051,9 @@ func Test_listdict_index() 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:') " Nvim doesn't have test_unknown() " let t = test_unknown() " call assert_fails("echo t[0]", 'E685:') diff --git a/test/old/testdir/vim9.vim b/test/old/testdir/vim9.vim index 7b9ec4bfc4..ba0ef53e67 100644 --- a/test/old/testdir/vim9.vim +++ b/test/old/testdir/vim9.vim @@ -2,6 +2,10 @@ " Use a different file name for each run. let s:sequence = 1 +func CheckDefExecFailure(lines, error, lnum = -3) + return +endfunc + func CheckScriptFailure(lines, error, lnum = -3) if get(a:lines, 0, '') ==# 'vim9script' return -- cgit