diff options
author | w0rp <devw0rp@gmail.com> | 2020-08-24 09:33:07 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2020-08-24 09:33:07 +0100 |
commit | 3e2abe3f25493af63af91a6013447e378e09f6ec (patch) | |
tree | dceeaf74a9795138dff8335b6b1758b7420e57e2 /test/test_format_command.vader | |
parent | 1a7366067af97cda00268d52de5a873827c52962 (diff) | |
download | ale-3e2abe3f25493af63af91a6013447e378e09f6ec.zip |
#2556 - Support modifiers for formatted filenames
Diffstat (limited to 'test/test_format_command.vader')
-rw-r--r-- | test/test_format_command.vader | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/test/test_format_command.vader b/test/test_format_command.vader index f8e2a66e..9d730fce 100644 --- a/test/test_format_command.vader +++ b/test/test_format_command.vader @@ -126,16 +126,49 @@ Execute(EscapeCommandPart should pipe in temporary files appropriately): Assert !empty(g:match), 'No match found! Result was: ' . g:result[1] AssertEqual ale#Escape(g:result[0]), g:match[1] +Execute(FormatCommand should apply filename modifiers to the current file): + AssertEqual + \ ale#Escape(expand('%:p:h')) + \ . ' ' . ale#Escape('dummy.txt') + \ . ' ' . ale#Escape(expand('%:p:h:t')) + \ . ' ' . ale#Escape('txt') + \ . ' ' . ale#Escape(expand('%:p:r')), + \ ale#command#FormatCommand(bufnr(''), '', '%s:h %s:t %s:h:t %s:e %s:r', 0, v:null, [])[1] + +Execute(FormatCommand should apply filename modifiers to the temporary file): + let g:result = ale#command#FormatCommand(bufnr(''), '', '%t:h %t:t %t:h:t %t:e %t:r', 0, v:null, []) + + AssertEqual + \ ale#Escape(fnamemodify(g:result[0], ':h')) + \ . ' ' . ale#Escape('dummy.txt') + \ . ' ' . ale#Escape(fnamemodify(g:result[0], ':h:t')) + \ . ' ' . ale#Escape('txt') + \ . ' ' . ale#Escape(fnamemodify(g:result[0], ':r')), + \ g:result[1] + Execute(FormatCommand should apply filename mappings the current file): - let g:result = ale#command#FormatCommand(bufnr('%'), '', '%s', 1, v:null, [ + let g:result = ale#command#FormatCommand(bufnr('%'), '', '%s', 0, v:null, [ \ [expand('%:p:h'), '/foo/bar'], \]) Assert g:result[1] =~# '/foo/bar' Execute(FormatCommand should apply filename mappings to temporary files): - let g:result = ale#command#FormatCommand(bufnr('%'), '', '%t', 1, v:null, [ + let g:result = ale#command#FormatCommand(bufnr('%'), '', '%t', 0, v:null, [ \ [fnamemodify(tempname(), ':h:h'), '/foo/bar'] \]) Assert g:result[1] =~# '/foo/bar' + +Execute(FormatCommand should apply filename modifiers to mapped filenames): + let g:result = ale#command#FormatCommand(bufnr('%'), '', '%s:h', 0, v:null, [ + \ [expand('%:p:h'), '/foo/bar'], + \]) + + AssertEqual ale#Escape('/foo/bar'), g:result[1] + + let g:result = ale#command#FormatCommand(bufnr('%'), '', '%t:h:h:h', 0, v:null, [ + \ [fnamemodify(tempname(), ':h:h'), '/foo/bar'] + \]) + + AssertEqual ale#Escape('/foo/bar'), g:result[1] |