6 $ENV{PERL5LIB} = '../lib';
11 my @prgs = split "\n########\n", <DATA>;
12 print "1..", scalar @prgs, "\n";
14 my $Is_VMS = $^O eq 'VMS';
15 my $Is_MSWin32 = $^O eq 'MSWin32';
16 my $Is_NetWare = $^O eq 'NetWare';
17 my $tmpfile = "tmp0000";
19 1 while -f ++$tmpfile;
20 END { if ($tmpfile) { 1 while unlink $tmpfile} }
28 my($prog,$expected) = split(/\nEXPECT\n/, $_);
29 if ( $prog =~ /--FILE--/) {
30 my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
32 die "Internal error test $i didn't split into pairs, got " .
33 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
36 my $filename = shift @files ;
37 my $code = shift @files ;
38 push @temps, $filename ;
39 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
44 $prog = shift @files ;
46 open TEST, ">$tmpfile";
47 print TEST $prog,"\n";
49 my $results = $Is_VMS ?
50 `./perl $switch $tmpfile 2>&1` :
52 `.\\perl -I../lib $switch $tmpfile 2>&1` :
54 `perl -I../lib $switch $tmpfile 2>&1` :
55 `./perl $switch $tmpfile 2>&1`;
58 # allow expected output to be written as if $prog is on STDIN
59 $results =~ s/tmp\d+/-/g;
60 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
61 # bison says 'parse error' instead of 'syntax error',
62 # various yaccs may or may not capitalize 'syntax'.
63 $results =~ s/^(syntax|parse) error/syntax error/mig;
64 $expected =~ s/\n+$//;
65 my $prefix = ($results =~ s/^PREFIX\n//) ;
66 if ( $results =~ s/^SKIPPED\n//) {
69 elsif (($prefix and $results !~ /^\Q$expected/) or
70 (!$prefix and $results ne $expected)){
71 print STDERR "PROG: $switch\n$prog\n";
72 print STDERR "EXPECTED:\n$expected\n";
73 print STDERR "GOT:\n$results\n";
76 print "ok ", ++$i, "\n";
83 # Error - not predeclaring a sub
87 Number found where operator expected at - line 3, near "Fred 1"
88 (Do you need to predeclare Fred?)
89 syntax error at - line 3, near "Fred 1"
90 Execution of - aborted due to compilation errors.
93 # Error - not predeclaring a sub in time
98 Number found where operator expected at - line 3, near "Fred 1"
99 (Do you need to predeclare Fred?)
100 syntax error at - line 3, near "Fred 1"
101 BEGIN not safe after errors--compilation aborted at - line 4.
107 sub Fred { print $_[0] + $_[1], "\n" }
112 # override a built-in function
113 use subs qw( open ) ;
115 sub open { print $_[0] + $_[1], "\n" }
120 # override a built-in function, call after definition
121 use subs qw( open ) ;
122 sub open { print $_[0] + $_[1], "\n" }
128 # override a built-in function, call with ()
129 use subs qw( open ) ;
131 sub open { print $_[0] + $_[1], "\n" }
136 # override a built-in function, call with () after definition
137 use subs qw( open ) ;
138 sub open { print $_[0] + $_[1], "\n" }
148 use subs qw( Fred ) ;
150 sub Fred { print $_[0] + $_[1], "\n" }
155 # check that it isn't affected by block scope
157 use subs qw( Fred ) ;
160 sub Fred { print $_[0] + $_[1], "\n" }