diff options
author | Jurica Bradaric <jbradaric@gmail.com> | 2016-05-14 22:00:27 +0200 |
---|---|---|
committer | Jurica Bradaric <jbradaric@gmail.com> | 2016-06-09 20:34:43 +0200 |
commit | 81b9b37e01ba4ef30dc196990a0bfa3de514b5ad (patch) | |
tree | be7e16a115eeb17a0922675394ce33a31359d986 /test/functional/legacy/function_sort_spec.lua | |
parent | e35562474803f369bdf7cea306640da3bef6cad3 (diff) | |
download | rneovim-81b9b37e01ba4ef30dc196990a0bfa3de514b5ad.tar.gz rneovim-81b9b37e01ba4ef30dc196990a0bfa3de514b5ad.tar.bz2 rneovim-81b9b37e01ba4ef30dc196990a0bfa3de514b5ad.zip |
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
Diffstat (limited to 'test/functional/legacy/function_sort_spec.lua')
-rw-r--r-- | test/functional/legacy/function_sort_spec.lua | 13 |
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) |