better diagnostics for bad %DB::sub entries
[p5sagit/Sub-Name.git] / t / exotic_names.t
index 621cad6..06d6484 100644 (file)
@@ -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";
+    }
 }
 
 #######################################################################
@@ -104,8 +110,10 @@ for my $ord (@ordinal) {
           no strict 'refs';
           *palatable:: = *{"aliased::native::${pkg}::"};
           # now palatable:: literally means aliased::native::${pkg}::
-          ${"palatable::$subname"} = 1;
-          ${"palatable::"}{"sub"} = ${"palatable::"}{$subname};
+          my $encoded_sub = $subname;
+          utf8::encode($encoded_sub) if "$]" < 5.016 and $ord > 255;
+          ${"palatable::$encoded_sub"} = 1;
+          ${"palatable::"}{"sub"} = ${"palatable::"}{$encoded_sub};
           # and palatable::sub means aliased::native::${pkg}::${subname}
         }
         $sub = compile_named_sub 'palatable::sub' => '(caller(0))[3]';