mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 12:44:27 +08:00
Better testing for quotes.
This commit is contained in:
@@ -4,6 +4,7 @@ let g:delimitMate_autoclose = 1
|
||||
"''x" "''x"
|
||||
"'\<BS>x" "x"
|
||||
"'\<C-G>gx" "''x"
|
||||
# This will fail for double quote.
|
||||
"'\"x" "'\"x\"'"
|
||||
"@'x" "@'x'"
|
||||
"@#\<Left>'x" "@'x'#"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
let g:delimitMate_quotes = '" '' ` ” « |'
|
||||
"let g:delimitMate_quotes = '" '' ` ” « |'
|
||||
let g:delimitMate_quotes = '" '' ` « |'
|
||||
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
||||
call vimtest#StartTap()
|
||||
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"'''))
|
||||
@@ -6,7 +7,9 @@ let itemsnumber = len(split(g:delimitMate_quotes, ' '))
|
||||
call vimtap#Plan(testsnumber * itemsnumber)
|
||||
let reload = 1
|
||||
let tcount = 1
|
||||
let linenr = 0
|
||||
for item in lines
|
||||
let linenr += 1
|
||||
if item =~ '^#\|^\s*$'
|
||||
" A comment or empty line.
|
||||
continue
|
||||
@@ -23,22 +26,21 @@ for item in lines
|
||||
call vimtap#Diag('DelimitMateReload')
|
||||
let reload = 0
|
||||
endif
|
||||
let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
|
||||
let quotes = split(g:delimitMate_quotes, '\s')
|
||||
for quote in quotes
|
||||
if vimtap#Skip(1, tcount != 26, "This test is invalid for double quote.")
|
||||
let tcount += 1
|
||||
continue
|
||||
endif
|
||||
let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
|
||||
let input_q = substitute(input,"'" , escape(escape(quote, '"'), '\'), 'g')
|
||||
let output_q = substitute(output,"'" , escape(escape(quote, '"'), '\'), 'g')
|
||||
%d
|
||||
exec 'normal i'.eval(input_q)."\<Esc>"
|
||||
let line = getline('.')
|
||||
let passed = line == eval(output_q)
|
||||
if quote == '”' || tcount == 31
|
||||
if quote == '”'
|
||||
call vimtap#Todo(1)
|
||||
endif
|
||||
if 1 "!vimtap#Skip(1, tcount != 21, 'Test 21')
|
||||
call vimtap#Ok(passed, eval(substitute(input_q, '\\<', '<','g')) . ' => ' . line .
|
||||
\ (passed ? ' =' : ' !') . '= ' . eval(output_q))
|
||||
endif
|
||||
call vimtap#Is(getline('.'), eval(output_q), 'Line '.linenr.': '.eval(substitute(input_q, '\\<', '<','g')))
|
||||
let tcount += 1
|
||||
endfor
|
||||
endfor
|
||||
|
||||
Reference in New Issue
Block a user