]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/30-scope.t
b9c71545dd1ede3a5627eea26f4c74a3a01ca944
[perl/modules/indirect.git] / t / 30-scope.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 my $total = 8;
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           '-c',
17           't/data/mixed.d'
18    ];
19
20 plan skip_all => "Couldn't capture buffers" if $success and not defined $stderr;
21 plan tests => $total + 1;
22
23 $stderr = join '', @$stderr;
24 unless ($success) {
25  diag $stderr;
26  diag "Failed to execute data file (error $err_code)";
27  fail "Couldn't run test $_" for 1 .. $total + 1;
28  exit $total + 1;
29 }
30
31 my %fail = map { $_ => 1 } 2, 3, 5, 7;
32 my %failed;
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 ($o =~ /^P(\d+)$/) {
39   $id = $1;
40  } else {
41   diag "$m $o";
42   ++$extra_fail;
43  }
44  if ($id) {
45   if (exists $fail{$id}) {
46    pass("test $id failed as expected");
47    delete $fail{$id};
48    $failed{$id} = 1;
49   } else {
50    fail("test $id shouldn't have failed");
51   }
52  }
53 }
54
55 pass("test $_ hasn't failed") for grep { !$failed{$_} } 1 .. $total;
56 fail("test $_ should have failed") for sort { $a <=> $b } keys %fail;
57 is($extra_fail, 0, 'no extra fails');