1" Test the :compiler command
2
3source check.vim
4
5func Test_compiler()
6  if !executable('perl')
7    return
8  endif
9  CheckFeature quickfix
10
11  " $LANG changes the output of Perl.
12  if $LANG != ''
13    unlet $LANG
14  endif
15
16  " %:S does not work properly with 'shellslash' set
17  let save_shellslash = &shellslash
18  set noshellslash
19
20  e Xfoo.pl
21  compiler perl
22  call assert_equal('perl', b:current_compiler)
23  call assert_fails('let g:current_compiler', 'E121:')
24
25  call setline(1, ['#!/usr/bin/perl -w', 'use strict;', 'my $foo=1'])
26  w!
27  call feedkeys(":make\<CR>\<CR>", 'tx')
28  call assert_fails('clist', 'E42:')
29
30  call setline(1, ['#!/usr/bin/perl -w', 'use strict;', '$foo=1'])
31  w!
32  call feedkeys(":make\<CR>\<CR>", 'tx')
33  let a=execute('clist')
34  call assert_match('\n \d\+ Xfoo.pl:3: Global symbol "$foo" '
35  \ .               'requires explicit package name', a)
36
37
38  let &shellslash = save_shellslash
39  call delete('Xfoo.pl')
40  bw!
41endfunc
42
43func Test_compiler_without_arg()
44  let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
45  let a = split(execute('compiler'))
46  call assert_match(runtime .. '/compiler/ant.vim$',   a[0])
47  call assert_match(runtime .. '/compiler/bcc.vim$',   a[1])
48  call assert_match(runtime .. '/compiler/xmlwf.vim$', a[-1])
49endfunc
50
51func Test_compiler_completion()
52  call feedkeys(":compiler \<C-A>\<C-B>\"\<CR>", 'tx')
53  call assert_match('^"compiler ant bcc .* xmlwf$', @:)
54
55  call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx')
56  call assert_equal('"compiler pbx perl php pylint pyunit', @:)
57
58  call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx')
59  call assert_equal('"compiler! pbx perl php pylint pyunit', @:)
60endfunc
61
62func Test_compiler_error()
63  call assert_fails('compiler doesnotexist', 'E666:')
64endfunc
65