]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/21-bad-use.t
dc2ca5af92c1e00a3f840b1587400ca879b429b3
[perl/modules/indirect.git] / t / 21-bad-use.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 my $total = 28;
7
8 use Test::More;
9
10 use IPC::Cmd qw/run/;
11
12 (my $success, my $err_code, undef, undef, my $stderr)
13  = run command => [
14           $^X,
15           map('-I' . $_, @INC),
16           '-Mindirect',
17           '-c',
18           't/data/bad.d'
19    ];
20
21 plan skip_all => "Couldn't capture buffers" if $success and not defined $stderr;
22 plan tests => $total + 1;
23
24 $stderr = join '', @$stderr;
25 unless ($success) {
26  diag $stderr;
27  diag "Failed to execute data file (error $err_code)";
28  fail "Couldn't run test $_" for 1 .. $total + 1;
29  exit $total + 1;
30 }
31
32 my %fail;
33 my $extra_fail = 0;
34
35 while ($stderr =~ /^Indirect\s+call\s+of\s+method\s+"([^"]+)"\s+on\s+object\s+"([^"]+)"/mg) {
36  my ($m, $o) = ($1, $2);
37  my $id;
38  if ($m =~ /^(?:new|potato)(\d+)$/) {
39   $id = $1;
40  } elsif ($o =~ /^Hlagh(\d+)$/) {
41   $id = $1;
42  } else {
43   diag "$m $o";
44   ++$extra_fail;
45  }
46  if ($id) {
47   fail("test $id shouldn't have failed");
48   $fail{$id} = 1;
49  }
50 }
51
52 pass("test $_ hasn't failed") for grep { !$fail{$_} } 1 .. $total;
53 is($extra_fail, 0, 'no extra fails');