Mercurial > vim
comparison src/testdir/test_sort.vim @ 19231:b8fd7364befd v8.2.0174
patch 8.2.0174: various commands not completely tested
Commit: https://github.com/vim/vim/commit/5d98dc2a48156d44139b75c689bd3137ff7fe8bf
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 29 21:57:34 2020 +0100
patch 8.2.0174: various commands not completely tested
Problem: Various commands not completely tested.
Solution: Add more test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5551)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 29 Jan 2020 22:00:04 +0100 |
parents | f581167d59bf |
children | 2a017e9dc6da |
comparison
equal
deleted
inserted
replaced
19230:21e430519a6c | 19231:b8fd7364befd |
---|---|
1148 \ 'name' : 'float', | 1148 \ 'name' : 'float', |
1149 \ 'cmd' : 'sort f', | 1149 \ 'cmd' : 'sort f', |
1150 \ 'input' : [ | 1150 \ 'input' : [ |
1151 \ '1.234', | 1151 \ '1.234', |
1152 \ '0.88', | 1152 \ '0.88', |
1153 \ '123.456', | 1153 \ ' + 123.456', |
1154 \ '1.15e-6', | 1154 \ '1.15e-6', |
1155 \ '-1.1e3', | 1155 \ '-1.1e3', |
1156 \ '-1.01e3', | 1156 \ '-1.01e3', |
1157 \ '', | 1157 \ '', |
1158 \ '' | 1158 \ '' |
1163 \ '-1.1e3', | 1163 \ '-1.1e3', |
1164 \ '-1.01e3', | 1164 \ '-1.01e3', |
1165 \ '1.15e-6', | 1165 \ '1.15e-6', |
1166 \ '0.88', | 1166 \ '0.88', |
1167 \ '1.234', | 1167 \ '1.234', |
1168 \ '123.456' | 1168 \ ' + 123.456' |
1169 \ ] | 1169 \ ] |
1170 \ }, | 1170 \ }, |
1171 \ { | 1171 \ { |
1172 \ 'name' : 'alphabetical, sorted input', | 1172 \ 'name' : 'alphabetical, sorted input', |
1173 \ 'cmd' : 'sort', | 1173 \ 'cmd' : 'sort', |
1193 \ ], | 1193 \ ], |
1194 \ 'expected' : [ | 1194 \ 'expected' : [ |
1195 \ 'aa', | 1195 \ 'aa', |
1196 \ 'bb', | 1196 \ 'bb', |
1197 \ 'cc', | 1197 \ 'cc', |
1198 \ ] | |
1199 \ }, | |
1200 \ { | |
1201 \ 'name' : 'sort one line buffer', | |
1202 \ 'cmd' : 'sort', | |
1203 \ 'input' : [ | |
1204 \ 'single line' | |
1205 \ ], | |
1206 \ 'expected' : [ | |
1207 \ 'single line' | |
1208 \ ] | |
1209 \ }, | |
1210 \ { | |
1211 \ 'name' : 'sort ignoring case', | |
1212 \ 'cmd' : '%sort i', | |
1213 \ 'input' : [ | |
1214 \ 'BB', | |
1215 \ 'Cc', | |
1216 \ 'aa' | |
1217 \ ], | |
1218 \ 'expected' : [ | |
1219 \ 'aa', | |
1220 \ 'BB', | |
1221 \ 'Cc' | |
1198 \ ] | 1222 \ ] |
1199 \ }, | 1223 \ }, |
1200 \ ] | 1224 \ ] |
1201 | 1225 |
1202 for t in tests | 1226 for t in tests |
1215 else | 1239 else |
1216 call assert_true(&modified, t.name . ': &mod is not correct') | 1240 call assert_true(&modified, t.name . ': &mod is not correct') |
1217 endif | 1241 endif |
1218 endfor | 1242 endfor |
1219 | 1243 |
1220 call assert_fails('sort no', 'E474') | 1244 " Needs atleast two lines for this test |
1245 call setline(1, ['line1', 'line2']) | |
1246 call assert_fails('sort no', 'E474:') | |
1247 call assert_fails('sort c', 'E475:') | |
1248 call assert_fails('sort #pat%', 'E682:') | |
1221 | 1249 |
1222 enew! | 1250 enew! |
1223 endfunc | 1251 endfunc |
1224 | 1252 |
1225 func Test_sort_large_num() | 1253 func Test_sort_large_num() |
1319 | 1347 |
1320 call assert_equal([1,2,3], map(getline(1, '$'), 'v:val+0')) | 1348 call assert_equal([1,2,3], map(getline(1, '$'), 'v:val+0')) |
1321 " the output comes from the :g command, not from the :sort | 1349 " the output comes from the :g command, not from the :sort |
1322 call assert_match("6 fewer lines", res) | 1350 call assert_match("6 fewer lines", res) |
1323 enew! | 1351 enew! |
1324 endfunc | 1352 endfunc |
1353 | |
1354 " Test for a :sort command followed by another command | |
1355 func Test_sort_followed_by_cmd() | |
1356 new | |
1357 let var = '' | |
1358 call setline(1, ['cc', 'aa', 'bb']) | |
1359 %sort | let var = "sortcmdtest" | |
1360 call assert_equal(var, "sortcmdtest") | |
1361 call assert_equal(['aa', 'bb', 'cc'], getline(1, '$')) | |
1362 " Test for :sort followed by a comment | |
1363 call setline(1, ['3b', '1c', '2a']) | |
1364 %sort /\d\+/ " sort alphabetically | |
1365 call assert_equal(['2a', '3b', '1c'], getline(1, '$')) | |
1366 close! | |
1367 endfunc | |
1368 | |
1369 " Test for :sort using last search pattern | |
1370 func Test_sort_last_search_pat() | |
1371 new | |
1372 let @/ = '\d\+' | |
1373 call setline(1, ['3b', '1c', '2a']) | |
1374 sort // | |
1375 call assert_equal(['2a', '3b', '1c'], getline(1, '$')) | |
1376 close! | |
1377 endfunc | |
1378 | |
1379 " Test for retaining marks across a :sort | |
1380 func Test_sort_with_marks() | |
1381 new | |
1382 call setline(1, ['cc', 'aa', 'bb']) | |
1383 call setpos("'c", [0, 1, 0, 0]) | |
1384 call setpos("'a", [0, 2, 0, 0]) | |
1385 call setpos("'b", [0, 3, 0, 0]) | |
1386 %sort | |
1387 call assert_equal(['aa', 'bb', 'cc'], getline(1, '$')) | |
1388 call assert_equal(2, line("'a")) | |
1389 call assert_equal(3, line("'b")) | |
1390 call assert_equal(1, line("'c")) | |
1391 close! | |
1392 endfunc | |
1393 | |
1394 " vim: shiftwidth=2 sts=2 expandtab |