vim-patch:7.4.1394

Problem:    Can't sort inside a sort function.
Solution:   Use a struct to store the sort parameters. (Jacob Niehus)

0b962473dd
This commit is contained in:
Jurica Bradaric
2016-05-14 22:00:27 +02:00
parent e355624748
commit 81b9b37e01
3 changed files with 108 additions and 69 deletions

View File

@@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
local execute = helpers.execute
describe('sort', function()
before_each(clear)
@@ -26,4 +27,16 @@ describe('sort', function()
it('numbers compared as float', function()
eq({0.28, 3, 13.5}, eval("sort([13.5, 0.28, 3], 'f')"))
end)
it('ability to call sort() from a compare function', function()
execute('func Compare1(a, b) abort')
execute([[call sort(range(3), 'Compare2')]])
execute('return a:a ># a:b')
execute('endfunc')
execute('func Compare2(a, b) abort')
execute('return a:a <# a:b')
execute('endfunc')
eq({1, 3, 5}, eval("sort([3, 1, 5], 'Compare1')"))
end)
end)