To: vim_dev@googlegroups.com Subject: Patch 8.2.1946 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1946 Problem: sort() with NULL string not tested. Solution: Add a test. use v:collate. (Dominique Pellé, closes #7247) Files: src/testdir/test_sort.vim *** ../vim-8.2.1945/src/testdir/test_sort.vim 2020-11-01 17:19:01.677362237 +0100 --- src/testdir/test_sort.vim 2020-11-03 18:42:26.959348933 +0100 *************** *** 24,44 **** " 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"' 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"' call assert_equal(['a', 'A', 'o', 'O', 'p', 'P', 'ä', 'Ä', 'œ', 'œ', 'ô', 'Ô'], \ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l')) endif endif 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')) --- 24,48 ---- " This does not appear to work correctly on Mac. if !has('mac') " With the following locales, the accentuated letters are ordered " similarly to the non-accentuated letters... ! 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 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', test_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')) *************** *** 1229,1236 **** " 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') let tests += [ \ { \ 'name' : 'sort with locale', --- 1233,1239 ---- " With the following locales, the accentuated letters are ordered " similarly to the non-accentuated letters. " This does not appear to work on Mac ! if v:collate =~? '^\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8$' && !has('mac') let tests += [ \ { \ 'name' : 'sort with locale', *** ../vim-8.2.1945/src/version.c 2020-11-03 18:20:15.422456327 +0100 --- src/version.c 2020-11-03 18:47:21.042637035 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1946, /**/ -- hundred-and-one symptoms of being an internet addict: 187. You promise yourself that you'll only stay online for another 15 minutes...at least once every hour. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///