summaryrefslogtreecommitdiff
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-03-25 17:55:42 +0100
committerBram Moolenaar <Bram@vim.org>2016-03-25 17:55:42 +0100
commit610cc1b9b3c8104382f5506606c1f87118c28114 (patch)
tree2fadd562705c8828dbda358b3beb905f506a8e39 /src/testdir
parent780d4c3fff3c06baa3135a9f9739c56a0c280a94 (diff)
downloadvim-610cc1b9b3c8104382f5506606c1f87118c28114.zip
patch 7.4.1652
Problem: Old style test for fnamemodify(). Solution: Turn it into a new style test.
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/Make_all.mak1
-rw-r--r--src/testdir/test105.in47
-rw-r--r--src/testdir/test105.ok31
-rw-r--r--src/testdir/test_alot.vim1
-rw-r--r--src/testdir/test_fnamemodify.vim43
5 files changed, 44 insertions, 79 deletions
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 455ca7b61..98cf98562 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -85,7 +85,6 @@ SCRIPTS_ALL = \
test102.out \
test103.out \
test104.out \
- test105.out \
test107.out \
test108.out \
test_autocmd_option.out \
diff --git a/src/testdir/test105.in b/src/testdir/test105.in
deleted file mode 100644
index 4cc026144..000000000
--- a/src/testdir/test105.in
+++ /dev/null
@@ -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
-
diff --git a/src/testdir/test105.ok b/src/testdir/test105.ok
deleted file mode 100644
index 6642bfe4f..000000000
--- a/src/testdir/test105.ok
+++ /dev/null
@@ -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
diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim
index 37cdc8b60..fcf358b53 100644
--- a/src/testdir/test_alot.vim
+++ b/src/testdir/test_alot.vim
@@ -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
diff --git a/src/testdir/test_fnamemodify.vim b/src/testdir/test_fnamemodify.vim
new file mode 100644
index 000000000..902be40dc
--- /dev/null
+++ b/src/testdir/test_fnamemodify.vim
@@ -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