Skip to content

Commit 35efa22

Browse files
committed
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 #7247)
1 parent 0d90e72 commit 35efa22

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/testdir/test_sort.vim

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,25 @@ func Test_sort_strings()
2424

2525
" This does not appear to work correctly on Mac.
2626
if !has('mac')
27-
let lc = execute('language collate')
2827
" With the following locales, the accentuated letters are ordered
2928
" similarly to the non-accentuated letters...
30-
if lc =~? '"\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8"'
29+
if v:collate =~? '^\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8$'
3130
call assert_equal(['a', 'A', 'ä', 'Ä', 'o', 'O', 'ô', 'Ô', 'œ', 'œ', 'p', 'P'],
3231
\ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l'))
3332
" ... whereas with a Swedish locale, the accentuated letters are ordered
3433
" after Z.
35-
elseif lc =~? '"sv.*utf-\?8"'
34+
elseif v:collate =~? '^sv.*utf-\?8$'
3635
call assert_equal(['a', 'A', 'o', 'O', 'p', 'P', 'ä', 'Ä', 'œ', 'œ', 'ô', 'Ô'],
3736
\ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l'))
3837
endif
3938
endif
4039
endfunc
4140

41+
func Test_sort_null_string()
42+
" null strings are sorted as empty strings.
43+
call assert_equal(['', 'a', 'b'], sort(['b', test_null_string(), 'a']))
44+
endfunc
45+
4246
func Test_sort_numeric()
4347
call assert_equal([1, 2, 3], sort([3, 2, 1], 'n'))
4448
call assert_equal([3, 13, 28], sort([13, 28, 3], 'n'))
@@ -1229,8 +1233,7 @@ func Test_sort_cmd()
12291233
" With the following locales, the accentuated letters are ordered
12301234
" similarly to the non-accentuated letters.
12311235
" This does not appear to work on Mac
1232-
let lc = execute('language collate')
1233-
if lc =~? '"\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8"' && !has('mac')
1236+
if v:collate =~? '^\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8$' && !has('mac')
12341237
let tests += [
12351238
\ {
12361239
\ 'name' : 'sort with locale',

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1946,
753755
/**/
754756
1945,
755757
/**/

0 commit comments

Comments
 (0)