summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_sort.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-01-30 18:24:53 +0100
committerBram Moolenaar <Bram@vim.org>2020-01-30 18:24:53 +0100
commit5feabe00c47fa66d5f4c95213f150488433f78e3 (patch)
tree9e9e980d294d8a3cc5c004f2733538cabef16d86 /src/testdir/test_sort.vim
parent9f2d020d396132ecbc0be6faa1de29c7078bb5ac (diff)
patch 8.2.0183: tests fail when the float feature is disabledv8.2.0183
Problem: Tests fail when the float feature is disabled. Solution: Skip tests that don't work without float support.
Diffstat (limited to 'src/testdir/test_sort.vim')
-rw-r--r--src/testdir/test_sort.vim58
1 files changed, 34 insertions, 24 deletions
diff --git a/src/testdir/test_sort.vim b/src/testdir/test_sort.vim
index 4abe31d457..b7c68f072f 100644
--- a/src/testdir/test_sort.vim
+++ b/src/testdir/test_sort.vim
@@ -1,5 +1,7 @@
" Tests for the "sort()" function and for the ":sort" command.
+source check.vim
+
func Compare1(a, b) abort
call sort(range(3), 'Compare2')
return a:a - a:b
@@ -28,6 +30,7 @@ func Test_sort_numbers()
endfunc
func Test_sort_float()
+ CheckFeature float
call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f'))
endfunc
@@ -37,6 +40,8 @@ func Test_sort_nested()
endfunc
func Test_sort_default()
+ CheckFeature float
+
" docs say omitted, empty or zero argument sorts on string representation.
call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"]))
call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"], ''))
@@ -1145,30 +1150,6 @@ func Test_sort_cmd()
\ ]
\ },
\ {
- \ 'name' : 'float',
- \ 'cmd' : 'sort f',
- \ 'input' : [
- \ '1.234',
- \ '0.88',
- \ ' + 123.456',
- \ '1.15e-6',
- \ '-1.1e3',
- \ '-1.01e3',
- \ '',
- \ ''
- \ ],
- \ 'expected' : [
- \ '',
- \ '',
- \ '-1.1e3',
- \ '-1.01e3',
- \ '1.15e-6',
- \ '0.88',
- \ '1.234',
- \ ' + 123.456'
- \ ]
- \ },
- \ {
\ 'name' : 'alphabetical, sorted input',
\ 'cmd' : 'sort',
\ 'input' : [
@@ -1223,6 +1204,35 @@ func Test_sort_cmd()
\ },
\ ]
+ if has('float')
+ let tests += [
+ \ {
+ \ 'name' : 'float',
+ \ 'cmd' : 'sort f',
+ \ 'input' : [
+ \ '1.234',
+ \ '0.88',
+ \ ' + 123.456',
+ \ '1.15e-6',
+ \ '-1.1e3',
+ \ '-1.01e3',
+ \ '',
+ \ ''
+ \ ],
+ \ 'expected' : [
+ \ '',
+ \ '',
+ \ '-1.1e3',
+ \ '-1.01e3',
+ \ '1.15e-6',
+ \ '0.88',
+ \ '1.234',
+ \ ' + 123.456'
+ \ ]
+ \ },
+ \ ]
+ endif
+
for t in tests
enew!
call append(0, t.input)