1
0
forked from aniani/vim

patch 8.2.2286: sort test fails when locale is Canadian English

Problem:    Sort test fails when locale is Canadian English. (Neil H Watson)
Solution:   Expect a different sort order. (closes #7609)
This commit is contained in:
Bram Moolenaar
2021-01-03 16:18:04 +01:00
parent b0d8182fa3
commit fefa6c347e
2 changed files with 111 additions and 55 deletions

View File

@@ -24,14 +24,18 @@ func Test_sort_strings()
" This does not appear to work correctly on Mac. " This does not appear to work correctly on Mac.
if !has('mac') if !has('mac')
" With the following locales, the accentuated letters are ordered if v:collate =~? '^en_ca.*\.utf-\?8$' && !has('mac')
" similarly to the non-accentuated letters... " with Canadian English capitals come before lower case.
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'))
elseif v:collate =~? '^\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8$'
" With the following locales, the accentuated letters are ordered
" similarly to the non-accentuated letters...
call assert_equal(['a', 'A', 'ä', 'Ä', 'o', 'O', 'ô', 'Ô', 'œ', 'œ', 'p', 'P'], call assert_equal(['a', 'A', 'ä', 'Ä', 'o', 'O', 'ô', 'Ô', 'œ', 'œ', 'p', 'P'],
\ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l')) \ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l'))
" ... whereas with a Swedish locale, the accentuated letters are ordered
" after Z.
elseif v:collate =~? '^sv.*utf-\?8$' elseif v:collate =~? '^sv.*utf-\?8$'
" ... whereas with a Swedish locale, the accentuated letters are ordered
" after Z.
call assert_equal(['a', 'A', 'o', 'O', 'p', 'P', 'ä', 'Ä', 'œ', 'œ', 'ô', 'Ô'], call assert_equal(['a', 'A', 'o', 'O', 'p', 'P', 'ä', 'Ä', 'œ', 'œ', 'ô', 'Ô'],
\ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l')) \ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l'))
endif endif
@@ -1230,56 +1234,106 @@ func Test_sort_cmd()
\ }, \ },
\ ] \ ]
" With the following locales, the accentuated letters are ordered " This does not appear to work correctly on Mac.
" similarly to the non-accentuated letters. if !has('mac')
" This does not appear to work on Mac if v:collate =~? '^en_ca.*\.utf-\?8$'
if v:collate =~? '^\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8$' && !has('mac') " en_CA.utf-8 sorts capitals before lower case
let tests += [ let tests += [
\ { \ {
\ 'name' : 'sort with locale', \ 'name' : 'sort with locale ' .. v:collate,
\ 'cmd' : '%sort l', \ 'cmd' : '%sort l',
\ 'input' : [ \ 'input' : [
\ 'A', \ 'A',
\ 'E', \ 'E',
\ 'O', \ 'O',
\ 'À', \ 'À',
\ 'È', \ 'È',
\ 'É', \ 'É',
\ 'Ô', \ 'Ô',
\ 'Œ', \ 'Œ',
\ 'Z', \ 'Z',
\ 'a', \ 'a',
\ 'e', \ 'e',
\ 'o', \ 'o',
\ 'à', \ 'à',
\ 'è', \ 'è',
\ 'é', \ 'é',
\ 'ô', \ 'ô',
\ 'œ', \ 'œ',
\ 'z' \ 'z'
\ ], \ ],
\ 'expected' : [ \ 'expected' : [
\ 'a', \ 'A',
\ 'A', \ 'a',
\ 'à', \ 'À',
\ 'À', \ 'à',
\ 'e', \ 'E',
\ 'E', \ 'e',
\ 'é', \ 'É',
\ 'É', \ 'é',
\ 'è', \ 'È',
\ 'È', \ 'è',
\ 'o', \ 'O',
\ 'O', \ 'o',
\ 'ô', \ 'Ô',
\ 'Ô', \ 'ô',
\ 'œ', \ 'œ',
\ 'Œ', \ 'Œ',
\ 'z', \ 'Z',
\ 'Z' \ 'z'
\ ] \ ]
\ }, \ },
\ ] \ ]
elseif v:collate =~? '^\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8$'
" With these locales, the accentuated letters are ordered
" similarly to the non-accentuated letters.
let tests += [
\ {
\ 'name' : 'sort with locale ' .. v:collate,
\ 'cmd' : '%sort l',
\ 'input' : [
\ 'A',
\ 'E',
\ 'O',
\ 'À',
\ 'È',
\ 'É',
\ 'Ô',
\ 'Œ',
\ 'Z',
\ 'a',
\ 'e',
\ 'o',
\ 'à',
\ 'è',
\ 'é',
\ 'ô',
\ 'œ',
\ 'z'
\ ],
\ 'expected' : [
\ 'a',
\ 'A',
\ 'à',
\ 'À',
\ 'e',
\ 'E',
\ 'é',
\ 'É',
\ 'è',
\ 'È',
\ 'o',
\ 'O',
\ 'ô',
\ 'Ô',
\ 'œ',
\ 'Œ',
\ 'z',
\ 'Z'
\ ]
\ },
\ ]
endif
endif endif
if has('float') if has('float')
let tests += [ let tests += [

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2286,
/**/ /**/
2285, 2285,
/**/ /**/