annotate src/testdir/test_sort.vim @ 7291:6ffc75d807bd v7.4.951

commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 3 16:33:12 2015 +0100 patch 7.4.951 Problem: Sorting number strings does not work as expected. (Luc Hermitte) Solution: Add the 'N" argument to sort()
author Christian Brabandt <cb@256bit.org>
date Thu, 03 Dec 2015 16:45:05 +0100
parents
children 20dc2763a3b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6ffc75d807bd commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_sort_strings()
6ffc75d807bd commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " numbers compared as strings
6ffc75d807bd commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 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
6 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
7 endfunc
6ffc75d807bd commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
6ffc75d807bd commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 func Test_sort_numeric()
6ffc75d807bd commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 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
11 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
12 " strings are not sorted
6ffc75d807bd commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 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
14 endfunc
6ffc75d807bd commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
6ffc75d807bd commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 func Test_sort_numbers()
6ffc75d807bd commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 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
18 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
19 endfunc