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