Mercurial > vim
diff src/testdir/test_sort.vim @ 8202:c16aa03d8db5 v7.4.1394
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 22 22:51:33 2016 +0100
patch 7.4.1394
Problem: Can't sort inside a sort function.
Solution: Use a struct to store the sort parameters. (Jacob Niehus)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 22 Feb 2016 23:00:05 +0100 |
parents | 20dc2763a3b9 |
children | c11aaa31a0ed |
line wrap: on
line diff
--- a/src/testdir/test_sort.vim +++ b/src/testdir/test_sort.vim @@ -1,5 +1,14 @@ " Test sort() +:func Compare1(a, b) abort + call sort(range(3), 'Compare2') + return a:a ># a:b +:endfunc + +:func Compare2(a, b) abort + return a:a <# a:b +:endfunc + func Test_sort_strings() " numbers compared as strings call assert_equal([1, 2, 3], sort([3, 2, 1])) @@ -21,3 +30,8 @@ endfunc func Test_sort_float() call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f')) endfunc + +func Test_sort_nested() + " test ability to call sort() from a compare function + call assert_equal([1, 3, 5], sort([3, 1, 5], 'Compare1')) +endfunc