Mercurial > vim
annotate src/testdir/test_sort.vim @ 8259:99a70c3b902f v7.4.1422
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 26 11:17:46 2016 +0100
patch 7.4.1422
Problem: Error when reading fails uses wrong errno. Keeping channel open
after job stops results in test failing.
Solution: Move the error up. Add ch_job_killed.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 26 Feb 2016 11:30:05 +0100 |
parents | c11aaa31a0ed |
children | 2aa24f702b8d |
rev | line source |
---|---|
7291
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test sort() |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
8202
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
3 :func Compare1(a, b) abort |
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
4 call sort(range(3), 'Compare2') |
8208
c11aaa31a0ed
commit https://github.com/vim/vim/commit/0bb6108eb4e1ecaed437bc507f514f5da7816d9e
Christian Brabandt <cb@256bit.org>
parents:
8202
diff
changeset
|
5 return a:a - a:b |
8202
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
6 :endfunc |
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
7 |
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
8 :func Compare2(a, b) abort |
8208
c11aaa31a0ed
commit https://github.com/vim/vim/commit/0bb6108eb4e1ecaed437bc507f514f5da7816d9e
Christian Brabandt <cb@256bit.org>
parents:
8202
diff
changeset
|
9 return a:a - a:b |
8202
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
10 :endfunc |
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
11 |
7291
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 func Test_sort_strings() |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 " numbers compared as strings |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_equal([1, 2, 3], sort([3, 2, 1])) |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 call assert_equal([13, 28, 3], sort([3, 28, 13])) |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 endfunc |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 func Test_sort_numeric() |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 call assert_equal([1, 2, 3], sort([3, 2, 1], 'n')) |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 call assert_equal([3, 13, 28], sort([13, 28, 3], 'n')) |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 " strings are not sorted |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 call assert_equal(['13', '28', '3'], sort(['13', '28', '3'], 'n')) |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 endfunc |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 func Test_sort_numbers() |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 call assert_equal([3, 13, 28], sort([13, 28, 3], 'N')) |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 call assert_equal(['3', '13', '28'], sort(['13', '28', '3'], 'N')) |
6ffc75d807bd
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 endfunc |
7689
20dc2763a3b9
commit https://github.com/vim/vim/commit/f7edf40448a09e04eec3bd05e043f7fea93b07c9
Christian Brabandt <cb@256bit.org>
parents:
7291
diff
changeset
|
29 |
20dc2763a3b9
commit https://github.com/vim/vim/commit/f7edf40448a09e04eec3bd05e043f7fea93b07c9
Christian Brabandt <cb@256bit.org>
parents:
7291
diff
changeset
|
30 func Test_sort_float() |
20dc2763a3b9
commit https://github.com/vim/vim/commit/f7edf40448a09e04eec3bd05e043f7fea93b07c9
Christian Brabandt <cb@256bit.org>
parents:
7291
diff
changeset
|
31 call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f')) |
20dc2763a3b9
commit https://github.com/vim/vim/commit/f7edf40448a09e04eec3bd05e043f7fea93b07c9
Christian Brabandt <cb@256bit.org>
parents:
7291
diff
changeset
|
32 endfunc |
8202
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
33 |
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
34 func Test_sort_nested() |
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
35 " test ability to call sort() from a compare function |
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
36 call assert_equal([1, 3, 5], sort([3, 1, 5], 'Compare1')) |
c16aa03d8db5
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Christian Brabandt <cb@256bit.org>
parents:
7689
diff
changeset
|
37 endfunc |