comparison src/testdir/test_search.vim @ 29224:ca46658481cf v8.2.5131

patch 8.2.5131: timeout implementation is not optimal Commit: https://github.com/vim/vim/commit/e530395c2cd261d598094dc9ea785e90a753c5f1 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 19 17:05:47 2022 +0100 patch 8.2.5131: timeout implementation is not optimal Problem: Timeout implementation is not optimal. Solution: Further improvements for timeouts. Add a test for searchpair() timeout. (partly by Paul Ollis)
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 Jun 2022 18:15:03 +0200
parents 0af5fe160e4e
children 96ff6c230a66
comparison
equal deleted inserted replaced
29223:18ff9d5a73ed 29224:ca46658481cf
353 call assert_inrange(0.09, 0.300, elapsed) 353 call assert_inrange(0.09, 0.300, elapsed)
354 354
355 bwipe! 355 bwipe!
356 endfunc 356 endfunc
357 357
358 func SearchpairSkip()
359 let id = synID(line('.'), col('.'), 0)
360 let attr = synIDattr(id, 'name')
361 return attr !~ 'comment'
362 endfunc
363
364 func Test_searchpair_timeout_with_skip()
365 let g:test_is_flaky = 1
366
367 edit ../evalfunc.c
368 if has('win32')
369 " Windows timeouts are rather coarse grained, about 16ms.
370 let ms = 20
371 let min_time = 0.016
372 let max_time = min_time * 10.0
373 else
374 let ms = 1
375 let min_time = 0.001
376 let max_time = min_time * 10.0
377 if GetVimCommand() =~ 'valgrind.*--log-file='
378 let max_time += 0.04 " this can be slow with valgrind
379 endif
380 endif
381 let start = reltime()
382 let found = searchpair('(', '', ')', 'crnm', 'SearchpairSkip()', 0, ms)
383 let elapsed = reltimefloat(reltime(start))
384 call assert_inrange(min_time, max_time, elapsed)
385
386 bwipe!
387 endfunc
388
358 func Test_searchpairpos() 389 func Test_searchpairpos()
359 new 390 new
360 call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]']) 391 call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]'])
361 392
362 4 393 4