7 @INC = qw(: ::lib ::macos:lib);
17 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
18 print "1..0 # Skip -- Perl configured without B module\n";
32 my $verbose = @ARGV; # set if ANY ARGS
35 my $Is_VMS = $^O eq 'VMS';
36 my $Is_MacOS = $^O eq 'MacOS';
38 my $path = join " ", map { qq["-I$_"] } @INC;
39 $path = '"-I../lib" "-Iperl_root:[lib]"' if $Is_VMS; # gets too long otherwise
40 my $redir = $Is_MacOS ? "" : "2>&1";
41 my $is_thread = $Config{use5005threads} && $Config{use5005threads} eq 'define';
44 ok "# use5005threads: test skipped\n";
46 $a = `$^X $path "-MO=Showlex" -e "my \@one" $redir`;
47 like ($a, qr/sv_undef.*PVNV.*\@one.*sv_undef.*AV/s,
48 "canonical usage works");
53 my ($na,$nb,$nc); # holds regex-strs
54 my ($out, $newlex); # output, option-flag
57 my ($varname,$newlex) = @_;
59 ? 'PVNV \(0x[0-9a-fA-F]+\) "\\'.$varname.'" = '
60 : "PVNV \\\(0x[0-9a-fA-F]+\\\) \\$varname\n";
63 for $newlex ('', '-newlex') {
65 $out = runperl ( switches => ["-MO=Showlex,$newlex"],
66 prog => 'my ($a,$b)', stderr => 1 );
67 $na = padrep('$a',$newlex);
68 $nb = padrep('$b',$newlex);
69 like ($out, qr/1: $na/ms, 'found $a in "my ($a,$b)"');
70 like ($out, qr/2: $nb/ms, 'found $b in "my ($a,$b)"');
72 print $out if $verbose;
75 skip "no perlio in this build", 5
76 unless $Config::Config{useperlio};
78 our $buf = 'arb startval';
79 my $ak = B::Showlex::walk_output (\$buf);
81 my $walker = B::Showlex::compile( $newlex, sub{my($foo,$bar)} );
83 $na = padrep('$foo',$newlex);
84 $nb = padrep('$bar',$newlex);
85 like ($buf, qr/1: $na/ms, 'found $foo in "sub { my ($foo,$bar) }"');
86 like ($buf, qr/2: $nb/ms, 'found $bar in "sub { my ($foo,$bar) }"');
88 print $buf if $verbose;
90 $ak = B::Showlex::walk_output (\$buf);
92 my $src = 'sub { my ($scalar,@arr,%hash) }';
94 $walker = B::Showlex::compile($sub);
96 $na = padrep('$scalar',$newlex);
97 $nb = padrep('@arr',$newlex);
98 $nc = padrep('%hash',$newlex);
99 like ($buf, qr/1: $na/ms, 'found $scalar in "'. $src .'"');
100 like ($buf, qr/2: $nb/ms, 'found @arr in "'. $src .'"');
101 like ($buf, qr/3: $nc/ms, 'found %hash in "'. $src .'"');
103 print $buf if $verbose;
105 # fibonacci function under test
107 my ($self,%props)=@_;
111 for (my $i=2; $i<10; $i++) {
112 $fib[$i] = $fib[$i-2] + $fib[$i-1];
119 $walker = B::Showlex::compile($asub, $newlex, -nosp);
121 print $buf if $verbose;
123 $walker = B::Concise::compile($asub, '-exec');