blob: 29d02b213d75234ccefc3d8c6c883316ff3f951f [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
8 e Xfoo.pl
9 compiler perl
10 call assert_equal('perl', b:current_compiler)
11 call assert_fails('let g:current_compiler', 'E121:')
12
13 call setline(1, ['#!/usr/bin/perl -w', 'use strict;', 'my $foo=1'])
14 w!
15 call feedkeys(":make\<CR>\<CR>", 'tx')
16 call assert_fails('clist', 'E42:')
17
18 call setline(1, ['#!/usr/bin/perl -w', 'use strict;', '$foo=1'])
19 w!
20 call feedkeys(":make\<CR>\<CR>", 'tx')
21 let a=execute('clist')
Bram Moolenaar54651f72018-05-19 15:52:11 +020022 call assert_match("\n 1 Xfoo.pl:3: Global symbol \"\$foo\" "
23 \ . "requires explicit package name", a)
Bram Moolenaar10561fe2018-05-19 15:01:10 +020024
25 call delete('Xfoo.pl')
26 bw!
27endfunc
28
29func Test_compiler_without_arg()
30 let a=split(execute('compiler'))
Bram Moolenaard19b2342018-05-19 16:45:15 +020031 call assert_match('^.*runtime/compiler/ant.vim$', a[0])
32 call assert_match('^.*runtime/compiler/bcc.vim$', a[1])
33 call assert_match('^.*runtime/compiler/xmlwf.vim$', a[-1])
Bram Moolenaar10561fe2018-05-19 15:01:10 +020034endfunc
35
36func Test_compiler_completion()
37 call feedkeys(":compiler \<C-A>\<C-B>\"\<CR>", 'tx')
38 call assert_match('^"compiler ant bcc .* xmlwf$', @:)
39
40 call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx')
41 call assert_equal('"compiler pbx perl php pylint pyunit', @:)
42
43 call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx')
44 call assert_equal('"compiler! pbx perl php pylint pyunit', @:)
45endfunc
46
47func Test_compiler_error()
48 call assert_fails('compiler doesnotexist', 'E666:')
49endfunc