Bump versions of charnames and Unicode::UCD after last patches
[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';
0642d82a 7 require './test.pl';
8ebc5c01 8}
9
10$| = 1;
11
44a8e56a 12my $Is_VMS = $^O eq 'VMS';
68dc0745 13my $Is_MSWin32 = $^O eq 'MSWin32';
2986a63f 14my $Is_NetWare = $^O eq 'NetWare';
8ebc5c01 15my $i = 0 ;
8ebc5c01 16
17my @prgs = () ;
18
7b903762 19foreach (sort glob("lib/strict/*")) {
8ebc5c01 20
cbc25c42 21 next if -d || /(~|\.orig|,v)$/;
d8b8f155 22
8ebc5c01 23 open F, "<$_" or die "Cannot open $_: $!\n" ;
24 while (<F>) {
25 last if /^__END__/ ;
26 }
27
28 {
29 local $/ = undef;
30 @prgs = (@prgs, split "\n########\n", <F>) ;
31 }
d1e4d418 32 close F or die "Could not close: $!" ;
8ebc5c01 33}
34
35undef $/;
36
82c44e33 37print "1.." . (@prgs + 4) . "\n";
8ebc5c01 38
39
40for (@prgs){
41 my $switch = "";
42 my @temps = () ;
43 if (s/^\s*-\w+//){
44 $switch = $&;
45 }
46 my($prog,$expected) = split(/\nEXPECT\n/, $_);
47 if ( $prog =~ /--FILE--/) {
48 my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
49 shift @files ;
50 die "Internal error test $i didn't split into pairs, got " .
51 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
52 if @files % 2 ;
53 while (@files > 2) {
54 my $filename = shift @files ;
55 my $code = shift @files ;
56 push @temps, $filename ;
57 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
58 print F $code ;
d1e4d418 59 close F or die "Could not close: $!" ;
8ebc5c01 60 }
61 shift @files ;
62 $prog = shift @files ;
63 }
f89542f7 64 my $tmpfile = tempfile();
e69a2255 65 open TEST, ">$tmpfile" or die "Could not open: $!";
44a8e56a 66 print TEST $prog,"\n";
d1e4d418 67 close TEST or die "Could not close: $!";
f0963acb 68 my $results = $Is_MSWin32 ?
be708cc0 69 `.\\perl -I../lib $switch $tmpfile 2>&1` :
2986a63f 70 $^O eq 'NetWare' ?
be708cc0 71 `perl -I../lib $switch $tmpfile 2>&1` :
7678c486 72 `$^X $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
0642d82a 76 $results =~ s/tmp\d+[A-Z][A-Z]?/-/g;
44a8e56a 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//) ;
ace56ae5 80 my $TODO = $prog =~ m/^#\s*TODO:/;
8ebc5c01 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)){
ace56ae5 86 if (! $TODO) {
87 print STDERR "PROG: $switch\n$prog\n";
88 print STDERR "EXPECTED:\n$expected\n";
89 print STDERR "GOT:\n$results\n";
90 }
8ebc5c01 91 print "not ";
92 }
ace56ae5 93 print "ok " . ++$i . ($TODO ? " # TODO" : "") . "\n";
8ebc5c01 94 foreach (@temps)
95 { unlink $_ if $_ }
96}
210bfd0c 97
98eval qq(use strict 'garbage');
e279cb0b 99print +($@ =~ /^Unknown 'strict' tag\(s\) 'garbage'/)
210bfd0c 100 ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@";
101
102eval qq(no strict 'garbage');
e279cb0b 103print +($@ =~ /^Unknown 'strict' tag\(s\) 'garbage'/)
210bfd0c 104 ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@";
105
106eval qq(use strict qw(foo bar));
e279cb0b 107print +($@ =~ /^Unknown 'strict' tag\(s\) 'foo bar'/)
210bfd0c 108 ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@";
109
110eval qq(no strict qw(foo bar));
e279cb0b 111print +($@ =~ /^Unknown 'strict' tag\(s\) 'foo bar'/)
210bfd0c 112 ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@";