@@ -15,6 +15,25 @@ func Test_sort_strings()
1515 " numbers compared as strings
1616 call assert_equal ([1 , 2 , 3 ], sort ([3 , 2 , 1 ]))
1717 call assert_equal ([13 , 28 , 3 ], sort ([3 , 28 , 13 ]))
18+
19+ call assert_equal ([' A' , ' O' , ' P' , ' a' , ' o' , ' p' , ' Ä' , ' Ô' , ' ä' , ' ô' , ' œ' , ' œ' ],
20+ \ sort ([' A' , ' O' , ' P' , ' a' , ' o' , ' p' , ' Ä' , ' Ô' , ' ä' , ' ô' , ' œ' , ' œ' ]))
21+
22+ call assert_equal ([' A' , ' a' , ' o' , ' O' , ' p' , ' P' , ' Ä' , ' Ô' , ' ä' , ' ô' , ' œ' , ' œ' ],
23+ \ sort ([' A' , ' a' , ' o' , ' O' , ' œ' , ' œ' , ' p' , ' P' , ' Ä' , ' ä' , ' ô' , ' Ô' ], ' i' ))
24+
25+ let lc = execute (' language collate' )
26+ " With the following locales, the accentuated letters are ordered
27+ " similarly to the non-accentuated letters...
28+ if lc = ~? ' "\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8"'
29+ call assert_equal ([' a' , ' A' , ' ä' , ' Ä' , ' o' , ' O' , ' ô' , ' Ô' , ' œ' , ' œ' , ' p' , ' P' ],
30+ \ sort ([' A' , ' a' , ' o' , ' O' , ' œ' , ' œ' , ' p' , ' P' , ' Ä' , ' ä' , ' ô' , ' Ô' ], ' l' ))
31+ " ... whereas with a Swedish locale, the accentuated letters are ordered
32+ " after Z.
33+ elseif lc = ~? ' "sv.*utf-\?8"'
34+ call assert_equal ([' a' , ' A' , ' o' , ' O' , ' p' , ' P' , ' ä' , ' Ä' , ' œ' , ' œ' , ' ô' , ' Ô' ],
35+ \ sort ([' A' , ' a' , ' o' , ' O' , ' œ' , ' œ' , ' p' , ' P' , ' Ä' , ' ä' , ' ô' , ' Ô' ], ' l' ))
36+ endif
1837endfunc
1938
2039func Test_sort_numeric ()
@@ -1204,6 +1223,57 @@ func Test_sort_cmd()
12041223 \ },
12051224 \ ]
12061225
1226+ " With the following locales, the accentuated letters are ordered
1227+ " similarly to the non-accentuated letters...
1228+ let lc = execute (' language collate' )
1229+ if lc = ~? ' "\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8"'
1230+ let tests += [
1231+ \ {
1232+ \ ' name' : ' sort with locale' ,
1233+ \ ' cmd' : ' %sort l' ,
1234+ \ ' input' : [
1235+ \ ' A' ,
1236+ \ ' E' ,
1237+ \ ' O' ,
1238+ \ ' À' ,
1239+ \ ' È' ,
1240+ \ ' É' ,
1241+ \ ' Ô' ,
1242+ \ ' Œ' ,
1243+ \ ' Z' ,
1244+ \ ' a' ,
1245+ \ ' e' ,
1246+ \ ' o' ,
1247+ \ ' à' ,
1248+ \ ' è' ,
1249+ \ ' é' ,
1250+ \ ' ô' ,
1251+ \ ' œ' ,
1252+ \ ' z'
1253+ \ ],
1254+ \ ' expected' : [
1255+ \ ' a' ,
1256+ \ ' A' ,
1257+ \ ' à' ,
1258+ \ ' À' ,
1259+ \ ' e' ,
1260+ \ ' E' ,
1261+ \ ' é' ,
1262+ \ ' É' ,
1263+ \ ' è' ,
1264+ \ ' È' ,
1265+ \ ' o' ,
1266+ \ ' O' ,
1267+ \ ' ô' ,
1268+ \ ' Ô' ,
1269+ \ ' œ' ,
1270+ \ ' Œ' ,
1271+ \ ' z' ,
1272+ \ ' Z'
1273+ \ ]
1274+ \ },
1275+ \ ]
1276+ endif
12071277 if has (' float' )
12081278 let tests += [
12091279 \ {
0 commit comments