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