aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-09-11 19:44:11 +0100
committerzeertzjq <zeertzjq@outlook.com>2023-06-12 13:27:07 +0800
commit7f8c1e53a6c27ce6957b102d7b1c9ec808f61d60 (patch)
tree3024d342d0f98e83344eaf2fb3add9b750d62101 /test
parentc690f1019477e4c9a63e22e7c68bf1f65cc69fc7 (diff)
downloadrneovim-7f8c1e53a6c27ce6957b102d7b1c9ec808f61d60.tar.gz
rneovim-7f8c1e53a6c27ce6957b102d7b1c9ec808f61d60.tar.bz2
rneovim-7f8c1e53a6c27ce6957b102d7b1c9ec808f61d60.zip
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 <Bram@vim.org>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_substitute.vim9
1 files changed, 8 insertions, 1 deletions
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.