1N/A#!./perl
1N/A
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
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# use an eval().
1N/A
1N/ABEGIN {
1N/A chdir 't' if -d 't';
1N/A @INC = '../lib';
1N/A require './test.pl'; # for which_perl() etc
1N/A}
1N/A
1N/Ause strict;
1N/A
1N/Amy $Perl = which_perl();
1N/A
1N/A$|=1;
1N/A
1N/Amy @prgs = ();
1N/Awhile(<DATA>) {
1N/A if(m/^#{8,}\s*(.*)/) {
1N/A push @prgs, ['', $1];
1N/A }
1N/A else {
1N/A $prgs[-1][0] .= $_;
1N/A }
1N/A}
1N/Aplan tests => scalar @prgs;
1N/A
1N/Aforeach my $prog (@prgs) {
1N/A my($raw_prog, $name) = @$prog;
1N/A
1N/A my $switch;
1N/A if ($raw_prog =~ s/^\s*(-\w.*)//){
1N/A $switch = $1;
1N/A }
1N/A
1N/A my($prog,$expected) = split(/\nEXPECT\n/, $raw_prog);
1N/A
1N/A if ($prog =~ /^\# SKIP: (.+)/m) {
1N/A if (eval $1) {
1N/A ok(1, "Skip: $1");
1N/A next;
1N/A }
1N/A }
1N/A
1N/A $expected =~ s/\n+$//;
1N/A
1N/A fresh_perl_is($prog, $expected, { switches => [$switch] }, $name);
1N/A}
1N/A
1N/A__END__
1N/A########
1N/A$a = ":="; split /($a)/o, "a:=b:=c"; print "@_"
1N/AEXPECT
1N/Aa := b := c
1N/A########
1N/A$cusp = ~0 ^ (~0 >> 1);
1N/Ause integer;
1N/A$, = " ";
1N/Aprint +($cusp - 1) % 8, $cusp % 8, -$cusp % 8, 8 | (($cusp + 1) % 8 + 7), "!\n";
1N/AEXPECT
1N/A7 0 0 8 !
1N/A########
1N/A$foo=undef; $foo->go;
1N/AEXPECT
1N/ACan't call method "go" on an undefined value at - line 1.
1N/A########
1N/ABEGIN
1N/A {
1N/A "foo";
1N/A }
1N/A########
1N/A$array[128]=1
1N/A########
1N/A$x=0x0eabcd; print $x->ref;
1N/AEXPECT
1N/ACan't call method "ref" without a package or object reference at - line 1.
1N/A########
1N/Achop ($str .= <DATA>);
1N/A########
1N/Aclose ($banana);
1N/A########
1N/A$x=2;$y=3;$x<$y ? $x : $y += 23;print $x;
1N/AEXPECT
1N/A25
1N/A########
1N/Aeval 'sub bar {print "In bar"}';
1N/A########
1N/Asystem './perl -ne "print if eof" /dev/null' unless $^O eq 'MacOS'
1N/A########
1N/Achop($file = <DATA>);
1N/A########
1N/Apackage N;
1N/Asub new {my ($obj,$n)=@_; bless \$n}
1N/A$aa=new N 1;
1N/A$aa=12345;
1N/Aprint $aa;
1N/AEXPECT
1N/A12345
1N/A########
1N/A$_="foo";
1N/Aprintf(STDOUT "%s\n", $_);
1N/AEXPECT
1N/Afoo
1N/A########
1N/Apush(@a, 1, 2, 3,)
1N/A########
1N/Aquotemeta ""
1N/A########
1N/Afor ("ABCDE") {
1N/A &sub;
1N/As/./&sub($&)/eg;
1N/Aprint;}
1N/Asub sub {local($_) = @_;
1N/A$_ x 4;}
1N/AEXPECT
1N/AModification of a read-only value attempted at - line 3.
1N/A########
1N/Apackage FOO;sub new {bless {FOO => BAR}};
1N/Apackage main;
1N/Ause strict vars;
1N/Amy $self = new FOO;
1N/Aprint $$self{FOO};
1N/AEXPECT
1N/ABAR
1N/A########
1N/A$_="foo";
1N/As/.{1}//s;
1N/Aprint;
1N/AEXPECT
1N/Aoo
1N/A########
1N/Aprint scalar ("foo","bar")
1N/AEXPECT
1N/Abar
1N/A########
1N/Asub by_number { $a <=> $b; };# inline function for sort below
1N/A$as_ary{0}="a0";
1N/A@ordered_array=sort by_number keys(%as_ary);
1N/A########
1N/Asub NewShell
1N/A{
1N/A local($Host) = @_;
1N/A my($m2) = $#Shells++;
1N/A $Shells[$m2]{HOST} = $Host;
1N/A return $m2;
1N/A}
1N/A
1N/Asub ShowShell
1N/A{
1N/A local($i) = @_;
1N/A}
1N/A
1N/A&ShowShell(&NewShell(beach,Work,"+0+0"));
1N/A&ShowShell(&NewShell(beach,Work,"+0+0"));
1N/A&ShowShell(&NewShell(beach,Work,"+0+0"));
1N/A########
1N/A {
1N/A package FAKEARRAY;
1N/A
1N/A sub TIEARRAY
1N/A { print "TIEARRAY @_\n";
1N/A die "bomb out\n" unless $count ++ ;
1N/A bless ['foo']
1N/A }
1N/A sub FETCH { print "fetch @_\n"; $_[0]->[$_[1]] }
1N/A sub STORE { print "store @_\n"; $_[0]->[$_[1]] = $_[2] }
1N/A sub DESTROY { print "DESTROY \n"; undef @{$_[0]}; }
1N/A }
1N/A
1N/Aeval 'tie @h, FAKEARRAY, fred' ;
1N/Atie @h, FAKEARRAY, fred ;
1N/AEXPECT
1N/ATIEARRAY FAKEARRAY fred
1N/ATIEARRAY FAKEARRAY fred
1N/ADESTROY
1N/A########
1N/ABEGIN { die "phooey\n" }
1N/AEXPECT
1N/Aphooey
1N/ABEGIN failed--compilation aborted at - line 1.
1N/A########
1N/ABEGIN { 1/$zero }
1N/AEXPECT
1N/AIllegal division by zero at - line 1.
1N/ABEGIN failed--compilation aborted at - line 1.
1N/A########
1N/ABEGIN { undef = 0 }
1N/AEXPECT
1N/AModification of a read-only value attempted at - line 1.
1N/ABEGIN failed--compilation aborted at - line 1.
1N/A########
1N/A{
1N/A package foo;
1N/A sub PRINT {
1N/A shift;
1N/A print join(' ', reverse @_)."\n";
1N/A }
1N/A sub PRINTF {
1N/A shift;
1N/A my $fmt = shift;
1N/A print sprintf($fmt, @_)."\n";
1N/A }
1N/A sub TIEHANDLE {
1N/A bless {}, shift;
1N/A }
1N/A sub READLINE {
1N/A "Out of inspiration";
1N/A }
1N/A sub DESTROY {
1N/A print "and destroyed as well\n";
1N/A }
1N/A sub READ {
1N/A shift;
1N/A print STDOUT "foo->can(READ)(@_)\n";
1N/A return 100;
1N/A }
1N/A sub GETC {
1N/A shift;
1N/A print STDOUT "Don't GETC, Get Perl\n";
1N/A return "a";
1N/A }
1N/A}
1N/A{
1N/A local(*FOO);
1N/A tie(*FOO,'foo');
1N/A print FOO "sentence.", "reversed", "a", "is", "This";
1N/A print "-- ", <FOO>, " --\n";
1N/A my($buf,$len,$offset);
1N/A $buf = "string";
1N/A $len = 10; $offset = 1;
1N/A read(FOO, $buf, $len, $offset) == 100 or die "foo->READ failed";
1N/A getc(FOO) eq "a" or die "foo->GETC failed";
1N/A printf "%s is number %d\n", "Perl", 1;
1N/A}
1N/AEXPECT
1N/AThis is a reversed sentence.
1N/A-- Out of inspiration --
1N/Afoo->can(READ)(string 10 1)
1N/ADon't GETC, Get Perl
1N/APerl is number 1
1N/Aand destroyed as well
1N/A########
1N/Amy @a; $a[2] = 1; for (@a) { $_ = 2 } print "@a\n"
1N/AEXPECT
1N/A2 2 2
1N/A########
1N/A# used to attach defelem magic to all immortal values,
1N/A# which made restore of local $_ fail.
1N/Afoo(2>1);
1N/Asub foo { bar() for @_; }
1N/Asub bar { local $_; }
1N/Aprint "ok\n";
1N/AEXPECT
1N/Aok
1N/A########
1N/A@a = ($a, $b, $c, $d) = (5, 6);
1N/Aprint "ok\n"
1N/A if ($a[0] == 5 and $a[1] == 6 and !defined $a[2] and !defined $a[3]);
1N/AEXPECT
1N/Aok
1N/A########
1N/Aprint "ok\n" if (1E2<<1 == 200 and 3E4<<3 == 240000);
1N/AEXPECT
1N/Aok
1N/A########
1N/Aprint "ok\n" if ("\0" lt "\xFF");
1N/AEXPECT
1N/Aok
1N/A########
1N/Aopen(H,$^O eq 'MacOS' ? ':run:fresh_perl.t' : 'run/fresh_perl.t'); # must be in the 't' directory
1N/Astat(H);
1N/Aprint "ok\n" if (-e _ and -f _ and -r _);
1N/AEXPECT
1N/Aok
1N/A########
1N/Asub thing { 0 || return qw(now is the time) }
1N/Aprint thing(), "\n";
1N/AEXPECT
1N/Anowisthetime
1N/A########
1N/A$ren = 'joy';
1N/A$stimpy = 'happy';
1N/A{ local $main::{ren} = *stimpy; print $ren, ' ' }
1N/Aprint $ren, "\n";
1N/AEXPECT
1N/Ahappy joy
1N/A########
1N/A$stimpy = 'happy';
1N/A{ local $main::{ren} = *stimpy; print ${'ren'}, ' ' }
1N/Aprint +(defined(${'ren'}) ? 'oops' : 'joy'), "\n";
1N/AEXPECT
1N/Ahappy joy
1N/A########
1N/Apackage p;
1N/Asub func { print 'really ' unless wantarray; 'p' }
1N/Asub groovy { 'groovy' }
1N/Apackage main;
1N/Aprint p::func()->groovy(), "\n"
1N/AEXPECT
1N/Areally groovy
1N/A########
1N/A@list = ([ 'one', 1 ], [ 'two', 2 ]);
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/AEXPECT
1N/A2 3
1N/A########
1N/A($k, $s) = qw(x 0);
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/A########
1N/Amy $a = 'outer';
1N/Aeval q[ my $a = 'inner'; eval q[ print "$a " ] ];
1N/Aeval { my $x = 'peace'; eval q[ print "$x\n" ] }
1N/AEXPECT
1N/Ainner peace
1N/A########
1N/A-w
1N/A$| = 1;
1N/Asub foo {
1N/A print "In foo1\n";
1N/A eval 'sub foo { print "In foo2\n" }';
1N/A print "Exiting foo1\n";
1N/A}
1N/Afoo;
1N/Afoo;
1N/AEXPECT
1N/AIn foo1
1N/ASubroutine foo redefined at (eval 1) line 1.
1N/AExiting foo1
1N/AIn foo2
1N/A########
1N/A$s = 0;
1N/Amap {#this newline here tickles the bug
1N/A$s += $_} (1,2,4);
1N/Aprint "eat flaming death\n" unless ($s == 7);
1N/A########
1N/Asub foo { local $_ = shift; split; @_ }
1N/A@x = foo(' x y z ');
1N/Aprint "you die joe!\n" unless "@x" eq 'x y z';
1N/A########
1N/A/(?{"{"})/ # Check it outside of eval too
1N/AEXPECT
1N/ASequence (?{...}) not terminated or not {}-balanced in regex; marked by <-- HERE in m/(?{ <-- HERE "{"})/ at - line 1.
1N/A########
1N/A/(?{"{"}})/ # Check it outside of eval too
1N/AEXPECT
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/A########
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/AEXPECT
1N/Aargv <a b c d e>
1N/Abegin <a>
1N/Acheck <b>
1N/Ainit <c>
1N/Aend <d>
1N/Aargv <e>
1N/A########
1N/A-l
1N/A# fdopen from a system descriptor to a system descriptor used to close
1N/A# the former.
1N/Aopen STDERR, '>&=STDOUT' or die $!;
1N/Aselect STDOUT; $| = 1; print fileno STDOUT or die $!;
1N/Aselect STDERR; $| = 1; print fileno STDERR or die $!;
1N/AEXPECT
1N/A1
1N/A2
1N/A########
1N/A-w
1N/Asub testme { my $a = "test"; { local $a = "new test"; print $a }}
1N/AEXPECT
1N/ACan't localize lexical variable $a at - line 2.
1N/A########
1N/Apackage X;
1N/Asub ascalar { my $r; bless \$r }
1N/Asub DESTROY { print "destroyed\n" };
1N/Apackage main;
1N/A*s = ascalar X;
1N/AEXPECT
1N/Adestroyed
1N/A########
1N/Apackage X;
1N/Asub anarray { bless [] }
1N/Asub DESTROY { print "destroyed\n" };
1N/Apackage main;
1N/A*a = anarray X;
1N/AEXPECT
1N/Adestroyed
1N/A########
1N/Apackage X;
1N/Asub ahash { bless {} }
1N/Asub DESTROY { print "destroyed\n" };
1N/Apackage main;
1N/A*h = ahash X;
1N/AEXPECT
1N/Adestroyed
1N/A########
1N/Apackage X;
1N/Asub aclosure { my $x; bless sub { ++$x } }
1N/Asub DESTROY { print "destroyed\n" };
1N/Apackage main;
1N/A*c = aclosure X;
1N/AEXPECT
1N/Adestroyed
1N/A########
1N/Apackage X;
1N/Asub any { bless {} }
1N/Amy $f = "FH000"; # just to thwart any future optimisations
1N/Asub afh { select select ++$f; my $r = *{$f}{IO}; delete $X::{$f}; bless $r }
1N/Asub DESTROY { print "destroyed\n" }
1N/Apackage main;
1N/A$x = any X; # to bump sv_objcount. IO objs aren't counted??
1N/A*f = afh X;
1N/AEXPECT
1N/Adestroyed
1N/Adestroyed
1N/A########
1N/ABEGIN {
1N/A $| = 1;
1N/A $SIG{__WARN__} = sub {
1N/A eval { print $_[0] };
1N/A die "bar\n";
1N/A };
1N/A warn "foo\n";
1N/A}
1N/AEXPECT
1N/Afoo
1N/Abar
1N/ABEGIN failed--compilation aborted at - line 8.
1N/A########
1N/Apackage X;
1N/A@ISA='Y';
1N/Asub new {
1N/A my $class = shift;
1N/A my $self = { };
1N/A bless $self, $class;
1N/A my $init = shift;
1N/A $self->foo($init);
1N/A print "new", $init;
1N/A return $self;
1N/A}
1N/Asub DESTROY {
1N/A my $self = shift;
1N/A print "DESTROY", $self->foo;
1N/A}
1N/Apackage Y;
1N/Asub attribute {
1N/A my $self = shift;
1N/A my $var = shift;
1N/A if (@_ == 0) {
1N/A return $self->{$var};
1N/A } elsif (@_ == 1) {
1N/A $self->{$var} = shift;
1N/A }
1N/A}
1N/Asub AUTOLOAD {
1N/A $AUTOLOAD =~ /::([^:]+)$/;
1N/A my $method = $1;
1N/A splice @_, 1, 0, $method;
1N/A goto &attribute;
1N/A}
1N/Apackage main;
1N/Amy $x = X->new(1);
1N/Afor (2..3) {
1N/A my $y = X->new($_);
1N/A print $y->foo;
1N/A}
1N/Aprint $x->foo;
1N/AEXPECT
1N/Anew1new22DESTROY2new33DESTROY31DESTROY1
1N/A########
1N/Are();
1N/Asub re {
1N/A my $re = join '', eval 'qr/(??{ $obj->method })/';
1N/A $re;
1N/A}
1N/AEXPECT
1N/A########
1N/Ause strict;
1N/Amy $foo = "ZZZ\n";
1N/AEND { print $foo }
1N/AEXPECT
1N/AZZZ
1N/A########
1N/Aeval '
1N/Ause strict;
1N/Amy $foo = "ZZZ\n";
1N/AEND { print $foo }
1N/A';
1N/AEXPECT
1N/AZZZ
1N/A########
1N/A-w
1N/Aif (@ARGV) { print "" }
1N/Aelse {
1N/A if ($x == 0) { print "" } else { print $x }
1N/A}
1N/AEXPECT
1N/AUse of uninitialized value in numeric eq (==) at - line 4.
1N/A########
1N/A$x = sub {};
1N/Afoo();
1N/Asub foo { eval { return }; }
1N/Aprint "ok\n";
1N/AEXPECT
1N/Aok
1N/A########
1N/A# moved to op/lc.t
1N/AEXPECT
1N/A########
1N/Asub f { my $a = 1; my $b = 2; my $c = 3; my $d = 4; next }
1N/Amy $x = "foo";
1N/A{ f } continue { print $x, "\n" }
1N/AEXPECT
1N/Afoo
1N/A########
1N/Asub C () { 1 }
1N/Asub M { $_[0] = 2; }
1N/Aeval "C";
1N/AM(C);
1N/AEXPECT
1N/AModification of a read-only value attempted at - line 2.
1N/A########
1N/Aprint qw(ab a\b a\\b);
1N/AEXPECT
1N/Aaba\ba\b
1N/A########
1N/A# lexicals declared after the myeval() definition should not be visible
1N/A# within it
1N/Asub myeval { eval $_[0] }
1N/Amy $foo = "ok 2\n";
1N/Amyeval('sub foo { local $foo = "ok 1\n"; print $foo; }');
1N/Adie $@ if $@;
1N/Afoo();
1N/Aprint $foo;
1N/AEXPECT
1N/Aok 1
1N/Aok 2
1N/A########
1N/A# lexicals outside an eval"" should be visible inside subroutine definitions
1N/A# within it
1N/Aeval <<'EOT'; die $@ if $@;
1N/A{
1N/A my $X = "ok\n";
1N/A eval 'sub Y { print $X }'; die $@ if $@;
1N/A Y();
1N/A}
1N/AEOT
1N/AEXPECT
1N/Aok
1N/A########
1N/A# This test is here instead of lib/locale.t because
1N/A# the bug depends on in the internal state of the locale
1N/A# settings and pragma/locale messes up that state pretty badly.
1N/A# We need a "fresh run".
1N/ABEGIN {
1N/A eval { require POSIX };
1N/A if ($@) {
1N/A exit(0); # running minitest?
1N/A }
1N/A}
1N/Ause Config;
1N/Amy $have_setlocale = $Config{d_setlocale} eq 'define';
1N/A$have_setlocale = 0 if $@;
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$have_setlocale = 0 if (($^O eq 'MSWin32' || $^O eq 'NetWare') && $Config{cc} =~ /^(cl|gcc)/i);
1N/Aexit(0) unless $have_setlocale;
1N/Amy @locales;
1N/Aif (-x "/usr/bin/locale" && open(LOCALES, "/usr/bin/locale -a 2>/dev/null|")) {
1N/A while(<LOCALES>) {
1N/A chomp;
1N/A push(@locales, $_);
1N/A }
1N/A close(LOCALES);
1N/A}
1N/Aexit(0) unless @locales;
1N/Afor (@locales) {
1N/A use POSIX qw(locale_h);
1N/A use locale;
1N/A setlocale(LC_NUMERIC, $_) or next;
1N/A my $s = sprintf "%g %g", 3.1, 3.1;
1N/A next if $s eq '3.1 3.1' || $s =~ /^(3.+1) \1$/;
1N/A print "$_ $s\n";
1N/A}
1N/AEXPECT
1N/A########
1N/A# [ID 20001202.002] and change #8066 added 'at -e line 1';
1N/A# reversed again as a result of [perl #17763]
1N/Adie qr(x)
1N/AEXPECT
1N/A(?-xism:x)
1N/A########
1N/A# 20001210.003 mjd@plover.com
1N/Aformat REMITOUT_TOP =
1N/AFOO
1N/A.
1N/A
1N/Aformat REMITOUT =
1N/ABAR
1N/A.
1N/A
1N/A# This loop causes a segv in 5.6.0
1N/Afor $lineno (1..61) {
1N/A write REMITOUT;
1N/A}
1N/A
1N/Aprint "It's OK!";
1N/AEXPECT
1N/AIt's OK!
1N/A########
1N/A# Inaba Hiroto
1N/Areset;
1N/Aif (0) {
1N/A if ("" =~ //) {
1N/A }
1N/A}
1N/A########
1N/A# Nicholas Clark
1N/A$ENV{TERM} = 0;
1N/Areset;
1N/A// if 0;
1N/A########
1N/A# Vadim Konovalov
1N/Ause strict;
1N/Asub new_pmop($) {
1N/A my $pm = shift;
1N/A return eval "sub {shift=~/$pm/}";
1N/A}
1N/Anew_pmop "abcdef"; reset;
1N/Anew_pmop "abcdef"; reset;
1N/Anew_pmop "abcdef"; reset;
1N/Anew_pmop "abcdef"; reset;
1N/A########
1N/A# David Dyck
1N/A# coredump in 5.7.1
1N/Aclose STDERR; die;
1N/AEXPECT
1N/A########
1N/A-w
1N/A"x" =~ /(\G?x)?/; # core dump in 20000716.007
1N/A########
1N/A# Bug 20010515.004
1N/Amy @h = 1 .. 10;
1N/Abad(@h);
1N/Asub bad {
1N/A undef @h;
1N/A print "O";
1N/A print for @_;
1N/A print "K";
1N/A}
1N/AEXPECT
1N/AOK
1N/A########
1N/A# Bug 20010506.041
1N/A"abcd\x{1234}" =~ /(a)(b[c])(d+)?/i and print "ok\n";
1N/AEXPECT
1N/Aok
1N/A########
1N/Amy $foo = Bar->new();
1N/Amy @dst;
1N/AEND {
1N/A ($_ = "@dst") =~ s/\(0x.+?\)/(0x...)/;
1N/A print $_, "\n";
1N/A}
1N/Apackage Bar;
1N/Asub new {
1N/A my Bar $self = bless [], Bar;
1N/A eval '$self';
1N/A return $self;
1N/A}
1N/Asub DESTROY {
1N/A push @dst, "$_[0]";
1N/A}
1N/AEXPECT
1N/ABar=ARRAY(0x...)
1N/A######## (?{...}) compilation bounces on PL_rs
1N/A-0
1N/A{
1N/A /(?{ $x })/;
1N/A # {
1N/A}
1N/ABEGIN { print "ok\n" }
1N/AEXPECT
1N/Aok
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/A$foo = \-f "blah";
1N/Aprint "ok" if ref $foo && !$$foo;
1N/AEXPECT
1N/Aok
1N/A######## [ID 20011128.159] 'X' =~ /\X/ segfault in 5.6.1
1N/Aprint "ok" if 'X' =~ /\X/;
1N/AEXPECT
1N/Aok
1N/A######## segfault in 5.6.1 within peep()
1N/A@a = (1..9);
1N/A@b = sort { @c = sort { @d = sort { 0 } @a; @d; } @a; } @a;
1N/Aprint join '', @a, "\n";
1N/AEXPECT
1N/A123456789
1N/A######## [ID 20020104.007] "coredump on dbmclose"
1N/Apackage Foo;
1N/Aeval { require AnyDBM_File }; # not all places have dbm* functions
1N/Aif ($@) {
1N/A print "ok\n";
1N/A exit 0;
1N/A}
1N/Apackage Foo;
1N/Asub new {
1N/A my $proto = shift;
1N/A my $class = ref($proto) || $proto;
1N/A my $self = {};
1N/A bless($self,$class);
1N/A my %LT;
1N/A dbmopen(%LT, "dbmtest", 0666) ||
1N/A die "Can't open dbmtest because of $!\n";
1N/A $self->{'LT'} = \%LT;
1N/A return $self;
1N/A}
1N/Asub DESTROY {
1N/A my $self = shift;
1N/A dbmclose(%{$self->{'LT'}});
1N/A 1 while unlink 'dbmtest';
1N/A 1 while unlink <dbmtest.*>;
1N/A print "ok\n";
1N/A}
1N/Apackage main;
1N/A$test = Foo->new(); # must be package var
1N/AEXPECT
1N/Aok
1N/A######## example from Camel 5, ch. 15, pp.406 (with my)
1N/A# SKIP: ord "A" == 193 # EBCDIC
1N/Ause strict;
1N/Ause utf8;
1N/Amy $人 = 2; # 0xe4 0xba 0xba: U+4eba, "human" in CJK ideograph
1N/A$人++; # a child is born
1N/Aprint $人, "\n";
1N/AEXPECT
1N/A3
1N/A######## example from Camel 5, ch. 15, pp.406 (with our)
1N/A# SKIP: ord "A" == 193 # EBCDIC
1N/Ause strict;
1N/Ause utf8;
1N/Aour $人 = 2; # 0xe4 0xba 0xba: U+4eba, "human" in CJK ideograph
1N/A$人++; # a child is born
1N/Aprint $人, "\n";
1N/AEXPECT
1N/A3
1N/A######## example from Camel 5, ch. 15, pp.406 (with package vars)
1N/A# SKIP: ord "A" == 193 # EBCDIC
1N/Ause utf8;
1N/A$人 = 2; # 0xe4 0xba 0xba: U+4eba, "human" in CJK ideograph
1N/A$人++; # a child is born
1N/Aprint $人, "\n";
1N/AEXPECT
1N/A3
1N/A######## example from Camel 5, ch. 15, pp.406 (with use vars)
1N/A# SKIP: ord "A" == 193 # EBCDIC
1N/Ause strict;
1N/Ause utf8;
1N/Ause vars qw($人);
1N/A$人 = 2; # 0xe4 0xba 0xba: U+4eba, "human" in CJK ideograph
1N/A$人++; # a child is born
1N/Aprint $人, "\n";
1N/AEXPECT
1N/A3
1N/A########
1N/A# test that closures generated by eval"" hold on to the CV of the eval""
1N/A# for their entire lifetime
1N/A$code = eval q[
1N/A sub { eval '$x = "ok 1\n"'; }
1N/A];
1N/A&{$code}();
1N/Aprint $x;
1N/AEXPECT
1N/Aok 1
1N/A######## [ID 20020623.009] nested eval/sub segfaults
1N/A$eval = eval 'sub { eval "sub { %S }" }';
1N/A$eval->({});
1N/A######## [perl #17951] Strange UTF error
1N/A-W
1N/A# From: "John Kodis" <kodis@mail630.gsfc.nasa.gov>
1N/A# Newsgroups: comp.lang.perl.moderated
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/A$_ = "foobar\n";
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# Illegal hexadecimal digit ' ' ignored at /usr/lib/perl5/5.8.0/utf8_heavy.pl line 152
1N/A# is what matters.
1N/A/^([[:digit:]]+)/;
1N/AEXPECT
1N/A######## [perl #20667] unicode regex vs non-unicode regex
1N/A$toto = 'Hello';
1N/A$toto =~ /\w/; # this line provokes the problem!
1N/A$name = 'A B';
1N/A# utf8::upgrade($name) if @ARGV;
1N/Aif ($name =~ /(\p{IsUpper}) (\p{IsUpper})/){
1N/A print "It's good! >$1< >$2<\n";
1N/A} else {
1N/A print "It's not good...\n";
1N/A}
1N/AEXPECT
1N/AIt's good! >A< >B<
1N/A######## [perl #8760] strangness with utf8 and warn
1N/A$_="foo";utf8::upgrade($_);/bar/i,warn$_;
1N/AEXPECT
1N/Afoo at - line 1.
1N/A######## glob() bug Mon, 01 Sep 2003 02:25:41 -0700 <200309010925.h819Pf0X011457@smtp3.ActiveState.com>
1N/A-lw
1N/ABEGIN {
1N/A eval 'require Fcntl';
1N/A if ($@) { print qq[./"TEST"\n./"TEST"\n]; exit 0 } # running minitest?
1N/A}
1N/Aif ($^O eq 'VMS') { # VMS is not *that* kind of a glob.
1N/Aprint qq[./"TEST"\n./"TEST"\n];
1N/A} else {
1N/Aprint glob(q(./"TEST"));
1N/Ause File::Glob;
1N/Aprint glob(q(./"TEST"));
1N/A}
1N/AEXPECT
1N/A./"TEST"
1N/A./"TEST"
1N/A######## glob() bug Mon, 01 Sep 2003 02:25:41 -0700 <200309010925.h819Pf0X011457@smtp3.ActiveState.com>
1N/A-lw
1N/ABEGIN {
1N/A eval 'require Fcntl';
1N/A if ($@) { print qq[./"TEST"\n./"TEST"\n]; exit 0 } # running minitest?
1N/A}
1N/Aif ($^O eq 'VMS') { # VMS is not *that* kind of a glob.
1N/Aprint qq[./"TEST"\n./"TEST"\n];
1N/A} else {
1N/Ause File::Glob;
1N/Aprint glob(q(./"TEST"));
1N/Ause File::Glob;
1N/Aprint glob(q(./"TEST"));
1N/A}
1N/AEXPECT
1N/A./"TEST"
1N/A./"TEST"
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-lw
1N/ABEGIN {
1N/A eval 'require Encode';
1N/A if ($@) { exit 0 } # running minitest?
1N/A}
1N/A# Test case cut down by jhi
1N/A$SIG{__WARN__} = sub { $@ = shift };
1N/Ause Encode;
1N/Amy $t = "\xE9";
1N/AEncode::_utf8_on($t);
1N/A$t =~ s/([^a])//ge;
1N/A$@ =~ s/ at .*/ at/;
1N/Aprint $@
1N/AEXPECT
1N/AMalformed UTF-8 character (unexpected end of string) at