mirror of
https://github.com/chenasraf/vim-matchup.git
synced 2026-05-17 17:38:01 +00:00
Add a few tests
This commit is contained in:
10
test/new/test-core/Makefile
Normal file
10
test/new/test-core/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
.PHONY: test
|
||||
|
||||
MYVIM ?= nvim --headless
|
||||
|
||||
INMAKE := 1
|
||||
export INMAKE
|
||||
|
||||
test:
|
||||
@$(MYVIM) -u test_pos.vim
|
||||
@$(MYVIM) -u test_perf.vim
|
||||
3
test/new/test-core/test.txt
Normal file
3
test/new/test-core/test.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
example
|
||||
|
||||
|
||||
36
test/new/test-core/test_perf.vim
Normal file
36
test/new/test-core/test_perf.vim
Normal file
@@ -0,0 +1,36 @@
|
||||
set nocompatible
|
||||
source ../common/bootstrap.vim
|
||||
|
||||
function! s:isclose(a, b, rtol)
|
||||
return abs(a:a - a:b) <= a:rtol * abs(a:b)
|
||||
endfunction
|
||||
|
||||
silent edit test.txt
|
||||
|
||||
call matchup#perf#tic('testing')
|
||||
|
||||
call matchup#perf#timeout_start(100)
|
||||
sleep 90m
|
||||
call assert_equal(0, matchup#perf#timeout_check())
|
||||
call assert_true(s:isclose(matchup#perf#timeout(), 10, 0.1))
|
||||
sleep 11m
|
||||
call assert_equal(1, matchup#perf#timeout_check())
|
||||
|
||||
call matchup#perf#toc('testing', 'checkpoint1')
|
||||
|
||||
call matchup#perf#tic('testing')
|
||||
sleep 10m
|
||||
call matchup#perf#toc('testing', 'checkpoint1')
|
||||
|
||||
" [testing]
|
||||
" checkpoint1 101.63ms 101.63ms 101.63ms%
|
||||
let out = matchup#util#command('MatchupShowTimes')
|
||||
let out = join(out, '\n')
|
||||
let p = '\s\+\([0-9.]\+\)ms'
|
||||
let out = matchlist(out, '\[testing]\_.\{-}checkpoint1' . p . p . p)
|
||||
|
||||
call assert_true(s:isclose(out[1], 80, 0.10))
|
||||
call assert_true(s:isclose(out[2], 10, 0.05))
|
||||
call assert_true(s:isclose(out[3], 100, 0.05))
|
||||
|
||||
call matchup#test#finished()
|
||||
26
test/new/test-core/test_pos.vim
Normal file
26
test/new/test-core/test_pos.vim
Normal file
@@ -0,0 +1,26 @@
|
||||
set nocompatible
|
||||
source ../common/bootstrap.vim
|
||||
|
||||
silent edit test.txt
|
||||
|
||||
call matchup#perf#timeout_start(0)
|
||||
|
||||
normal! gg_
|
||||
call assert_equal([0, 1, 1, 0, 1], matchup#pos#get_cursor())
|
||||
|
||||
normal! $
|
||||
call assert_equal([0, 1, 7, 0, 2147483647], matchup#pos#get_cursor())
|
||||
|
||||
let [l, c] = matchup#pos#get_cursor()[1:2]
|
||||
call assert_equal([0, 2, 1, 0], matchup#pos#next(l, c))
|
||||
call assert_equal([0, 1, 8, 0], matchup#pos#next_eol(l, c))
|
||||
|
||||
let pos = matchup#pos#(l, c)
|
||||
let pos = matchup#pos#next_eol(matchup#pos#next_eol(pos))
|
||||
call assert_equal([0, 2, 1, 0], pos)
|
||||
call assert_equal([2, 1], matchup#pos#(pos))
|
||||
|
||||
call assert_equal(1, matchup#pos#smaller_or_equal([2, 10], [3, 1]))
|
||||
call assert_equal(1, matchup#pos#larger([3, 1], [1, 3]))
|
||||
|
||||
call matchup#test#finished()
|
||||
@@ -18,4 +18,4 @@ let s:corresponding = matchup#delim#get_matching(s:current)
|
||||
call matchup#test#assert_equal(9, s:current.lnum)
|
||||
call matchup#test#assert_equal(1, len(s:corresponding))
|
||||
|
||||
quit!
|
||||
call matchup#test#finished()
|
||||
|
||||
Reference in New Issue
Block a user