develooper Front page | perl.perl5.porters | Postings from April 2000

[PATCH] t/lib/b.t

Thread Next
From:
simon.p.cozens
Date:
April 2, 2000 22:41
Subject:
[PATCH] t/lib/b.t
Message ID:
CA2568B6.001E953B.00@au-aapmta001.aap.pwcinternal.com
This appears not to have properly come through my dodgy Perl
sendmail, so I'm resending it through the even dodgier Lotus
Notes. Apologies if the original post hits you later.

Simon

Here are some tests for B:

#!./perl

BEGIN {
    chdir 't' if -d 't';
    unshift @INC, '../lib';
}

$|  = 1;
use warnings;
use strict;

print "1..10\n";

my $test = 1;

sub ok { print "ok $test\n"; $test++ }

use B::Deparse;
my $deparse = B::Deparse->new() or print "not ";
ok;

print "not " if "{\n    1;\n}" ne $deparse->coderef2text(sub {1});
ok;

print "not " if "{\n    '???';\n    2;\n}" ne
                    $deparse->coderef2text(sub {1;2});
ok;

print "not " if "{\n    \$test /= 2 if ++\$test;\n}" ne
                    $deparse->coderef2text(sub {++$test and $test/=2;});
ok;

my $a = `$^X -I../lib -MO=Deparse -anle 1 2>&1`;
$b = <<'EOF';

LINE: while (defined($_ = <ARGV>)) {
    chomp $_;
    @F = split(/\s+/, $_, 0);
    '???';
}

-e syntax OK
EOF
print "not " if $a ne $b;
ok;

$a = `$^X -I../lib -MO=Debug -e 1 2>&1`;
print "not " unless $a =~
/\bLISTOP\b.*\bOP\b.*\bCOP\b.*\bOP\b/s;
ok;

$a = `$^X -I../lib -MO=Terse -e 1 2>&1`;
print "not " unless $a =~
/\bLISTOP\b.*leave.*\bOP\b.*enter.*\bCOP\b.*nextstate.*\bOP\b.*null/s;
ok;

$a = `$^X -I../lib -MO=Terse -ane 's/foo/bar/' 2>&1`;
$a =~ s/\(0x[^)]+\)//g;
$a =~ s/\[[^\]]+\]//g;
$a =~ s/\s+/ /g;
$b = 'LISTOP leave OP enter COP nextstate label "LINE" BINOP leaveloop LOOP
'.
     'enterloop UNOP null LOGOP and UNOP defined UNOP null UNOP null SVOP
gvsv'.
     ' GV *_ UNOP readline SVOP gv GV *ARGV LISTOP lineseq COP nextstate
BINOP'.
     ' aassign UNOP null OP pushmark LISTOP split PMOP pushre /\s+/ UNOP
null '.
     'SVOP gvsv GV *_ SVOP const IV 0 UNOP null OP pushmark UNOP rv2av SVOP
'.
     'gv GV *F COP nextstate PMOP subst /foo/ SVOP const PV "bar" OP
unstack '.
     'COP nextstate -e syntax OK ';
# my @a = split //, $a; my @b = split //, $b;
# for (0..@a) { print "ch. $_ : |$a[$_]| vs. |$b[$_]|\n" if $a[$_] ne
$b[$_]}
print "not " if $a ne $b;
ok;

$a = `$^X -I../lib -MB::Stash -Mwarnings -e1`;
$b =
'-umain,-uattributes,-uDB,-uCwd,-uExporter,-uExporter::Heavy,-uwarnings,'
    ."-uCarp,-uCarp::Heavy\n";
print "not " if $a ne $b;
ok;

$a = `$^X -I../lib -MO=Showlex -e "my %one" 2>&1`;
print "not " unless $a =~ /sv_undef.*PVNV.*%one.*sv_undef.*HV/s;
ok;

----------------------------------------------------------------
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited.   If you received
 this in error, please contact the sender and delete the material from any
computer.



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About