6 $ENV{PERL5LIB} = '../lib';
11 my @prgs = split "\n########\n", <DATA>;
12 print "1..", scalar @prgs, "\n";
14 my $tmpfile = "tmp0000";
16 1 while -f ++$tmpfile;
17 END { unlink $tmpfile if $tmpfile; }
25 my($prog,$expected) = split(/\nEXPECT\n/, $_);
26 if ( $prog =~ /--FILE--/) {
27 my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
29 die "Internal error test $i didn't split into pairs, got " .
30 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
33 my $filename = shift @files ;
34 my $code = shift @files ;
35 push @temps, $filename ;
36 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
41 $prog = shift @files ;
43 open TEST, "| sh -c './perl $switch' >$tmpfile 2>&1";
44 print TEST $prog, "\n";
47 my $results = `cat $tmpfile`;
49 $expected =~ s/\n+$//;
50 my $prefix = ($results =~ s/^PREFIX\n//) ;
51 if ( $results =~ s/^SKIPPED\n//) {
54 elsif (($prefix and $results !~ /^\Q$expected/) or
55 (!$prefix and $results ne $expected)){
56 print STDERR "PROG: $switch\n$prog\n";
57 print STDERR "EXPECTED:\n$expected\n";
58 print STDERR "GOT:\n$results\n";
61 print "ok ", ++$i, "\n";
68 # Error - not predeclaring a sub
72 Number found where operator expected at - line 3, near "Fred 1"
73 (Do you need to predeclare Fred?)
74 syntax error at - line 3, near "Fred 1"
75 Execution of - aborted due to compilation errors.
78 # Error - not predeclaring a sub in time
83 Number found where operator expected at - line 3, near "Fred 1"
84 (Do you need to predeclare Fred?)
85 syntax error at - line 3, near "Fred 1"
86 Execution of - aborted due to compilation errors.
92 sub Fred { print $_[0] + $_[1], "\n" }
97 # override a built-in function
100 sub open { print $_[0] + $_[1], "\n" }
109 use subs qw( Fred ) ;
111 sub Fred { print $_[0] + $_[1], "\n" }
116 # check that it isn't affected by block scope
118 use subs qw( Fred ) ;
121 sub Fred { print $_[0] + $_[1], "\n" }