blob: 46c14d8bc391a3f496e72ae42307a1cd59f2dcf4 [file] [log] [blame]
Bram Moolenaar10561fe2018-05-19 15:01:10 +02001" Test the :compiler command
2
3func Test_compiler()
4 if !executable('perl')
5 return
6 endif
7
Bram Moolenaarf0447e82018-07-03 21:26:38 +02008 " $LANG changes the output of Perl.
9 if $LANG != ''
10 unlet $LANG
11 endif
12
Bram Moolenaar10561fe2018-05-19 15:01:10 +020013 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')
Bram Moolenaar54651f72018-05-19 15:52:11 +020027 call assert_match("\n 1 Xfoo.pl:3: Global symbol \"\$foo\" "
28 \ . "requires explicit package name", a)
Bram Moolenaar10561fe2018-05-19 15:01:10 +020029
30 call delete('Xfoo.pl')
31 bw!
32endfunc
33
34func Test_compiler_without_arg()
35 let a=split(execute('compiler'))
Bram Moolenaard19b2342018-05-19 16:45:15 +020036 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])
Bram Moolenaar10561fe2018-05-19 15:01:10 +020039endfunc
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