aboutsummaryrefslogtreecommitdiff
path: root/test/old/testdir
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-19 17:44:19 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-08-19 18:05:46 +0800
commit4c7df98e4eeed20f8a9c461729935b79743d7752 (patch)
treedd49a0e4c1490d1eb660b6321d108d3924f9de62 /test/old/testdir
parentd7ae9ae3e52362da33902c31ecccc79c49d3866e (diff)
downloadrneovim-4c7df98e4eeed20f8a9c461729935b79743d7752.tar.gz
rneovim-4c7df98e4eeed20f8a9c461729935b79743d7752.tar.bz2
rneovim-4c7df98e4eeed20f8a9c461729935b79743d7752.zip
vim-patch:9.0.1515: reverse() does not work for a String
Problem: reverse() does not work for a String. Solution: Implement reverse() for a String. (Yegappan Lakshmanan, closes vim/vim#12179) https://github.com/vim/vim/commit/03ff1c2dde7f15eca5c9baa6dafbda9b49bedc3b vim-patch:9.0.1738: Duplicate code to reverse a string Problem: Duplicate code to reverse a string Solution: Move reverse_text() to strings.c and remove string_reverse(). closes: vim/vim#12847 https://github.com/vim/vim/commit/4dd266cb66d901cf5324f09405cfea3f004bd29f Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'test/old/testdir')
-rw-r--r--test/old/testdir/test_functions.vim17
-rw-r--r--test/old/testdir/test_listdict.vim2
2 files changed, 18 insertions, 1 deletions
diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim
index c91e989233..dbd1119350 100644
--- a/test/old/testdir/test_functions.vim
+++ b/test/old/testdir/test_functions.vim
@@ -3148,4 +3148,21 @@ func Test_delfunc_while_listing()
call StopVimInTerminal(buf)
endfunc
+" Test for the reverse() function with a string
+func Test_string_reverse()
+ call assert_equal('', reverse(v:_null_string))
+ for [s1, s2] in [['', ''], ['a', 'a'], ['ab', 'ba'], ['abc', 'cba'],
+ \ ['abcd', 'dcba'], ['«-«-»-»', '»-»-«-«'],
+ \ ['🇦', '🇦'], ['🇦🇧', '🇧🇦'], ['🇦🇧🇨', '🇨🇧🇦'],
+ \ ['🇦«🇧-🇨»🇩', '🇩»🇨-🇧«🇦']]
+ call assert_equal(s2, reverse(s1))
+ endfor
+
+ " test in latin1 encoding
+ let save_enc = &encoding
+ " set encoding=latin1
+ call assert_equal('dcba', reverse('abcd'))
+ let &encoding = save_enc
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_listdict.vim b/test/old/testdir/test_listdict.vim
index 354d987c79..3677125d68 100644
--- a/test/old/testdir/test_listdict.vim
+++ b/test/old/testdir/test_listdict.vim
@@ -894,7 +894,7 @@ func Test_reverse_sort_uniq()
END
call CheckLegacyAndVim9Success(lines)
- call assert_fails('call reverse("")', 'E899:')
+ call assert_fails('call reverse({})', 'E899:')
call assert_fails('call uniq([1, 2], {x, y -> []})', 'E745:')
call assert_fails("call sort([1, 2], function('min'), 1)", "E1206:")
call assert_fails("call sort([1, 2], function('invalid_func'))", "E700:")