Mercurial > vim
comparison src/testdir/test_sort.vim @ 19249:2a017e9dc6da v8.2.0183
patch 8.2.0183: tests fail when the float feature is disabled
Commit: https://github.com/vim/vim/commit/5feabe00c47fa66d5f4c95213f150488433f78e3
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 30 18:24:53 2020 +0100
patch 8.2.0183: tests fail when the float feature is disabled
Problem: Tests fail when the float feature is disabled.
Solution: Skip tests that don't work without float support.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 30 Jan 2020 18:30:04 +0100 |
parents | b8fd7364befd |
children | 6fd567c927c0 |
comparison
equal
deleted
inserted
replaced
19248:5e803caf5e9c | 19249:2a017e9dc6da |
---|---|
1 " Tests for the "sort()" function and for the ":sort" command. | 1 " Tests for the "sort()" function and for the ":sort" command. |
2 | |
3 source check.vim | |
2 | 4 |
3 func Compare1(a, b) abort | 5 func Compare1(a, b) abort |
4 call sort(range(3), 'Compare2') | 6 call sort(range(3), 'Compare2') |
5 return a:a - a:b | 7 return a:a - a:b |
6 endfunc | 8 endfunc |
26 call assert_equal([3, 13, 28], sort([13, 28, 3], 'N')) | 28 call assert_equal([3, 13, 28], sort([13, 28, 3], 'N')) |
27 call assert_equal(['3', '13', '28'], sort(['13', '28', '3'], 'N')) | 29 call assert_equal(['3', '13', '28'], sort(['13', '28', '3'], 'N')) |
28 endfunc | 30 endfunc |
29 | 31 |
30 func Test_sort_float() | 32 func Test_sort_float() |
33 CheckFeature float | |
31 call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f')) | 34 call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f')) |
32 endfunc | 35 endfunc |
33 | 36 |
34 func Test_sort_nested() | 37 func Test_sort_nested() |
35 " test ability to call sort() from a compare function | 38 " test ability to call sort() from a compare function |
36 call assert_equal([1, 3, 5], sort([3, 1, 5], 'Compare1')) | 39 call assert_equal([1, 3, 5], sort([3, 1, 5], 'Compare1')) |
37 endfunc | 40 endfunc |
38 | 41 |
39 func Test_sort_default() | 42 func Test_sort_default() |
43 CheckFeature float | |
44 | |
40 " docs say omitted, empty or zero argument sorts on string representation. | 45 " docs say omitted, empty or zero argument sorts on string representation. |
41 call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"])) | 46 call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"])) |
42 call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"], '')) | 47 call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"], '')) |
43 call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"], 0)) | 48 call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"], 0)) |
44 call assert_equal(['2', 'A', 'a', 'AA', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"], 1)) | 49 call assert_equal(['2', 'A', 'a', 'AA', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"], 1)) |
1143 \ 'b0b101100', | 1148 \ 'b0b101100', |
1144 \ 'b0b111000' | 1149 \ 'b0b111000' |
1145 \ ] | 1150 \ ] |
1146 \ }, | 1151 \ }, |
1147 \ { | 1152 \ { |
1148 \ 'name' : 'float', | |
1149 \ 'cmd' : 'sort f', | |
1150 \ 'input' : [ | |
1151 \ '1.234', | |
1152 \ '0.88', | |
1153 \ ' + 123.456', | |
1154 \ '1.15e-6', | |
1155 \ '-1.1e3', | |
1156 \ '-1.01e3', | |
1157 \ '', | |
1158 \ '' | |
1159 \ ], | |
1160 \ 'expected' : [ | |
1161 \ '', | |
1162 \ '', | |
1163 \ '-1.1e3', | |
1164 \ '-1.01e3', | |
1165 \ '1.15e-6', | |
1166 \ '0.88', | |
1167 \ '1.234', | |
1168 \ ' + 123.456' | |
1169 \ ] | |
1170 \ }, | |
1171 \ { | |
1172 \ 'name' : 'alphabetical, sorted input', | 1153 \ 'name' : 'alphabetical, sorted input', |
1173 \ 'cmd' : 'sort', | 1154 \ 'cmd' : 'sort', |
1174 \ 'input' : [ | 1155 \ 'input' : [ |
1175 \ 'a', | 1156 \ 'a', |
1176 \ 'b', | 1157 \ 'b', |
1220 \ 'BB', | 1201 \ 'BB', |
1221 \ 'Cc' | 1202 \ 'Cc' |
1222 \ ] | 1203 \ ] |
1223 \ }, | 1204 \ }, |
1224 \ ] | 1205 \ ] |
1206 | |
1207 if has('float') | |
1208 let tests += [ | |
1209 \ { | |
1210 \ 'name' : 'float', | |
1211 \ 'cmd' : 'sort f', | |
1212 \ 'input' : [ | |
1213 \ '1.234', | |
1214 \ '0.88', | |
1215 \ ' + 123.456', | |
1216 \ '1.15e-6', | |
1217 \ '-1.1e3', | |
1218 \ '-1.01e3', | |
1219 \ '', | |
1220 \ '' | |
1221 \ ], | |
1222 \ 'expected' : [ | |
1223 \ '', | |
1224 \ '', | |
1225 \ '-1.1e3', | |
1226 \ '-1.01e3', | |
1227 \ '1.15e-6', | |
1228 \ '0.88', | |
1229 \ '1.234', | |
1230 \ ' + 123.456' | |
1231 \ ] | |
1232 \ }, | |
1233 \ ] | |
1234 endif | |
1225 | 1235 |
1226 for t in tests | 1236 for t in tests |
1227 enew! | 1237 enew! |
1228 call append(0, t.input) | 1238 call append(0, t.input) |
1229 $delete _ | 1239 $delete _ |