aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-04-20 00:59:25 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2021-04-20 10:12:09 +0100
commit8c55a16e7d9ad14df797d17802ab749e20b433c7 (patch)
treeec864cac586311a6d93669235247405c00db563b
parenta83292685bc582744804a14f4fcb417502f40707 (diff)
downloadrneovim-8c55a16e7d9ad14df797d17802ab749e20b433c7.tar.gz
rneovim-8c55a16e7d9ad14df797d17802ab749e20b433c7.tar.bz2
rneovim-8c55a16e7d9ad14df797d17802ab749e20b433c7.zip
vim-patch:8.2.1946: sort() with NULL string not tested
Problem: sort() with NULL string not tested. Solution: Add a test. use v:collate. (Dominique Pellé, closes vim/vim#7247) https://github.com/vim/vim/commit/35efa22ff2b98126363098db9304796b5624f97f
-rw-r--r--src/nvim/testdir/test_sort.vim13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim
index e4584a8eb7..3b1dc4ae1c 100644
--- a/src/nvim/testdir/test_sort.vim
+++ b/src/nvim/testdir/test_sort.vim
@@ -22,21 +22,25 @@ func Test_sort_strings()
" This does not appear to work correctly on Mac.
if !has('mac')
- let lc = execute('language collate')
" With the following locales, the accentuated letters are ordered
" similarly to the non-accentuated letters...
- if lc =~? '"\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8"'
+ if v:collate =~? '^\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8$'
call assert_equal(['a', 'A', 'ä', 'Ä', 'o', 'O', 'ô', 'Ô', 'œ', 'œ', 'p', 'P'],
\ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l'))
" ... whereas with a Swedish locale, the accentuated letters are ordered
" after Z.
- elseif lc =~? '"sv.*utf-\?8"'
+ elseif v:collate =~? '^sv.*utf-\?8$'
call assert_equal(['a', 'A', 'o', 'O', 'p', 'P', 'ä', 'Ä', 'œ', 'œ', 'ô', 'Ô'],
\ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l'))
endif
endif
endfunc
+func Test_sort_null_string()
+ " null strings are sorted as empty strings.
+ call assert_equal(['', 'a', 'b'], sort(['b', v:_null_string, 'a']))
+endfunc
+
func Test_sort_numeric()
call assert_equal([1, 2, 3], sort([3, 2, 1], 'n'))
call assert_equal([3, 13, 28], sort([13, 28, 3], 'n'))
@@ -1248,8 +1252,7 @@ func Test_sort_cmd()
" With the following locales, the accentuated letters are ordered
" similarly to the non-accentuated letters.
" This does not appear to work on Mac
- let lc = execute('language collate')
- if lc =~? '"\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8"' && !has('mac')
+ if v:collate =~? '^\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8$' && !has('mac')
let tests += [
\ {
\ 'name' : 'sort with locale',