aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/function_sort_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/legacy/function_sort_spec.lua')
-rw-r--r--test/functional/legacy/function_sort_spec.lua13
1 files changed, 13 insertions, 0 deletions
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)