3 # NOTE: Please don't add tests to this file unless they *need* to be run in
4 # separate executable and can't simply use eval.
8 $ENV{PERL5LIB} = "../lib";
13 @prgs = split "\n########\n", <DATA>;
14 print "1..", scalar @prgs, "\n";
16 $tmpfile = "misctmp000";
17 1 while -f ++$tmpfile;
18 END { unlink $tmpfile if $tmpfile; }
20 $CAT = (($^O eq 'MSWin32') ? '.\perl -e "print <>"' : 'cat');
27 my($prog,$expected) = split(/\nEXPECT\n/, $_);
28 if ($^O eq 'MSWin32') {
29 open TEST, "| .\\perl -I../lib $switch >$tmpfile 2>&1";
32 open TEST, "| sh -c './perl $switch' >$tmpfile 2>&1";
34 print TEST $prog, "\n";
37 $results = `$CAT $tmpfile`;
39 $expected =~ s/\n+$//;
40 if ( $results ne $expected){
41 print STDERR "PROG: $switch\n$prog\n";
42 print STDERR "EXPECTED:\n$expected\n";
43 print STDERR "GOT:\n$results\n";
46 print "ok ", ++$i, "\n";
52 $a = ":="; split /($a)/o, "a:=b:=c"; print "@_"
56 $cusp = ~0 ^ (~0 >> 1);
58 print +($cusp - 1) % 8, $cusp % 8, -$cusp % 8, ($cusp + 1) % 8, "!\n";
64 Can't call method "go" without a package or object reference at - line 1.
73 $x=0x0eabcd; print $x->ref;
75 Can't call method "ref" without a package or object reference at - line 1.
77 chop ($str .= <STDIN>);
81 $x=2;$y=3;$x<$y ? $x : $y += 23;print $x;
85 eval {sub bar {print "In bar";}}
87 system './perl -ne "print if eof" /dev/null'
92 sub new {my ($obj,$n)=@_; bless \$n}
101 Can't modify hash deref in repeat at - line 1, near "0;"
102 Execution of - aborted due to compilation errors.
105 printf(STDOUT "%s\n", $_);
117 sub sub {local($_) = @_;
120 Modification of a read-only value attempted at - line 3.
122 package FOO;sub new {bless {FOO => BAR}};
136 print scalar ("foo","bar")
140 sub by_number { $a <=> $b; };# inline function for sort below
142 @ordered_array=sort by_number keys(%as_ary);
147 my($m2) = $#Shells++;
148 $Shells[$m2]{HOST} = $Host;
157 &ShowShell(&NewShell(beach,Work,"+0+0"));
158 &ShowShell(&NewShell(beach,Work,"+0+0"));
159 &ShowShell(&NewShell(beach,Work,"+0+0"));
165 { print "TIEARRAY @_\n";
166 die "bomb out\n" unless $count ++ ;
169 sub FETCH { print "fetch @_\n"; $_[0]->[$_[1]] }
170 sub STORE { print "store @_\n"; $_[0]->[$_[1]] = $_[2] }
171 sub DESTROY { print "DESTROY \n"; undef @{$_[0]}; }
174 eval 'tie @h, FAKEARRAY, fred' ;
175 tie @h, FAKEARRAY, fred ;
177 TIEARRAY FAKEARRAY fred
178 TIEARRAY FAKEARRAY fred
181 BEGIN { die "phooey\n" }
184 BEGIN failed--compilation aborted at - line 1.
188 Illegal division by zero at - line 1.
189 BEGIN failed--compilation aborted at - line 1.
193 Modification of a read-only value attempted at - line 1.
194 BEGIN failed--compilation aborted at - line 1.
200 print join(' ', reverse @_)."\n";
205 print sprintf($fmt, @_)."\n";
211 "Out of inspiration";
214 print "and destroyed as well\n";
218 print STDOUT "foo->can(READ)(@_)\n";
223 print STDOUT "Don't GETC, Get Perl\n";
230 print FOO "sentence.", "reversed", "a", "is", "This";
231 print "-- ", <FOO>, " --\n";
232 my($buf,$len,$offset);
234 $len = 10; $offset = 1;
235 read(FOO, $buf, $len, $offset) == 100 or die "foo->READ failed";
236 getc(FOO) eq "a" or die "foo->GETC failed";
237 printf "%s is number %d\n", "Perl", 1;
240 This is a reversed sentence.
241 -- Out of inspiration --
242 foo->can(READ)(string 10 1)
245 and destroyed as well
247 my @a; $a[2] = 1; for (@a) { $_ = 2 } print "@a\n"
251 @a = ($a, $b, $c, $d) = (5, 6);
253 if ($a[0] == 5 and $a[1] == 6 and !defined $a[2] and !defined $a[3]);
257 print "ok\n" if (1E2<<1 == 200 and 3E4<<3 == 240000);
261 print "ok\n" if ("\0" lt "\xFF");
265 open(H,'op/misc.t'); # must be in the 't' directory
267 print "ok\n" if (-e _ and -f _ and -r _);
271 sub thing { 0 || return qw(now is the time) }
278 { local $main::{ren} = *stimpy; print $ren, ' ' }
284 { local $main::{ren} = *stimpy; print ${'ren'}, ' ' }
285 print +(defined(${'ren'}) ? 'oops' : 'joy'), "\n";
290 sub func { print 'really ' unless wantarray; 'p' }
291 sub groovy { 'groovy' }
293 print p::func()->groovy(), "\n"
297 @list = ([ 'one', 1 ], [ 'two', 2 ]);
298 sub func { $num = shift; (grep $_->[1] == $num, @list)[0] }
299 print scalar(map &func($_), 1 .. 3), " ",
300 scalar(map scalar &func($_), 1 .. 3), "\n";
305 @{$h{$k}} = qw(1 2 4);
306 for (@{$h{$k}}) { $s += $_; delete $h{$k} if ($_ == 2) }
307 print "bogus\n" unless $s == 7;
310 eval q[ my $a = 'inner'; eval q[ print "$a " ] ];
311 eval { my $x = 'peace'; eval q[ print "$x\n" ] }
319 eval 'sub foo { print "In foo2\n" }';
320 print "Exiting foo1\n";
326 Subroutine foo redefined at (eval 1) line 1.
331 map {#this newline here tickles the bug
333 print "eat flaming death\n" unless ($s == 7);
335 sub foo { local $_ = shift; split; @_ }
337 print "you die joe!\n" unless "@x" eq 'x y z';
339 /(?{"{"})/ # Check it outside of eval too
341 Sequence (?{...}) not terminated or not {}-balanced at - line 1, within pattern
342 /(?{"{"})/: Sequence (?{...}) not terminated or not {}-balanced at - line 1.
344 /(?{"{"}})/ # Check it outside of eval too
346 Unmatched right bracket at (re_eval 1) line 1, at end of line
347 syntax error at (re_eval 1) line 1, near ""{"}"
348 Compilation failed in regexp at - line 1.
350 BEGIN { @ARGV = qw(a b c) }
351 BEGIN { print "argv <@ARGV>\nbegin <",shift,">\n" }
352 END { print "end <",shift,">\nargv <@ARGV>\n" }
353 INIT { print "init <",shift,">\n" }
362 # fdopen from a system descriptor to a system descriptor used to close
364 open STDERR, '>&=STDOUT' or die $!;
365 select STDOUT; $| = 1; print fileno STDOUT;
366 select STDERR; $| = 1; print fileno STDERR;