diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
| commit | d5f194ce780c95821a855aca3c19426576d28ae0 (patch) | |
| tree | d45f461b19f9118ad2bb1f440a7a08973ad18832 /test/old | |
| parent | c5d770d311841ea5230426cc4c868e8db27300a8 (diff) | |
| parent | 44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff) | |
| download | rneovim-rahm.tar.gz rneovim-rahm.tar.bz2 rneovim-rahm.zip | |
Diffstat (limited to 'test/old')
37 files changed, 3480 insertions, 162 deletions
diff --git a/test/old/testdir/gen_opt_test.vim b/test/old/testdir/gen_opt_test.vim index be5a7e6ee4..f12ce8c7c4 100644 --- a/test/old/testdir/gen_opt_test.vim +++ b/test/old/testdir/gen_opt_test.vim @@ -87,7 +87,7 @@ let test_values = { \ ['xxx', 'help,nofile']], \ 'clipboard': [['', 'unnamed'], ['xxx', '\ze*', 'exclude:\\%(']], \ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup', - \ 'noinsert', 'noselect', 'fuzzy', 'menu,longest'], + \ 'noinsert', 'noselect', 'fuzzy', 'preinsert', 'menu,longest'], \ ['xxx', 'menu,,,longest,']], \ 'encoding': [['utf8'], []], \ 'foldcolumn': [[0, 1, 4, 'auto', 'auto:1', 'auto:9'], [-1, 13, 999]], @@ -117,12 +117,11 @@ let test_values = { "\ 'imstyle': [[0, 1], [-1, 2, 999]], \ 'lines': [[2, 24, 1000], [-1, 0, 1]], \ 'linespace': [[-1, 0, 2, 4, 999], ['']], - \ 'msghistory': [[0, 1, 100, 10000], [-1, 10001]], \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]], \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]], \ 'report': [[0, 1, 2, 9999], [-1]], - \ 'scroll': [[0, 1, 2, 20], [-1, 999]], - \ 'scrolljump': [[-100, -1, 0, 1, 2, 20], [-101, 999]], + \ 'scroll': [[0, 1, 2, 15], [-1, 999]], + \ 'scrolljump': [[-100, -1, 0, 1, 2, 15], [-101, 999]], \ 'scrolloff': [[0, 1, 8, 999], [-1]], \ 'shiftwidth': [[0, 1, 8, 999], [-1]], \ 'sidescroll': [[0, 1, 8, 999], [-1]], @@ -146,8 +145,8 @@ let test_values = { \ 'winwidth': [[1, 10, 999], [-1, 0]], \ "\ string options - \ 'ambiwidth': [['', 'single', 'double'], ['xxx']], - \ 'background': [['', 'light', 'dark'], ['xxx']], + \ 'ambiwidth': [['single', 'double'], ['xxx']], + \ 'background': [['light', 'dark'], ['xxx']], "\ 'backspace': [[0, 1, 2, 3, '', 'indent', 'eol', 'start', 'nostop', "\ " 'eol,start', 'indent,eol,nostop'], "\ " [-1, 4, 'xxx']], @@ -187,7 +186,7 @@ let test_values = { \ ['xxx']], \ 'concealcursor': [['', 'n', 'v', 'i', 'c', 'nvic'], ['xxx']], "\ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup', - "\ " 'popuphidden', 'noinsert', 'noselect', 'fuzzy', 'menu,longest'], + "\ " 'popuphidden', 'noinsert', 'noselect', 'fuzzy', 'preinsert', 'menu,longest'], "\ " ['xxx', 'menu,,,longest,']], \ 'completeitemalign': [['abbr,kind,menu', 'menu,abbr,kind'], \ ['', 'xxx', 'abbr', 'abbr,menu', 'abbr,menu,kind,abbr', @@ -210,17 +209,19 @@ let test_values = { \ 'icase', 'iwhite', 'iwhiteall', 'horizontal', 'vertical', \ 'closeoff', 'hiddenoff', 'foldcolumn:0', 'foldcolumn:12', \ 'followwrap', 'internal', 'indent-heuristic', 'algorithm:myers', - \ 'algorithm:minimal', 'algorithm:patience', - \ 'algorithm:histogram', 'icase,iwhite'], - \ ['xxx', 'foldcolumn:xxx', 'algorithm:xxx', 'algorithm:']], + \ 'icase,iwhite', 'algorithm:minimal', 'algorithm:patience', + \ 'algorithm:histogram', 'linematch:5'], + \ ['xxx', 'foldcolumn:', 'foldcolumn:x', 'foldcolumn:xxx', + \ 'linematch:', 'linematch:x', 'linematch:xxx', 'algorithm:', + \ 'algorithm:xxx', 'context:', 'context:x', 'context:xxx']], \ 'display': [['', 'lastline', 'truncate', 'uhex', 'lastline,uhex'], \ ['xxx']], - \ 'eadirection': [['', 'both', 'ver', 'hor'], ['xxx', 'ver,hor']], + \ 'eadirection': [['both', 'ver', 'hor'], ['xxx', 'ver,hor']], "\ 'encoding': [['latin1'], ['xxx', '']], \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'], \ ['xxx']], \ 'fileencoding': [['', 'latin1', 'xxx'], []], - \ 'fileformat': [['', 'dos', 'unix', 'mac'], ['xxx']], + \ 'fileformat': [['dos', 'unix', 'mac'], ['xxx']], \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']], \ 'fillchars': [['', 'stl:x', 'stlnc:x', 'vert:x', 'fold:x', 'foldopen:x', \ 'foldclose:x', 'foldsep:x', 'diff:x', 'eob:x', 'lastline:x', @@ -264,10 +265,18 @@ let test_values = { \ 'eol:\\u21b5', 'eol:\\U000021b5', 'eol:x,space:y'], \ ['xxx', 'eol:']], \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']], + \ 'messagesopt': [['hit-enter,history:1', 'hit-enter,history:10000', + \ 'history:100,wait:100', 'history:0,wait:0', + \ 'hit-enter,history:1,wait:1'], + \ ['xxx', 'history:500', 'hit-enter,history:-1', + \ 'hit-enter,history:10001', 'history:0,wait:10001', + \ 'hit-enter', 'history:10,wait:99999999999999999999', + \ 'history:99999999999999999999,wait:10', 'wait:10', + \ 'history:-10', 'history:10,wait:-10']], \ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']], \ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'], \ ['xxx', 'n,v,i']], - \ 'mousemodel': [['', 'extend', 'popup', 'popup_setpos'], ['xxx']], + \ 'mousemodel': [['extend', 'popup', 'popup_setpos'], ['xxx']], \ 'mouseshape': [['', 'n:arrow'], ['xxx']], \ 'nrformats': [['', 'alpha', 'octal', 'hex', 'bin', 'unsigned', 'blank', \ 'alpha,hex,bin'], @@ -292,7 +301,7 @@ let test_values = { \ 'sessionoptions': [['', 'blank', 'curdir', 'sesdir', \ 'help,options,slash'], \ ['xxx', 'curdir,sesdir']], - \ 'showcmdloc': [['', 'last', 'statusline', 'tabline'], ['xxx']], + \ 'showcmdloc': [['last', 'statusline', 'tabline'], ['xxx']], "\ 'signcolumn': [['', 'auto', 'no', 'yes', 'number'], ['xxx', 'no,yes']], \ 'spellfile': [['', 'file.en.add', 'xxx.en.add,yyy.gb.add,zzz.ja.add', \ '/tmp/dir\ with\ space/en.utf-8.add', @@ -304,7 +313,7 @@ let test_values = { \ 'spellsuggest': [['', 'best', 'double', 'fast', '100', 'timeout:100', \ 'timeout:-1', 'file:/tmp/file', 'expr:Func()', 'double,33'], \ ['xxx', '-1', 'timeout:', 'best,double', 'double,fast']], - \ 'splitkeep': [['', 'cursor', 'screen', 'topline'], ['xxx']], + \ 'splitkeep': [['cursor', 'screen', 'topline'], ['xxx']], \ 'statusline': [['', 'xxx'], ['%$', '%{', '%{%', '%{%}', '%(', '%)']], "\ 'swapsync': [['', 'sync', 'fsync'], ['xxx']], \ 'switchbuf': [['', 'useopen', 'usetab', 'split', 'vsplit', 'newtab', diff --git a/test/old/testdir/runnvim.vim b/test/old/testdir/runnvim.vim index 578614c8a1..f5945aeaee 100644 --- a/test/old/testdir/runnvim.vim +++ b/test/old/testdir/runnvim.vim @@ -8,6 +8,7 @@ function s:logger.on_exit(id, data, event) endfunction let s:logger.env = #{VIMRUNTIME: $VIMRUNTIME} +let s:logger.term = v:true " Replace non-printable chars by special sequence, or "<%x>". let s:escaped_char = {"\n": '\n', "\r": '\r', "\t": '\t'} @@ -25,7 +26,7 @@ function Main() set lines=25 set columns=80 enew - let job = termopen(args, s:logger) + let job = jobstart(args, s:logger) let results = jobwait([job], 5 * 60 * 1000) " TODO(ZyX-I): Get colors let screen = getline(1, '$') diff --git a/test/old/testdir/runtest.vim b/test/old/testdir/runtest.vim index 058635c332..3d210695c4 100644 --- a/test/old/testdir/runtest.vim +++ b/test/old/testdir/runtest.vim @@ -55,6 +55,10 @@ silent! endwhile " In the GUI we can always change the screen size. if has('gui_running') + if has('gui_gtk') + " to keep screendump size unchanged + set guifont=Monospace\ 10 + endif set columns=80 lines=25 endif diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim index e7b4bb1a88..61596fc83a 100644 --- a/test/old/testdir/setup.vim +++ b/test/old/testdir/setup.vim @@ -1,6 +1,5 @@ if exists('s:did_load') " Align Nvim defaults to Vim. - set backspace= set commentstring=/*\ %s\ */ set complete=.,w,b,u,t,i set define=^\\s*#\\s*define @@ -66,7 +65,7 @@ mapclear mapclear! aunmenu * tlunmenu * -autocmd! nvim_popupmenu +autocmd! nvim.popupmenu " Undo the 'grepprg' and 'grepformat' setting in _defaults.lua. set grepprg& grepformat& diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim index 64599c869a..d5f7c928de 100644 --- a/test/old/testdir/test_autocmd.vim +++ b/test/old/testdir/test_autocmd.vim @@ -1198,8 +1198,8 @@ func Test_OptionSet() call assert_equal(g:opt[0], g:opt[1]) " 14: Setting option backspace through :let" - let g:options = [['backspace', '', '', '', 'eol,indent,start', 'global', 'set']] - let &bs = "eol,indent,start" + let g:options = [['backspace', 'indent,eol,start', 'indent,eol,start', 'indent,eol,start', '', 'global', 'set']] + let &bs = '' call assert_equal([], g:options) call assert_equal(g:opt[0], g:opt[1]) @@ -4181,4 +4181,28 @@ func Test_autocmd_BufWinLeave_with_vsp() exe "bw! " .. dummy endfunc +func Test_OptionSet_cmdheight() + set mouse=a laststatus=2 + au OptionSet cmdheight :let &l:ch = v:option_new + + resize -1 + call assert_equal(2, &l:ch) + resize +1 + call assert_equal(1, &l:ch) + + call Ntest_setmouse(&lines - 1, 1) + call feedkeys("\<LeftMouse>", 'xt') + call Ntest_setmouse(&lines - 2, 1) + call feedkeys("\<LeftDrag>", 'xt') + call assert_equal(2, &l:ch) + + tabnew | resize +1 + call assert_equal(1, &l:ch) + tabfirst + call assert_equal(2, &l:ch) + + tabonly + set cmdheight& mouse& laststatus& +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_bufwintabinfo.vim b/test/old/testdir/test_bufwintabinfo.vim index 57492e07c9..0a4bd0b674 100644 --- a/test/old/testdir/test_bufwintabinfo.vim +++ b/test/old/testdir/test_bufwintabinfo.vim @@ -114,6 +114,18 @@ func Test_getbufwintabinfo() wincmd t | only endfunc +function Test_get_wininfo_leftcol() + set nowrap + set winwidth=10 + vsp + call setline(1, ['abcdefghijklmnopqrstuvwxyz']) + norm! 5zl + call assert_equal(5, getwininfo()[0].leftcol) + bwipe! + set wrap& + set winwidth& +endfunc + function Test_get_buf_options() let opts = bufnr()->getbufvar('&') call assert_equal(v:t_dict, type(opts)) diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index 290af4a4ca..d4ad63d43e 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -291,8 +291,8 @@ func Test_changing_cmdheight() call term_sendkeys(buf, ":resize -3\<CR>") call VerifyScreenDump(buf, 'Test_changing_cmdheight_1', {}) - " using the space available doesn't change the status line - call term_sendkeys(buf, ":set cmdheight+=3\<CR>") + " :resize now also changes 'cmdheight' accordingly + call term_sendkeys(buf, ":set cmdheight+=1\<CR>") call VerifyScreenDump(buf, 'Test_changing_cmdheight_2', {}) " using more space moves the status line up @@ -300,10 +300,10 @@ func Test_changing_cmdheight() call VerifyScreenDump(buf, 'Test_changing_cmdheight_3', {}) " reducing cmdheight moves status line down - call term_sendkeys(buf, ":set cmdheight-=2\<CR>") + call term_sendkeys(buf, ":set cmdheight-=3\<CR>") call VerifyScreenDump(buf, 'Test_changing_cmdheight_4', {}) - " reducing window size and then setting cmdheight + " reducing window size and then setting cmdheight call term_sendkeys(buf, ":resize -1\<CR>") call term_sendkeys(buf, ":set cmdheight=1\<CR>") call VerifyScreenDump(buf, 'Test_changing_cmdheight_5', {}) @@ -316,6 +316,10 @@ func Test_changing_cmdheight() call term_sendkeys(buf, ":call EchoOne()\<CR>") call VerifyScreenDump(buf, 'Test_changing_cmdheight_7', {}) + " window commands do not reduce 'cmdheight' to value lower than :set by user + call term_sendkeys(buf, "\<CR>:wincmd _\<CR>") + call VerifyScreenDump(buf, 'Test_changing_cmdheight_8', {}) + " clean up call StopVimInTerminal(buf) endfunc @@ -4036,6 +4040,27 @@ func Test_rulerformat_position() call StopVimInTerminal(buf) endfunc +" Test for using "%!" in 'rulerformat' to use a function +func Test_rulerformat_function() + CheckScreendump + + let lines =<< trim END + func TestRulerFn() + return '10,20%=30%%' + endfunc + END + call writefile(lines, 'Xrulerformat_function', 'D') + + let buf = RunVimInTerminal('-S Xrulerformat_function', #{rows: 2, cols: 40}) + call term_sendkeys(buf, ":set ruler rulerformat=%!TestRulerFn()\<CR>") + call term_sendkeys(buf, ":redraw!\<CR>") + call term_wait(buf) + call VerifyScreenDump(buf, 'Test_rulerformat_function', {}) + + " clean up + call StopVimInTerminal(buf) +endfunc + func Test_getcompletion_usercmd() command! -nargs=* -complete=command TestCompletion echo <q-args> diff --git a/test/old/testdir/test_compiler.vim b/test/old/testdir/test_compiler.vim index 07b57b76d9..1310cbadfc 100644 --- a/test/old/testdir/test_compiler.vim +++ b/test/old/testdir/test_compiler.vim @@ -18,6 +18,8 @@ func Test_compiler() endif e Xfoo.pl + " Play nice with other tests. + defer setqflist([]) compiler perl call assert_equal('perl', b:current_compiler) call assert_fails('let g:current_compiler', 'E121:') @@ -65,10 +67,10 @@ func Test_compiler_completion() call assert_match('^"compiler ' .. clist .. '$', @:) call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx') - call assert_match('"compiler pandoc pbx perl\( p[a-z_]\+\)\+ pylint pyunit', @:) + call assert_match('"compiler pandoc pbx perl\( p[a-z_]\+\)\+ pyunit', @:) call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx') - call assert_match('"compiler! pandoc pbx perl\( p[a-z_]\+\)\+ pylint pyunit', @:) + call assert_match('"compiler! pandoc pbx perl\( p[a-z_]\+\)\+ pyunit', @:) endfunc func Test_compiler_error() @@ -78,3 +80,634 @@ func Test_compiler_error() call assert_fails('compiler! doesnotexist', 'E666:') unlet! g:current_compiler endfunc + +func s:SpotBugsParseFilterMakePrg(dirname, makeprg) + let result = {} + let result.sourcepath = '' + let result.classfiles = [] + + " Get the argument after the rightmost occurrence of "-sourcepath". + let offset = strridx(a:makeprg, '-sourcepath') + if offset < 0 + return result + endif + let offset += 1 + strlen('-sourcepath') + let result.sourcepath = matchstr(strpart(a:makeprg, offset), '.\{-}\ze[ \t]') + let offset += 1 + strlen(result.sourcepath) + + " Get the class file arguments, dropping the pathname prefix. + let offset = stridx(a:makeprg, a:dirname, offset) + if offset < 0 + return result + endif + + while offset > -1 + let candidate = matchstr(a:makeprg, '[^ \t]\{-}\.class\>', offset) + if empty(candidate) + break + endif + call add(result.classfiles, candidate) + let offset = stridx(a:makeprg, a:dirname, (1 + strlen(candidate) + offset)) + endwhile + + call sort(result.classfiles) + return result +endfunc + +func Test_compiler_spotbugs_makeprg() + let save_shellslash = &shellslash + set shellslash + + call assert_true(mkdir('Xspotbugs/src/tests/α/β/γ/δ', 'pR')) + call assert_true(mkdir('Xspotbugs/tests/α/β/γ/δ', 'pR')) + + let lines =<< trim END + // EOL comment. /* + abstract class + 𐌂1 /* Multiline comment. */ { + /* Multiline comment. */ // EOL comment. /* + static final String COMMENT_A_LIKE = "/*"; + { new Object() {/* Try globbing. */}; } + static { interface 𐌉𐌉1 {} } + static class 𐌂11 { interface 𐌉𐌉2 {} } + } + /* Multiline comment. */ // EOL comment. /* + final class 𐌂2 { + public static void main(String... aa) { + record 𐌓() {} + enum 𐌄 {} + } + } // class + END + + " THE EXPECTED RESULTS. + let results = {} + let results['Xspotbugs/src/tests/𐌂1.java'] = { + \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/𐌂1.java', + \ ':p:h:S')}, + \ 'classfiles': sort([ + \ 'Xspotbugs/tests/𐌂1$1.class', + \ 'Xspotbugs/tests/𐌂1$1𐌉𐌉1.class', + \ 'Xspotbugs/tests/𐌂1$𐌂11$𐌉𐌉2.class', + \ 'Xspotbugs/tests/𐌂1$𐌂11.class', + \ 'Xspotbugs/tests/𐌂1.class', + \ 'Xspotbugs/tests/𐌂2$1𐌄.class', + \ 'Xspotbugs/tests/𐌂2$1𐌓.class', + \ 'Xspotbugs/tests/𐌂2.class']), + \ } + " No class file for an empty source file even with "-Xpkginfo:always". + let results['Xspotbugs/src/tests/package-info.java'] = { + \ 'Sourcepath': {-> ''}, + \ 'classfiles': [], + \ } + let results['Xspotbugs/src/tests/α/𐌂1.java'] = { + \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/𐌂1.java', + \ ':p:h:h:S')}, + \ 'classfiles': sort([ + \ 'Xspotbugs/tests/α/𐌂1$1.class', + \ 'Xspotbugs/tests/α/𐌂1$1𐌉𐌉1.class', + \ 'Xspotbugs/tests/α/𐌂1$𐌂11$𐌉𐌉2.class', + \ 'Xspotbugs/tests/α/𐌂1$𐌂11.class', + \ 'Xspotbugs/tests/α/𐌂1.class', + \ 'Xspotbugs/tests/α/𐌂2$1𐌄.class', + \ 'Xspotbugs/tests/α/𐌂2$1𐌓.class', + \ 'Xspotbugs/tests/α/𐌂2.class']), + \ } + let results['Xspotbugs/src/tests/α/package-info.java'] = { + \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/package-info.java', + \ ':p:h:S')}, + \ 'classfiles': ['Xspotbugs/tests/α/package-info.class'], + \ } + let results['Xspotbugs/src/tests/α/β/𐌂1.java'] = { + \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/𐌂1.java', + \ ':p:h:h:h:S')}, + \ 'classfiles': sort([ + \ 'Xspotbugs/tests/α/β/𐌂1$1.class', + \ 'Xspotbugs/tests/α/β/𐌂1$1𐌉𐌉1.class', + \ 'Xspotbugs/tests/α/β/𐌂1$𐌂11$𐌉𐌉2.class', + \ 'Xspotbugs/tests/α/β/𐌂1$𐌂11.class', + \ 'Xspotbugs/tests/α/β/𐌂1.class', + \ 'Xspotbugs/tests/α/β/𐌂2$1𐌄.class', + \ 'Xspotbugs/tests/α/β/𐌂2$1𐌓.class', + \ 'Xspotbugs/tests/α/β/𐌂2.class']), + \ } + let results['Xspotbugs/src/tests/α/β/package-info.java'] = { + \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/package-info.java', + \ ':p:h:S')}, + \ 'classfiles': ['Xspotbugs/tests/α/β/package-info.class'], + \ } + let results['Xspotbugs/src/tests/α/β/γ/𐌂1.java'] = { + \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/γ/𐌂1.java', + \ ':p:h:h:h:h:S')}, + \ 'classfiles': sort([ + \ 'Xspotbugs/tests/α/β/γ/𐌂1$1.class', + \ 'Xspotbugs/tests/α/β/γ/𐌂1$1𐌉𐌉1.class', + \ 'Xspotbugs/tests/α/β/γ/𐌂1$𐌂11$𐌉𐌉2.class', + \ 'Xspotbugs/tests/α/β/γ/𐌂1$𐌂11.class', + \ 'Xspotbugs/tests/α/β/γ/𐌂1.class', + \ 'Xspotbugs/tests/α/β/γ/𐌂2$1𐌄.class', + \ 'Xspotbugs/tests/α/β/γ/𐌂2$1𐌓.class', + \ 'Xspotbugs/tests/α/β/γ/𐌂2.class']), + \ } + let results['Xspotbugs/src/tests/α/β/γ/package-info.java'] = { + \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/γ/package-info.java', + \ ':p:h:S')}, + \ 'classfiles': ['Xspotbugs/tests/α/β/γ/package-info.class'], + \ } + let results['Xspotbugs/src/tests/α/β/γ/δ/𐌂1.java'] = { + \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/γ/δ/𐌂1.java', + \ ':p:h:h:h:h:h:S')}, + \ 'classfiles': sort([ + \ 'Xspotbugs/tests/α/β/γ/δ/𐌂1$1.class', + \ 'Xspotbugs/tests/α/β/γ/δ/𐌂1$1𐌉𐌉1.class', + \ 'Xspotbugs/tests/α/β/γ/δ/𐌂1$𐌂11$𐌉𐌉2.class', + \ 'Xspotbugs/tests/α/β/γ/δ/𐌂1$𐌂11.class', + \ 'Xspotbugs/tests/α/β/γ/δ/𐌂1.class', + \ 'Xspotbugs/tests/α/β/γ/δ/𐌂2$1𐌄.class', + \ 'Xspotbugs/tests/α/β/γ/δ/𐌂2$1𐌓.class', + \ 'Xspotbugs/tests/α/β/γ/δ/𐌂2.class']), + \ } + let results['Xspotbugs/src/tests/α/β/γ/δ/package-info.java'] = { + \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/γ/δ/package-info.java', + \ ':p:h:S')}, + \ 'classfiles': ['Xspotbugs/tests/α/β/γ/δ/package-info.class'], + \ } + + " MAKE CLASS FILES DISCOVERABLE! + let g:spotbugs_properties = { + \ 'sourceDirPath': ['src/tests'], + \ 'classDirPath': ['tests'], + \ } + + call assert_true(has_key(s:SpotBugsParseFilterMakePrg('Xspotbugs', ''), 'sourcepath')) + call assert_true(has_key(s:SpotBugsParseFilterMakePrg('Xspotbugs', ''), 'classfiles')) + + " Write 45 mock-up class files for 10 source files. + for [class_dir, src_dir, package] in [ + \ ['Xspotbugs/tests/', 'Xspotbugs/src/tests/', ''], + \ ['Xspotbugs/tests/α/', 'Xspotbugs/src/tests/α/', 'package α;'], + \ ['Xspotbugs/tests/α/β/', 'Xspotbugs/src/tests/α/β/', 'package α.β;'], + \ ['Xspotbugs/tests/α/β/γ/', 'Xspotbugs/src/tests/α/β/γ/', 'package α.β.γ;'], + \ ['Xspotbugs/tests/α/β/γ/δ/', 'Xspotbugs/src/tests/α/β/γ/δ/', 'package α.β.γ.δ;']] + for class_file in ['𐌂1$1.class', '𐌂1$1𐌉𐌉1.class', '𐌂1$𐌂11$𐌉𐌉2.class', + \ '𐌂1$𐌂11.class', '𐌂1.class', '𐌂2$1𐌄.class', '𐌂2$1𐌓.class', '𐌂2.class'] + call writefile(0zcafe.babe.0000.0041, class_dir .. class_file) + endfor + call writefile(0zcafe.babe.0000.0041, class_dir .. 'package-info.class') + + " Write Java source files. + let type_file = src_dir .. '𐌂1.java' + call writefile(insert(copy(lines), package), type_file) + let package_file = src_dir .. 'package-info.java' + call writefile([package], src_dir .. 'package-info.java') + + " Note that using "off" for the first _outer_ iteration is preferable + " because only then "hlexists()" may be 0 (see "compiler/spotbugs.vim"). + for s in ['off', 'on'] + execute 'syntax ' .. s + + execute 'edit ' .. type_file + compiler spotbugs + let result = s:SpotBugsParseFilterMakePrg('Xspotbugs', &l:makeprg) + call assert_equal(results[type_file].Sourcepath(), result.sourcepath) + call assert_equal(results[type_file].classfiles, result.classfiles) + bwipeout + + execute 'edit ' .. package_file + compiler spotbugs + let result = s:SpotBugsParseFilterMakePrg('Xspotbugs', &l:makeprg) + call assert_equal(results[package_file].Sourcepath(), result.sourcepath) + call assert_equal(results[package_file].classfiles, result.classfiles) + bwipeout + endfor + endfor + + let &shellslash = save_shellslash +endfunc + +func s:SpotBugsBeforeFileTypeTryPluginAndClearCache(state) + " Ponder over "extend(spotbugs#DefaultProperties(), g:spotbugs_properties)" + " in "ftplugin/java.vim". + let g:spotbugs#state = a:state + runtime autoload/spotbugs.vim +endfunc + +func Test_compiler_spotbugs_properties() + let save_shellslash = &shellslash + set shellslash + setlocal makeprg= + filetype plugin on + + call assert_true(mkdir('Xspotbugs/src', 'pR')) + call assert_true(mkdir('Xspotbugs/tests', 'pR')) + let type_file = 'Xspotbugs/src/𐌄.java' + let test_file = 'Xspotbugs/tests/𐌄$.java' + call writefile(['enum 𐌄{}'], type_file) + call writefile(['class 𐌄${}'], test_file) + + " TEST INTEGRATION WITH A BOGUS COMPILER PLUGIN. + if !filereadable($VIMRUNTIME .. '/compiler/foo.vim') && !executable('foo') + let g:spotbugs_properties = {'compiler': 'foo'} + " XXX: In case this "if" block is no longer first. + call s:SpotBugsBeforeFileTypeTryPluginAndClearCache({ + \ 'compiler': g:spotbugs_properties.compiler, + \ }) + execute 'edit ' .. type_file + call assert_equal('java', &l:filetype) + " This variable will indefinitely keep the compiler name. + call assert_equal('foo', g:spotbugs#state.compiler) + " The "compiler" entry should be gone after FileType and default entries + " should only appear for a supported compiler. + call assert_false(has_key(g:spotbugs_properties, 'compiler')) + call assert_true(empty(g:spotbugs_properties)) + " Query default implementations. + call assert_true(exists('*spotbugs#DefaultProperties')) + call assert_true(exists('*spotbugs#DefaultPreCompilerAction')) + call assert_true(exists('*spotbugs#DefaultPreCompilerTestAction')) + call assert_true(empty(spotbugs#DefaultProperties())) + " Get a ":message". + redir => out + call spotbugs#DefaultPreCompilerAction() + redir END + call assert_equal('Not supported: "foo"', out[stridx(out, 'Not') :]) + " Get a ":message". + redir => out + call spotbugs#DefaultPreCompilerTestAction() + redir END + call assert_equal('Not supported: "foo"', out[stridx(out, 'Not') :]) + " No ":autocmd"s without one of "PreCompiler*Action", "PostCompilerAction". + call assert_false(exists('#java_spotbugs')) + bwipeout + endif + + let s:spotbugs_results = { + \ 'preActionDone': 0, + \ 'preTestActionDone': 0, + \ 'preTestLocalActionDone': 0, + \ 'postActionDone': 0, + \ 'preCommandArguments': '', + \ 'preTestCommandArguments': '', + \ 'postCommandArguments': '', + \ } + defer execute('unlet s:spotbugs_results') + + func! g:SpotBugsPreAction() abort + let s:spotbugs_results.preActionDone = 1 + " XXX: Notify the spotbugs compiler about success or failure. + cc + endfunc + defer execute('delfunction g:SpotBugsPreAction') + + func! g:SpotBugsPreTestAction() abort + let s:spotbugs_results.preTestActionDone = 1 + " XXX: Let see compilation fail. + throw 'Oops' + endfunc + defer execute('delfunction g:SpotBugsPreTestAction') + + func! g:SpotBugsPreTestLocalAction() abort + let s:spotbugs_results.preTestLocalActionDone = 1 + " XXX: Notify the spotbugs compiler about success or failure. + cc + endfunc + defer execute('delfunction g:SpotBugsPreTestLocalAction') + + func! g:SpotBugsPostAction() abort + let s:spotbugs_results.postActionDone = 1 + endfunc + defer execute('delfunction g:SpotBugsPostAction') + + func! g:SpotBugsPreCommand(arguments) abort + let s:spotbugs_results.preActionDone = 1 + let s:spotbugs_results.preCommandArguments = a:arguments + " XXX: Notify the spotbugs compiler about success or failure. + cc + endfunc + defer execute('delfunction g:SpotBugsPreCommand') + + func! g:SpotBugsPreTestCommand(arguments) abort + let s:spotbugs_results.preTestActionDone = 1 + let s:spotbugs_results.preTestCommandArguments = a:arguments + " XXX: Notify the spotbugs compiler about success or failure. + cc + endfunc + defer execute('delfunction g:SpotBugsPreTestCommand') + + func! g:SpotBugsPostCommand(arguments) abort + let s:spotbugs_results.postActionDone = 1 + let s:spotbugs_results.postCommandArguments = a:arguments + endfunc + defer execute('delfunction g:SpotBugsPostCommand') + + func! g:SpotBugsPostCompilerActionExecutor(action) abort + try + " XXX: Notify the spotbugs compiler about success or failure. + cc + catch /\<E42:/ + execute a:action + endtry + endfunc + defer execute('delfunction g:SpotBugsPostCompilerActionExecutor') + + " TEST INTEGRATION WITH A SUPPORTED COMPILER PLUGIN. + if filereadable($VIMRUNTIME .. '/compiler/maven.vim') + let save_PATH = $PATH + if !executable('mvn') + if has('win32') + let $PATH = 'Xspotbugs;' .. $PATH + " This is what ":help executable()" suggests. + call writefile([], 'Xspotbugs/mvn.cmd') + else + let $PATH = 'Xspotbugs:' .. $PATH + call writefile([], 'Xspotbugs/mvn') + call setfperm('Xspotbugs/mvn', 'rwx------') + endif + endif + + let g:spotbugs_properties = { + \ 'compiler': 'maven', + \ 'PreCompilerAction': function('g:SpotBugsPreAction'), + \ 'PreCompilerTestAction': function('g:SpotBugsPreTestAction'), + \ 'PostCompilerAction': function('g:SpotBugsPostA |