forked from aniani/vim
patch 8.2.0366: hardcopy command not tested enough
Problem: Hardcopy command not tested enough. Solution: Add tests for printing. (Dominique Pelle, closes #5748)
This commit is contained in:
@@ -1,39 +1,137 @@
|
|||||||
" Test :hardcopy
|
" Test :hardcopy
|
||||||
|
|
||||||
func Test_printoptions_parsing()
|
func Test_printoptions()
|
||||||
" Only test that this doesn't throw an error.
|
edit test_hardcopy.vim
|
||||||
set printoptions=left:5in,right:10pt,top:8mm,bottom:2pc
|
syn on
|
||||||
set printoptions=left:2in,top:30pt,right:16mm,bottom:3pc
|
|
||||||
set printoptions=header:3,syntax:y,number:7,wrap:n
|
for opt in ['left:5in,right:10pt,top:8mm,bottom:2pc',
|
||||||
set printoptions=duplex:short,collate:n,jobsplit:y,portrait:n
|
\ 'left:2in,top:30pt,right:16mm,bottom:3pc',
|
||||||
set printoptions=paper:10x14
|
\ 'header:3,syntax:y,number:y,wrap:n',
|
||||||
set printoptions=paper:A3
|
\ 'header:3,syntax:n,number:y,wrap:y',
|
||||||
set printoptions=paper:A4
|
\ 'duplex:short,collate:n,jobsplit:y,portrait:n',
|
||||||
set printoptions=paper:A5
|
\ 'duplex:long,collate:y,jobsplit:n,portrait:y',
|
||||||
set printoptions=paper:B4
|
\ 'paper:10x14',
|
||||||
set printoptions=paper:B5
|
\ 'paper:A3',
|
||||||
set printoptions=paper:executive
|
\ 'paper:A4',
|
||||||
set printoptions=paper:folio
|
\ 'paper:A5',
|
||||||
set printoptions=paper:ledger
|
\ 'paper:B4',
|
||||||
set printoptions=paper:legal
|
\ 'paper:B5',
|
||||||
set printoptions=paper:letter
|
\ 'paper:executive',
|
||||||
set printoptions=paper:quarto
|
\ 'paper:folio',
|
||||||
set printoptions=paper:statement
|
\ 'paper:ledger',
|
||||||
set printoptions=paper:tabloid
|
\ 'paper:legal',
|
||||||
set printoptions=formfeed:y
|
\ 'paper:letter',
|
||||||
set printoptions=
|
\ 'paper:quarto',
|
||||||
set printoptions&
|
\ 'paper:statement',
|
||||||
|
\ 'paper:tabloid',
|
||||||
|
\ 'formfeed:y',
|
||||||
|
\ '']
|
||||||
|
exe 'set printoptions=' .. opt
|
||||||
|
if has('postscript')
|
||||||
|
hardcopy > Xhardcopy_printoptions
|
||||||
|
let lines = readfile('Xhardcopy_printoptions')
|
||||||
|
call assert_true(len(lines) > 20, opt)
|
||||||
|
call assert_true(lines[0] =~ 'PS-Adobe', opt)
|
||||||
|
call delete('Xhardcopy_printoptions')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
call assert_fails('set printoptions=paper', 'E550:')
|
call assert_fails('set printoptions=paper', 'E550:')
|
||||||
call assert_fails('set printoptions=shredder:on', 'E551:')
|
call assert_fails('set printoptions=shredder:on', 'E551:')
|
||||||
call assert_fails('set printoptions=left:no', 'E552:')
|
call assert_fails('set printoptions=left:no', 'E552:')
|
||||||
|
set printoptions&
|
||||||
|
bwipe
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_printmbfont_parsing()
|
func Test_printmbfont()
|
||||||
" Only test that this doesn't throw an error.
|
" Print a small help page which contains tabs to cover code that expands tabs to spaces.
|
||||||
set printmbfont=r:WadaMin-Regular,b:WadaMin-Bold,i:WadaMin-Italic,o:WadaMin-Bold-Italic,c:yes,a:no
|
help help
|
||||||
set printmbfont=
|
syn on
|
||||||
|
|
||||||
|
for opt in [':WadaMin-Regular,b:WadaMin-Bold,i:WadaMin-Italic,o:WadaMin-Bold-Italic,c:yes,a:no',
|
||||||
|
\ '']
|
||||||
|
exe 'set printmbfont=' .. opt
|
||||||
|
if has('postscript')
|
||||||
|
hardcopy > Xhardcopy_printmbfont
|
||||||
|
let lines = readfile('Xhardcopy_printmbfont')
|
||||||
|
call assert_true(len(lines) > 20, opt)
|
||||||
|
call assert_true(lines[0] =~ 'PS-Adobe', opt)
|
||||||
|
call delete('Xhardcopy_printmbfont')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
set printmbfont&
|
set printmbfont&
|
||||||
|
bwipe
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_printexpr()
|
||||||
|
if !has('unix')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Not a very useful printexpr value, but enough to test
|
||||||
|
" hardcopy with 'printexpr'.
|
||||||
|
function PrintFile(fname)
|
||||||
|
call writefile(['Test printexpr: ' .. v:cmdarg],
|
||||||
|
\ 'Xhardcopy_printexpr')
|
||||||
|
call delete(a:fname)
|
||||||
|
return 0
|
||||||
|
endfunc
|
||||||
|
set printexpr=PrintFile(v:fname_in)
|
||||||
|
|
||||||
|
help help
|
||||||
|
hardcopy dummy args
|
||||||
|
call assert_equal(['Test printexpr: dummy args'],
|
||||||
|
\ readfile('Xhardcopy_printexpr'))
|
||||||
|
call delete('Xhardcopy_printexpr')
|
||||||
|
|
||||||
|
" Function return 1 to test print failure.
|
||||||
|
function PrintFails(fname)
|
||||||
|
call delete(a:fname)
|
||||||
|
return 1
|
||||||
|
endfunc
|
||||||
|
set printexpr=PrintFails(v:fname_in)
|
||||||
|
call assert_fails('hardcopy', 'E365:')
|
||||||
|
|
||||||
|
set printexpr&
|
||||||
|
bwipe
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_errors()
|
||||||
|
" FIXME: Windows fails differently than Unix.
|
||||||
|
if has('unix')
|
||||||
|
edit test_hardcopy.vim
|
||||||
|
call assert_fails('hardcopy >', 'E324:')
|
||||||
|
bwipe
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_dark_background()
|
||||||
|
edit test_hardcopy.vim
|
||||||
|
syn on
|
||||||
|
|
||||||
|
for bg in ['dark', 'light']
|
||||||
|
exe 'set background=' .. bg
|
||||||
|
|
||||||
|
if has('postscript')
|
||||||
|
hardcopy > Xhardcopy_dark_background
|
||||||
|
let lines = readfile('Xhardcopy_dark_background')
|
||||||
|
call assert_true(len(lines) > 20)
|
||||||
|
call assert_true(lines[0] =~ 'PS-Adobe')
|
||||||
|
call delete('Xhardcopy_dark_background')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
set background&
|
||||||
|
bwipe
|
||||||
|
endfun
|
||||||
|
|
||||||
|
func Test_empty_buffer()
|
||||||
|
" FIXME: Unclear why this fails on Windows.
|
||||||
|
if has('unix')
|
||||||
|
new
|
||||||
|
call assert_equal("\nNo text to be printed", execute('hardcopy'))
|
||||||
|
bwipe
|
||||||
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_printheader_parsing()
|
func Test_printheader_parsing()
|
||||||
@@ -46,22 +144,6 @@ func Test_printheader_parsing()
|
|||||||
set printheader&
|
set printheader&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test that :hardcopy produces a non-empty file.
|
|
||||||
" We don't check much of the contents.
|
|
||||||
func Test_with_syntax()
|
|
||||||
if has('postscript')
|
|
||||||
edit test_hardcopy.vim
|
|
||||||
set printoptions=syntax:y
|
|
||||||
syn on
|
|
||||||
hardcopy > Xhardcopy
|
|
||||||
let lines = readfile('Xhardcopy')
|
|
||||||
call assert_true(len(lines) > 20)
|
|
||||||
call assert_true(lines[0] =~ 'PS-Adobe')
|
|
||||||
call delete('Xhardcopy')
|
|
||||||
set printoptions&
|
|
||||||
endif
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_fname_with_spaces()
|
func Test_fname_with_spaces()
|
||||||
if !has('postscript')
|
if !has('postscript')
|
||||||
return
|
return
|
||||||
@@ -86,4 +168,3 @@ func Test_illegal_byte()
|
|||||||
bwipe!
|
bwipe!
|
||||||
call delete('Xpstest')
|
call delete('Xpstest')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -738,6 +738,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
366,
|
||||||
/**/
|
/**/
|
||||||
365,
|
365,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user