This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ignore yet another known scalar leak
[perl5.git] / t / pragma / strict.t
CommitLineData
8ebc5c01 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
93430cb4 5 unshift @INC, '../lib';
8ebc5c01 6 $ENV{PERL5LIB} = '../lib';
7}
8
9$| = 1;
10
44a8e56a 11my $Is_VMS = $^O eq 'VMS';
68dc0745 12my $Is_MSWin32 = $^O eq 'MSWin32';
8ebc5c01 13my $tmpfile = "tmp0000";
14my $i = 0 ;
151 while -f ++$tmpfile;
44a8e56a 16END { if ($tmpfile) { 1 while unlink $tmpfile; } }
8ebc5c01 17
18my @prgs = () ;
19
20foreach (sort glob("pragma/strict-*")) {
21
d8b8f155
CS
22 next if /(~|\.orig)$/;
23
8ebc5c01 24 open F, "<$_" or die "Cannot open $_: $!\n" ;
25 while (<F>) {
26 last if /^__END__/ ;
27 }
28
29 {
30 local $/ = undef;
31 @prgs = (@prgs, split "\n########\n", <F>) ;
32 }
33 close F ;
34}
35
36undef $/;
37
38print "1..", scalar @prgs, "\n";
39
40
41for (@prgs){
42 my $switch = "";
43 my @temps = () ;
44 if (s/^\s*-\w+//){
45 $switch = $&;
46 }
47 my($prog,$expected) = split(/\nEXPECT\n/, $_);
48 if ( $prog =~ /--FILE--/) {
49 my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
50 shift @files ;
51 die "Internal error test $i didn't split into pairs, got " .
52 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
53 if @files % 2 ;
54 while (@files > 2) {
55 my $filename = shift @files ;
56 my $code = shift @files ;
57 push @temps, $filename ;
58 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
59 print F $code ;
60 close F ;
61 }
62 shift @files ;
63 $prog = shift @files ;
64 }
44a8e56a 65 open TEST, ">$tmpfile";
66 print TEST $prog,"\n";
8ebc5c01 67 close TEST;
44a8e56a 68 my $results = $Is_VMS ?
69 `MCR $^X $switch $tmpfile` :
68dc0745 70 $Is_MSWin32 ?
71 `.\\perl -I../lib $switch $tmpfile 2>&1` :
648cac19 72 `./perl $switch $tmpfile 2>&1`;
8ebc5c01 73 my $status = $?;
8ebc5c01 74 $results =~ s/\n+$//;
44a8e56a 75 # allow expected output to be written as if $prog is on STDIN
76 $results =~ s/tmp\d+/-/g;
77 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
8ebc5c01 78 $expected =~ s/\n+$//;
79 my $prefix = ($results =~ s/^PREFIX\n//) ;
80 if ( $results =~ s/^SKIPPED\n//) {
81 print "$results\n" ;
82 }
83 elsif (($prefix and $results !~ /^\Q$expected/) or
84 (!$prefix and $results ne $expected)){
85 print STDERR "PROG: $switch\n$prog\n";
86 print STDERR "EXPECTED:\n$expected\n";
87 print STDERR "GOT:\n$results\n";
88 print "not ";
89 }
90 print "ok ", ++$i, "\n";
91 foreach (@temps)
92 { unlink $_ if $_ }
93}