corrected bad_type() prototype.
[p5sagit/p5-mst-13.2.git] / t / pragma / warning.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';
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/warn-*")) {
21
d8b8f155 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 = $&;
44a8e56a 46 $switch =~ s/(-\S*[A-Z]\S*)/"-$1"/ if $Is_VMS; # protect uc switches
8ebc5c01 47 }
48 my($prog,$expected) = split(/\nEXPECT\n/, $_);
49 if ( $prog =~ /--FILE--/) {
50 my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
51 shift @files ;
52 die "Internal error test $i didn't split into pairs, got " .
53 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
54 if @files % 2 ;
55 while (@files > 2) {
56 my $filename = shift @files ;
57 my $code = shift @files ;
58 push @temps, $filename ;
59 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
60 print F $code ;
61 close F ;
62 }
63 shift @files ;
64 $prog = shift @files ;
65 }
44a8e56a 66 open TEST, ">$tmpfile";
67 print TEST $prog,"\n";
8ebc5c01 68 close TEST;
44a8e56a 69 my $results = $Is_VMS ?
70 `MCR $^X $switch $tmpfile` :
68dc0745 71 $Is_MSWin32 ?
72 `.\\perl -I../lib $switch $tmpfile 2>&1` :
44a8e56a 73 `sh -c './perl $switch $tmpfile' 2>&1`;
8ebc5c01 74 my $status = $?;
8ebc5c01 75 $results =~ s/\n+$//;
44a8e56a 76 # allow expected output to be written as if $prog is on STDIN
77 $results =~ s/tmp\d+/-/g;
78 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
8ebc5c01 79 $expected =~ s/\n+$//;
80 my $prefix = ($results =~ s/^PREFIX\n//) ;
81 if ( $results =~ s/^SKIPPED\n//) {
82 print "$results\n" ;
83 }
84 elsif (($prefix and $results !~ /^\Q$expected/) or
85 (!$prefix and $results ne $expected)){
86 print STDERR "PROG: $switch\n$prog\n";
87 print STDERR "EXPECTED:\n$expected\n";
88 print STDERR "GOT:\n$results\n";
89 print "not ";
90 }
91 print "ok ", ++$i, "\n";
92 foreach (@temps)
93 { unlink $_ if $_ }
94}