4 ## Many of these tests are originally from Michael Schroeder
5 ## <Michael.Schroeder@informatik.uni-erlangen.de>
6 ## Adapted and expanded by Gurusamy Sarathy <gsar@activestate.com>
11 $Is_VMS = $^O eq 'VMS';
12 $Is_MSWin32 = $^O eq 'MSWin32';
13 $Is_NetWare = $^O eq 'NetWare';
14 $Is_MacOS = $^O eq 'MacOS';
15 $ENV{PERL5LIB} = "../lib" unless $Is_VMS;
20 @prgs = split "\n########\n", <DATA>;
21 print "1..", scalar @prgs, "\n";
23 $tmpfile = "runltmp000";
24 1 while -f ++$tmpfile;
25 END { if ($tmpfile) { 1 while unlink $tmpfile; } }
32 my($prog,$expected) = split(/\nEXPECT\n/, $_);
33 open TEST, ">$tmpfile";
35 close TEST or die "Could not close: $!";
36 my $results = $Is_VMS ?
37 `$^X "-I[-.lib]" $switch $tmpfile 2>&1` :
39 `.\\perl -I../lib $switch $tmpfile 2>&1` :
41 `perl -I../lib $switch $tmpfile 2>&1` :
43 `$^X -I::lib -MMac::err=unix $switch $tmpfile` :
44 `./perl $switch $tmpfile 2>&1`;
47 # allow expected output to be written as if $prog is on STDIN
48 $results =~ s/runltmp\d+/-/g;
49 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
50 $expected =~ s/\n+$//;
51 if ($results ne $expected) {
52 print STDERR "PROG: $switch\n$prog\n";
53 print STDERR "EXPECTED:\n$expected\n";
54 print STDERR "GOT:\n$results\n";
57 print "ok ", ++$i, "\n";
63 @a = sort { last ; } @a;
66 Can't "last" outside a loop block at - line 3.
76 print "still in fetch\n";
85 - >test at (eval 1) line 1.
117 print STDERR "PRINT CALLED\n";
118 (split(/./, 'x'x10000))[0];
119 eval('die("test\n")');
127 print STDERR "DONE\n";
134 eval('die("foooo\n")');
136 $SIG{'__WARN__'} = 'warnhook';
150 eval('die("test\n")');
156 $bar = bless {}, TEST;
164 $a <=> $b unless eval('$a == 0 ? bless undef : ($a <=> $b)');
168 print join(', ', @a)."\n";
173 goto bar if $a == 0 || $b == 0;
178 print join(', ', @a)."\n";
181 print "bar reached\n";
183 Can't "goto" out of a pseudo block at - line 2.
187 (split(/./, 'x'x10000))[0];
188 my (@y) = ( 4, 6, 5);
189 @y = sort { $a <=> $b } @y;
190 my $t = "sortfn ".join(', ', @y)."\n";
191 print $t if ($seen{$t}++ == 0);
192 return $_[0] <=> $_[1];
195 @x = sort { &sortfn($a, $b) } @x;
196 print "---- ".join(', ', @x)."\n";
202 @a = sort { eval('die("no way")') , $a <=> $b} @a;
203 print join(", ", @a)."\n";
210 @a = sort { last foo; } @a;
213 Label not found for "last foo" at - line 2.
236 Can't "next" outside a loop block at - line 8.
257 Can't find label bbb at - line 8.
260 $a <=> $b unless eval('$a == 0 ? die("foo\n") : ($a <=> $b)');
264 print join(', ', @a)."\n";
277 (split(/./, 'x'x10000))[0];
294 Can't "next" outside a loop block at - line 4.
299 @a = sort { exit(0) } @a;
301 END { print "foobar\n" }
305 $SIG{__DIE__} = sub {
308 while (($p,$f,$l,$s) = caller(++$i)) {
309 print "$p|$f|$l|$s\n";
313 &{sub { eval 'die' }}();
314 sub foo { eval { die } } foo();
315 {package rmb; sub{ eval{die} } ->() }; # check __ANON__ knows package
321 main|-|9|main::__ANON__
327 rmb|-|11|rmb::__ANON__
332 return bless [qw(foo fee fie foe)], $_[0];
345 print join('|', @bar[0..3]), "\n";
350 sub TIEHASH { bless {}, TH }
351 sub STORE { eval { print "@_[1,2]\n" }; die "bar\n" }
353 eval { $h{A} = 1; print "never\n"; };
364 sub f { my $x = shift; d(); }
370 while (do { { package DB; @a = caller($i++) } } ) {
372 for (@a) { print "$_\n"; $_ = '' }
378 sub TIEHANDLE { bless {} }
385 Can't "next" outside a loop block at - line 2.
387 sub TIEHANDLE { bless {} }
388 sub PRINT { print "[TIE] $_[1]" }
396 sub TIEHANDLE { bless {} }
398 (split(/./, 'x'x10000))[0];
399 eval('die("test\n")');
402 open OLDERR, '>&STDERR';
405 use warnings FATAL => qw(uninitialized);
409 [TIE] Use of uninitialized value in print at - line 11.