6 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
7 print "1..0 # Skip -- Perl configured without B module\n";
21 my $verbose = @ARGV; # set if ANY ARGS
24 my $Is_VMS = $^O eq 'VMS';
26 my $path = join " ", map { qq["-I$_"] } @INC;
27 $path = '"-I../lib" "-Iperl_root:[lib]"' if $Is_VMS; # gets too long otherwise
28 my $is_thread = $Config{use5005threads} && $Config{use5005threads} eq 'define';
31 ok "# use5005threads: test skipped\n";
33 $a = `$^X $path "-MO=Showlex" -e "my \@one" 2>&1`;
34 like ($a, qr/sv_undef.*PVNV.*\@one.*Nullsv.*AV/s,
35 "canonical usage works");
40 my ($na,$nb,$nc); # holds regex-strs
41 my ($out, $newlex); # output, option-flag
44 my ($varname,$newlex) = @_;
46 ? 'PVNV \(0x[0-9a-fA-F]+\) "\\'.$varname.'" = '
47 : "PVNV \\\(0x[0-9a-fA-F]+\\\) \\$varname\n";
50 for $newlex ('', '-newlex') {
52 $out = runperl ( switches => ["-MO=Showlex,$newlex"],
53 prog => 'my ($a,$b)', stderr => 1 );
54 $na = padrep('$a',$newlex);
55 $nb = padrep('$b',$newlex);
56 like ($out, qr/1: $na/ms, 'found $a in "my ($a,$b)"');
57 like ($out, qr/2: $nb/ms, 'found $b in "my ($a,$b)"');
59 print $out if $verbose;
62 skip "no perlio in this build", 5
63 unless $Config::Config{useperlio};
65 our $buf = 'arb startval';
66 my $ak = B::Showlex::walk_output (\$buf);
68 my $walker = B::Showlex::compile( $newlex, sub{my($foo,$bar)} );
70 $na = padrep('$foo',$newlex);
71 $nb = padrep('$bar',$newlex);
72 like ($buf, qr/1: $na/ms, 'found $foo in "sub { my ($foo,$bar) }"');
73 like ($buf, qr/2: $nb/ms, 'found $bar in "sub { my ($foo,$bar) }"');
75 print $buf if $verbose;
77 $ak = B::Showlex::walk_output (\$buf);
79 my $src = 'sub { my ($scalar,@arr,%hash) }';
81 $walker = B::Showlex::compile($sub);
83 $na = padrep('$scalar',$newlex);
84 $nb = padrep('@arr',$newlex);
85 $nc = padrep('%hash',$newlex);
86 like ($buf, qr/1: $na/ms, 'found $scalar in "'. $src .'"');
87 like ($buf, qr/2: $nb/ms, 'found @arr in "'. $src .'"');
88 like ($buf, qr/3: $nc/ms, 'found %hash in "'. $src .'"');
90 print $buf if $verbose;
92 # fibonacci function under test
98 for (my $i=2; $i<10; $i++) {
99 $fib[$i] = $fib[$i-2] + $fib[$i-1];
106 $walker = B::Showlex::compile($asub, $newlex, -nosp);
108 print $buf if $verbose;
110 $walker = B::Concise::compile($asub, '-exec');