2018-12-17 06:28:27 -05:00
|
|
|
" don't spam the user when Vim is started in Vi compatibility mode
|
|
|
|
let s:cpo_save = &cpo
|
|
|
|
set cpo&vim
|
|
|
|
|
2018-11-01 06:03:42 -04:00
|
|
|
function! Test_gomodVersion_highlight() abort
|
|
|
|
try
|
|
|
|
syntax on
|
|
|
|
|
2019-03-27 11:08:56 -04:00
|
|
|
let l:dir = gotest#write_file('gomodtest/go.mod', [
|
2018-11-01 06:03:42 -04:00
|
|
|
\ 'module github.com/fatih/vim-go',
|
|
|
|
\ '',
|
|
|
|
\ '\x1frequire (',
|
|
|
|
\ '\tversion/simple v1.0.0',
|
2019-03-27 11:08:56 -04:00
|
|
|
\ '\tversion/simple-pre-release v1.0.0-rc',
|
|
|
|
\ '\tversion/simple-pre-release v1.0.0+meta',
|
|
|
|
\ '\tversion/simple-pre-release v1.0.0-rc+meta',
|
2018-11-01 06:03:42 -04:00
|
|
|
\ '\tversion/pseudo/premajor v1.0.0-20060102150405-0123456789abcdef',
|
|
|
|
\ '\tversion/pseudo/prerelease v1.0.0-prerelease.0.20060102150405-0123456789abcdef',
|
|
|
|
\ '\tversion/pseudo/prepatch v1.0.1-0.20060102150405-0123456789abcdef',
|
|
|
|
\ '\tversion/simple/incompatible v2.0.0+incompatible',
|
|
|
|
\ '\tversion/pseudo/premajor/incompatible v2.0.0-20060102150405-0123456789abcdef+incompatible',
|
|
|
|
\ '\tversion/pseudo/prerelease/incompatible v2.0.0-prerelease.0.20060102150405-0123456789abcdef+incompatible',
|
|
|
|
\ '\tversion/pseudo/prepatch/incompatible v2.0.1-0.20060102150405-0123456789abcdef+incompatible',
|
|
|
|
\ ')'])
|
|
|
|
|
|
|
|
let l:lineno = 4
|
|
|
|
let l:lineclose = line('$')
|
|
|
|
while l:lineno < l:lineclose
|
|
|
|
let l:line = getline(l:lineno)
|
|
|
|
let l:col = col([l:lineno, '$']) - 1
|
|
|
|
let l:idx = len(l:line) - 1
|
|
|
|
let l:from = stridx(l:line, ' ') + 1
|
|
|
|
|
|
|
|
while l:idx >= l:from
|
|
|
|
call cursor(l:lineno, l:col)
|
|
|
|
let l:synname = synIDattr(synID(l:lineno, l:col, 1), 'name')
|
|
|
|
let l:errlen = len(v:errors)
|
|
|
|
|
|
|
|
call assert_equal('gomodVersion', l:synname, 'version on line ' . l:lineno)
|
|
|
|
|
|
|
|
" continue at the next line if there was an error at this column;
|
|
|
|
" there's no need to test each column once an error is detected.
|
|
|
|
if l:errlen < len(v:errors)
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
|
|
|
|
let l:col -= 1
|
|
|
|
let l:idx -= 1
|
|
|
|
endwhile
|
|
|
|
let l:lineno += 1
|
|
|
|
endwhile
|
|
|
|
finally
|
|
|
|
call delete(l:dir, 'rf')
|
|
|
|
endtry
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
function! Test_gomodVersion_incompatible_highlight() abort
|
|
|
|
try
|
|
|
|
syntax on
|
|
|
|
|
2019-03-27 11:08:56 -04:00
|
|
|
let l:dir = gotest#write_file('gomodtest/go.mod', [
|
2018-11-01 06:03:42 -04:00
|
|
|
\ 'module github.com/fatih/vim-go',
|
|
|
|
\ '',
|
|
|
|
\ '\x1frequire (',
|
|
|
|
\ '\tversion/invalid/premajor/incompatible v1.0.0-20060102150405-0123456789abcdef+incompatible',
|
|
|
|
\ '\tversion/invalid/prerelease/incompatible v1.0.0-prerelease.0.20060102150405-0123456789abcdef+incompatible',
|
|
|
|
\ '\tversion/invalid/prepatch/incompatible v1.0.1-0.20060102150405-0123456789abcdef+incompatible',
|
|
|
|
\ ')'])
|
|
|
|
|
|
|
|
let l:lineno = 4
|
|
|
|
let l:lineclose = line('$')
|
|
|
|
while l:lineno < l:lineclose
|
|
|
|
let l:line = getline(l:lineno)
|
|
|
|
let l:col = col([l:lineno, '$']) - 1
|
|
|
|
let l:idx = len(l:line) - 1
|
|
|
|
let l:from = stridx(l:line, '+')
|
|
|
|
|
|
|
|
while l:idx >= l:from
|
|
|
|
call cursor(l:lineno, l:col)
|
|
|
|
let l:synname = synIDattr(synID(l:lineno, l:col, 1), 'name')
|
|
|
|
let l:errlen = len(v:errors)
|
|
|
|
|
|
|
|
call assert_notequal('gomodVersion', l:synname, 'version on line ' . l:lineno)
|
|
|
|
|
|
|
|
" continue at the next line if there was an error at this column;
|
|
|
|
" there's no need to test each column once an error is detected.
|
|
|
|
if l:errlen < len(v:errors)
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
|
|
|
|
let l:col -= 1
|
|
|
|
let l:idx -= 1
|
|
|
|
endwhile
|
|
|
|
let l:lineno += 1
|
|
|
|
endwhile
|
|
|
|
finally
|
|
|
|
call delete(l:dir, 'rf')
|
|
|
|
endtry
|
|
|
|
endfunc
|
|
|
|
|
2018-12-17 06:28:27 -05:00
|
|
|
" restore Vi compatibility settings
|
|
|
|
let &cpo = s:cpo_save
|
|
|
|
unlet s:cpo_save
|
|
|
|
|
2018-11-01 06:03:42 -04:00
|
|
|
" vim: sw=2 ts=2 et
|