diff --git a/test/new/test-core/Makefile b/test/new/test-core/Makefile new file mode 100644 index 0000000..27820fd --- /dev/null +++ b/test/new/test-core/Makefile @@ -0,0 +1,10 @@ +.PHONY: test + +MYVIM ?= nvim --headless + +INMAKE := 1 +export INMAKE + +test: + @$(MYVIM) -u test_pos.vim + @$(MYVIM) -u test_perf.vim diff --git a/test/new/test-core/test.txt b/test/new/test-core/test.txt new file mode 100644 index 0000000..3c4d5f9 --- /dev/null +++ b/test/new/test-core/test.txt @@ -0,0 +1,3 @@ +example + + diff --git a/test/new/test-core/test_perf.vim b/test/new/test-core/test_perf.vim new file mode 100644 index 0000000..f4877e7 --- /dev/null +++ b/test/new/test-core/test_perf.vim @@ -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() diff --git a/test/new/test-core/test_pos.vim b/test/new/test-core/test_pos.vim new file mode 100644 index 0000000..75bf3c3 --- /dev/null +++ b/test/new/test-core/test_pos.vim @@ -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() diff --git a/test/new/test-delim/test.vim b/test/new/test-delim/test.vim index 5ccefa5..595cfc1 100644 --- a/test/new/test-delim/test.vim +++ b/test/new/test-delim/test.vim @@ -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()