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';
25 my $Is_MacOS = $^O eq 'MacOS';
27 my $path = join " ", map { qq["-I$_"] } @INC;
28 $path = '"-I../lib" "-Iperl_root:[lib]"' if $Is_VMS; # gets too long otherwise
29 my $redir = $Is_MacOS ? "" : "2>&1";
30 my $is_thread = $Config{use5005threads} && $Config{use5005threads} eq 'define';
33 ok "# use5005threads: test skipped\n";
35 $a = `$^X $path "-MO=Showlex" -e "my \@one" $redir`;
36 like ($a, qr/sv_undef.*PVNV.*\@one.*sv_undef.*AV/s,
37 "canonical usage works");
42 my ($na,$nb,$nc); # holds regex-strs
43 my ($out, $newlex); # output, option-flag
46 my ($varname,$newlex) = @_;
48 ? 'PVNV \(0x[0-9a-fA-F]+\) "\\'.$varname.'" = '
49 : "PVNV \\\(0x[0-9a-fA-F]+\\\) \\$varname\n";
52 for $newlex ('', '-newlex') {
54 $out = runperl ( switches => ["-MO=Showlex,$newlex"],
55 prog => 'my ($a,$b)', stderr => 1 );
56 $na = padrep('$a',$newlex);
57 $nb = padrep('$b',$newlex);
58 like ($out, qr/1: $na/ms, 'found $a in "my ($a,$b)"');
59 like ($out, qr/2: $nb/ms, 'found $b in "my ($a,$b)"');
61 print $out if $verbose;
64 skip "no perlio in this build", 5
65 unless $Config::Config{useperlio};
67 our $buf = 'arb startval';
68 my $ak = B::Showlex::walk_output (\$buf);
70 my $walker = B::Showlex::compile( $newlex, sub{my($foo,$bar)} );
72 $na = padrep('$foo',$newlex);
73 $nb = padrep('$bar',$newlex);
74 like ($buf, qr/1: $na/ms, 'found $foo in "sub { my ($foo,$bar) }"');
75 like ($buf, qr/2: $nb/ms, 'found $bar in "sub { my ($foo,$bar) }"');
77 print $buf if $verbose;
79 $ak = B::Showlex::walk_output (\$buf);
81 my $src = 'sub { my ($scalar,@arr,%hash) }';
83 $walker = B::Showlex::compile($sub);
85 $na = padrep('$scalar',$newlex);
86 $nb = padrep('@arr',$newlex);
87 $nc = padrep('%hash',$newlex);
88 like ($buf, qr/1: $na/ms, 'found $scalar in "'. $src .'"');
89 like ($buf, qr/2: $nb/ms, 'found @arr in "'. $src .'"');
90 like ($buf, qr/3: $nc/ms, 'found %hash in "'. $src .'"');
92 print $buf if $verbose;
94 # fibonacci function under test
100 for (my $i=2; $i<10; $i++) {
101 $fib[$i] = $fib[$i-2] + $fib[$i-1];
108 $walker = B::Showlex::compile($asub, $newlex, -nosp);
110 print $buf if $verbose;
112 $walker = B::Concise::compile($asub, '-exec');