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>
12 $Is_VMS = $^O eq 'VMS';
13 $Is_MSWin32 = $^O eq 'MSWin32';
14 $Is_NetWare = $^O eq 'NetWare';
15 $ENV{PERL5LIB} = "../lib" unless $Is_VMS;
20 @prgs = split "\n########\n", <DATA>;
21 print "1..", scalar @prgs, "\n";
23 $tmpfile = tempfile();
30 my($prog,$expected) = split(/\nEXPECT\n/, $_);
31 open TEST, ">$tmpfile";
33 close TEST or die "Could not close: $!";
34 my $results = $Is_VMS ?
35 `$^X "-I[-.lib]" $switch $tmpfile 2>&1` :
37 `.\\perl -I../lib $switch $tmpfile 2>&1` :
39 `perl -I../lib $switch $tmpfile 2>&1` :
40 `./perl $switch $tmpfile 2>&1`;
43 # allow expected output to be written as if $prog is on STDIN
44 $results =~ s/$::tempfile_regexp/-/ig;
45 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
46 $expected =~ s/\n+$//;
47 if ($results ne $expected) {
48 print STDERR "PROG: $switch\n$prog\n";
49 print STDERR "EXPECTED:\n$expected\n";
50 print STDERR "GOT:\n$results\n";
53 print "ok ", ++$i, "\n";
59 @a = sort { last ; } @a;
62 Can't "last" outside a loop block at - line 3.
72 print "still in fetch\n";
81 - >test at (eval 1) line 1.
113 print STDERR "PRINT CALLED\n";
114 (split(/./, 'x'x10000))[0];
115 eval('die("test\n")');
123 print STDERR "DONE\n";
130 eval('die("foooo\n")');
132 $SIG{'__WARN__'} = 'warnhook';
146 eval('die("test\n")');
152 $bar = bless {}, TEST;
160 $a <=> $b unless eval('$a == 0 ? bless undef : ($a <=> $b)');
164 print join(', ', @a)."\n";
169 goto bar if $a == 0 || $b == 0;
174 print join(', ', @a)."\n";
177 print "bar reached\n";
179 Can't "goto" out of a pseudo block at - line 2.
183 (split(/./, 'x'x10000))[0];
184 my (@y) = ( 4, 6, 5);
185 @y = sort { $a <=> $b } @y;
186 my $t = "sortfn ".join(', ', @y)."\n";
187 print $t if ($seen{$t}++ == 0);
188 return $_[0] <=> $_[1];
191 @x = sort { &sortfn($a, $b) } @x;
192 print "---- ".join(', ', @x)."\n";
198 @a = sort { eval('die("no way")') , $a <=> $b} @a;
199 print join(", ", @a)."\n";
206 @a = sort { last foo; } @a;
209 Label not found for "last foo" at - line 2.
232 Can't "next" outside a loop block at - line 8.
253 Can't find label bbb at - line 8.
256 $a <=> $b unless eval('$a == 0 ? die("foo\n") : ($a <=> $b)');
260 print join(', ', @a)."\n";
273 (split(/./, 'x'x10000))[0];
290 Can't "next" outside a loop block at - line 4.
295 @a = sort { exit(0) } @a;
297 END { print "foobar\n" }
301 $SIG{__DIE__} = sub {
304 while (($p,$f,$l,$s) = caller(++$i)) {
305 print "$p|$f|$l|$s\n";
309 &{sub { eval 'die' }}();
310 sub foo { eval { die } } foo();
311 {package rmb; sub{ eval{die} } ->() }; # check __ANON__ knows package
317 main|-|9|main::__ANON__
323 rmb|-|11|rmb::__ANON__
328 return bless [qw(foo fee fie foe)], $_[0];
341 print join('|', @bar[0..3]), "\n";
346 sub TIEHASH { bless {}, TH }
347 sub STORE { eval { print "@_[1,2]\n" }; die "bar\n" }
349 eval { $h{A} = 1; print "never\n"; };
360 sub f { my $x = shift; d(); }
366 while (do { { package DB; @a = caller($i++) } } ) {
368 for (@a) { print "$_\n"; $_ = '' }
374 sub TIEHANDLE { bless {} }
381 Can't "next" outside a loop block at - line 2.
383 sub TIEHANDLE { bless {} }
384 sub PRINT { print "[TIE] $_[1]" }
392 sub TIEHANDLE { bless {} }
394 (split(/./, 'x'x10000))[0];
395 eval('die("test\n")');
398 open OLDERR, '>&STDERR';
401 use warnings FATAL => qw(uninitialized);
405 [TIE] Use of uninitialized value in print at - line 11.