diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2018-09-27 10:47:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-27 10:47:37 +0200 |
| commit | 33887206b9e94a1ed7cce898d869023ff6ceb874 (patch) | |
| tree | e4b499748288526e5a41e5880d60184bea324784 /src/nvim/testdir | |
| parent | ba17bcfefc626729d30388401b77ef524f9c90d2 (diff) | |
| parent | 96a34daab76f4ab24fea499d5fd929542c0997b0 (diff) | |
| download | rneovim-33887206b9e94a1ed7cce898d869023ff6ceb874.tar.gz rneovim-33887206b9e94a1ed7cce898d869023ff6ceb874.tar.bz2 rneovim-33887206b9e94a1ed7cce898d869023ff6ceb874.zip | |
Merge #9060 from janlazo/vim-8.1.0120
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_sort.vim | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim index 4fddb47b58..6dc1d468c0 100644 --- a/src/nvim/testdir/test_sort.vim +++ b/src/nvim/testdir/test_sort.vim @@ -1,13 +1,13 @@ -" Test sort() +" Tests for the "sort()" function and for the ":sort" command. -:func Compare1(a, b) abort +func Compare1(a, b) abort call sort(range(3), 'Compare2') return a:a - a:b -:endfunc +endfunc -:func Compare2(a, b) abort +func Compare2(a, b) abort return a:a - a:b -:endfunc +endfunc func Test_sort_strings() " numbers compared as strings @@ -45,7 +45,7 @@ func Test_sort_default() call assert_fails('call sort([3.3, 1, "2"], 3)', "E474") endfunc -" Tests for the :sort command +" Tests for the ":sort" command. func Test_sort_cmd() let tests = [ \ { @@ -1167,15 +1167,54 @@ func Test_sort_cmd() \ '1.234', \ '123.456' \ ] - \ } + \ }, + \ { + \ 'name' : 'alphabetical, sorted input', + \ 'cmd' : 'sort', + \ 'input' : [ + \ 'a', + \ 'b', + \ 'c', + \ ], + \ 'expected' : [ + \ 'a', + \ 'b', + \ 'c', + \ ] + \ }, + \ { + \ 'name' : 'alphabetical, sorted input, unique at end', + \ 'cmd' : 'sort u', + \ 'input' : [ + \ 'aa', + \ 'bb', + \ 'cc', + \ 'cc', + \ ], + \ 'expected' : [ + \ 'aa', + \ 'bb', + \ 'cc', + \ ] + \ }, \ ] for t in tests enew! call append(0, t.input) $delete _ - exe t.cmd + setlocal nomodified + execute t.cmd + call assert_equal(t.expected, getline(1, '$'), t.name) + + " Previously, the ":sort" command would set 'modified' even if the buffer + " contents did not change. Here, we check that this problem is fixed. + if t.input == t.expected + call assert_false(&modified, t.name . ': &mod is not correct') + else + call assert_true(&modified, t.name . ': &mod is not correct') + endif endfor call assert_fails('sort no', 'E474') |