Commit | Line | Data |
a0d0e21e |
1 | #!./perl |
2 | |
eeabcb2d |
3 | # ** DO NOT ADD ANY MORE TESTS HERE ** |
4 | # Instead, put the test in the appropriate test file and use the |
235bddc8 |
5 | # fresh_perl_is()/fresh_perl_like() functions in t/test.pl. |
eeabcb2d |
6 | |
c9beb3f5 |
7 | # This is for tests that will normally cause segfaults, and other nasty |
8 | # errors that might kill the interpreter and for some reason you can't |
9 | # use an eval(). |
10 | # |
11 | # New tests are added to the bottom. For example. |
12 | # |
13 | # ######## perlbug ID 20020831.001 |
14 | # ($a, b) = (1,2) |
15 | # EXPECT |
16 | # Can't modify constant item in list assignment - at line 1 |
17 | # |
18 | # to test that the code "($a, b) = (1,2)" causes the appropriate syntax |
19 | # error, rather than just segfaulting as reported in perlbug ID |
20 | # 20020831.001 |
fb73857a |
21 | |
c9beb3f5 |
22 | BEGIN { |
23 | chdir 't' if -d 't'; |
24 | @INC = '../lib'; |
b5fe401b |
25 | require './test.pl'; |
c9beb3f5 |
26 | } |
27 | |
28 | use strict; |
a0d0e21e |
29 | |
b5fe401b |
30 | my $Perl = which_perl; |
31 | |
a0d0e21e |
32 | $|=1; |
33 | |
c9beb3f5 |
34 | my @prgs = (); |
35 | while(<DATA>) { |
36 | if(m/^#{8,}\s*(.*)/) { |
37 | push @prgs, ['', $1]; |
38 | } |
39 | else { |
40 | $prgs[-1][0] .= $_; |
41 | } |
42 | } |
eeabcb2d |
43 | plan tests => scalar @prgs; |
a0d0e21e |
44 | |
c9beb3f5 |
45 | foreach my $prog (@prgs) { |
46 | my($raw_prog, $name) = @$prog; |
68dc0745 |
47 | |
a0d0e21e |
48 | my $switch; |
c9beb3f5 |
49 | if ($raw_prog =~ s/^\s*(-\w.*)//){ |
fb73857a |
50 | $switch = $1; |
a0d0e21e |
51 | } |
c9beb3f5 |
52 | |
53 | my($prog,$expected) = split(/\nEXPECT\n/, $raw_prog); |
54 | |
235bddc8 |
55 | $expected =~ s/\n+$//; |
56 | |
57 | fresh_perl_is($prog, $expected, { switches => [$switch] }, $name); |
a0d0e21e |
58 | } |
59 | |
60 | __END__ |
2ace3117 |
61 | ######## |
44a8e56a |
62 | $a = ":="; split /($a)/o, "a:=b:=c"; print "@_" |
63 | EXPECT |
64 | a := b := c |
65 | ######## |
36477c24 |
66 | $cusp = ~0 ^ (~0 >> 1); |
85e0ebd8 |
67 | use integer; |
36477c24 |
68 | $, = " "; |
85e0ebd8 |
69 | print +($cusp - 1) % 8, $cusp % 8, -$cusp % 8, 8 | (($cusp + 1) % 8 + 7), "!\n"; |
36477c24 |
70 | EXPECT |
85e0ebd8 |
71 | 7 0 0 8 ! |
36477c24 |
72 | ######## |
a0d0e21e |
73 | $foo=undef; $foo->go; |
74 | EXPECT |
72b5445b |
75 | Can't call method "go" on an undefined value at - line 1. |
a0d0e21e |
76 | ######## |
77 | BEGIN |
78 | { |
79 | "foo"; |
80 | } |
81 | ######## |
a0d0e21e |
82 | $array[128]=1 |
83 | ######## |
84 | $x=0x0eabcd; print $x->ref; |
85 | EXPECT |
86 | Can't call method "ref" without a package or object reference at - line 1. |
87 | ######## |
648cac19 |
88 | chop ($str .= <DATA>); |
a0d0e21e |
89 | ######## |
90 | close ($banana); |
91 | ######## |
92 | $x=2;$y=3;$x<$y ? $x : $y += 23;print $x; |
93 | EXPECT |
94 | 25 |
95 | ######## |
96 | eval {sub bar {print "In bar";}} |
97 | ######## |
68dc0745 |
98 | system './perl -ne "print if eof" /dev/null' |
a0d0e21e |
99 | ######## |
648cac19 |
100 | chop($file = <DATA>); |
a0d0e21e |
101 | ######## |
102 | package N; |
103 | sub new {my ($obj,$n)=@_; bless \$n} |
104 | $aa=new N 1; |
105 | $aa=12345; |
106 | print $aa; |
107 | EXPECT |
108 | 12345 |
109 | ######## |
110 | %@x=0; |
111 | EXPECT |
f1612b5c |
112 | Can't modify hash dereference in repeat (x) at - line 1, near "0;" |
3fe9a6f1 |
113 | Execution of - aborted due to compilation errors. |
a0d0e21e |
114 | ######## |
115 | $_="foo"; |
116 | printf(STDOUT "%s\n", $_); |
117 | EXPECT |
118 | foo |
119 | ######## |
120 | push(@a, 1, 2, 3,) |
121 | ######## |
122 | quotemeta "" |
123 | ######## |
124 | for ("ABCDE") { |
125 | ⊂ |
126 | s/./&sub($&)/eg; |
127 | print;} |
128 | sub sub {local($_) = @_; |
129 | $_ x 4;} |
130 | EXPECT |
131 | Modification of a read-only value attempted at - line 3. |
132 | ######## |
133 | package FOO;sub new {bless {FOO => BAR}}; |
134 | package main; |
135 | use strict vars; |
136 | my $self = new FOO; |
137 | print $$self{FOO}; |
138 | EXPECT |
139 | BAR |
140 | ######## |
141 | $_="foo"; |
142 | s/.{1}//s; |
143 | print; |
144 | EXPECT |
145 | oo |
146 | ######## |
147 | print scalar ("foo","bar") |
148 | EXPECT |
149 | bar |
150 | ######## |
151 | sub by_number { $a <=> $b; };# inline function for sort below |
152 | $as_ary{0}="a0"; |
153 | @ordered_array=sort by_number keys(%as_ary); |
154 | ######## |
155 | sub NewShell |
156 | { |
157 | local($Host) = @_; |
158 | my($m2) = $#Shells++; |
159 | $Shells[$m2]{HOST} = $Host; |
160 | return $m2; |
161 | } |
162 | |
163 | sub ShowShell |
164 | { |
165 | local($i) = @_; |
166 | } |
167 | |
168 | &ShowShell(&NewShell(beach,Work,"+0+0")); |
169 | &ShowShell(&NewShell(beach,Work,"+0+0")); |
170 | &ShowShell(&NewShell(beach,Work,"+0+0")); |
171 | ######## |
172 | { |
173 | package FAKEARRAY; |
174 | |
175 | sub TIEARRAY |
176 | { print "TIEARRAY @_\n"; |
177 | die "bomb out\n" unless $count ++ ; |
178 | bless ['foo'] |
179 | } |
180 | sub FETCH { print "fetch @_\n"; $_[0]->[$_[1]] } |
181 | sub STORE { print "store @_\n"; $_[0]->[$_[1]] = $_[2] } |
182 | sub DESTROY { print "DESTROY \n"; undef @{$_[0]}; } |
183 | } |
184 | |
185 | eval 'tie @h, FAKEARRAY, fred' ; |
186 | tie @h, FAKEARRAY, fred ; |
187 | EXPECT |
188 | TIEARRAY FAKEARRAY fred |
189 | TIEARRAY FAKEARRAY fred |
190 | DESTROY |
191 | ######## |
192 | BEGIN { die "phooey\n" } |
193 | EXPECT |
194 | phooey |
195 | BEGIN failed--compilation aborted at - line 1. |
196 | ######## |
197 | BEGIN { 1/$zero } |
198 | EXPECT |
199 | Illegal division by zero at - line 1. |
200 | BEGIN failed--compilation aborted at - line 1. |
201 | ######## |
202 | BEGIN { undef = 0 } |
203 | EXPECT |
204 | Modification of a read-only value attempted at - line 1. |
205 | BEGIN failed--compilation aborted at - line 1. |
a7adf1f0 |
206 | ######## |
207 | { |
208 | package foo; |
209 | sub PRINT { |
210 | shift; |
211 | print join(' ', reverse @_)."\n"; |
212 | } |
46fc3d4c |
213 | sub PRINTF { |
214 | shift; |
215 | my $fmt = shift; |
216 | print sprintf($fmt, @_)."\n"; |
217 | } |
a7adf1f0 |
218 | sub TIEHANDLE { |
219 | bless {}, shift; |
220 | } |
58f51617 |
221 | sub READLINE { |
222 | "Out of inspiration"; |
223 | } |
a7adf1f0 |
224 | sub DESTROY { |
225 | print "and destroyed as well\n"; |
2ae324a7 |
226 | } |
227 | sub READ { |
228 | shift; |
229 | print STDOUT "foo->can(READ)(@_)\n"; |
230 | return 100; |
231 | } |
232 | sub GETC { |
233 | shift; |
234 | print STDOUT "Don't GETC, Get Perl\n"; |
235 | return "a"; |
236 | } |
a7adf1f0 |
237 | } |
238 | { |
239 | local(*FOO); |
240 | tie(*FOO,'foo'); |
241 | print FOO "sentence.", "reversed", "a", "is", "This"; |
58f51617 |
242 | print "-- ", <FOO>, " --\n"; |
2ae324a7 |
243 | my($buf,$len,$offset); |
244 | $buf = "string"; |
245 | $len = 10; $offset = 1; |
246 | read(FOO, $buf, $len, $offset) == 100 or die "foo->READ failed"; |
247 | getc(FOO) eq "a" or die "foo->GETC failed"; |
46fc3d4c |
248 | printf "%s is number %d\n", "Perl", 1; |
a7adf1f0 |
249 | } |
250 | EXPECT |
251 | This is a reversed sentence. |
58f51617 |
252 | -- Out of inspiration -- |
2ae324a7 |
253 | foo->can(READ)(string 10 1) |
254 | Don't GETC, Get Perl |
46fc3d4c |
255 | Perl is number 1 |
a7adf1f0 |
256 | and destroyed as well |
a6006777 |
257 | ######## |
258 | my @a; $a[2] = 1; for (@a) { $_ = 2 } print "@a\n" |
259 | EXPECT |
260 | 2 2 2 |
261 | ######## |
8ff950ac |
262 | # used to attach defelem magic to all immortal values, |
8b530633 |
263 | # which made restore of local $_ fail. |
264 | foo(2>1); |
265 | sub foo { bar() for @_; } |
266 | sub bar { local $_; } |
267 | print "ok\n"; |
268 | EXPECT |
269 | ok |
270 | ######## |
a6006777 |
271 | @a = ($a, $b, $c, $d) = (5, 6); |
272 | print "ok\n" |
273 | if ($a[0] == 5 and $a[1] == 6 and !defined $a[2] and !defined $a[3]); |
274 | EXPECT |
275 | ok |
276 | ######## |
277 | print "ok\n" if (1E2<<1 == 200 and 3E4<<3 == 240000); |
278 | EXPECT |
279 | ok |
280 | ######## |
8ebc5c01 |
281 | print "ok\n" if ("\0" lt "\xFF"); |
a6006777 |
282 | EXPECT |
283 | ok |
284 | ######## |
235bddc8 |
285 | open(H,'run/fresh_perl.t'); # must be in the 't' directory |
a6006777 |
286 | stat(H); |
287 | print "ok\n" if (-e _ and -f _ and -r _); |
288 | EXPECT |
289 | ok |
290 | ######## |
291 | sub thing { 0 || return qw(now is the time) } |
292 | print thing(), "\n"; |
293 | EXPECT |
294 | nowisthetime |
295 | ######## |
296 | $ren = 'joy'; |
297 | $stimpy = 'happy'; |
298 | { local $main::{ren} = *stimpy; print $ren, ' ' } |
299 | print $ren, "\n"; |
300 | EXPECT |
301 | happy joy |
302 | ######## |
303 | $stimpy = 'happy'; |
304 | { local $main::{ren} = *stimpy; print ${'ren'}, ' ' } |
305 | print +(defined(${'ren'}) ? 'oops' : 'joy'), "\n"; |
306 | EXPECT |
307 | happy joy |
308 | ######## |
309 | package p; |
310 | sub func { print 'really ' unless wantarray; 'p' } |
311 | sub groovy { 'groovy' } |
312 | package main; |
313 | print p::func()->groovy(), "\n" |
314 | EXPECT |
315 | really groovy |
316 | ######## |
d53f8f1c |
317 | @list = ([ 'one', 1 ], [ 'two', 2 ]); |
318 | sub func { $num = shift; (grep $_->[1] == $num, @list)[0] } |
319 | print scalar(map &func($_), 1 .. 3), " ", |
320 | scalar(map scalar &func($_), 1 .. 3), "\n"; |
321 | EXPECT |
322 | 2 3 |
323 | ######## |
44a8e56a |
324 | ($k, $s) = qw(x 0); |
325 | @{$h{$k}} = qw(1 2 4); |
326 | for (@{$h{$k}}) { $s += $_; delete $h{$k} if ($_ == 2) } |
327 | print "bogus\n" unless $s == 7; |
328 | ######## |
329 | my $a = 'outer'; |
330 | eval q[ my $a = 'inner'; eval q[ print "$a " ] ]; |
331 | eval { my $x = 'peace'; eval q[ print "$x\n" ] } |
332 | EXPECT |
333 | inner peace |
774d564b |
334 | ######## |
335 | -w |
336 | $| = 1; |
337 | sub foo { |
338 | print "In foo1\n"; |
339 | eval 'sub foo { print "In foo2\n" }'; |
340 | print "Exiting foo1\n"; |
341 | } |
342 | foo; |
343 | foo; |
344 | EXPECT |
345 | In foo1 |
346 | Subroutine foo redefined at (eval 1) line 1. |
347 | Exiting foo1 |
348 | In foo2 |
349 | ######## |
350 | $s = 0; |
351 | map {#this newline here tickles the bug |
352 | $s += $_} (1,2,4); |
353 | print "eat flaming death\n" unless ($s == 7); |
1ca7b98a |
354 | ######## |
355 | sub foo { local $_ = shift; split; @_ } |
356 | @x = foo(' x y z '); |
357 | print "you die joe!\n" unless "@x" eq 'x y z'; |
c277df42 |
358 | ######## |
359 | /(?{"{"})/ # Check it outside of eval too |
360 | EXPECT |
2cd61cdb |
361 | Sequence (?{...}) not terminated or not {}-balanced at - line 1, within pattern |
7253e4e3 |
362 | Sequence (?{...}) not terminated or not {}-balanced in regex; marked by <-- HERE in m/(?{ <-- HERE "{"})/ at - line 1. |
c277df42 |
363 | ######## |
364 | /(?{"{"}})/ # Check it outside of eval too |
365 | EXPECT |
d98d5fff |
366 | Unmatched right curly bracket at (re_eval 1) line 1, at end of line |
c277df42 |
367 | syntax error at (re_eval 1) line 1, near ""{"}" |
2cd61cdb |
368 | Compilation failed in regexp at - line 1. |
0da4822f |
369 | ######## |
ff689196 |
370 | BEGIN { @ARGV = qw(a b c d e) } |
0da4822f |
371 | BEGIN { print "argv <@ARGV>\nbegin <",shift,">\n" } |
372 | END { print "end <",shift,">\nargv <@ARGV>\n" } |
373 | INIT { print "init <",shift,">\n" } |
7d30b5c4 |
374 | CHECK { print "check <",shift,">\n" } |
0da4822f |
375 | EXPECT |
ff689196 |
376 | argv <a b c d e> |
0da4822f |
377 | begin <a> |
7d30b5c4 |
378 | check <b> |
ff689196 |
379 | init <c> |
380 | end <d> |
381 | argv <e> |
4599a1de |
382 | ######## |
3500f679 |
383 | -l |
384 | # fdopen from a system descriptor to a system descriptor used to close |
385 | # the former. |
386 | open STDERR, '>&=STDOUT' or die $!; |
75642110 |
387 | select STDOUT; $| = 1; print fileno STDOUT or die $!; |
388 | select STDERR; $| = 1; print fileno STDERR or die $!; |
3500f679 |
389 | EXPECT |
390 | 1 |
391 | 2 |
392 | ######## |
20408e3c |
393 | -w |
394 | sub testme { my $a = "test"; { local $a = "new test"; print $a }} |
395 | EXPECT |
396 | Can't localize lexical variable $a at - line 2. |
397 | ######## |
51ae5c03 |
398 | package X; |
399 | sub ascalar { my $r; bless \$r } |
400 | sub DESTROY { print "destroyed\n" }; |
401 | package main; |
402 | *s = ascalar X; |
403 | EXPECT |
404 | destroyed |
405 | ######## |
406 | package X; |
407 | sub anarray { bless [] } |
408 | sub DESTROY { print "destroyed\n" }; |
409 | package main; |
410 | *a = anarray X; |
411 | EXPECT |
412 | destroyed |
413 | ######## |
414 | package X; |
415 | sub ahash { bless {} } |
416 | sub DESTROY { print "destroyed\n" }; |
417 | package main; |
418 | *h = ahash X; |
419 | EXPECT |
420 | destroyed |
421 | ######## |
422 | package X; |
423 | sub aclosure { my $x; bless sub { ++$x } } |
424 | sub DESTROY { print "destroyed\n" }; |
425 | package main; |
426 | *c = aclosure X; |
427 | EXPECT |
428 | destroyed |
429 | ######## |
430 | package X; |
431 | sub any { bless {} } |
432 | my $f = "FH000"; # just to thwart any future optimisations |
ded8aa31 |
433 | sub afh { select select ++$f; my $r = *{$f}{IO}; delete $X::{$f}; bless $r } |
51ae5c03 |
434 | sub DESTROY { print "destroyed\n" } |
435 | package main; |
436 | $x = any X; # to bump sv_objcount. IO objs aren't counted?? |
437 | *f = afh X; |
438 | EXPECT |
439 | destroyed |
440 | destroyed |
441 | ######## |
ebf99b04 |
442 | BEGIN { |
443 | $| = 1; |
444 | $SIG{__WARN__} = sub { |
445 | eval { print $_[0] }; |
446 | die "bar\n"; |
447 | }; |
448 | warn "foo\n"; |
449 | } |
450 | EXPECT |
451 | foo |
452 | bar |
453 | BEGIN failed--compilation aborted at - line 8. |
8feb4e9f |
454 | ######## |
455 | package X; |
456 | @ISA='Y'; |
457 | sub new { |
458 | my $class = shift; |
459 | my $self = { }; |
460 | bless $self, $class; |
461 | my $init = shift; |
462 | $self->foo($init); |
463 | print "new", $init; |
464 | return $self; |
465 | } |
466 | sub DESTROY { |
467 | my $self = shift; |
468 | print "DESTROY", $self->foo; |
469 | } |
470 | package Y; |
471 | sub attribute { |
472 | my $self = shift; |
473 | my $var = shift; |
474 | if (@_ == 0) { |
475 | return $self->{$var}; |
476 | } elsif (@_ == 1) { |
477 | $self->{$var} = shift; |
478 | } |
479 | } |
480 | sub AUTOLOAD { |
481 | $AUTOLOAD =~ /::([^:]+)$/; |
482 | my $method = $1; |
483 | splice @_, 1, 0, $method; |
484 | goto &attribute; |
485 | } |
486 | package main; |
487 | my $x = X->new(1); |
488 | for (2..3) { |
489 | my $y = X->new($_); |
490 | print $y->foo; |
491 | } |
492 | print $x->foo; |
493 | EXPECT |
494 | new1new22DESTROY2new33DESTROY31DESTROY1 |
dfad63ad |
495 | ######## |
496 | re(); |
497 | sub re { |
14455d6c |
498 | my $re = join '', eval 'qr/(??{ $obj->method })/'; |
dfad63ad |
499 | $re; |
500 | } |
501 | EXPECT |
1aff0e91 |
502 | ######## |
503 | use strict; |
504 | my $foo = "ZZZ\n"; |
505 | END { print $foo } |
506 | EXPECT |
507 | ZZZ |
508 | ######## |
509 | eval ' |
510 | use strict; |
511 | my $foo = "ZZZ\n"; |
512 | END { print $foo } |
513 | '; |
514 | EXPECT |
515 | ZZZ |
7399586d |
516 | ######## |
517 | -w |
518 | if (@ARGV) { print "" } |
519 | else { |
520 | if ($x == 0) { print "" } else { print $x } |
521 | } |
522 | EXPECT |
b89fed5f |
523 | Use of uninitialized value in numeric eq (==) at - line 4. |
1d76a5c3 |
524 | ######## |
525 | $x = sub {}; |
526 | foo(); |
527 | sub foo { eval { return }; } |
528 | print "ok\n"; |
529 | EXPECT |
530 | ok |
07447971 |
531 | ######## |
b0f2b690 |
532 | # moved to op/lc.t |
07447971 |
533 | EXPECT |
92d29cee |
534 | ######## |
535 | sub f { my $a = 1; my $b = 2; my $c = 3; my $d = 4; next } |
536 | my $x = "foo"; |
537 | { f } continue { print $x, "\n" } |
538 | EXPECT |
539 | foo |
6a7129a1 |
540 | ######## |
541 | sub C () { 1 } |
542 | sub M { $_[0] = 2; } |
543 | eval "C"; |
544 | M(C); |
545 | EXPECT |
546 | Modification of a read-only value attempted at - line 2. |
00c29ff8 |
547 | ######## |
548 | print qw(ab a\b a\\b); |
549 | EXPECT |
550 | aba\ba\b |
dd8482fc |
551 | ######## |
c71fccf1 |
552 | # lexicals declared after the myeval() definition should not be visible |
553 | # within it |
554 | sub myeval { eval $_[0] } |
555 | my $foo = "ok 2\n"; |
556 | myeval('sub foo { local $foo = "ok 1\n"; print $foo; }'); |
557 | die $@ if $@; |
558 | foo(); |
559 | print $foo; |
560 | EXPECT |
561 | ok 1 |
562 | ok 2 |
563 | ######## |
2090ab20 |
564 | # lexicals outside an eval"" should be visible inside subroutine definitions |
565 | # within it |
566 | eval <<'EOT'; die $@ if $@; |
567 | { |
568 | my $X = "ok\n"; |
569 | eval 'sub Y { print $X }'; die $@ if $@; |
570 | Y(); |
571 | } |
572 | EOT |
573 | EXPECT |
574 | ok |
575 | ######## |
dd8482fc |
576 | # This test is here instead of pragma/locale.t because |
577 | # the bug depends on in the internal state of the locale |
578 | # settings and pragma/locale messes up that state pretty badly. |
579 | # We need a "fresh run". |
c9f931b8 |
580 | BEGIN { |
581 | eval { require POSIX }; |
582 | if ($@) { |
583 | exit(0); # running minitest? |
584 | } |
585 | } |
dd8482fc |
586 | use Config; |
587 | my $have_setlocale = $Config{d_setlocale} eq 'define'; |
dd8482fc |
588 | $have_setlocale = 0 if $@; |
589 | # Visual C's CRT goes silly on strings of the form "en_US.ISO8859-1" |
590 | # and mingw32 uses said silly CRT |
2986a63f |
591 | $have_setlocale = 0 if (($^O eq 'MSWin32' || $^O eq 'NetWare') && $Config{cc} =~ /^(cl|gcc)/i); |
dd8482fc |
592 | exit(0) unless $have_setlocale; |
593 | my @locales; |
594 | if (-x "/usr/bin/locale" && open(LOCALES, "/usr/bin/locale -a|")) { |
595 | while(<LOCALES>) { |
596 | chomp; |
597 | push(@locales, $_); |
598 | } |
599 | close(LOCALES); |
600 | } |
601 | exit(0) unless @locales; |
602 | for (@locales) { |
603 | use POSIX qw(locale_h); |
604 | use locale; |
88e7acd2 |
605 | setlocale(LC_NUMERIC, $_) or next; |
dd8482fc |
606 | my $s = sprintf "%g %g", 3.1, 3.1; |
607 | next if $s eq '3.1 3.1' || $s =~ /^(3.+1) \1$/; |
608 | print "$_ $s\n"; |
609 | } |
610 | EXPECT |
b927783e |
611 | ######## |
612 | die qr(x) |
613 | EXPECT |
614 | (?-xism:x) at - line 1. |
615 | ######## |
7ef822cd |
616 | # 20001210.003 mjd@plover.com |
617 | format REMITOUT_TOP = |
618 | FOO |
619 | . |
620 | |
621 | format REMITOUT = |
622 | BAR |
623 | . |
624 | |
625 | # This loop causes a segv in 5.6.0 |
626 | for $lineno (1..61) { |
627 | write REMITOUT; |
628 | } |
629 | |
630 | print "It's OK!"; |
631 | EXPECT |
632 | It's OK! |
cb55de95 |
633 | ######## |
634 | # Inaba Hiroto |
635 | reset; |
636 | if (0) { |
637 | if ("" =~ //) { |
638 | } |
639 | } |
640 | ######## |
641 | # Nicholas Clark |
642 | $ENV{TERM} = 0; |
643 | reset; |
644 | // if 0; |
645 | ######## |
646 | # Vadim Konovalov |
647 | use strict; |
648 | sub new_pmop($) { |
649 | my $pm = shift; |
650 | return eval "sub {shift=~/$pm/}"; |
651 | } |
652 | new_pmop "abcdef"; reset; |
653 | new_pmop "abcdef"; reset; |
654 | new_pmop "abcdef"; reset; |
655 | new_pmop "abcdef"; reset; |
880649cd |
656 | ######## |
657 | # David Dyck |
658 | # coredump in 5.7.1 |
659 | close STDERR; die; |
660 | EXPECT |
dba9804b |
661 | ######## |
99799961 |
662 | -w |
663 | "x" =~ /(\G?x)?/; # core dump in 20000716.007 |
99799961 |
664 | ######## |
dba9804b |
665 | # Bug 20010515.004 |
666 | my @h = 1 .. 10; |
667 | bad(@h); |
668 | sub bad { |
669 | undef @h; |
670 | print "O"; |
671 | print for @_; |
672 | print "K"; |
673 | } |
674 | EXPECT |
675 | OK |
97b9a4cb |
676 | ######## |
677 | # Bug 20010506.041 |
678 | "abcd\x{1234}" =~ /(a)(b[c])(d+)?/i and print "ok\n"; |
679 | EXPECT |
680 | ok |
0b490c9c |
681 | ######## |
682 | # Bug 20010422.005 |
683 | {s//${}/; //} |
684 | EXPECT |
2172ddaf |
685 | syntax error at - line 2, near "${}" |
0b490c9c |
686 | Execution of - aborted due to compilation errors. |
585602fa |
687 | ######## |
688 | # Bug 20010528.007 |
689 | "\x{" |
690 | EXPECT |
691 | Missing right brace on \x{} at - line 2, within string |
692 | Execution of - aborted due to compilation errors. |
08b362fd |
693 | ######## |
694 | my $foo = Bar->new(); |
695 | my @dst; |
696 | END { |
697 | ($_ = "@dst") =~ s/\(0x.+?\)/(0x...)/; |
698 | print $_, "\n"; |
699 | } |
700 | package Bar; |
701 | sub new { |
702 | my Bar $self = bless [], Bar; |
703 | eval '$self'; |
704 | return $self; |
705 | } |
706 | sub DESTROY { |
707 | push @dst, "$_[0]"; |
708 | } |
709 | EXPECT |
710 | Bar=ARRAY(0x...) |
1f96ff2a |
711 | ######## |
7c8c5f1c |
712 | ######## found by Markov chain stress testing |
1f96ff2a |
713 | eval "a.b.c.d.e.f;sub" |
714 | EXPECT |
c9beb3f5 |
715 | |
716 | ######## perlbug ID 20010831.001 |
717 | ($a, b) = (1, 2); |
718 | EXPECT |
719 | Can't modify constant item in list assignment at - line 1, near ");" |
720 | Execution of - aborted due to compilation errors. |
f8d0fd74 |
721 | ######## tying a bareword causes a segfault in 5.6.1 |
722 | tie FOO, "Foo"; |
723 | EXPECT |
724 | Can't modify constant item in tie at - line 1, near ""Foo";" |
725 | Execution of - aborted due to compilation errors. |
abfc75a9 |
726 | ######## undefing constant causes a segfault in 5.6.1 [ID 20010906.019] |
727 | undef foo; |
728 | EXPECT |
729 | Can't modify constant item in undef operator at - line 1, near "foo;" |
730 | Execution of - aborted due to compilation errors. |
8bfdd7d9 |
731 | ######## (?{...}) compilation bounces on PL_rs |
732 | -0 |
733 | { |
734 | /(?{ $x })/; |
735 | # { |
736 | } |
737 | BEGIN { print "ok\n" } |
738 | EXPECT |
739 | ok |
c74e71c7 |
740 | ######## read($var, FILE, 1) segfaults on 5.6.1 [ID 20011025.054] |
741 | read($bla, FILE, 1); |
742 | EXPECT |
743 | Can't modify constant item in read at - line 1, near "1)" |
744 | Execution of - aborted due to compilation errors. |
80071be7 |
745 | ######## scalar ref to file test operator segfaults on 5.6.1 [ID 20011127.155] |
746 | # This only happens if the filename is 11 characters or less. |
747 | $foo = \-f "blah"; |
748 | print "ok" if ref $foo && !$$foo; |
749 | EXPECT |
750 | ok |
15a59b2d |
751 | ######## [ID 20011128.159] 'X' =~ /\X/ segfault in 5.6.1 |
752 | print "ok" if 'X' =~ /\X/; |
753 | EXPECT |
754 | ok |
f9dc862f |
755 | ######## segfault in 5.6.1 within peep() |
756 | @a = (1..9); |
757 | @b = sort { @c = sort { @d = sort { 0 } @a; @d; } @a; } @a; |
758 | print join '', @a, "\n"; |
759 | EXPECT |
760 | 123456789 |
a6fc0784 |
761 | ######## [ID 20020104.007] "coredump on dbmclose" |
762 | package Foo; |
763 | eval { dbmclose %h }; # not all places have dbm* functions |
764 | if ($@) { |
765 | print "ok\n"; |
766 | exit 0; |
767 | } |
768 | package Foo; |
769 | sub new { |
770 | my $proto = shift; |
771 | my $class = ref($proto) || $proto; |
772 | my $self = {}; |
773 | bless($self,$class); |
774 | my %LT; |
775 | dbmopen(%LT, "dbmtest", 0666) || |
776 | die "Can't open dbmtest because of $!\n"; |
777 | $self->{'LT'} = \%LT; |
778 | return $self; |
779 | } |
780 | sub DESTROY { |
781 | my $self = shift; |
782 | dbmclose(%{$self->{'LT'}}); |
783 | return 1; |
784 | } |
785 | package main; |
786 | $test = Foo->new(); # must be package var |
787 | END |
788 | { |
26d793c1 |
789 | 1 while unlink 'dbmtest'; |
a6fc0784 |
790 | 1 while unlink <dbmtest.*>; |
791 | print "ok\n"; |
792 | } |
793 | EXPECT |
794 | ok |