From: Graham Knop <haarg@haarg.org>
Date: Mon, 3 Oct 2016 23:26:34 +0000 (-0400)
Subject: better diagnostics for bad %DB::sub entries
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=99a530d939a559a2592fb9b5a00a96cf44b4e448;p=p5sagit%2FSub-Name.git

better diagnostics for bad %DB::sub entries

Rather than just checking for existence, compare with what was actually
created.  Also skip test when %DB::sub isn't populated (such as perl
5.8.0 when run without -d).
---

diff --git a/t/exotic_names.t b/t/exotic_names.t
index 6a5e28e..06d6484 100644
--- a/t/exotic_names.t
+++ b/t/exotic_names.t
@@ -54,7 +54,13 @@ sub caller3_ok {
 
     is $stash_name, $expected, "stash name for $type is correct $for_what";
     is $sub->(), $expected, "caller() in $type returns correct name $for_what";
-    ok $DB::sub{$expected}, "%DB::sub entry for $type is correct $for_what";
+    SKIP: {
+      skip '%DB::sub not populated when enabled at runtime', 1
+        unless keys %DB::sub;
+      my ($prefix) = $expected =~ /^(.*?test::[^:]+::)/;
+      my ($db_found) = grep /^$prefix/, keys %DB::sub;
+      is $db_found, $expected, "%DB::sub entry for $type is correct $for_what";
+    }
 }
 
 #######################################################################