Bram Moolenaar | 10561fe | 2018-05-19 15:01:10 +0200 | [diff] [blame] | 1 | " Test the :compiler command |
| 2 | |
| 3 | func Test_compiler() |
| 4 | if !executable('perl') |
| 5 | return |
| 6 | endif |
| 7 | |
Bram Moolenaar | f0447e8 | 2018-07-03 21:26:38 +0200 | [diff] [blame] | 8 | " $LANG changes the output of Perl. |
| 9 | if $LANG != '' |
| 10 | unlet $LANG |
| 11 | endif |
| 12 | |
Bram Moolenaar | dff2adc | 2019-07-31 22:18:22 +0200 | [diff] [blame] | 13 | " %:S does not work properly with 'shellslash' set |
| 14 | let save_shellslash = &shellslash |
| 15 | set noshellslash |
| 16 | |
Bram Moolenaar | 10561fe | 2018-05-19 15:01:10 +0200 | [diff] [blame] | 17 | 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 Moolenaar | cebfcff | 2019-09-18 21:42:38 +0200 | [diff] [blame] | 31 | call assert_match('\n \d\+ Xfoo.pl:3: Global symbol "$foo" ' |
| 32 | \ . 'requires explicit package name', a) |
| 33 | |
Bram Moolenaar | 10561fe | 2018-05-19 15:01:10 +0200 | [diff] [blame] | 34 | |
Bram Moolenaar | dff2adc | 2019-07-31 22:18:22 +0200 | [diff] [blame] | 35 | let &shellslash = save_shellslash |
Bram Moolenaar | 10561fe | 2018-05-19 15:01:10 +0200 | [diff] [blame] | 36 | call delete('Xfoo.pl') |
| 37 | bw! |
| 38 | endfunc |
| 39 | |
| 40 | func Test_compiler_without_arg() |
| 41 | let a=split(execute('compiler')) |
Bram Moolenaar | 1ac41a5 | 2019-10-10 13:30:12 +0200 | [diff] [blame] | 42 | call assert_match($VIMRUNTIME .. '/compiler/ant.vim$', a[0]) |
| 43 | call assert_match($VIMRUNTIME .. '/compiler/bcc.vim$', a[1]) |
| 44 | call assert_match($VIMRUNTIME .. '/compiler/xmlwf.vim$', a[-1]) |
Bram Moolenaar | 10561fe | 2018-05-19 15:01:10 +0200 | [diff] [blame] | 45 | endfunc |
| 46 | |
| 47 | func Test_compiler_completion() |
| 48 | call feedkeys(":compiler \<C-A>\<C-B>\"\<CR>", 'tx') |
| 49 | call assert_match('^"compiler ant bcc .* xmlwf$', @:) |
| 50 | |
| 51 | call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx') |
| 52 | call assert_equal('"compiler pbx perl php pylint pyunit', @:) |
| 53 | |
| 54 | call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx') |
| 55 | call assert_equal('"compiler! pbx perl php pylint pyunit', @:) |
| 56 | endfunc |
| 57 | |
| 58 | func Test_compiler_error() |
| 59 | call assert_fails('compiler doesnotexist', 'E666:') |
| 60 | endfunc |