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