mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 12:44:27 +08:00
Migrate testing to tcltest + expect
This commit is contained in:
10
Makefile
10
Makefile
@@ -1,11 +1,15 @@
|
|||||||
.DEFAULT: test
|
.DEFAULT: test
|
||||||
|
|
||||||
test_files := $(filter-out _setup.vim,$(wildcard test/*.vim))
|
test_files := $(wildcard test/*.test)
|
||||||
|
short_targets := $(patsubst test/%,%,$(test_files))
|
||||||
|
|
||||||
.PHONY: all test $(test_files)
|
.PHONY: monitor test $(test_files) $(short_targets)
|
||||||
|
|
||||||
test:
|
test:
|
||||||
$(MAKE) -C test
|
$(MAKE) -C test
|
||||||
|
|
||||||
$(test_files):
|
monitor:
|
||||||
|
$(MAKE) -C test monitor
|
||||||
|
|
||||||
|
$(test_files) $(short_targets):
|
||||||
$(MAKE) -C test $(patsubst test/%,%,$@)
|
$(MAKE) -C test $(patsubst test/%,%,$@)
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
all: build/runVimTests
|
test_files := $(wildcard *.test)
|
||||||
time build/runVimTests/bin/runVimTests.sh -0 .
|
|
||||||
|
|
||||||
build/runVimTests: build/VimTAP
|
.PHONY: all monitor $(test_files)
|
||||||
git clone https://github.com/inkarkat/runVimTests $@
|
|
||||||
|
|
||||||
# Use VimTAP as directory name, as used with runVimTestsSetup.vim.
|
all:
|
||||||
build/VimTAP:
|
time tclsh all.tcl
|
||||||
git clone https://github.com/inkarkat/vimtap $@
|
|
||||||
|
|
||||||
test_files := $(filter-out _setup.vim,$(wildcard *.vim))
|
|
||||||
|
|
||||||
.PHONY: $(test_files)
|
|
||||||
|
|
||||||
$(test_files):
|
$(test_files):
|
||||||
time build/runVimTests/bin/runVimTests.sh -0 $@
|
time tclsh $@
|
||||||
|
printf "\a"
|
||||||
|
|
||||||
|
monitor:
|
||||||
|
fswatch -o ../autoload/*.vim ../plugin/*.vim *.test \
|
||||||
|
| xargs -n1 -I\{\} time tclsh all.tcl || printf "\a"
|
||||||
|
|||||||
119
test/_setup.vim
119
test/_setup.vim
@@ -1,120 +1,11 @@
|
|||||||
" function! DMTest_single(setup, typed, expected[, skip_expr[, todo_expr]])
|
|
||||||
" - Runs a single test.
|
|
||||||
" - Add 1 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" function! DMTest_pairs(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every pair.
|
|
||||||
" - Add 7 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" function! DMTest_quotes(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every quote.
|
|
||||||
" - Add 5 to vimtap#Plan().
|
|
||||||
|
|
||||||
let &rtp = expand('<sfile>:p:h:h') . ',' . &rtp . ',' . expand('<sfile>:p:h:h') . '/after'
|
|
||||||
set bs=2
|
set bs=2
|
||||||
set hidden
|
set hidden
|
||||||
|
set noshowmode
|
||||||
set whichwrap=[]
|
set whichwrap=[]
|
||||||
|
set noswapfile
|
||||||
|
let &hl = join(map(split(&hl, ','), 'substitute(v:val, '':.\+'', ''n'', ''g'')'), ',')
|
||||||
|
let &rtp = expand('<sfile>:p:h:h') . ',' . &rtp . ',' . expand('<sfile>:p:h:h') . '/after'
|
||||||
let g:delimitMate_pairs = ['()','{}','[]','<>','¿?','¡!',',:']
|
let g:delimitMate_pairs = ['()','{}','[]','<>','¿?','¡!',',:']
|
||||||
let g:delimitMate_quotes = ['"', "'", '`', '«', '|']
|
let g:delimitMate_quotes = ['"', "'", '`', '«', '|']
|
||||||
ru plugin/delimitMate.vim
|
ru plugin/delimitMate.vim
|
||||||
let runVimTests = expand('<sfile>:p:h').'/build/runVimTests'
|
au VimEnter * echom 'Start test'
|
||||||
if isdirectory(runVimTests)
|
|
||||||
let &rtp = runVimTests . ',' . &rtp
|
|
||||||
endif
|
|
||||||
let vimTAP = expand('<sfile>:p:h').'/build/VimTAP'
|
|
||||||
if isdirectory(vimTAP)
|
|
||||||
let &rtp = vimTAP . ',' . &rtp
|
|
||||||
endif
|
|
||||||
|
|
||||||
function! s:setup_buffer(buf_content)
|
|
||||||
"silent DelimitMateReload "call delimitMate#setup()
|
|
||||||
silent %d_
|
|
||||||
if !empty(a:buf_content)
|
|
||||||
call setline(1, a:buf_content)
|
|
||||||
call feedkeys("gg0", 'ntx')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"function! DMTest_single(setup, typed, expected[, skip_expr[, todo_expr]])
|
|
||||||
" Runs a single test (add 1 to vimtap#Plan())
|
|
||||||
function! DMTest_single(setup, typed, expected, ...)
|
|
||||||
if type(a:setup) == v:t_list
|
|
||||||
let setup = copy(a:setup)
|
|
||||||
else
|
|
||||||
let setup = [a:setup]
|
|
||||||
endif
|
|
||||||
if type(a:expected) == v:t_list
|
|
||||||
let expected = copy(a:expected)
|
|
||||||
else
|
|
||||||
let expected = [a:expected]
|
|
||||||
endif
|
|
||||||
let skip_expr = a:0 && !empty(a:1) ? a:1 : 0
|
|
||||||
let todo_expr = a:0 > 1 && !empty(a:2) ? a:2 : 0
|
|
||||||
if vimtap#Skip(1, !eval(skip_expr), skip_expr)
|
|
||||||
return
|
|
||||||
elseif eval(todo_expr)
|
|
||||||
call vimtap#Todo(1)
|
|
||||||
endif
|
|
||||||
call s:setup_buffer(setup)
|
|
||||||
echom strtrans(a:typed)
|
|
||||||
call feedkeys(a:typed, 'mt')
|
|
||||||
call test_disable_char_avail(1)
|
|
||||||
call feedkeys('', 'x')
|
|
||||||
call feedkeys('', 'x')
|
|
||||||
call test_disable_char_avail(0)
|
|
||||||
call vimtap#Is(getline(1,'$'), expected, strtrans(a:typed))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:do_set(pat, sub, set, setup, typed, expected, ...)
|
|
||||||
let skip_expr = get(a:, '1', '')
|
|
||||||
let todo_expr = get(a:, '2', '')
|
|
||||||
let escaped = '\.*^$'
|
|
||||||
for elem in a:set
|
|
||||||
if type(a:setup) == v:t_list
|
|
||||||
let setup = copy(a:setup)
|
|
||||||
else
|
|
||||||
let setup = [a:setup]
|
|
||||||
endif
|
|
||||||
if type(a:expected) == v:t_list
|
|
||||||
let expected = copy(a:expected)
|
|
||||||
else
|
|
||||||
let expected = [a:expected]
|
|
||||||
endif
|
|
||||||
if strchars(elem) > 1
|
|
||||||
"let [left, right] = map(split(elem, '\zs'), 'escape(v:val, escaped)')
|
|
||||||
let left = escape(strcharpart(elem, 0, 1), escaped)
|
|
||||||
let right = escape(strcharpart(elem, 1, 1), escaped)
|
|
||||||
let sub = a:sub
|
|
||||||
else
|
|
||||||
let quote = escape(elem, escaped)
|
|
||||||
let sub = eval(a:sub)
|
|
||||||
endif
|
|
||||||
call map(setup, "substitute(v:val, a:pat, sub, 'g')")
|
|
||||||
let typed = substitute(a:typed, a:pat, sub, 'g')
|
|
||||||
call map(expected, "substitute(v:val, a:pat, sub, 'g')")
|
|
||||||
call DMTest_single(setup, typed, expected, skip_expr, todo_expr)
|
|
||||||
endfor
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"function! DMTest_pairs(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" Runs one test for every pair (add 7 to vimtap#Plan())
|
|
||||||
function! DMTest_pairs(setup, typed, expected, ...)
|
|
||||||
let skip_expr = get(a:, '1', '')
|
|
||||||
let todo_expr = get(a:, '2', '')
|
|
||||||
let pairs = delimitMate#option('pairs')
|
|
||||||
let pat = '[()]'
|
|
||||||
let sub = '\=submatch(0) == "(" ? left : right'
|
|
||||||
return s:do_set(pat, sub, pairs, a:setup, a:typed, a:expected, skip_expr, todo_expr)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"function! DMTest_quotes(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" Runs one test for every quote (add 5 to vimtap#Plan())
|
|
||||||
function! DMTest_quotes(setup, typed, expected, ...)
|
|
||||||
let skip_expr = get(a:, '1', '')
|
|
||||||
let todo_expr = get(a:, '2', '')
|
|
||||||
let quotes = delimitMate#option('quotes')
|
|
||||||
let pat = "'"
|
|
||||||
let sub = 'quote'
|
|
||||||
return s:do_set(pat, sub, quotes, a:setup, a:typed, a:expected, skip_expr, todo_expr)
|
|
||||||
endfunction
|
|
||||||
" vim: sw=2 et
|
|
||||||
|
|||||||
18
test/all.tcl
Normal file
18
test/all.tcl
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package require tcltest 2
|
||||||
|
namespace import -force ::tcltest::*
|
||||||
|
configure {*}$argv -testdir [file dir [info script]]
|
||||||
|
|
||||||
|
# Hook to determine if any of the tests failed. Then we can exit with
|
||||||
|
# proper exit code: 0=all passed, 1=one or more failed
|
||||||
|
proc tcltest::cleanupTestsHook {} {
|
||||||
|
variable numTests
|
||||||
|
upvar 2 testFileFailures crashed
|
||||||
|
set ::exitCode [expr {$numTests(Failed) > 0}]
|
||||||
|
if {[info exists crashed]} {
|
||||||
|
set ::exitCode [expr {$::exitCode || [llength $crashed]}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
runAllTests
|
||||||
|
puts "\a"
|
||||||
|
exit $exitCode
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
" call DMTest_single(setup, typed, expected[, skip_expr[, todo_expr]])
|
|
||||||
" - Runs a single test.
|
|
||||||
" - Add 1 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" call DMTest_pairs(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every pair.
|
|
||||||
" - Add 7 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" call DMTest_quotes(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every quote.
|
|
||||||
" - Add 5 to vimtap#Plan().
|
|
||||||
|
|
||||||
call vimtest#StartTap()
|
|
||||||
|
|
||||||
call vimtap#Plan(239)
|
|
||||||
|
|
||||||
|
|
||||||
let g:delimitMate_matchpairs = '(:),{:},[:],<:>,¿:?,¡:!,,::'
|
|
||||||
let g:delimitMate_autoclose = 1
|
|
||||||
call DMTest_pairs('', "i(", "()")
|
|
||||||
|
|
||||||
call DMTest_pairs('()', "a\<BS>", "")
|
|
||||||
|
|
||||||
call DMTest_pairs('()', "a)x", "()x")
|
|
||||||
|
|
||||||
"call DMTest_pairs('', "((\<C-G>gx", "(())x")
|
|
||||||
call DMTest_pairs('', "i(x\<Esc>u", "")
|
|
||||||
|
|
||||||
call DMTest_pairs('', "i@(x", "@(x)")
|
|
||||||
|
|
||||||
call DMTest_pairs('@#', "a(x", "@(x)#")
|
|
||||||
|
|
||||||
call DMTest_pairs('\', "a(x", '\(x')
|
|
||||||
|
|
||||||
call DMTest_pairs('(\)', "la)x", '(\)x)')
|
|
||||||
|
|
||||||
call DMTest_pairs('"abc"', "ifoo(", 'foo("abc"')
|
|
||||||
|
|
||||||
"call DMTest_pairs('', "(\<S-Tab>x", "()x")
|
|
||||||
|
|
||||||
let g:delimitMate_autoclose = 0
|
|
||||||
call DMTest_pairs('', "i(x", "(x")
|
|
||||||
|
|
||||||
call DMTest_pairs('', "i()x", "(x)")
|
|
||||||
|
|
||||||
call DMTest_pairs('', "i())x", "()x")
|
|
||||||
|
|
||||||
call DMTest_pairs('', "i()\<BS>x", "x")
|
|
||||||
|
|
||||||
call DMTest_pairs('', "i@()x", "@(x)")
|
|
||||||
|
|
||||||
call DMTest_pairs('@#', "a()x", "@(x)#")
|
|
||||||
|
|
||||||
let g:delimitMate_autoclose = 1
|
|
||||||
" Handle backspace gracefully.
|
|
||||||
set backspace=
|
|
||||||
call DMTest_pairs('', "i(\<Esc>a\<BS>x", "(x)")
|
|
||||||
|
|
||||||
set backspace=2
|
|
||||||
" closing parens removes characters. #133
|
|
||||||
call DMTest_pairs('(a)', "a)", "()a)")
|
|
||||||
|
|
||||||
" Expand iabbreviations
|
|
||||||
iabb def ghi
|
|
||||||
" Not sure how to make it work on the test
|
|
||||||
call DMTest_single('', "idef(", "ghi()", 0, 1)
|
|
||||||
iunabb def
|
|
||||||
|
|
||||||
call DMTest_pairs("abc а", "$i(", "abc (а")
|
|
||||||
|
|
||||||
call DMTest_pairs("abc ñ", "$i(", "abc (ñ")
|
|
||||||
|
|
||||||
call DMTest_pairs("abc $", "$i(", "abc ($")
|
|
||||||
|
|
||||||
call DMTest_pairs("abc £", "$i(", "abc (£")
|
|
||||||
|
|
||||||
call DMTest_pairs("abc d", "$i(", "abc (d")
|
|
||||||
|
|
||||||
call DMTest_pairs("abc .", "$i(", "abc ().")
|
|
||||||
|
|
||||||
call DMTest_pairs("abc ", "$i(", "abc () ")
|
|
||||||
|
|
||||||
call DMTest_pairs("abc (", "$i(", "abc ((")
|
|
||||||
|
|
||||||
" Play nice with undo.
|
|
||||||
call DMTest_pairs('', "ia\<C-G>u(c)b\<Esc>u", "a")
|
|
||||||
|
|
||||||
" TODO: way to jump over one or several closing chars
|
|
||||||
call DMTest_single('()', 'a\<magic>x', '()x', 0, 1)
|
|
||||||
|
|
||||||
call DMTest_single('{()}', 'la\<magic>x', '{()}x', 0, 1)
|
|
||||||
|
|
||||||
let g:delimitMate_balance_pairs = 0
|
|
||||||
call DMTest_pairs('ab cd)', "la(x", 'ab(x) cd)')
|
|
||||||
" Issue #229
|
|
||||||
call DMTest_pairs('((ab cd)', "$i)x", '((ab cd)x')
|
|
||||||
|
|
||||||
let g:delimitMate_balance_pairs = 1
|
|
||||||
call DMTest_pairs('ab cd)', "la(x", 'ab(x cd)')
|
|
||||||
" Issue #229
|
|
||||||
call DMTest_pairs('((ab cd)', "$i)x", '((ab cd)x)')
|
|
||||||
unlet g:delimitMate_balance_pairs
|
|
||||||
|
|
||||||
" Issue #220
|
|
||||||
let g:delimitMate_jump_next = 0
|
|
||||||
call DMTest_pairs('()', 'a)', '())')
|
|
||||||
unlet g:delimitMate_jump_next
|
|
||||||
|
|
||||||
" Issues #207 and #223
|
|
||||||
let g:delimitMate_jump_long = 1
|
|
||||||
call DMTest_single('{[(foobar)]}', 'fbi)x', '{[(foobar)x]}')
|
|
||||||
|
|
||||||
" Issues #207 and #223
|
|
||||||
call DMTest_single('{[(foobar)]}', 'fbi]x', '{[(foobar)]x}')
|
|
||||||
unlet g:delimitMate_jump_long
|
|
||||||
|
|
||||||
" Issues #207 and #223
|
|
||||||
let g:delimitMate_jump_all = 1
|
|
||||||
call DMTest_single('{[(foobar)]}', 'fbi<magic>x', '{[(foobar)]}x', 0, 1)
|
|
||||||
unlet g:delimitMate_jump_all
|
|
||||||
|
|
||||||
let g:delimitMate_jump_back = 1
|
|
||||||
call DMTest_pairs('', 'i()x', '()x')
|
|
||||||
unlet g:delimitMate_jump_back
|
|
||||||
|
|
||||||
" Disable on syntax groups
|
|
||||||
new
|
|
||||||
syntax on
|
|
||||||
set ft=vim
|
|
||||||
let g:delimitMate_excluded_regions = ['String']
|
|
||||||
call DMTest_pairs('echo " "', "f\"la(", 'echo " ( "')
|
|
||||||
unlet g:delimitMate_excluded_regions
|
|
||||||
|
|
||||||
filetype indent plugin on
|
|
||||||
set ft=php
|
|
||||||
" Issue #160
|
|
||||||
call DMTest_single('<?php incl', "A\<C-X>\<C-O>\<C-Y>", '<?php include()', 0, 1)
|
|
||||||
syntax off
|
|
||||||
bp
|
|
||||||
|
|
||||||
" This breaks Vim for now, so let's put it at the end
|
|
||||||
" Play nice with redo
|
|
||||||
call DMTest_single('abc ', "Afoo(x\<Esc>.", 'abc foo(x)foo(x)', 0, 1)
|
|
||||||
|
|
||||||
call vimtest#Quit()
|
|
||||||
" vim: sw=2 et
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
" call DMTest_single(setup, typed, expected[, skip_expr[, todo_expr]])
|
|
||||||
" - Runs a single test.
|
|
||||||
" - Add 1 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" call DMTest_pairs(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every pair.
|
|
||||||
" - Add 7 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" call DMTest_quotes(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every quote.
|
|
||||||
" - Add 5 to vimtap#Plan().
|
|
||||||
|
|
||||||
call vimtest#StartTap()
|
|
||||||
|
|
||||||
call vimtap#Plan(147)
|
|
||||||
|
|
||||||
|
|
||||||
let g:delimitMate_autoclose = 1
|
|
||||||
call DMTest_quotes('', "i'x", "'x'")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i'x\<Esc>u", "")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i''x", "''x")
|
|
||||||
|
|
||||||
call DMTest_quotes("''", "a\<BS>x", "x")
|
|
||||||
|
|
||||||
"call DMTest_quotes('', "'\<C-G>gx", "''x")
|
|
||||||
" This will fail for double quote.
|
|
||||||
call DMTest_quotes('', "i'\"x", "'\"x\"'", 'a:typed =~ "i\"\"x"')
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i@'x", "@'x'")
|
|
||||||
|
|
||||||
call DMTest_quotes('@#', "a'x", "@'x'#")
|
|
||||||
|
|
||||||
"call DMTest_quotes('', "'\<S-Tab>x", "''x")
|
|
||||||
call DMTest_quotes('abc', "A'", "abc'")
|
|
||||||
|
|
||||||
call DMTest_quotes('abc\', "A'x", "abc\\'x")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "au'Привет'", "u'Привет'")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "au'string'", "u'string'")
|
|
||||||
|
|
||||||
let g:delimitMate_autoclose = 0
|
|
||||||
call DMTest_quotes('', "a'x", "'x")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "a''x", "'x'")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "a'''x", "''x")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "a''\<BS>x", "x")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "a@''x", "@'x'")
|
|
||||||
|
|
||||||
call DMTest_quotes('@#', "a''x", "@'x'#")
|
|
||||||
|
|
||||||
let g:delimitMate_autoclose = 1
|
|
||||||
" Handle backspace gracefully.
|
|
||||||
set backspace=
|
|
||||||
call DMTest_quotes('', "a'\<Esc>a\<BS>x", "'x'")
|
|
||||||
|
|
||||||
set backspace=2
|
|
||||||
"set cpo=ces$
|
|
||||||
"call DMTest_quotes('', "'x", "'x'")
|
|
||||||
" Make sure smart quote works beyond first column.
|
|
||||||
call DMTest_quotes(' ', "a'x", " 'x'")
|
|
||||||
|
|
||||||
" smart quote, check fo char on the right.
|
|
||||||
call DMTest_quotes('a b', "la'", "a 'b")
|
|
||||||
|
|
||||||
" Make sure we jump over a quote on the right. #89.
|
|
||||||
call DMTest_quotes('', "a('test'x", "('test'x)")
|
|
||||||
|
|
||||||
" Duplicate whole line when inserting quote at bol #105
|
|
||||||
call DMTest_quotes('}', "i'", "''}")
|
|
||||||
|
|
||||||
call DMTest_quotes("'abc ", "A'", "'abc '")
|
|
||||||
|
|
||||||
call DMTest_quotes("''abc ", "A'", "''abc ''")
|
|
||||||
|
|
||||||
" Nesting quotes:
|
|
||||||
let g:delimitMate_nesting_quotes = delimitMate#option('quotes')
|
|
||||||
call DMTest_quotes("''", "A'x", "'''x'''")
|
|
||||||
|
|
||||||
call DMTest_quotes("'''", "A'x", "''''x''''")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i''x", "''x")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i'x", "'x'")
|
|
||||||
|
|
||||||
unlet g:delimitMate_nesting_quotes
|
|
||||||
" expand iabbreviations
|
|
||||||
iabb def ghi
|
|
||||||
call DMTest_single('', 'idef"', 'ghi"')
|
|
||||||
|
|
||||||
iunabb def
|
|
||||||
""call DMTest_quotes('', "i'\<CR>\<BS>", "''")
|
|
||||||
" Double quote starts a comment in viml
|
|
||||||
set ft=vim
|
|
||||||
call DMTest_single('', 'i"', '"')
|
|
||||||
|
|
||||||
syntax on
|
|
||||||
" Allow quote to exit from string when disabled by syntax group.
|
|
||||||
call DMTest_quotes("'abc'", "$i'x", "'abc'x")
|
|
||||||
|
|
||||||
set ft=
|
|
||||||
|
|
||||||
call vimtest#Quit()
|
|
||||||
" vim: sw=2 et
|
|
||||||
49
test/eol_marker.test
Normal file
49
test/eol_marker.test
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# singleTest name desc setup input result vimCmds? skipScript?
|
||||||
|
#
|
||||||
|
# - desc can be empty and input would be used.
|
||||||
|
# - vimCmds is a list of ex commands.
|
||||||
|
# - skipScript will be evaluated in the scope of the function "single" and it
|
||||||
|
# should return a keywowd such as toDo, badTest or other as listed in the
|
||||||
|
# docs for tcltest. e.g.:
|
||||||
|
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
|
||||||
|
# see tcltest documentation for other values.
|
||||||
|
|
||||||
|
# Get some help:
|
||||||
|
source helper.tcl
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
|
||||||
|
lappend vimCmds {let g:delimitMate_eol_marker = ';'}
|
||||||
|
lappend vimCmds {let g:delimitMate_insert_eol_marker = 0}
|
||||||
|
|
||||||
|
single ins_eol_marker_0-1 {} "" "i(" "()" ${vimCmds}
|
||||||
|
|
||||||
|
single ins_eol_marker_0-2 {} "" "i(\rx" "(\nx\n)" ${vimCmds}
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
|
||||||
|
lappend vimCmds {let g:delimitMate_eol_marker = ';'}
|
||||||
|
lappend vimCmds {let g:delimitMate_insert_eol_marker = 1}
|
||||||
|
single ins_eol_marker_1-1 {} "" "i(" "();" ${vimCmds}
|
||||||
|
|
||||||
|
single ins_eol_marker_1-2 {} " a" "0i(" "() a" ${vimCmds}
|
||||||
|
|
||||||
|
single ins_eol_marker_1-3 {} "" "i(\rx" "(\nx\n);" ${vimCmds}
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
|
||||||
|
lappend vimCmds {let g:delimitMate_eol_marker = ';'}
|
||||||
|
lappend vimCmds {let g:delimitMate_insert_eol_marker = 2}
|
||||||
|
single ins_eol_marker_2-1 {} "" "i(" "()" ${vimCmds}
|
||||||
|
|
||||||
|
single ins_eol_marker_2-2 {} "" "i(\rx" "(\nx\n);" ${vimCmds}
|
||||||
|
|
||||||
|
# Issue #195
|
||||||
|
single issue_195-1 {} "" "i{(\rx" "{(\nx\n)}" ${vimCmds}
|
||||||
|
|
||||||
|
# Issue #195
|
||||||
|
single issue_195-2 {} ";" "I{(\rx" "{(\nx\n)};" ${vimCmds}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# This gives nice statistics and cleans up the mess left behind.
|
||||||
|
cleanupTests
|
||||||
|
# vim: set filetype=tcl et sw=2 sts=0 ts=8:
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
" call DMTest_single(setup, typed, expected[, skip_expr[, todo_expr]])
|
|
||||||
" - Runs a single test.
|
|
||||||
" - Add 1 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" call DMTest_pairs(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every pair.
|
|
||||||
" - Add 7 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" call DMTest_quotes(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every quote.
|
|
||||||
" - Add 5 to vimtap#Plan().
|
|
||||||
|
|
||||||
call vimtest#StartTap()
|
|
||||||
call vimtap#Plan(10)
|
|
||||||
|
|
||||||
let g:delimitMate_expand_cr = 1
|
|
||||||
let g:delimitMate_eol_marker = ';'
|
|
||||||
" NOTE: Do not forget to update the plan ^
|
|
||||||
let g:delimitMate_insert_eol_marker = 0
|
|
||||||
|
|
||||||
call DMTest_single('', 'i(', '()')
|
|
||||||
|
|
||||||
call DMTest_single('', "i(\<CR>x", ['(', 'x', ')'])
|
|
||||||
|
|
||||||
let g:delimitMate_insert_eol_marker = 1
|
|
||||||
call DMTest_single('', 'i(', '();')
|
|
||||||
|
|
||||||
call DMTest_single(' a', 'i(', '() a')
|
|
||||||
|
|
||||||
call DMTest_single('', "i(\<CR>x", ['(', 'x', ');'])
|
|
||||||
|
|
||||||
let g:delimitMate_insert_eol_marker = 2
|
|
||||||
call DMTest_single('', 'i(', '()')
|
|
||||||
|
|
||||||
call DMTest_single('', "i(\<CR>x", ['(', 'x', ');'])
|
|
||||||
|
|
||||||
" Issue #195
|
|
||||||
call DMTest_single('', "i{(\<CR>x", ['{(', 'x', ')}'])
|
|
||||||
|
|
||||||
" Issue #195
|
|
||||||
call DMTest_single('', "i;\<Left>{(\<CR>x", ['{(', 'x', ')};'])
|
|
||||||
|
|
||||||
" Issue #195
|
|
||||||
call DMTest_single('', "i\<Left>{(\<CR>x", ['{(', 'x', ')};'], 0, 1)
|
|
||||||
|
|
||||||
" End: quit vim.
|
|
||||||
call vimtest#Quit()
|
|
||||||
" vim: sw=2 et
|
|
||||||
92
test/expand_cr.test
Normal file
92
test/expand_cr.test
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
# singleTest name desc setup input result vimCmds? skipScript?
|
||||||
|
#
|
||||||
|
# - desc can be empty and input would be used.
|
||||||
|
# - vimCmds is a list of ex commands.
|
||||||
|
# - skipScript will be evaluated in the scope of the function "single" and it
|
||||||
|
# should return a keywowd such as toDo, badTest or other as listed in the
|
||||||
|
# docs for tcltest. e.g.:
|
||||||
|
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
|
||||||
|
# see tcltest documentation for other values.
|
||||||
|
|
||||||
|
# Get some help:
|
||||||
|
source helper.tcl
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
|
||||||
|
#"let g:delimitMate_eol_marker = ';'
|
||||||
|
lappend vimCmds {filetype indent on}
|
||||||
|
lappend vimCmds {set bs=2 et sts=4 sw=4 ft=javascript}
|
||||||
|
single javascript-1 {} "\$(document).ready(function() {})" "f{a\rx" \
|
||||||
|
"\$(document).ready(function() {\n x\n})" ${vimCmds}
|
||||||
|
|
||||||
|
# Issue #95
|
||||||
|
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
|
||||||
|
lappend vimCmds {let b:delimitMate_jump_expansion = 1}
|
||||||
|
set skipScript {string cat toDo}
|
||||||
|
single issue_95 {} "" "i(\rtest)x" "(\ntest\n)x" ${vimCmds} ${skipScript}
|
||||||
|
|
||||||
|
# Remove CR expansion on BS
|
||||||
|
set skipScript {string cat toDo}
|
||||||
|
single bs {} "" "i(\r\bx" "(x)" ${vimCmds} ${skipScript}
|
||||||
|
|
||||||
|
# Consider indentation with BS inside an empty CR expansion.
|
||||||
|
single bs_indentation {} "" "i( \r\b\bx" "(x)" ${vimCmds}
|
||||||
|
|
||||||
|
# Conflict with indentation settings (cindent). Issue #95
|
||||||
|
lappend vimCmds {se cindent}
|
||||||
|
single issue_95 {} "sub foo {\n while (1) {\n\n }\n}" "3Gi\bx" \
|
||||||
|
"sub foo {\n while (1) {x}\n}" ${vimCmds}
|
||||||
|
|
||||||
|
single nested_expansion-1 {} "sub foo {\n while (1) {\n bar\n }\n}" \
|
||||||
|
"3GA}x" "sub foo {\n while (1) {\n bar\n }x\n}" ${vimCmds}
|
||||||
|
|
||||||
|
single nested_expansion-2 {} "sub foo {\n while (1) {\n bar\n }\n}" \
|
||||||
|
"3GA{x" "sub foo {\n while (1) {\n bar{x}\n }\n}" ${vimCmds}
|
||||||
|
|
||||||
|
single bracketed {} "\"{bracketed}" "\033A\"x" "\"{bracketed}\"x" ${vimCmds}
|
||||||
|
|
||||||
|
# Syntax folding enabled by autocmd breaks expansion.
|
||||||
|
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
|
||||||
|
lappend vimCmds {se cindent}
|
||||||
|
lappend vimCmds {set bs=2 et sts=4 sw=4}
|
||||||
|
lappend vimCmds {autocmd InsertEnter <buffer> let w:fdm=&foldmethod \
|
||||||
|
| setl foldmethod=manual}
|
||||||
|
lappend vimCmds {autocmd InsertLeave <buffer> let &foldmethod = w:fdm}
|
||||||
|
lappend vimCmds {set foldmethod=marker}
|
||||||
|
lappend vimCmds {set foldmarker={,}}
|
||||||
|
lappend vimCmds {set foldlevel=0}
|
||||||
|
lappend vimCmds {set backspace=2}
|
||||||
|
single folding {} "" "iabc {\rx" "abc {\n x\n}" ${vimCmds}
|
||||||
|
|
||||||
|
# expand_cr != 2}
|
||||||
|
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
|
||||||
|
lappend vimCmds {se cindent}
|
||||||
|
lappend vimCmds {set bs=2 et sts=4 sw=4 ft=javascript}
|
||||||
|
lappend vimCmds {let b:delimitMate_jump_expansion = 1}
|
||||||
|
single axpand_cr_no_2 {} "abc(def)" "\$i\rx" "abc(def\n x)" ${vimCmds}
|
||||||
|
|
||||||
|
# expand_cr == 2
|
||||||
|
set vimCmds [list {let g:delimitMate_expand_cr = 2}]
|
||||||
|
lappend vimCmds {se cindent}
|
||||||
|
lappend vimCmds {set bs=2 et sts=4 sw=4 ft=javascript}
|
||||||
|
lappend vimCmds {let b:delimitMate_jump_expansion = 1}
|
||||||
|
single expand_cr_2 {} "abc(def)" "\$i\rx" "abc(def\n x\n )" ${vimCmds}
|
||||||
|
|
||||||
|
# Play nice with smartindent
|
||||||
|
set vimCmds [list {let g:delimitMate_expand_cr = 2}]
|
||||||
|
lappend vimCmds {let b:delimitMate_jump_expansion = 1}
|
||||||
|
lappend vimCmds {set smartindent}
|
||||||
|
single smartindent-1 {} "" "i{\rx" "{\n x\n}" ${vimCmds}
|
||||||
|
|
||||||
|
single quotes-1 {} "" "i\" x" {" x"} ${vimCmds}
|
||||||
|
|
||||||
|
single quotes-2 {} "" "i\"\rx" "\"\nx\"" ${vimCmds}
|
||||||
|
|
||||||
|
lappend vimCmds {let g:delimitMate_expand_inside_quotes = 1}
|
||||||
|
single quotes-3 {} "" "i\"\nx" "\"\nx\n\"" ${vimCmds}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# This gives nice statistics and cleans up the mess left behind.
|
||||||
|
cleanupTests
|
||||||
|
# vim: set filetype=tcl et sw=2 sts=0 ts=8:
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
" call DMTest_single(setup, typed, expected[, skip_expr[, todo_expr]])
|
|
||||||
" - Runs a single test.
|
|
||||||
" - Add 1 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" call DMTest_pairs(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every pair.
|
|
||||||
" - Add 7 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" call DMTest_quotes(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every quote.
|
|
||||||
" - Add 5 to vimtap#Plan().
|
|
||||||
|
|
||||||
call vimtest#StartTap()
|
|
||||||
call vimtap#Plan(27)
|
|
||||||
|
|
||||||
|
|
||||||
let g:delimitMate_expand_cr = 1
|
|
||||||
"let g:delimitMate_eol_marker = ';'
|
|
||||||
filetype indent on
|
|
||||||
set bs=2 et sts=4 sw=4 ft=javascript
|
|
||||||
call DMTest_single('$(document).ready(function() {})',
|
|
||||||
\ "31|i\<CR>x",
|
|
||||||
\ ["$(document).ready(function() {", " x", "})"])
|
|
||||||
|
|
||||||
" Issue #95
|
|
||||||
new
|
|
||||||
let b:delimitMate_jump_expansion = 1
|
|
||||||
call DMTest_single('',
|
|
||||||
\ "i(\<CR>test)x",
|
|
||||||
\ ['(', 'test', ')x'])
|
|
||||||
|
|
||||||
" Remove CR expansion on BS
|
|
||||||
call DMTest_single('',
|
|
||||||
\ "i(\<CR>\<BS>x",
|
|
||||||
\ ['(x)'])
|
|
||||||
|
|
||||||
" Consider indentation with BS inside an empty CR expansion.
|
|
||||||
call DMTest_single('', "i( \<CR>\<BS>\<BS>x", '(x)')
|
|
||||||
|
|
||||||
" Conflict with indentation settings (cindent). Issue #95
|
|
||||||
se cindent
|
|
||||||
|
|
||||||
call DMTest_single(
|
|
||||||
\ ['sub foo {',
|
|
||||||
\ ' while (1) {',
|
|
||||||
\ '',
|
|
||||||
\ ' }',
|
|
||||||
\ '}'],
|
|
||||||
\ "3Gi\<BS>x",
|
|
||||||
\ ['sub foo {',
|
|
||||||
\ ' while (1) {x}',
|
|
||||||
\ '}'])
|
|
||||||
|
|
||||||
call DMTest_single(
|
|
||||||
\ ['sub foo {',
|
|
||||||
\ ' while (1) {',
|
|
||||||
\ ' bar',
|
|
||||||
\ ' }',
|
|
||||||
\ '}'],
|
|
||||||
\ "3GA}x",
|
|
||||||
\ ['sub foo {',
|
|
||||||
\ ' while (1) {',
|
|
||||||
\ ' bar',
|
|
||||||
\ ' }x',
|
|
||||||
\ '}'])
|
|
||||||
|
|
||||||
call DMTest_single(
|
|
||||||
\ ['sub foo {',
|
|
||||||
\ ' while (1) {',
|
|
||||||
\ ' bar',
|
|
||||||
\ ' }',
|
|
||||||
\ '}'],
|
|
||||||
\ "3GA{x",
|
|
||||||
\ ['sub foo {',
|
|
||||||
\ ' while (1) {',
|
|
||||||
\ ' bar{x}',
|
|
||||||
\ ' }',
|
|
||||||
\ '}'])
|
|
||||||
|
|
||||||
call DMTest_single('"{bracketed}', "\<Esc>A\"x", '"{bracketed}"x')
|
|
||||||
|
|
||||||
" Syntax folding enabled by autocmd breaks expansion.
|
|
||||||
new
|
|
||||||
autocmd InsertEnter <buffer> let w:fdm=&foldmethod | setl foldmethod=manual
|
|
||||||
autocmd InsertLeave <buffer> let &foldmethod = w:fdm
|
|
||||||
set foldmethod=marker
|
|
||||||
set foldmarker={,}
|
|
||||||
set foldlevel=0
|
|
||||||
set backspace=2
|
|
||||||
call DMTest_single('',
|
|
||||||
\ "iabc {\<CR>x",
|
|
||||||
\ ['abc {',
|
|
||||||
\ ' x',
|
|
||||||
\ '}'])
|
|
||||||
:bp
|
|
||||||
|
|
||||||
" expand_cr != 2
|
|
||||||
call DMTest_single('abc(def)',
|
|
||||||
\ "i\<Esc>$i\<CR>x",
|
|
||||||
\ ['abc(def',
|
|
||||||
\ ' x)'])
|
|
||||||
|
|
||||||
" expand_cr == 2
|
|
||||||
let g:delimitMate_expand_cr = 2
|
|
||||||
call DMTest_single('abc(def)',
|
|
||||||
\ "$i\<CR>x",
|
|
||||||
\ ['abc(def',
|
|
||||||
\ ' x',
|
|
||||||
\ ' )'])
|
|
||||||
|
|
||||||
" Play nice with smartindent
|
|
||||||
set all&
|
|
||||||
set whichwrap=[]
|
|
||||||
set bs=2
|
|
||||||
set smartindent
|
|
||||||
call DMTest_single('', "i{\<CR>x", ['{', ' x', '}'])
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i' x", "' x'")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i'\<CR>x", ["'", "x'"])
|
|
||||||
|
|
||||||
let g:delimitMate_expand_inside_quotes = 1
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i'\<CR>x", ["'", "x", "'"])
|
|
||||||
|
|
||||||
call vimtest#Quit()
|
|
||||||
" vim: sw=2 et
|
|
||||||
48
test/expand_space.test
Normal file
48
test/expand_space.test
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# singleTest name desc setup input result vimCmds? skipScript?
|
||||||
|
#
|
||||||
|
# - desc can be empty and input would be used.
|
||||||
|
# - vimCmds is a list of ex commands.
|
||||||
|
# - skipScript will be evaluated in the scope of the function "single" and it
|
||||||
|
# should return a keywowd such as toDo, badTest or other as listed in the
|
||||||
|
# docs for tcltest. e.g.:
|
||||||
|
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
|
||||||
|
# see tcltest documentation for other values.
|
||||||
|
|
||||||
|
# Get some help:
|
||||||
|
source helper.tcl
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_expand_space = 1}]
|
||||||
|
lappend vimCmds {let g:delimitMate_autoclose = 1}
|
||||||
|
|
||||||
|
pairs pairs-1 {} "" "i( x" "( x )" ${vimCmds}
|
||||||
|
|
||||||
|
pairs pairs-2 {} "( )" "la\bx" "(x)" ${vimCmds}
|
||||||
|
|
||||||
|
pairs pairs-3 {} "" "iabc x" "abc x" ${vimCmds}
|
||||||
|
|
||||||
|
quotes quotes-1 {} "" "i' x" "' x'" ${vimCmds}
|
||||||
|
|
||||||
|
lappend vimCmds {let g:delimitMate_expand_inside_quotes = 1}
|
||||||
|
quotes quotes-2 {} "" "i' x" "' x '" ${vimCmds}
|
||||||
|
|
||||||
|
quotes quotes-3 {} "" "i' \bx" "'x'" ${vimCmds}
|
||||||
|
|
||||||
|
set skipScript {string cat quoteBug}
|
||||||
|
lappend vimCmds {let g:delimitMate_autoclose = 0}
|
||||||
|
quotes quotes-4 {} "abc\\" "A'' x" "abc\\'' x '" ${vimCmds} ${skipScript}
|
||||||
|
|
||||||
|
# Issue #95
|
||||||
|
lappend vimCmds {let b:delimitMate_jump_expansion = 1}
|
||||||
|
set skipScript {string cat toDo}
|
||||||
|
pairs issue_95 {} "" "i( test)x" "( test )x" ${vimCmds} ${skipScript}
|
||||||
|
|
||||||
|
pairs pairs-4 {} "" "i() \bx" "(x)" ${vimCmds}
|
||||||
|
|
||||||
|
quotes quotes-5 {} "" "i'' \bx" "'x'" ${vimCmds}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# This gives nice statistics and cleans up the mess left behind.
|
||||||
|
cleanupTests
|
||||||
|
# vim: set filetype=tcl et sw=2 sts=0 ts=8:
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
" call DMTest_single(setup, typed, expected[, skip_expr[, todo_expr]])
|
|
||||||
" - Runs a single test.
|
|
||||||
" - Add 1 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" call DMTest_pairs(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every pair.
|
|
||||||
" - Add 7 to vimtap#Plan().
|
|
||||||
"
|
|
||||||
" call DMTest_quotes(setup, typed, expected, [skip_expr[, todo_expr]])
|
|
||||||
" - Runs one test for every quote.
|
|
||||||
" - Add 5 to vimtap#Plan().
|
|
||||||
|
|
||||||
call vimtest#StartTap()
|
|
||||||
|
|
||||||
call vimtap#Plan(60)
|
|
||||||
|
|
||||||
|
|
||||||
let g:delimitMate_expand_space = 1
|
|
||||||
|
|
||||||
let g:delimitMate_autoclose = 1
|
|
||||||
call DMTest_pairs('', "i(\<Space>x", "( x )")
|
|
||||||
|
|
||||||
call DMTest_pairs('( )', "la\<BS>x", "(x)")
|
|
||||||
|
|
||||||
call DMTest_pairs('', "iabc x", "abc x")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i' x", "' x'")
|
|
||||||
|
|
||||||
let g:delimitMate_expand_inside_quotes = 1
|
|
||||||
call DMTest_quotes('', "i' x", "' x '")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i' \<BS>x", "'x'")
|
|
||||||
|
|
||||||
call DMTest_quotes('abc\', "A'' x", "abc\\'' x '")
|
|
||||||
|
|
||||||
" Issue #95
|
|
||||||
let b:delimitMate_jump_expansion = 1
|
|
||||||
call DMTest_pairs('', "i( test)x", '( test )x')
|
|
||||||
|
|
||||||
let g:delimitMate_autoclose = 0
|
|
||||||
call DMTest_pairs('', "i()\<Space>\<BS>x", "(x)")
|
|
||||||
|
|
||||||
call DMTest_quotes('', "i'' \<BS>x", "'x'")
|
|
||||||
|
|
||||||
call vimtest#Quit()
|
|
||||||
" vim: sw=2 et
|
|
||||||
125
test/helper.tcl
Normal file
125
test/helper.tcl
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
if {[lsearch [namespace children] ::tcltest] == -1} {
|
||||||
|
package require tcltest 2
|
||||||
|
namespace import -force ::tcltest::*
|
||||||
|
}
|
||||||
|
|
||||||
|
configure -verbose {body error skip}
|
||||||
|
#configure -verbose {start msec pass body error skip}
|
||||||
|
|
||||||
|
set charMap [list \
|
||||||
|
"\"" "\\\"" \
|
||||||
|
"\$" "\\$" \
|
||||||
|
"\[" "\\\[" \
|
||||||
|
"\]" "\\\]" \
|
||||||
|
"\\" "\\\\" \
|
||||||
|
"{" "\\{" \
|
||||||
|
"}" "\\}" \
|
||||||
|
]
|
||||||
|
|
||||||
|
# In order to skip a test pass a script that, when evaluated, returns emptyTest
|
||||||
|
# for tests that can not pass, or knownBug for ToDo features. e.g.:
|
||||||
|
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
|
||||||
|
# see tcltest documentation for other values.
|
||||||
|
|
||||||
|
proc single {name desc setup input result \
|
||||||
|
{vimCmds {}} \
|
||||||
|
{constr {}} \
|
||||||
|
} {
|
||||||
|
set fnamePrefix "test_${name}"
|
||||||
|
global charMap
|
||||||
|
makeFile ${setup} "${fnamePrefix}.in"
|
||||||
|
makeFile {} "${fnamePrefix}.out"
|
||||||
|
makeFile [join ${vimCmds} "\n"] "${fnamePrefix}.vim"
|
||||||
|
set input [string map ${charMap} ${input}]
|
||||||
|
#puts [lindex ${vimCmds} 0]
|
||||||
|
set optCharMap [list {[} {\[} {]} {\]}]
|
||||||
|
set vimArgs [lmap option ${vimCmds} \
|
||||||
|
{string cat " -c \"[string map $charMap ${option}]\""}]
|
||||||
|
set body [string cat "
|
||||||
|
exec -- ./test.exp \"${fnamePrefix}\" \"${input}\"
|
||||||
|
return \[viewFile \"${fnamePrefix}.out\"\]
|
||||||
|
" ]
|
||||||
|
#puts ${body}
|
||||||
|
if {[string length ${desc}] eq 0} {
|
||||||
|
set desc ${input}
|
||||||
|
}
|
||||||
|
if {[string length ${constr}] ne 0} {
|
||||||
|
#puts ${constr}
|
||||||
|
set constr [eval ${constr}]
|
||||||
|
#puts ${constr}
|
||||||
|
}
|
||||||
|
set name "${name}: \"${setup}\", \"${desc}\" ->"
|
||||||
|
#puts $desc
|
||||||
|
#puts $name
|
||||||
|
test ${name} \
|
||||||
|
${desc} \
|
||||||
|
-body ${body} \
|
||||||
|
-constraints ${constr} \
|
||||||
|
-result ${result}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc multi {items evalScript name desc setup input result \
|
||||||
|
{vimCmds {}} \
|
||||||
|
{constr {}} \
|
||||||
|
} {
|
||||||
|
global charMap
|
||||||
|
set minor 0
|
||||||
|
foreach item $items {
|
||||||
|
incr minor
|
||||||
|
eval ${evalScript}
|
||||||
|
foreach var {desc setup input result} {
|
||||||
|
set "the_${var}" [string map ${aCharMap} [expr "$${var}"]]
|
||||||
|
}
|
||||||
|
set the_name "${name}.${minor}"
|
||||||
|
single \
|
||||||
|
${the_name} \
|
||||||
|
${the_desc} \
|
||||||
|
${the_setup} \
|
||||||
|
${the_input} \
|
||||||
|
${the_result} \
|
||||||
|
${vimCmds} \
|
||||||
|
${constr} \
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc quotes {name desc setup input result \
|
||||||
|
{vimCmds {}} \
|
||||||
|
{constr {}} \
|
||||||
|
} {
|
||||||
|
set quotes [list {'} \" {`} {«} {|}]
|
||||||
|
set mapScript {set aCharMap [list "'" ${item}]}
|
||||||
|
multi \
|
||||||
|
${quotes} \
|
||||||
|
${mapScript} \
|
||||||
|
${name} \
|
||||||
|
${desc} \
|
||||||
|
${setup} \
|
||||||
|
${input} \
|
||||||
|
${result} \
|
||||||
|
${vimCmds} \
|
||||||
|
${constr} \
|
||||||
|
}
|
||||||
|
|
||||||
|
proc pairs {name desc setup input result \
|
||||||
|
{vimCmds {}} \
|
||||||
|
{constr {}} \
|
||||||
|
} {
|
||||||
|
set pairs [list () \{\} \[\] <> ¿? ¡! ,:]
|
||||||
|
set mapScript {
|
||||||
|
set left [string index ${item} 0]
|
||||||
|
set right [string index ${item} 1]
|
||||||
|
set aCharMap [list ( ${left} ) ${right}]
|
||||||
|
}
|
||||||
|
multi \
|
||||||
|
${pairs} \
|
||||||
|
${mapScript} \
|
||||||
|
${name} \
|
||||||
|
${desc} \
|
||||||
|
${setup} \
|
||||||
|
${input} \
|
||||||
|
${result} \
|
||||||
|
${vimCmds} \
|
||||||
|
${constr} \
|
||||||
|
}
|
||||||
|
|
||||||
|
# vim: set filetype=tcl et sw=2 sts=0 ts=8:
|
||||||
153
test/pairs.test
Normal file
153
test/pairs.test
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
# singleTest name desc setup input result vimCmds? skipScript?
|
||||||
|
#
|
||||||
|
# - desc can be empty and input would be used.
|
||||||
|
# - vimCmds is a list of ex commands.
|
||||||
|
# - skipScript will be evaluated in the scope of the function "single" and it
|
||||||
|
# should return a keywowd such as toDo, badTest or other as listed in the
|
||||||
|
# docs for tcltest. e.g.:
|
||||||
|
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
|
||||||
|
# see tcltest documentation for other values.
|
||||||
|
|
||||||
|
# Get some help:
|
||||||
|
source helper.tcl
|
||||||
|
|
||||||
|
set vimCmds [list ]
|
||||||
|
pairs autoclose-1 {} {} "i(" "()"
|
||||||
|
|
||||||
|
pairs autoclose-2 {} {()} "a\b" ""
|
||||||
|
|
||||||
|
pairs autoclose-3 {} "()" "a)x" "()x"
|
||||||
|
|
||||||
|
set skipScript {string cat {toDo}}
|
||||||
|
single jump_all {} "" "((<magic>x" "(())x" {} ${skipScript}
|
||||||
|
|
||||||
|
pairs undo {} "" "i(x\033u" ""
|
||||||
|
|
||||||
|
pairs autoclose-4 {} "" "i@(x" "@(x)"
|
||||||
|
|
||||||
|
pairs autoclose-5 {} "@#" "a(x" "@(x)#"
|
||||||
|
|
||||||
|
pairs autoclose-6 {} "\\" "a(x" "\\(x"
|
||||||
|
|
||||||
|
pairs autoclose-7 {} "(\\)" "la)x" "(\\)x)"
|
||||||
|
|
||||||
|
pairs autoclose-8 {} {"abc"} "ifoo(" "foo(\"abc\""
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_autoclose = 0}]
|
||||||
|
pairs noautoclose-1 {} "" "i(x" "(x" ${vimCmds}
|
||||||
|
|
||||||
|
pairs noautoclose-2 {} "" "i()x" "(x)" ${vimCmds}
|
||||||
|
|
||||||
|
pairs noautoclose-3 {} "" "i())x" "()x" ${vimCmds}
|
||||||
|
|
||||||
|
pairs noautoclose-4 {} "" "i()\bx" "x" ${vimCmds}
|
||||||
|
|
||||||
|
pairs noautoclose-5 {} "" "i@()x" "@(x)" ${vimCmds}
|
||||||
|
|
||||||
|
pairs noautoclose-6 {} "@#" "a()x" "@(x)#" ${vimCmds}
|
||||||
|
|
||||||
|
#" Handle backspace gracefully.
|
||||||
|
set vimCmds [list {set backspace=}]
|
||||||
|
pairs bad_bs {} "" "i(\033a\bx" "(x)" ${vimCmds}
|
||||||
|
|
||||||
|
set vimCmds [list ]
|
||||||
|
|
||||||
|
# closing parens removes characters. #133
|
||||||
|
pairs autoclose-9 {} "(a)" "a)" "()a)" ${vimCmds}
|
||||||
|
|
||||||
|
# Expand iabbreviations
|
||||||
|
set vimCmds [list {iabb def ghi}]
|
||||||
|
# Not sure how to make it work on the test
|
||||||
|
pairs iabbr {} "" "idef(" "ghi()" ${vimCmds}
|
||||||
|
|
||||||
|
set vimCmds [list ]
|
||||||
|
|
||||||
|
pairs autoclose-10 {} {abc а} {$i(} {abc (а} ${vimCmds}
|
||||||
|
|
||||||
|
pairs autoclose-11 {} "abc ñ" "\$i(" "abc (ñ" ${vimCmds}
|
||||||
|
|
||||||
|
pairs autoclose-12 {} "abc \$" "\$i(" "abc (\$" ${vimCmds}
|
||||||
|
|
||||||
|
pairs autoclose-13 {} "abc £" "\$i(" "abc (£" ${vimCmds}
|
||||||
|
|
||||||
|
pairs autoclose-14 {} "abc d" "\$i(" "abc (d" ${vimCmds}
|
||||||
|
|
||||||
|
pairs autoclose-15 {} "abc ." "\$i(" "abc ()." ${vimCmds}
|
||||||
|
|
||||||
|
pairs autoclose-16 {} "abc " "\$i(" "abc () " ${vimCmds}
|
||||||
|
|
||||||
|
pairs autoclose-17 {} "abc (" "\$i(" "abc ((" ${vimCmds}
|
||||||
|
|
||||||
|
# Play nice with undo.
|
||||||
|
pairs undo {} "" "ia\007u(c)b\033u" "a" ${vimCmds}
|
||||||
|
|
||||||
|
# TODO: way to jump over one or several closing chars
|
||||||
|
set skipScript {string cat {toDo}}
|
||||||
|
single jump_to {} "()" "a\<magic>x" "()x" ${vimCmds} ${skipScript}
|
||||||
|
|
||||||
|
single jump_to {} "{()}" "la\\<magic>x" "{()}x" ${vimCmds} ${skipScript}
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_balance_pairs = 0}]
|
||||||
|
pairs no_balance_pairs-1 {} "ab cd)" "la(x" "ab(x) cd)" ${vimCmds}
|
||||||
|
|
||||||
|
# Issue #229
|
||||||
|
pairs issue_229-1 {} "((ab cd)" "\$i)x" "((ab cd)x" ${vimCmds}
|
||||||
|
|
||||||
|
set vimCmds [list ]
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_balance_pairs = 1}]
|
||||||
|
pairs issue_229-2 {} "ab cd)" "la(x" "ab(x cd)" ${vimCmds}
|
||||||
|
|
||||||
|
# Issue #229
|
||||||
|
pairs issue_229-3 {} "((ab cd)" "\$i)x" "((ab cd)x)" ${vimCmds}
|
||||||
|
|
||||||
|
# Issue #220
|
||||||
|
set vimCmds [list {let g:delimitMate_jump_next = 0}]
|
||||||
|
pairs issue_220-1 {} "()" "a)" "())" ${vimCmds}
|
||||||
|
|
||||||
|
# Issues #207 and #223
|
||||||
|
set vimCmds [list {let g:delimitMate_jump_long = 1}]
|
||||||
|
pairs jump_long-1 {} "{\[(foobar)\]}" "fbi)x" "{\[(foobar)x\]}" ${vimCmds}
|
||||||
|
|
||||||
|
# Issues #207 and #223
|
||||||
|
set skipScript {expr "[string first {[[foobar]]} \"${setup}\"] > -1 \
|
||||||
|
? {badTest} : {}"}
|
||||||
|
single jump_long-2 {} "{\[(foobar)\]}" "fbi\]x" "{\[(foobar)\]x}" ${vimCmds} ${skipScript}
|
||||||
|
|
||||||
|
# Issues #207 and #223
|
||||||
|
set skipScript {string cat {toDo}}
|
||||||
|
set vimCmds [list {let g:delimitMate_jump_all = 1}]
|
||||||
|
single issues_207_223 {} "{\[(foobar)\]}" "fbi<magic>x" "{\[(foobar)\]}x" \
|
||||||
|
${vimCmds} ${skipScript}
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_jump_back = 1}]
|
||||||
|
pairs jump_back {} "" "i()x" "()x" ${vimCmds}
|
||||||
|
|
||||||
|
# Disable on syntax groups
|
||||||
|
set vimCmds [list {syntax on}]
|
||||||
|
lappend vimCmds {set ft=vim}
|
||||||
|
lappend vimCmds {let g:delimitMate_excluded_regions = ['String']}
|
||||||
|
pairs ignore_syntax {} {echo " "} "f\"la(" {echo " ( "} ${vimCmds}
|
||||||
|
|
||||||
|
#" Issue #160
|
||||||
|
set vimCmds [list {filetype indent plugin on}]
|
||||||
|
lappend vimCmds {set ft=php}
|
||||||
|
set skipScript {string cat {toDo}}
|
||||||
|
single issue_160 {} "<?php incl" "A\x18\x0F\x19" "<?php include()" \
|
||||||
|
${vimCmds} ${skipScript}
|
||||||
|
|
||||||
|
set vimCmds [list ]
|
||||||
|
|
||||||
|
# Play nice with redo
|
||||||
|
pairs redo {} "abc " "Afoo(x\033." "abc foo(x)foo(x)" ${vimCmds}
|
||||||
|
|
||||||
|
pairs smart {} {""} "0a(x" {"(x"}
|
||||||
|
|
||||||
|
pairs smart {} {""} "0a()x" {"(x)"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# This gives nice statistics and cleans up the mess left behind.
|
||||||
|
cleanupTests
|
||||||
|
# vim: set filetype=tcl et sw=2 sts=0 ts=8:
|
||||||
107
test/quotes.test
Normal file
107
test/quotes.test
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
# singleTest name desc setup input result vimCmds? skipScript?
|
||||||
|
#
|
||||||
|
# - desc can be empty and input would be used.
|
||||||
|
# - vimCmds is a list of ex commands.
|
||||||
|
# - skipScript will be evaluated in the scope of the function "single" and it
|
||||||
|
# should return a keywowd such as toDo, badTest or other as listed in the
|
||||||
|
# docs for tcltest. e.g.:
|
||||||
|
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
|
||||||
|
# see tcltest documentation for other values.
|
||||||
|
|
||||||
|
# Get some help:
|
||||||
|
source helper.tcl
|
||||||
|
|
||||||
|
quotes autoclose-1 {} {} "i'x" "'x'"
|
||||||
|
|
||||||
|
quotes autoclose-2 {} {} "i'x\033u" {}
|
||||||
|
|
||||||
|
quotes autoclose-3 {} {} {i''x} {''x}
|
||||||
|
|
||||||
|
quotes autoclose-4 {} {''} "a\bx" {x}
|
||||||
|
|
||||||
|
set skipScript {expr "[string first {i\"} \"${input}\"] > -1 ? {badTest} : {}"}
|
||||||
|
quotes autoclose-5 {} "" "i'x\"" "'x\"'" {} ${skipScript}
|
||||||
|
|
||||||
|
quotes autoclose-6 {} {} "i@'x" "@'x'"
|
||||||
|
|
||||||
|
quotes autoclose-7 {} {@#} "a'x" "@'x'#"
|
||||||
|
|
||||||
|
#quotes autoclose-8 {} {} "'\<S-Tab>x" "''x"
|
||||||
|
|
||||||
|
single autoclose-8 {} {abc'} "A'" "abc'" {} {string cat toDo}
|
||||||
|
|
||||||
|
quotes autoclose-9 {} "abc\\" "A'x" {abc\'x}
|
||||||
|
|
||||||
|
quotes autoclose-10 {} {} "au'Привет'" "u'Привет'"
|
||||||
|
|
||||||
|
quotes autoclose-11 {} {} "au'string'" "u'string'"
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_autoclose = 0}]
|
||||||
|
quotes noautoclose-1 {} {} "a'x" "'x" ${vimCmds}
|
||||||
|
|
||||||
|
quotes noautoclose-2 {} {} "a''x" "'x'" ${vimCmds}
|
||||||
|
|
||||||
|
quotes noautoclose-3 {} {} "a'''x" "''x" ${vimCmds}
|
||||||
|
|
||||||
|
quotes noautoclose-4 {} {} "a''\bx" "x" ${vimCmds}
|
||||||
|
|
||||||
|
quotes noautoclose-5 {} {} "a@''x" "@'x'" ${vimCmds}
|
||||||
|
|
||||||
|
quotes noautoclose-6 {} "@#" "a''x" "@'x'#" ${vimCmds}
|
||||||
|
|
||||||
|
set vimCmds [list {let g:delimitMate_autoclose = 1}]
|
||||||
|
# Handle backspace gracefully.
|
||||||
|
lappend vimCmds {set backspace=}
|
||||||
|
quotes badBS-1 {} {} "a'\033a\bx" "'x'" ${vimCmds}
|
||||||
|
|
||||||
|
set vimCmds [list {set cpo=ces$}]
|
||||||
|
quotes cpo {} {} "a'x" "'x'" ${vimCmds}
|
||||||
|
|
||||||
|
# Make sure smart quote works beyond first column.
|
||||||
|
quotes beyond_first_column {} { } "a'x" " 'x'"
|
||||||
|
|
||||||
|
# smart quote, check fo char on the right.
|
||||||
|
quotes smart_quote-1 {} "a b" "la'" "a 'b"
|
||||||
|
|
||||||
|
# Make sure we jump over a quote on the right. #89.
|
||||||
|
quotes autoclose-12 {} {} "a('test'x" "('test'x)"
|
||||||
|
|
||||||
|
# Duplicate whole line when inserting quote at bol #105
|
||||||
|
quotes autoclose-13 {} "}" "i'" "''}"
|
||||||
|
|
||||||
|
quotes autoclose-14 {} "'abc " "A'" "'abc '"
|
||||||
|
|
||||||
|
quotes autoclose-15 {} "''abc " "A'" "''abc ''"
|
||||||
|
|
||||||
|
# Nesting quotes:
|
||||||
|
set vimCmds [list {let g:delimitMate_nesting_quotes = delimitMate#option('quotes')}]
|
||||||
|
quotes nesting-1 {} "''" "A'x" "'''x'''" ${vimCmds}
|
||||||
|
|
||||||
|
quotes nesting-2 {} "'''" "A'x" "''''x''''" ${vimCmds}
|
||||||
|
|
||||||
|
quotes nesting-3 {} {} "i''x" "''x" ${vimCmds}
|
||||||
|
|
||||||
|
quotes nesting-4 {} {} "i'x" "'x'" ${vimCmds}
|
||||||
|
|
||||||
|
set vimCmds [list]
|
||||||
|
|
||||||
|
# expand iabbreviations
|
||||||
|
set vimCmds [list {iabb def ghi}]
|
||||||
|
single iabbr {} {} {idef"} {ghi"} ${vimCmds}
|
||||||
|
|
||||||
|
set vimCmds [list]
|
||||||
|
|
||||||
|
quotes autoclose-16 {} {} "i'\n\b" "''"
|
||||||
|
|
||||||
|
# Double quote starts a comment in viml
|
||||||
|
set vimCmds [list {set ft=vim}]
|
||||||
|
single vim_comment {} {} {i"} {"} ${vimCmds}
|
||||||
|
|
||||||
|
#" Allow quote to exit from string when disabled by syntax group.
|
||||||
|
set vimCmds [list {syntax on}]
|
||||||
|
quotes disabled_syntax {} "'abc'" "\$i'x" "'abc'x" ${vimCmds}
|
||||||
|
|
||||||
|
# --------
|
||||||
|
# This gives nice statistics and cleans up the mess left behind.
|
||||||
|
cleanupTests
|
||||||
|
# vim: set filetype=tcl et sw=2 sts=0 ts=8:
|
||||||
20
test/test.exp
Executable file
20
test/test.exp
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env expect -f
|
||||||
|
|
||||||
|
set testName [lindex $argv 0]
|
||||||
|
set filein "${testName}.in"
|
||||||
|
set fileout "${testName}.out"
|
||||||
|
set input [lindex $argv 1]
|
||||||
|
|
||||||
|
set timeout 2
|
||||||
|
spawn env TERM=dumb vim -N -i NONE -u _setup.vim -S "${testName}.vim" -- ${filein}
|
||||||
|
match_max 100000
|
||||||
|
expect -exact "Start test"
|
||||||
|
foreach char [split ${input} {}] {
|
||||||
|
send -- "${char}"
|
||||||
|
sleep .01
|
||||||
|
}
|
||||||
|
send -- " "
|
||||||
|
sleep .01
|
||||||
|
send -- ":w! ${fileout}\r"
|
||||||
|
send -- ":qa!\r"
|
||||||
|
expect eof
|
||||||
Reference in New Issue
Block a user