extra code in pp_concat, Take 2
[p5sagit/p5-mst-13.2.git] / lib / strict.t
CommitLineData
8ebc5c01 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
20822f61 5 @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';
2986a63f 13my $Is_NetWare = $^O eq 'NetWare';
8ebc5c01 14my $tmpfile = "tmp0000";
15my $i = 0 ;
e69a2255 161 while -e ++$tmpfile;
44a8e56a 17END { if ($tmpfile) { 1 while unlink $tmpfile; } }
8ebc5c01 18
19my @prgs = () ;
20
e69a2255 21foreach (sort glob($^O eq 'MacOS' ? ":lib:strict:*" : "lib/strict/*")) {
8ebc5c01 22
cbc25c42 23 next if -d || /(~|\.orig|,v)$/;
d8b8f155 24
8ebc5c01 25 open F, "<$_" or die "Cannot open $_: $!\n" ;
26 while (<F>) {
27 last if /^__END__/ ;
28 }
29
30 {
31 local $/ = undef;
32 @prgs = (@prgs, split "\n########\n", <F>) ;
33 }
d1e4d418 34 close F or die "Could not close: $!" ;
8ebc5c01 35}
36
37undef $/;
38
82c44e33 39print "1.." . (@prgs + 4) . "\n";
8ebc5c01 40
41
42for (@prgs){
43 my $switch = "";
44 my @temps = () ;
45 if (s/^\s*-\w+//){
46 $switch = $&;
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 ;
95e8664e 58 $code =~ s|\./abc|:abc|g if $^O eq 'MacOS';
8ebc5c01 59 push @temps, $filename ;
60 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
61 print F $code ;
d1e4d418 62 close F or die "Could not close: $!" ;
8ebc5c01 63 }
64 shift @files ;
65 $prog = shift @files ;
95e8664e 66 $prog =~ s|\./abc|:abc|g if $^O eq 'MacOS';
8ebc5c01 67 }
e69a2255 68 open TEST, ">$tmpfile" or die "Could not open: $!";
44a8e56a 69 print TEST $prog,"\n";
d1e4d418 70 close TEST or die "Could not close: $!";
f0963acb 71 my $results = $Is_MSWin32 ?
be708cc0 72 `.\\perl -I../lib $switch $tmpfile 2>&1` :
2986a63f 73 $^O eq 'NetWare' ?
be708cc0 74 `perl -I../lib $switch $tmpfile 2>&1` :
75 $^O eq 'MacOS' ?
76 `$^X -I::lib -MMac::err=unix $switch $tmpfile` :
7678c486 77 `$^X $switch $tmpfile 2>&1`;
8ebc5c01 78 my $status = $?;
8ebc5c01 79 $results =~ s/\n+$//;
44a8e56a 80 # allow expected output to be written as if $prog is on STDIN
81 $results =~ s/tmp\d+/-/g;
82 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
8ebc5c01 83 $expected =~ s/\n+$//;
95e8664e 84 $expected =~ s|(\./)?abc\.pm|:abc.pm|g if $^O eq 'MacOS';
85 $expected =~ s|./abc|:abc|g if $^O eq 'MacOS';
8ebc5c01 86 my $prefix = ($results =~ s/^PREFIX\n//) ;
87 if ( $results =~ s/^SKIPPED\n//) {
88 print "$results\n" ;
89 }
90 elsif (($prefix and $results !~ /^\Q$expected/) or
91 (!$prefix and $results ne $expected)){
92 print STDERR "PROG: $switch\n$prog\n";
93 print STDERR "EXPECTED:\n$expected\n";
94 print STDERR "GOT:\n$results\n";
95 print "not ";
96 }
82c44e33 97 print "ok " . ++$i . "\n";
8ebc5c01 98 foreach (@temps)
99 { unlink $_ if $_ }
100}
210bfd0c 101
102eval qq(use strict 'garbage');
e279cb0b 103print +($@ =~ /^Unknown 'strict' tag\(s\) 'garbage'/)
210bfd0c 104 ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@";
105
106eval qq(no strict 'garbage');
e279cb0b 107print +($@ =~ /^Unknown 'strict' tag\(s\) 'garbage'/)
210bfd0c 108 ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@";
109
110eval qq(use strict qw(foo bar));
e279cb0b 111print +($@ =~ /^Unknown 'strict' tag\(s\) 'foo bar'/)
210bfd0c 112 ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@";
113
114eval qq(no strict qw(foo bar));
e279cb0b 115print +($@ =~ /^Unknown 'strict' tag\(s\) 'foo bar'/)
210bfd0c 116 ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@";