aboutsummaryrefslogtreecommitdiff
path: root/test/old/testdir/test_functions.vim
diff options
context:
space:
mode:
Diffstat (limited to 'test/old/testdir/test_functions.vim')
-rw-r--r--test/old/testdir/test_functions.vim20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim
index c91e989233..4ad01c8531 100644
--- a/test/old/testdir/test_functions.vim
+++ b/test/old/testdir/test_functions.vim
@@ -3148,4 +3148,24 @@ func Test_delfunc_while_listing()
call StopVimInTerminal(buf)
endfunc
+" Test for the reverse() function with a string
+func Test_string_reverse()
+ let lines =<< trim END
+ 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
+ END
+ call CheckLegacyAndVim9Success(lines)
+
+ " 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