From 81b9b37e01ba4ef30dc196990a0bfa3de514b5ad Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 14 May 2016 22:00:27 +0200 Subject: vim-patch:7.4.1394 Problem: Can't sort inside a sort function. Solution: Use a struct to store the sort parameters. (Jacob Niehus) https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9 --- test/functional/legacy/function_sort_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional/legacy/function_sort_spec.lua') diff --git a/test/functional/legacy/function_sort_spec.lua b/test/functional/legacy/function_sort_spec.lua index 9083911021..389fbf8e80 100644 --- a/test/functional/legacy/function_sort_spec.lua +++ b/test/functional/legacy/function_sort_spec.lua @@ -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) -- cgit