patch 7.4.1652
Problem: Old style test for fnamemodify(). Solution: Turn it into a new style test.
This commit is contained in:
@ -85,7 +85,6 @@ SCRIPTS_ALL = \
|
||||
test102.out \
|
||||
test103.out \
|
||||
test104.out \
|
||||
test105.out \
|
||||
test107.out \
|
||||
test108.out \
|
||||
test_autocmd_option.out \
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
Test filename modifiers vim: set ft=vim :
|
||||
|
||||
STARTTEST
|
||||
:source small.vim
|
||||
:%delete _
|
||||
:set shell=sh
|
||||
:set shellslash
|
||||
:let tab="\t"
|
||||
:command -nargs=1 Put :let expr=<q-args> | $put =expr.tab.strtrans(string(eval(expr)))
|
||||
:let $HOME=fnamemodify('.', ':p:h:h')
|
||||
:Put fnamemodify('.', ':p' )[-1:]
|
||||
:Put fnamemodify('.', ':p:h' )[-1:]
|
||||
:Put fnamemodify('test.out', ':p' )[-1:]
|
||||
:Put fnamemodify('test.out', ':.' )
|
||||
:Put fnamemodify('../testdir/a', ':.' )
|
||||
:Put fnamemodify('test.out', ':~' )
|
||||
:Put fnamemodify('../testdir/a', ':~' )
|
||||
:Put fnamemodify('../testdir/a', ':t' )
|
||||
:Put fnamemodify('.', ':p:t' )
|
||||
:Put fnamemodify('test.out', ':p:t' )
|
||||
:Put fnamemodify('test.out', ':p:e' )
|
||||
:Put fnamemodify('test.out', ':p:t:e' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':r' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':r:r' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':r:r:r' )
|
||||
:Put substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(testdir/.*\)', '\1', '')
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':e' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':e:e' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':e:e:e' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':e:e:e:e')
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':e:e:r' )
|
||||
:Put fnamemodify('abc def', ':S' )
|
||||
:Put fnamemodify('abc" "def', ':S' )
|
||||
:Put fnamemodify('abc"%"def', ':S' )
|
||||
:Put fnamemodify('abc'' ''def', ':S' )
|
||||
:Put fnamemodify('abc''%''def', ':S' )
|
||||
:Put fnamemodify("abc\ndef", ':S' )
|
||||
:Put expand('%:r:S') == shellescape(expand('%:r'))
|
||||
:Put join([expand('%:r'), expand('%:r:S'), expand('%')], ',')
|
||||
:set shell=tcsh
|
||||
:Put fnamemodify("abc\ndef", ':S' )
|
||||
:$put ='vim: ts=8'
|
||||
:1 delete _
|
||||
:w! test.out
|
||||
:qa!
|
||||
ENDTEST
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
fnamemodify('.', ':p' )[-1:] '/'
|
||||
fnamemodify('.', ':p:h' )[-1:] 'r'
|
||||
fnamemodify('test.out', ':p' )[-1:] 't'
|
||||
fnamemodify('test.out', ':.' ) 'test.out'
|
||||
fnamemodify('../testdir/a', ':.' ) 'a'
|
||||
fnamemodify('test.out', ':~' ) '~/testdir/test.out'
|
||||
fnamemodify('../testdir/a', ':~' ) '~/testdir/a'
|
||||
fnamemodify('../testdir/a', ':t' ) 'a'
|
||||
fnamemodify('.', ':p:t' ) ''
|
||||
fnamemodify('test.out', ':p:t' ) 'test.out'
|
||||
fnamemodify('test.out', ':p:e' ) 'out'
|
||||
fnamemodify('test.out', ':p:t:e' ) 'out'
|
||||
fnamemodify('abc.fb2.tar.gz', ':r' ) 'abc.fb2.tar'
|
||||
fnamemodify('abc.fb2.tar.gz', ':r:r' ) 'abc.fb2'
|
||||
fnamemodify('abc.fb2.tar.gz', ':r:r:r' ) 'abc'
|
||||
substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(testdir/.*\)', '\1', '') 'testdir/abc.fb2'
|
||||
fnamemodify('abc.fb2.tar.gz', ':e' ) 'gz'
|
||||
fnamemodify('abc.fb2.tar.gz', ':e:e' ) 'tar.gz'
|
||||
fnamemodify('abc.fb2.tar.gz', ':e:e:e' ) 'fb2.tar.gz'
|
||||
fnamemodify('abc.fb2.tar.gz', ':e:e:e:e') 'fb2.tar.gz'
|
||||
fnamemodify('abc.fb2.tar.gz', ':e:e:r' ) 'tar'
|
||||
fnamemodify('abc def', ':S' ) '''abc def'''
|
||||
fnamemodify('abc" "def', ':S' ) '''abc" "def'''
|
||||
fnamemodify('abc"%"def', ':S' ) '''abc"%"def'''
|
||||
fnamemodify('abc'' ''def', ':S' ) '''abc''\'''' ''\''''def'''
|
||||
fnamemodify('abc''%''def', ':S' ) '''abc''\''''%''\''''def'''
|
||||
fnamemodify("abc\ndef", ':S' ) '''abc^@def'''
|
||||
expand('%:r:S') == shellescape(expand('%:r')) 1
|
||||
join([expand('%:r'), expand('%:r:S'), expand('%')], ',') 'test105,''test105'',test105.in'
|
||||
fnamemodify("abc\ndef", ':S' ) '''abc\^@def'''
|
||||
vim: ts=8
|
||||
@ -8,6 +8,7 @@ source test_ex_undo.vim
|
||||
source test_expr.vim
|
||||
source test_expand.vim
|
||||
source test_feedkeys.vim
|
||||
source test_fnamemodify.vim
|
||||
source test_file_perm.vim
|
||||
source test_glob2regpat.vim
|
||||
source test_help_tagjump.vim
|
||||
|
||||
43
src/testdir/test_fnamemodify.vim
Normal file
43
src/testdir/test_fnamemodify.vim
Normal file
@ -0,0 +1,43 @@
|
||||
" Test filename modifiers.
|
||||
|
||||
func Test_fnamemodify()
|
||||
let $HOME = fnamemodify('.', ':p:h:h')
|
||||
set shell=sh
|
||||
|
||||
call assert_equal('/', fnamemodify('.', ':p')[-1:])
|
||||
call assert_equal('r', fnamemodify('.', ':p:h')[-1:])
|
||||
call assert_equal('t', fnamemodify('test.out', ':p')[-1:])
|
||||
call assert_equal('test.out', fnamemodify('test.out', ':.'))
|
||||
call assert_equal('a', fnamemodify('../testdir/a', ':.'))
|
||||
call assert_equal('~/testdir/test.out', fnamemodify('test.out', ':~'))
|
||||
call assert_equal('~/testdir/a', fnamemodify('../testdir/a', ':~'))
|
||||
call assert_equal('a', fnamemodify('../testdir/a', ':t'))
|
||||
call assert_equal('', fnamemodify('.', ':p:t'))
|
||||
call assert_equal('test.out', fnamemodify('test.out', ':p:t'))
|
||||
call assert_equal('out', fnamemodify('test.out', ':p:e'))
|
||||
call assert_equal('out', fnamemodify('test.out', ':p:t:e'))
|
||||
call assert_equal('abc.fb2.tar', fnamemodify('abc.fb2.tar.gz', ':r'))
|
||||
call assert_equal('abc.fb2', fnamemodify('abc.fb2.tar.gz', ':r:r'))
|
||||
call assert_equal('abc', fnamemodify('abc.fb2.tar.gz', ':r:r:r'))
|
||||
call assert_equal('testdir/abc.fb2', substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(testdir/.*\)', '\1', ''))
|
||||
call assert_equal('gz', fnamemodify('abc.fb2.tar.gz', ':e'))
|
||||
call assert_equal('tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e'))
|
||||
call assert_equal('fb2.tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e:e'))
|
||||
call assert_equal('fb2.tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e:e:e'))
|
||||
call assert_equal('tar', fnamemodify('abc.fb2.tar.gz', ':e:e:r'))
|
||||
|
||||
call assert_equal('''abc def''', fnamemodify('abc def', ':S'))
|
||||
call assert_equal('''abc" "def''', fnamemodify('abc" "def', ':S'))
|
||||
call assert_equal('''abc"%"def''', fnamemodify('abc"%"def', ':S'))
|
||||
call assert_equal('''abc''\'''' ''\''''def''', fnamemodify('abc'' ''def', ':S'))
|
||||
call assert_equal('''abc''\''''%''\''''def''', fnamemodify('abc''%''def', ':S'))
|
||||
call assert_equal(expand('%:r:S'), shellescape(expand('%:r')))
|
||||
sp test_alot.vim
|
||||
call assert_equal('test_alot,''test_alot'',test_alot.vim', join([expand('%:r'), expand('%:r:S'), expand('%')], ','))
|
||||
quit
|
||||
|
||||
call assert_equal("'abc\ndef'", fnamemodify("abc\ndef", ':S'))
|
||||
set shell=tcsh
|
||||
call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
|
||||
set shell&
|
||||
endfunc
|
||||
@ -748,6 +748,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1652,
|
||||
/**/
|
||||
1651,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user