aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_sort.vim
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-04-19 19:57:19 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2021-04-20 01:50:56 +0100
commit96f62394cfc74e731529ed68039aa8da1facdf13 (patch)
tree3c8ed8650db3b94f93f4279a5fc2219e1784756d /src/nvim/testdir/test_sort.vim
parent26bd5a58dff1b920757f3bc010c2e8f9dbfc9d40 (diff)
downloadrneovim-96f62394cfc74e731529ed68039aa8da1facdf13.tar.gz
rneovim-96f62394cfc74e731529ed68039aa8da1facdf13.tar.bz2
rneovim-96f62394cfc74e731529ed68039aa8da1facdf13.zip
vim-patch:8.2.0174: various commands not completely tested
Problem: Various commands not completely tested. Solution: Add more test cases. (Yegappan Lakshmanan, closes vim/vim#5551) https://github.com/vim/vim/commit/5d98dc2a48156d44139b75c689bd3137ff7fe8bf
Diffstat (limited to 'src/nvim/testdir/test_sort.vim')
-rw-r--r--src/nvim/testdir/test_sort.vim78
1 files changed, 74 insertions, 4 deletions
diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim
index 7533eaf2e8..8287a761c6 100644
--- a/src/nvim/testdir/test_sort.vim
+++ b/src/nvim/testdir/test_sort.vim
@@ -1150,7 +1150,7 @@ func Test_sort_cmd()
\ 'input' : [
\ '1.234',
\ '0.88',
- \ '123.456',
+ \ ' + 123.456',
\ '1.15e-6',
\ '-1.1e3',
\ '-1.01e3',
@@ -1165,7 +1165,7 @@ func Test_sort_cmd()
\ '1.15e-6',
\ '0.88',
\ '1.234',
- \ '123.456'
+ \ ' + 123.456'
\ ]
\ },
\ {
@@ -1197,6 +1197,30 @@ func Test_sort_cmd()
\ 'cc',
\ ]
\ },
+ \ {
+ \ 'name' : 'sort one line buffer',
+ \ 'cmd' : 'sort',
+ \ 'input' : [
+ \ 'single line'
+ \ ],
+ \ 'expected' : [
+ \ 'single line'
+ \ ]
+ \ },
+ \ {
+ \ 'name' : 'sort ignoring case',
+ \ 'cmd' : '%sort i',
+ \ 'input' : [
+ \ 'BB',
+ \ 'Cc',
+ \ 'aa'
+ \ ],
+ \ 'expected' : [
+ \ 'aa',
+ \ 'BB',
+ \ 'Cc'
+ \ ]
+ \ },
\ ]
for t in tests
@@ -1217,7 +1241,11 @@ func Test_sort_cmd()
endif
endfor
- call assert_fails('sort no', 'E474')
+ " Needs atleast two lines for this test
+ call setline(1, ['line1', 'line2'])
+ call assert_fails('sort no', 'E474:')
+ call assert_fails('sort c', 'E475:')
+ call assert_fails('sort #pat%', 'E682:')
enew!
endfunc
@@ -1319,4 +1347,46 @@ func Test_sort_cmd_report()
" the output comes from the :g command, not from the :sort
call assert_match("6 fewer lines", res)
enew!
- endfunc
+endfunc
+
+" Test for a :sort command followed by another command
+func Test_sort_followed_by_cmd()
+ new
+ let var = ''
+ call setline(1, ['cc', 'aa', 'bb'])
+ %sort | let var = "sortcmdtest"
+ call assert_equal(var, "sortcmdtest")
+ call assert_equal(['aa', 'bb', 'cc'], getline(1, '$'))
+ " Test for :sort followed by a comment
+ call setline(1, ['3b', '1c', '2a'])
+ %sort /\d\+/ " sort alphabetically
+ call assert_equal(['2a', '3b', '1c'], getline(1, '$'))
+ close!
+endfunc
+
+" Test for :sort using last search pattern
+func Test_sort_last_search_pat()
+ new
+ let @/ = '\d\+'
+ call setline(1, ['3b', '1c', '2a'])
+ sort //
+ call assert_equal(['2a', '3b', '1c'], getline(1, '$'))
+ close!
+endfunc
+
+" Test for retaining marks across a :sort
+func Test_sort_with_marks()
+ new
+ call setline(1, ['cc', 'aa', 'bb'])
+ call setpos("'c", [0, 1, 0, 0])
+ call setpos("'a", [0, 2, 0, 0])
+ call setpos("'b", [0, 3, 0, 0])
+ %sort
+ call assert_equal(['aa', 'bb', 'cc'], getline(1, '$'))
+ call assert_equal(2, line("'a"))
+ call assert_equal(3, line("'b"))
+ call assert_equal(1, line("'c"))
+ close!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab