]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/50-external.t
Properly handle heredocs
[perl/modules/indirect.git] / t / 50-external.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Config;
7
8 use Test::More tests => 7;
9
10 use lib 't/lib';
11 use VPIT::TestHelpers 'run_perl';
12
13 BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} }
14
15 SKIP: {
16  my $status = run_perl 'no indirect; qq{a\x{100}b} =~ /\A[\x00-\x7f]*\z/;';
17  skip RUN_PERL_FAILED() => 1 unless defined $status;
18  is $status, 0, 'RT #47866';
19 }
20
21 SKIP: {
22  skip 'Fixed in core only since 5.12' => 1 unless "$]" >= 5.012;
23
24  my $status = run_perl 'no indirect hook => sub { exit 2 }; new X';
25  skip RUN_PERL_FAILED() => 1 unless defined $status;
26  is $status, 2 << 8, 'no semicolon at the end of -e';
27 }
28
29 SKIP: {
30  load_or_skip('Devel::CallParser', undef, undef, 1);
31
32  my $status = run_perl "use Devel::CallParser (); no indirect; sub ok { } ok 1";
33  skip RUN_PERL_FAILED() => 1 unless defined $status;
34  is $status, 0, 'indirect is not getting upset by Devel::CallParser';
35 }
36
37 SKIP: {
38  my $has_package_empty = do {
39   local $@;
40   eval 'no warnings "deprecated"; package; 1'
41  };
42  skip 'Empty package only available on perl 5.8.x and below' => 1
43                                                       unless $has_package_empty;
44
45  my $status = run_perl 'no indirect hook => sub { }; exit 0; package; new X;';
46  skip RUN_PERL_FAILED() => 1 unless defined $status;
47  is $status, 0, 'indirect does not croak while package empty is in use';
48 }
49
50 my $fork_status;
51 if ($Config::Config{d_fork} or $Config::Config{d_pseudofork}) {
52  $fork_status = run_perl 'my $pid = fork; exit 1 unless defined $pid; if ($pid) { waitpid $pid, 0; my $status = $?; exit(($status >> 8) || $status) } else { exit 0 }';
53 }
54
55 SKIP: {
56  my $tests = 2;
57  skip 'fork() or pseudo-forks are required to check END blocks in subprocesses'
58                                           => $tests unless defined $fork_status;
59  skip "Could not even fork a simple process (sample returned $fork_status)"
60                                           => $tests unless $fork_status == 0;
61
62  my $status = run_perl 'require indirect; END { eval q[1] } my $pid = fork; exit 0 unless defined $pid; if ($pid) { waitpid $pid, 0; my $status = $?; exit(($status >> 8) || $status) } else { exit 0 }';
63  skip RUN_PERL_FAILED() => $tests unless defined $status;
64  is $status, 0, 'indirect and global END blocks executed at the end of a forked process (RT #99083)';
65
66  $status = run_perl 'require indirect; my $pid = fork; exit 0 unless defined $pid; if ($pid) { waitpid $pid, 0; my $status = $?; exit(($status >> 8) || $status) } else { eval q[END { eval q(1) }]; exit 0 }';
67  skip RUN_PERL_FAILED() => ($tests - 1) unless defined $status;
68  is $status, 0, 'indirect and local END blocks executed at the end of a forked process';
69 }
70
71 SKIP: {
72  my $status;
73  for my $run (1 .. 10) {
74   $status = run_perl_file 't/testcases/rt115392.pl';
75   skip RUN_PERL_FAILED() => 1 unless defined $status;
76   last if $status;
77  }
78  is $status, 0, 'RT #115392';
79 }