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>
10 unshift @INC, "../lib";
11 $Is_VMS = $^O eq 'VMS';
12 $Is_MSWin32 = $^O eq 'MSWin32';
13 $ENV{PERL5LIB} = "../lib" unless $Is_VMS;
18 @prgs = split "\n########\n", <DATA>;
19 print "1..", scalar @prgs, "\n";
21 $tmpfile = "runltmp000";
22 1 while -f ++$tmpfile;
23 END { if ($tmpfile) { 1 while unlink $tmpfile; } }
30 my($prog,$expected) = split(/\nEXPECT\n/, $_);
31 open TEST, ">$tmpfile";
34 my $results = $Is_VMS ?
35 `MCR $^X "-I[-.lib]" $switch $tmpfile` :
37 `.\\perl -I../lib $switch $tmpfile 2>&1` :
38 `./perl $switch $tmpfile 2>&1`;
41 # allow expected output to be written as if $prog is on STDIN
42 $results =~ s/runltmp\d+/-/g;
43 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
44 $expected =~ s/\n+$//;
45 if ($results ne $expected) {
46 print STDERR "PROG: $switch\n$prog\n";
47 print STDERR "EXPECTED:\n$expected\n";
48 print STDERR "GOT:\n$results\n";
51 print "ok ", ++$i, "\n";
57 @a = sort { last ; } @a;
60 Can't "last" outside a block at - line 3.
70 print "still in fetch\n";
79 - >test at (eval 1) line 1.
111 print STDERR "PRINT CALLED\n";
112 (split(/./, 'x'x10000))[0];
113 eval('die("test\n")');
121 print STDERR "DONE\n";
128 eval('die("foooo\n")');
130 $SIG{'__WARN__'} = 'warnhook';
144 eval('die("test\n")');
150 $bar = bless {}, TEST;
158 $a <=> $b unless eval('$a == 0 ? bless undef : ($a <=> $b)');
162 print join(', ', @a)."\n";
167 goto bar if $a == 0 || $b == 0;
172 print join(', ', @a)."\n";
175 print "bar reached\n";
177 Can't "goto" outside a block at - line 2.
180 (split(/./, 'x'x10000))[0];
181 my (@y) = ( 4, 6, 5);
182 @y = sort { $a <=> $b } @y;
183 print "sortfn ".join(', ', @y)."\n";
184 return $_[0] <=> $_[1];
187 @x = sort { &sortfn($a, $b) } @x;
188 print "---- ".join(', ', @x)."\n";
196 @a = sort { eval('die("no way")') , $a <=> $b} @a;
197 print join(", ", @a)."\n";
204 @a = sort { last foo; } @a;
207 Label not found for "last foo" at - line 2.
230 Can't "next" outside a block at - line 8.
251 Can't find label bbb at - line 8.
254 $a <=> $b unless eval('$a == 0 ? die("foo\n") : ($a <=> $b)');
258 print join(', ', @a)."\n";
271 (split(/./, 'x'x10000))[0];
288 Can't "next" outside a block at - line 4.
293 @a = sort { exit(0) } @a;
295 END { print "foobar\n" }
299 $SIG{__DIE__} = sub {
302 while (($p,$f,$l,$s) = caller(++$i)) {
303 print "$p|$f|$l|$s\n";
307 &{sub { eval 'die' }}();
308 sub foo { eval { die } } foo();
314 main|-|9|main::__ANON__
322 return bless [qw(foo fee fie foe)], $_[0];
335 print join('|', @bar[0..3]), "\n";
340 sub TIEHASH { bless {}, TH }
341 sub STORE { eval { print "@_[1,2]\n" }; die "bar\n" }
343 eval { $h{A} = 1; print "never\n"; };