view src/testdir/test50.in @ 9672:6255ff1ea003 v7.4.2112

commit https://github.com/vim/vim/commit/b56195ed00a9a79aa6217cddbeedbc8cc7a5b6d8 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jul 28 22:53:37 2016 +0200 patch 7.4.2112 Problem: getcompletion(.., 'dir') returns a match with trailing "*" when there are no matches. (Chdiza) Solution: Return an empty list when there are no matches. Add a trailing slash to directories. (Yegappan Lakshmanan) Add tests for no matches. (closes #947)
author Christian Brabandt <cb@256bit.org>
date Thu, 28 Jul 2016 23:00:06 +0200
parents 5cd32322154c
children
line wrap: on
line source

Test for shortpathname ':8' extension.
Only for use on Win32 systems!

STARTTEST
:so small.vim
:fun! TestIt(file, bits, expected)
	let res=fnamemodify(a:file,a:bits)
	if a:expected == ''
		echo "'".a:file."'->(".a:bits.")->'".res."'"
	else
		if substitute(res,'/','\\', 'g') != substitute( a:expected, '/','\\', 'g') 
			echo "FAILED: '".a:file."'->(".a:bits.")->'".res."'"
			echo "Expected: '".a:expected."'"
		else
			echo "OK"
		endif
	endif
endfun
:fun! MakeDir( dirname )
	"exe '!mkdir '.substitute(a:dirname,'/','\\','g')
	call system('mkdir '.substitute(a:dirname,'/','\\','g'))
endfun
:fun! RMDir( dirname)
	"exe '!rmdir '.substitute(a:dirname,'/','\\','g')
	call system('rmdir '.substitute(a:dirname,'/','\\','g'))
endfun
:fun! MakeFile( filename)
	"exe '!copy nul '.substitute(a:filename,'/','\\','g')
	call system('copy nul '.substitute(a:filename,'/','\\','g'))
endfun
:fun! TestColonEight()
   redir! >test.out
	" This could change for CygWin to //cygdrive/c
	let dir1='c:/x.x.y'
	if filereadable(dir1) || isdirectory(dir1)
		echo "FATAL: '".dir1."' exists, cannot run test"
		return
	endif
	let file1=dir1.'/zz.y.txt'
	let nofile1=dir1.'/z.y.txt'
	let dir2=dir1.'/VimIsTheGreatestSinceSlicedBread'
	let file2=dir2.'/z.txt'
	let nofile2=dir2.'/zz.txt'
	call MakeDir( dir1 )
	let resdir1 = substitute(fnamemodify(dir1, ':p:8'), '\\$', '', '')
	if resdir1 !~ '\V\^c:/XX\x\x\x\x~1.Y\$'
		echo "FATAL: unexpected short name: " . resdir1
		echo "INFO: please report your OS to vim-dev"
		return
	endif
	let resfile1=resdir1.'/ZZY~1.TXT'
	let resnofile1=resdir1.'/z.y.txt'
	let resdir2=resdir1.'/VIMIST~1'
	let resfile2=resdir2.'/z.txt'
	let resnofile2=resdir2.'/zz.txt'
	call MakeDir( dir2 )
	call MakeFile( file1 )
	call MakeFile( file2 )
	call TestIt(file1, ':p:8', resfile1)
	call TestIt(nofile1, ':p:8', resnofile1)
	call TestIt(file2, ':p:8', resfile2)
	call TestIt(nofile2, ':p:8', resnofile2)
	call TestIt(nofile2, ':p:8:h', fnamemodify(resnofile2,':h'))
	exe 'cd '.dir1
	call TestIt(file1, ':.:8', strpart(resfile1,strlen(resdir1)+1))
	call TestIt(nofile1, ':.:8', strpart(resnofile1,strlen(resdir1)+1))
	call TestIt(file2, ':.:8', strpart(resfile2,strlen(resdir1)+1))
	call TestIt(nofile2, ':.:8', strpart(resnofile2,strlen(resdir1)+1))
	let $HOME=dir1
	call TestIt(file1, ':~:8', '~'.strpart(resfile1,strlen(resdir1)))
	call TestIt(nofile1, ':~:8', '~'.strpart(resnofile1,strlen(resdir1)))
	call TestIt(file2, ':~:8', '~'.strpart(resfile2,strlen(resdir1)))
	call TestIt(nofile2, ':~:8', '~'.strpart(resnofile2,strlen(resdir1)))
	cd c:/
	call delete( file2 )
	call delete( file1 )
	call RMDir( dir2 )
	call RMDir( dir1 )
       echo
   redir END
endfun
:let dir = getcwd()
:call TestColonEight()
:exe "cd " . dir
:edit! test.out
:set ff=dos
:w
:qa!
ENDTEST