1*0Sstevel@tonic-gate#!./perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateBEGIN { 4*0Sstevel@tonic-gate chdir 't' if -d 't'; 5*0Sstevel@tonic-gate @INC = '../lib'; 6*0Sstevel@tonic-gate $ENV{PERL5LIB} = '../lib'; 7*0Sstevel@tonic-gate} 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gate$| = 1; 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gatemy $Is_VMS = $^O eq 'VMS'; 12*0Sstevel@tonic-gatemy $Is_MSWin32 = $^O eq 'MSWin32'; 13*0Sstevel@tonic-gatemy $Is_NetWare = $^O eq 'NetWare'; 14*0Sstevel@tonic-gatemy $tmpfile = "tmp0000"; 15*0Sstevel@tonic-gatemy $i = 0 ; 16*0Sstevel@tonic-gate1 while -e ++$tmpfile; 17*0Sstevel@tonic-gateEND { if ($tmpfile) { 1 while unlink $tmpfile; } } 18*0Sstevel@tonic-gate 19*0Sstevel@tonic-gatemy @prgs = () ; 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gateforeach (sort glob($^O eq 'MacOS' ? ":lib:strict:*" : "lib/strict/*")) { 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate next if -d || /(~|\.orig|,v)$/; 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate open F, "<$_" or die "Cannot open $_: $!\n" ; 26*0Sstevel@tonic-gate while (<F>) { 27*0Sstevel@tonic-gate last if /^__END__/ ; 28*0Sstevel@tonic-gate } 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate { 31*0Sstevel@tonic-gate local $/ = undef; 32*0Sstevel@tonic-gate @prgs = (@prgs, split "\n########\n", <F>) ; 33*0Sstevel@tonic-gate } 34*0Sstevel@tonic-gate close F or die "Could not close: $!" ; 35*0Sstevel@tonic-gate} 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gateundef $/; 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gateprint "1.." . (@prgs + 4) . "\n"; 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gatefor (@prgs){ 43*0Sstevel@tonic-gate my $switch = ""; 44*0Sstevel@tonic-gate my @temps = () ; 45*0Sstevel@tonic-gate if (s/^\s*-\w+//){ 46*0Sstevel@tonic-gate $switch = $&; 47*0Sstevel@tonic-gate } 48*0Sstevel@tonic-gate my($prog,$expected) = split(/\nEXPECT\n/, $_); 49*0Sstevel@tonic-gate if ( $prog =~ /--FILE--/) { 50*0Sstevel@tonic-gate my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ; 51*0Sstevel@tonic-gate shift @files ; 52*0Sstevel@tonic-gate die "Internal error test $i didn't split into pairs, got " . 53*0Sstevel@tonic-gate scalar(@files) . "[" . join("%%%%", @files) ."]\n" 54*0Sstevel@tonic-gate if @files % 2 ; 55*0Sstevel@tonic-gate while (@files > 2) { 56*0Sstevel@tonic-gate my $filename = shift @files ; 57*0Sstevel@tonic-gate my $code = shift @files ; 58*0Sstevel@tonic-gate $code =~ s|\./abc|:abc|g if $^O eq 'MacOS'; 59*0Sstevel@tonic-gate push @temps, $filename ; 60*0Sstevel@tonic-gate open F, ">$filename" or die "Cannot open $filename: $!\n" ; 61*0Sstevel@tonic-gate print F $code ; 62*0Sstevel@tonic-gate close F or die "Could not close: $!" ; 63*0Sstevel@tonic-gate } 64*0Sstevel@tonic-gate shift @files ; 65*0Sstevel@tonic-gate $prog = shift @files ; 66*0Sstevel@tonic-gate $prog =~ s|\./abc|:abc|g if $^O eq 'MacOS'; 67*0Sstevel@tonic-gate } 68*0Sstevel@tonic-gate open TEST, ">$tmpfile" or die "Could not open: $!"; 69*0Sstevel@tonic-gate print TEST $prog,"\n"; 70*0Sstevel@tonic-gate close TEST or die "Could not close: $!"; 71*0Sstevel@tonic-gate my $results = $Is_MSWin32 ? 72*0Sstevel@tonic-gate `.\\perl -I../lib $switch $tmpfile 2>&1` : 73*0Sstevel@tonic-gate $^O eq 'NetWare' ? 74*0Sstevel@tonic-gate `perl -I../lib $switch $tmpfile 2>&1` : 75*0Sstevel@tonic-gate $^O eq 'MacOS' ? 76*0Sstevel@tonic-gate `$^X -I::lib -MMac::err=unix $switch $tmpfile` : 77*0Sstevel@tonic-gate `./perl $switch $tmpfile 2>&1`; 78*0Sstevel@tonic-gate my $status = $?; 79*0Sstevel@tonic-gate $results =~ s/\n+$//; 80*0Sstevel@tonic-gate # allow expected output to be written as if $prog is on STDIN 81*0Sstevel@tonic-gate $results =~ s/tmp\d+/-/g; 82*0Sstevel@tonic-gate $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg 83*0Sstevel@tonic-gate $expected =~ s/\n+$//; 84*0Sstevel@tonic-gate $expected =~ s|(\./)?abc\.pm|:abc.pm|g if $^O eq 'MacOS'; 85*0Sstevel@tonic-gate $expected =~ s|./abc|:abc|g if $^O eq 'MacOS'; 86*0Sstevel@tonic-gate my $prefix = ($results =~ s/^PREFIX\n//) ; 87*0Sstevel@tonic-gate if ( $results =~ s/^SKIPPED\n//) { 88*0Sstevel@tonic-gate print "$results\n" ; 89*0Sstevel@tonic-gate } 90*0Sstevel@tonic-gate elsif (($prefix and $results !~ /^\Q$expected/) or 91*0Sstevel@tonic-gate (!$prefix and $results ne $expected)){ 92*0Sstevel@tonic-gate print STDERR "PROG: $switch\n$prog\n"; 93*0Sstevel@tonic-gate print STDERR "EXPECTED:\n$expected\n"; 94*0Sstevel@tonic-gate print STDERR "GOT:\n$results\n"; 95*0Sstevel@tonic-gate print "not "; 96*0Sstevel@tonic-gate } 97*0Sstevel@tonic-gate print "ok " . ++$i . "\n"; 98*0Sstevel@tonic-gate foreach (@temps) 99*0Sstevel@tonic-gate { unlink $_ if $_ } 100*0Sstevel@tonic-gate} 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gateeval qq(use strict 'garbage'); 103*0Sstevel@tonic-gateprint +($@ =~ /^Unknown 'strict' tag\(s\) 'garbage'/) 104*0Sstevel@tonic-gate ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@"; 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gateeval qq(no strict 'garbage'); 107*0Sstevel@tonic-gateprint +($@ =~ /^Unknown 'strict' tag\(s\) 'garbage'/) 108*0Sstevel@tonic-gate ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@"; 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gateeval qq(use strict qw(foo bar)); 111*0Sstevel@tonic-gateprint +($@ =~ /^Unknown 'strict' tag\(s\) 'foo bar'/) 112*0Sstevel@tonic-gate ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@"; 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gateeval qq(no strict qw(foo bar)); 115*0Sstevel@tonic-gateprint +($@ =~ /^Unknown 'strict' tag\(s\) 'foo bar'/) 116*0Sstevel@tonic-gate ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@"; 117