5 $ENV{PERL5LIB} = "../lib";
10 @prgs = split "\n########\n", <DATA>;
11 print "1..", scalar @prgs, "\n";
13 $tmpfile = "misctmp000";
14 1 while -f ++$tmpfile;
15 END { unlink $tmpfile if $tmpfile; }
17 $CAT = (($^O eq 'MSWin32') ? '.\perl -e "print <>"' : 'cat');
24 my($prog,$expected) = split(/\nEXPECT\n/, $_);
25 if ($^O eq 'MSWin32') {
26 open TEST, "| .\\perl -I../lib $switch >$tmpfile 2>&1";
29 open TEST, "| sh -c './perl $switch' >$tmpfile 2>&1";
31 print TEST $prog, "\n";
34 $results = `$CAT $tmpfile`;
36 $expected =~ s/\n+$//;
37 if ( $results ne $expected){
38 print STDERR "PROG: $switch\n$prog\n";
39 print STDERR "EXPECTED:\n$expected\n";
40 print STDERR "GOT:\n$results\n";
43 print "ok ", ++$i, "\n";
49 $a = ":="; split /($a)/o, "a:=b:=c"; print "@_"
53 $cusp = ~0 ^ (~0 >> 1);
55 print +($cusp - 1) % 8, $cusp % 8, -$cusp % 8, ($cusp + 1) % 8, "!\n";
61 Can't call method "go" without a package or object reference at - line 1.
70 $x=0x0eabcd; print $x->ref;
72 Can't call method "ref" without a package or object reference at - line 1.
74 chop ($str .= <STDIN>);
78 $x=2;$y=3;$x<$y ? $x : $y += 23;print $x;
82 eval {sub bar {print "In bar";}}
84 system './perl -ne "print if eof" /dev/null'
89 sub new {my ($obj,$n)=@_; bless \$n}
98 Can't coerce HASH to string in repeat at - line 1.
101 printf(STDOUT "%s\n", $_);
113 sub sub {local($_) = @_;
116 Modification of a read-only value attempted at - line 3.
118 package FOO;sub new {bless {FOO => BAR}};
132 print scalar ("foo","bar")
136 sub by_number { $a <=> $b; };# inline function for sort below
138 @ordered_array=sort by_number keys(%as_ary);
143 my($m2) = $#Shells++;
144 $Shells[$m2]{HOST} = $Host;
153 &ShowShell(&NewShell(beach,Work,"+0+0"));
154 &ShowShell(&NewShell(beach,Work,"+0+0"));
155 &ShowShell(&NewShell(beach,Work,"+0+0"));
161 { print "TIEARRAY @_\n";
162 die "bomb out\n" unless $count ++ ;
165 sub FETCH { print "fetch @_\n"; $_[0]->[$_[1]] }
166 sub STORE { print "store @_\n"; $_[0]->[$_[1]] = $_[2] }
167 sub DESTROY { print "DESTROY \n"; undef @{$_[0]}; }
170 eval 'tie @h, FAKEARRAY, fred' ;
171 tie @h, FAKEARRAY, fred ;
173 TIEARRAY FAKEARRAY fred
174 TIEARRAY FAKEARRAY fred
177 BEGIN { die "phooey\n" }
180 BEGIN failed--compilation aborted at - line 1.
184 Illegal division by zero at - line 1.
185 BEGIN failed--compilation aborted at - line 1.
189 Modification of a read-only value attempted at - line 1.
190 BEGIN failed--compilation aborted at - line 1.
196 print join(' ', reverse @_)."\n";
202 "Out of inspiration";
205 print "and destroyed as well\n";
209 print STDOUT "foo->can(READ)(@_)\n";
214 print STDOUT "Don't GETC, Get Perl\n";
221 print FOO "sentence.", "reversed", "a", "is", "This";
222 print "-- ", <FOO>, " --\n";
223 my($buf,$len,$offset);
225 $len = 10; $offset = 1;
226 read(FOO, $buf, $len, $offset) == 100 or die "foo->READ failed";
227 getc(FOO) eq "a" or die "foo->GETC failed";
230 This is a reversed sentence.
231 -- Out of inspiration --
232 foo->can(READ)(string 10 1)
234 and destroyed as well
236 my @a; $a[2] = 1; for (@a) { $_ = 2 } print "@a\n"
240 @a = ($a, $b, $c, $d) = (5, 6);
242 if ($a[0] == 5 and $a[1] == 6 and !defined $a[2] and !defined $a[3]);
246 print "ok\n" if (1E2<<1 == 200 and 3E4<<3 == 240000);
250 print "ok\n" if ("\0" lt "\xFF");
254 open(H,'op/misc.t'); # must be in the 't' directory
256 print "ok\n" if (-e _ and -f _ and -r _);
260 sub thing { 0 || return qw(now is the time) }
267 { local $main::{ren} = *stimpy; print $ren, ' ' }
273 { local $main::{ren} = *stimpy; print ${'ren'}, ' ' }
274 print +(defined(${'ren'}) ? 'oops' : 'joy'), "\n";
279 sub func { print 'really ' unless wantarray; 'p' }
280 sub groovy { 'groovy' }
282 print p::func()->groovy(), "\n"
286 @list = ([ 'one', 1 ], [ 'two', 2 ]);
287 sub func { $num = shift; (grep $_->[1] == $num, @list)[0] }
288 print scalar(map &func($_), 1 .. 3), " ",
289 scalar(map scalar &func($_), 1 .. 3), "\n";
294 @{$h{$k}} = qw(1 2 4);
295 for (@{$h{$k}}) { $s += $_; delete $h{$k} if ($_ == 2) }
296 print "bogus\n" unless $s == 7;
299 eval q[ my $a = 'inner'; eval q[ print "$a " ] ];
300 eval { my $x = 'peace'; eval q[ print "$x\n" ] }
308 eval 'sub foo { print "In foo2\n" }';
309 print "Exiting foo1\n";
315 Subroutine foo redefined at (eval 1) line 1.
320 map {#this newline here tickles the bug
322 print "eat flaming death\n" unless ($s == 7);
324 sub foo { local $_ = shift; split; @_ }
326 print "you die joe!\n" unless "@x" eq 'x y z';
328 sub foo { local(@_) = ('p', 'q', 'r'); }
329 sub bar { unshift @_, 'D'; @_ }
330 sub baz { push @_, 'E'; return @_ }
331 for (1..3) { print foo('a', 'b', 'c'), bar('d'), baz('e'), "\n" }