diff --git a/test/README b/test/README new file mode 100644 index 0000000..21b3cea --- /dev/null +++ b/test/README @@ -0,0 +1,13 @@ +The plugins runVimTests (http://www.vim.org/scripts/script.php?script_id=2565) +and VimTAP (http://www.vim.org/scripts/script.php?script_id=2213) are needed to +run these tests. + +Besides the _setup.vim configuration file present in this repo you need to +create a global one and place it in the same dir where the runVimTests +executable is located. Assuming the executable is at '~/bin/runVimTests' this +global configuration file should be '~/bin/runVimTestsSetup.vim' and should +have something like the following lines inside of it: + +" Prepend tests repos to &rtp +let &runtimepath = '/path/to/runVimTests_dir,' . &rtp +let &runtimepath = '/path/to/vimTAP_dir,' . &rtp diff --git a/test/_setup.vim b/test/_setup.vim new file mode 100644 index 0000000..46f4e13 --- /dev/null +++ b/test/_setup.vim @@ -0,0 +1,2 @@ +let &rtp = expand(':p:h:h') . ',' . &rtp . ',' . expand(':p:h:h') . '/after' +ru plugin/delimitMate.vim diff --git a/test/autoclose_matchpairs.txt b/test/autoclose_matchpairs.txt new file mode 100644 index 0000000..da2a1a1 --- /dev/null +++ b/test/autoclose_matchpairs.txt @@ -0,0 +1,26 @@ +let g:delimitMate_autoclose = 1 +"(x" "(x)" +"(\x" "x" +"()x" "()x" +"((\gx" "(())x" +"(x\u" "" +"@(x" "@(x)" +"@#\(x" "@(x)#" +"(\x" "()x" +let g:delimitMate_autoclose = 0 +"(x" "(x" +"()x" "(x)" +"())x" "()x" +"()\x" "x" +"@()x" "@(x)" +"@#\()x" "@(x)#" +let g:delimitMate_expand_space = 1 +let g:delimitMate_autoclose = 1 +"(\x" "( x )" +"(\\x" "(x)" +let g:delimitMate_autoclose = 0 +"()\\x" "(x)" +let g:delimitMate_autoclose = 1 +# Handle backspace gracefully. +set backspace= +"(\a\x" "(x)" diff --git a/test/autoclose_matchpairs.vim b/test/autoclose_matchpairs.vim new file mode 100644 index 0000000..cca6e93 --- /dev/null +++ b/test/autoclose_matchpairs.vim @@ -0,0 +1,41 @@ +let g:delimitMate_matchpairs = '(:),{:},[:],<:>,¿:?,¡:!' +let lines = readfile(expand(':t:r').'.txt') +call vimtest#StartTap() +let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"''')) +let itemsnumber = len(split(g:delimitMate_matchpairs, ',')) +call vimtap#Plan(testsnumber * itemsnumber) +let tcount = 1 +let reload = 1 +for item in lines + if item =~ '^#\|^\s*$' + " A comment or empty line. + continue + endif + if item !~ '^"' + " A command. + exec item + call vimtap#Diag(item) + let reload = 1 + continue + endif + if reload + DelimitMateReload + call vimtap#Diag('DelimitMateReload') + let reload = 0 + endif + let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"') + for [s:l,s:r] in map(split(g:delimitMate_matchpairs, ','), 'split(v:val, ":")') + let input2 = substitute(input, '(', s:l, 'g') + let input2 = substitute(input2, ')', s:r, 'g') + let output2 = substitute(output, '(', s:l, 'g') + let output2 = substitute(output2, ')', s:r, 'g') + %d + exec 'normal i'.eval(input2)."\" + let line = getline('.') + let passed = line == eval(output2) + call vimtap#Ok(passed, input2 . ' => ' . string(line) . + \ (passed ? ' =' : ' !') . '= ' . string(eval(output2))) + let tcount += 1 + endfor +endfor +call vimtest#Quit() diff --git a/test/autoclose_quotes.txt b/test/autoclose_quotes.txt new file mode 100644 index 0000000..c0d3c19 --- /dev/null +++ b/test/autoclose_quotes.txt @@ -0,0 +1,32 @@ +let g:delimitMate_autoclose = 1 +"'x" "'x'" +"'x\u" "" +"''x" "''x" +"'\x" "x" +"'\gx" "''x" +"'\"x" "'\"x\"'" +"@'x" "@'x'" +"@#\'x" "@'x'#" +"'\x" "''x" +"abc'" "abc'" +"abc\\'x" "abc\\'x" +"u'Привет'" "u'Привет'" +"u'string'" "u'string'" +let g:delimitMate_autoclose = 0 +"'x" "'x" +"''x" "'x'" +"'''x" "''x" +"''\x" "x" +"@''x" "@'x'" +"@#\''x" "@'x'#" +let g:delimitMate_expand_space = 1 +let g:delimitMate_autoclose = 1 +"'\x" "' x '" +"'\\x" "'x'" +"abc\\''\x" "abc\\' x'" +let g:delimitMate_autoclose = 0 +"''\\x" "'x'" +let g:delimitMate_autoclose = 1 +# Handle backspace gracefully. +set backspace= +"'\a\x" "'x'" diff --git a/test/autoclose_quotes.vim b/test/autoclose_quotes.vim new file mode 100644 index 0000000..635ff60 --- /dev/null +++ b/test/autoclose_quotes.vim @@ -0,0 +1,45 @@ +let g:delimitMate_quotes = '" '' ` ” « |' +let lines = readfile(expand(':t:r').'.txt') +call vimtest#StartTap() +let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"''')) +let itemsnumber = len(split(g:delimitMate_quotes, ' ')) +call vimtap#Plan(testsnumber * itemsnumber) +let reload = 1 +let tcount = 1 +for item in lines + if item =~ '^#\|^\s*$' + " A comment or empty line. + continue + endif + if item !~ '^"' + " A command. + exec item + call vimtap#Diag(item) + let reload = 1 + continue + endif + if reload + DelimitMateReload + 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 + 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)."\" + let line = getline('.') + let passed = line == eval(output_q) + if quote == '”' || tcount == 31 + 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 + let tcount += 1 + endfor +endfor +call vimtest#Quit()