aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-06-09 15:58:37 -0400
committerGitHub <noreply@github.com>2016-06-09 15:58:37 -0400
commit9e94ffd422ddd763b8b7e5185d8c40904d542e6e (patch)
treea6f4be34a53fb6ad670911fd6f9f46d33b5adeaa /test
parente35562474803f369bdf7cea306640da3bef6cad3 (diff)
parent86406ffc80e83afbdab0a57f1bff30e9c246d763 (diff)
downloadrneovim-9e94ffd422ddd763b8b7e5185d8c40904d542e6e.tar.gz
rneovim-9e94ffd422ddd763b8b7e5185d8c40904d542e6e.tar.bz2
rneovim-9e94ffd422ddd763b8b7e5185d8c40904d542e6e.zip
Merge pull request #4758 from jbradaric/vim-7.4.1394
vim-patch:7.4.1394,7.4.1397,7.4.1464,7.4.1468
Diffstat (limited to 'test')
-rw-r--r--test/functional/legacy/function_sort_spec.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/functional/legacy/function_sort_spec.lua b/test/functional/legacy/function_sort_spec.lua
index 9083911021..b274aee94b 100644
--- a/test/functional/legacy/function_sort_spec.lua
+++ b/test/functional/legacy/function_sort_spec.lua
@@ -2,6 +2,9 @@ local helpers = require('test.functional.helpers')
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
+local execute = helpers.execute
+local exc_exec = helpers.exc_exec
+local neq = helpers.neq
describe('sort', function()
before_each(clear)
@@ -26,4 +29,25 @@ 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)
+
+ it('default sort', function()
+ -- docs say omitted, empty or zero argument sorts on string representation
+ eq({'2', 'A', 'AA', 'a', 1, 3.3}, eval('sort([3.3, 1, "2", "A", "a", "AA"])'))
+ eq({'2', 'A', 'AA', 'a', 1, 3.3}, eval([[sort([3.3, 1, "2", "A", "a", "AA"], '')]]))
+ eq({'2', 'A', 'AA', 'a', 1, 3.3}, eval('sort([3.3, 1, "2", "A", "a", "AA"], 0)'))
+ eq({'2', 'A', 'a', 'AA', 1, 3.3}, eval('sort([3.3, 1, "2", "A", "a", "AA"], 1)'))
+ neq(exc_exec('call sort([3.3, 1, "2"], 3)'):find('E474:'), nil)
+ end)
end)