sub diag { print "# @_\n" } # but this is still handy
}
-plan tests => 149;
+plan tests => 156;
require_ok("B::Concise");
SKIP: {
# tests output to GLOB, using perlio feature directly
- skip "no perlio on this build", 122
+ skip "no perlio on this build", 127
unless $Config::Config{useperlio};
set_style_standard('concise'); # MUST CALL before output needed
is(scalar split(/\n/, $res), 3,
"'sub defd_empty {}' seen as 3 liner");
- is(1, $res =~ /leavesub/ && $res =~ /nextstate/,
+ is(1, $res =~ /leavesub/ && $res =~ /(next|db)state/,
"'sub defd_empty {}' seen as 2 ops: leavesub,nextstate");
($res,$err) = render('-basic', \¬_even_declared);
like($out, qr/Config::AUTOLOAD exists in stash, but has no START/,
"coderef properly undefined");
-__END__
+# test -stash and -src rendering
+# todo: stderr=1 puts '-e syntax OK' into $out,
+# conceivably fouling one of the lines that are tested
+$out = runperl ( switches => ["-MO=Concise,-stash=B::Concise,-src"],
+ prog => '-e 1', stderr => 1 );
+
+like($out, qr/FUNC: \*B::Concise::concise_cv_obj/,
+ "stash rendering of B::Concise includes Concise::concise_cv_obj");
+
+like($out, qr/FUNC: \*B::Concise::walk_output/,
+ "stash rendering includes Concise::walk_output");
+
+like($out, qr/FUNC: \*B::Concise::PAD_FAKELEX_MULTI/,
+ "stash rendering includes constant sub: PAD_FAKELEX_MULTI");
+
+like($out, qr/PAD_FAKELEX_MULTI is a constant sub, optimized to a IV/,
+ "stash rendering identifies it as constant");
+
+like($out, qr/\# 4\d\d: \s+ \$l->concise\(\$level\);/,
+ "src-line rendering works");
+$out = runperl ( switches => ["-MO=Concise,-stash=Data::Dumper,-src,-exec"],
+ prog => '-e 1', stderr => 1 );
+
+like($out, qr/FUNC: \*Data::Dumper::format_refaddr/,
+ "stash rendering loads package as needed");
+
+my $prog = q{package FOO; sub bar { print "bar" } package main; FOO::bar(); };
+
+# this would fail if %INC used for -stash test
+$out = runperl ( switches => ["-MO=Concise,-src,-stash=FOO,-main"],
+ prog => $prog, stderr => 1 );
+
+like($out, qr/FUNC: \*FOO::bar/,
+ "stash rendering works on inlined package");
+
+__END__