This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix test introduced in #31973 that failed on Win32
[perl5.git] / ext / B / t / concise.t
index fa696e7..315e378 100644 (file)
@@ -17,7 +17,7 @@ BEGIN {
     sub diag { print "# @_\n" } # but this is still handy
 }
 
-plan tests => 149;
+plan tests => 156;
 
 require_ok("B::Concise");
 
@@ -138,7 +138,7 @@ sub render {
 
 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
@@ -204,7 +204,7 @@ SKIP: {
        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', \&not_even_declared);
@@ -386,5 +386,40 @@ $out = runperl ( switches => ["-MO=Concise,Config::AUTOLOAD"],
 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__