fresh_perl.t revision 1
1N/A# ** DO NOT ADD ANY MORE TESTS HERE ** 1N/A# Instead, put the test in the appropriate test file and use the 1N/A# fresh_perl_is()/fresh_perl_like() functions in t/test.pl. 1N/A# This is for tests that used to abnormally cause segfaults, and other nasty 1N/A# errors that might kill the interpreter and for some reason you can't 1N/A chdir 't' if -d 't'; 1N/A if(m/^#{8,}\s*(.*)/) { 1N/A$a = ":="; split /($a)/o, "a:=b:=c"; print "@_" 1N/ACan't call method "go" on an undefined value at - line 1. 1N/A$x=0x0eabcd; print $x->ref; 1N/A$x=2;$y=3;$x<$y ? $x : $y += 23;print $x; 1N/Aeval 'sub bar {print "In bar"}'; 1N/Asub sub {local($_) = @_; 1N/Asub by_number { $a <=> $b; };# inline function for sort below 1N/A { print "TIEARRAY @_\n"; 1N/A sub FETCH { print "fetch @_\n"; $_[0]->[$_[1]] } 1N/A sub STORE { print "store @_\n"; $_[0]->[$_[1]] = $_[2] } 1N/Aeval 'tie @h, FAKEARRAY, fred' ; 1N/A "Out of inspiration"; 1N/A print "and destroyed as well\n"; 1N/A print FOO "sentence.", "reversed", "a", "is", "This"; 1N/Aand destroyed as well 1N/Amy @a; $a[2] = 1; for (@a) { $_ = 2 } print "@a\n" 1N/A# used to attach defelem magic to all immortal values, 1N/A# which made restore of local $_ fail. 1N/Asub foo { bar() for @_; } 1N/Asub bar { local $_; } 1N/A@a = ($a, $b, $c, $d) = (5, 6); 1N/A if ($a[0] == 5 and $a[1] == 6 and !defined $a[2] and !defined $a[3]); 1N/Aprint "ok\n" if (1E2<<1 == 200 and 3E4<<3 == 240000); 1N/Aprint "ok\n" if ("\0" lt "\xFF"); 1N/Aprint "ok\n" if (-e _ and -f _ and -r _); 1N/Asub thing { 0 || return qw(now is the time) } 1N/A{ local $main::{ren} = *stimpy; print $ren, ' ' } 1N/A{ local $main::{ren} = *stimpy; print ${'ren'}, ' ' } 1N/Asub func { print 'really ' unless wantarray; 'p' } 1N/Aprint p::func()->groovy(), "\n" 1N/Asub func { $num = shift; (grep $_->[1] == $num, @list)[0] } 1N/Aprint scalar(map &func($_), 1 .. 3), " ", 1N/A scalar(map scalar &func($_), 1 .. 3), "\n"; 1N/A@{$h{$k}} = qw(1 2 4); 1N/Afor (@{$h{$k}}) { $s += $_; delete $h{$k} if ($_ == 2) } 1N/Aprint "bogus\n" unless $s == 7; 1N/Aeval q[ my $a = 'inner'; eval q[ print "$a " ] ]; 1N/Aeval { my $x = 'peace'; eval q[ print "$x\n" ] } 1N/A eval 'sub foo { print "In foo2\n" }'; 1N/A print "Exiting foo1\n"; 1N/ASubroutine foo redefined at (eval 1) line 1. 1N/Amap {#this newline here tickles the bug 1N/Aprint "eat flaming death\n" unless ($s == 7); 1N/Asub foo { local $_ = shift; split; @_ } 1N/Aprint "you die joe!\n" unless "@x" eq 'x y z'; 1N/A/(?{"{"})/ # Check it outside of eval too 1N/ASequence (?{...}) not terminated or not {}-balanced in regex; marked by <-- HERE in m/(?{ <-- HERE "{"})/ at - line 1. 1N/A/(?{"{"}})/ # Check it outside of eval too 1N/AUnmatched right curly bracket at (re_eval 1) line 1, at end of line 1N/Asyntax error at (re_eval 1) line 1, near ""{"}" 1N/ACompilation failed in regexp at - line 1. 1N/ABEGIN { @ARGV = qw(a b c d e) } 1N/ABEGIN { print "argv <@ARGV>\nbegin <",shift,">\n" } 1N/AEND { print "end <",shift,">\nargv <@ARGV>\n" } 1N/AINIT { print "init <",shift,">\n" } 1N/ACHECK { print "check <",shift,">\n" } 1N/A# fdopen from a system descriptor to a system descriptor used to close 1N/Aselect STDOUT; $| = 1; print fileno STDOUT or die $!; 1N/Aselect STDERR; $| = 1; print fileno STDERR or die $!; 1N/Asub testme { my $a = "test"; { local $a = "new test"; print $a }} 1N/Amy $f = "FH000"; # just to thwart any future optimisations 1N/A$x = any X; # to bump sv_objcount. IO objs aren't counted?? 1N/A eval { print $_[0] }; 1N/A my $re = join '', eval 'qr/(??{ $obj->method })/'; 1N/A if ($x == 0) { print "" } else { print $x } 1N/Asub f { my $a = 1; my $b = 2; my $c = 3; my $d = 4; next } 1N/A{ f } continue { print $x, "\n" } 1N/A# lexicals declared after the myeval() definition should not be visible 1N/Amyeval('sub foo { local $foo = "ok 1\n"; print $foo; }'); 1N/A# lexicals outside an eval"" should be visible inside subroutine definitions 1N/A eval 'sub Y { print $X }'; die $@ if $@; 1N/A# the bug depends on in the internal state of the locale 1N/A# We need a "fresh run". 1N/A exit(0); # running minitest? 1N/A# Visual C's CRT goes silly on strings of the form "en_US.ISO8859-1" 1N/A# and mingw32 uses said silly CRT 1N/A next if $s eq '3.1 3.1' || $s =~ /^(3.+1) \1$/; 1N/A# [ID 20001202.002] and change #8066 added 'at -e line 1'; 1N/A# reversed again as a result of [perl #17763] 1N/A# 20001210.003 mjd@plover.com 1N/A# This loop causes a segv in 5.6.0 1N/A return eval "sub {shift=~/$pm/}"; 1N/Anew_pmop "abcdef"; reset; 1N/Anew_pmop "abcdef"; reset; 1N/Anew_pmop "abcdef"; reset; 1N/Anew_pmop "abcdef"; reset; 1N/A"x" =~ /(\G?x)?/; # core dump in 20000716.007 1N/A"abcd\x{1234}" =~ /(a)(b[c])(d+)?/i and print "ok\n"; 1N/Amy $foo = Bar->new(); 1N/A ($_ = "@dst") =~ s/\(0x.+?\)/(0x...)/; 1N/A my Bar $self = bless [], Bar; 1N/A######## (?{...}) compilation bounces on PL_rs 1N/ABEGIN { print "ok\n" } 1N/A######## scalar ref to file test operator segfaults on 5.6.1 [ID 20011127.155] 1N/A# This only happens if the filename is 11 characters or less. 1N/Aprint "ok" if ref $foo && !$$foo; 1N/A######## [ID 20011128.159] 'X' =~ /\X/ segfault in 5.6.1 1N/Aprint "ok" if 'X' =~ /\X/; 1N/A######## segfault in 5.6.1 within peep() 1N/A@b = sort { @c = sort { @d = sort { 0 } @a; @d; } @a; } @a; 1N/Aprint join '', @a, "\n"; 1N/A######## [ID 20020104.007] "coredump on dbmclose" 1N/Aeval { require AnyDBM_File }; # not all places have dbm* functions 1N/A my $class = ref($proto) || $proto; 1N/A bless($self,$class); 1N/A dbmopen(%LT, "dbmtest", 0666) || 1N/A 1 while unlink 'dbmtest'; 1N/A 1 while unlink <dbmtest.*>; 1N/A$test = Foo->new(); # must be package var 1N/A######## example from Camel 5, ch. 15, pp.406 (with my) 1N/A# SKIP: ord "A" == 193 # EBCDIC 1N/Amy $人 = 2; # 0xe4 0xba 0xba: U+4eba, "human" in CJK ideograph 1N/A$人++; # a child is born 1N/A######## example from Camel 5, ch. 15, pp.406 (with our) 1N/A# SKIP: ord "A" == 193 # EBCDIC 1N/Aour $人 = 2; # 0xe4 0xba 0xba: U+4eba, "human" in CJK ideograph 1N/A$人++; # a child is born 1N/A######## example from Camel 5, ch. 15, pp.406 (with package vars) 1N/A# SKIP: ord "A" == 193 # EBCDIC 1N/A$人 = 2; # 0xe4 0xba 0xba: U+4eba, "human" in CJK ideograph 1N/A$人++; # a child is born 1N/A######## example from Camel 5, ch. 15, pp.406 (with use vars) 1N/A# SKIP: ord "A" == 193 # EBCDIC 1N/A$人 = 2; # 0xe4 0xba 0xba: U+4eba, "human" in CJK ideograph 1N/A$人++; # a child is born 1N/A# test that closures generated by eval"" hold on to the CV of the eval"" 1N/A# for their entire lifetime 1N/A sub { eval '$x = "ok 1\n"'; } 1N/A######## [ID 20020623.009] nested eval/sub segfaults 1N/A$eval = eval 'sub { eval "sub { %S }" }'; 1N/A######## [perl #17951] Strange UTF error 1N/A# Subject: Strange UTF error 1N/A# Date: Fri, 11 Oct 2002 16:19:58 -0400 1N/A# Message-ID: <pan.2002.10.11.20.19.48.407190@mail630.gsfc.nasa.gov> 1N/Autf8::upgrade($_); # the original code used a UTF-8 locale (affects STDIN) 1N/A# matching is actually irrelevant: avoiding several dozen of these 1N/A######## [perl #20667] unicode regex vs non-unicode regex 1N/A$toto =~ /\w/; # this line provokes the problem! 1N/Aif ($name =~ /(\p{IsUpper}) (\p{IsUpper})/){ 1N/A print "It's good! >$1< >$2<\n"; 1N/A######## [perl #8760] strangness with utf8 and warn 1N/A$_="foo";utf8::upgrade($_);/bar/i,warn$_; 1N/A######## glob() bug Mon, 01 Sep 2003 02:25:41 -0700 <200309010925.h819Pf0X011457@smtp3.ActiveState.com> 1N/A eval 'require Fcntl'; 1N/A if ($@) { print qq[./"TEST"\n./"TEST"\n]; exit 0 } # running minitest? 1N/Aif ($^O eq 'VMS') { # VMS is not *that* kind of a glob. 1N/A######## glob() bug Mon, 01 Sep 2003 02:25:41 -0700 <200309010925.h819Pf0X011457@smtp3.ActiveState.com> 1N/A eval 'require Fcntl'; 1N/A if ($@) { print qq[./"TEST"\n./"TEST"\n]; exit 0 } # running minitest? 1N/Aif ($^O eq 'VMS') { # VMS is not *that* kind of a glob. 1N/A######## "Segfault using HTML::Entities", Richard Jolly <richardjolly@mac.com>, <A3C7D27E-C9F4-11D8-B294-003065AE00B6@mac.com> in perl-unicode@perl.org 1N/A eval 'require Encode'; 1N/A if ($@) { exit 0 } # running minitest? 1N/A# Test case cut down by jhi 1N/A$SIG{__WARN__} = sub { $@ = shift }; 1N/AEncode::_utf8_on($t); 1N/AMalformed UTF-8 character (unexpected end of string) at