summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_sort.vim
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-12-22 18:19:26 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-22 18:19:26 +0000
commitf973eeb4911de09258e84cb2248dc0f9392824b4 (patch)
tree81ac7737af13f9eff0d6b69306b7ed6691d23804 /src/testdir/test_sort.vim
parent1aeccdb464d81f0af047b399cbad160307a91f7c (diff)
patch 8.2.3871: list.c contains code for dict and blobv8.2.3871
Problem: List.c contains code for dict and blob. Solution: Refactor to put code where it belongs. (Yegappan Lakshmanan, closes #9386)
Diffstat (limited to 'src/testdir/test_sort.vim')
-rw-r--r--src/testdir/test_sort.vim16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/testdir/test_sort.vim b/src/testdir/test_sort.vim
index 82f70fff12..783ca9ed7a 100644
--- a/src/testdir/test_sort.vim
+++ b/src/testdir/test_sort.vim
@@ -1548,4 +1548,20 @@ func Test_sort_with_marks()
close!
endfunc
+" Test for sort() using a dict function
+func Test_sort_using_dict_func()
+ func DictSort(a, b) dict
+ if self.order == 'reverse'
+ return a:b - a:a
+ else
+ return a:a - a:b
+ endif
+ endfunc
+ let d = #{order: ''}
+ call assert_equal([1, 2, 3], sort([2, 1, 3], 'DictSort', d))
+ let d = #{order: 'reverse'}
+ call assert_equal([3, 2, 1], sort([2, 1, 3], 'DictSort', d))
+ delfunc DictSort
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab