blob: f561e84a3818e3a65b6f0bb04a80af9e54f87921 [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 Moolenaardff2adc2019-07-31 22:18:22 +020013 " %:S does not work properly with 'shellslash' set
14 let save_shellslash = &shellslash
15 set noshellslash
16
Bram Moolenaar10561fe2018-05-19 15:01:10 +020017 e Xfoo.pl
18 compiler perl
19 call assert_equal('perl', b:current_compiler)
20 call assert_fails('let g:current_compiler', 'E121:')
21
22 call setline(1, ['#!/usr/bin/perl -w', 'use strict;', 'my $foo=1'])
23 w!
24 call feedkeys(":make\<CR>\<CR>", 'tx')
25 call assert_fails('clist', 'E42:')
26
27 call setline(1, ['#!/usr/bin/perl -w', 'use strict;', '$foo=1'])
28 w!
29 call feedkeys(":make\<CR>\<CR>", 'tx')
30 let a=execute('clist')
Bram Moolenaar54651f72018-05-19 15:52:11 +020031 call assert_match("\n 1 Xfoo.pl:3: Global symbol \"\$foo\" "
32 \ . "requires explicit package name", a)
Bram Moolenaar10561fe2018-05-19 15:01:10 +020033
Bram Moolenaardff2adc2019-07-31 22:18:22 +020034 let &shellslash = save_shellslash
Bram Moolenaar10561fe2018-05-19 15:01:10 +020035 call delete('Xfoo.pl')
36 bw!
37endfunc
38
39func Test_compiler_without_arg()
40 let a=split(execute('compiler'))
Bram Moolenaard19b2342018-05-19 16:45:15 +020041 call assert_match('^.*runtime/compiler/ant.vim$', a[0])
42 call assert_match('^.*runtime/compiler/bcc.vim$', a[1])
43 call assert_match('^.*runtime/compiler/xmlwf.vim$', a[-1])
Bram Moolenaar10561fe2018-05-19 15:01:10 +020044endfunc
45
46func Test_compiler_completion()
47 call feedkeys(":compiler \<C-A>\<C-B>\"\<CR>", 'tx')
48 call assert_match('^"compiler ant bcc .* xmlwf$', @:)
49
50 call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx')
51 call assert_equal('"compiler pbx perl php pylint pyunit', @:)
52
53 call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx')
54 call assert_equal('"compiler! pbx perl php pylint pyunit', @:)
55endfunc
56
57func Test_compiler_error()
58 call assert_fails('compiler doesnotexist', 'E666:')
59endfunc