mirror of
https://github.com/neovim/neovim.git
synced 2026-01-06 03:17:23 +10:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user