Make TAP output UTF8
[p5sagit/Sub-Name.git] / t / exotic_names.t
index 00a8b46..00519ec 100644 (file)
@@ -11,6 +11,13 @@ use B 'svref_2object';
 # a heuristic with ambiguous eval and looking for octets in the stash
 use if $] >= 5.016, feature => 'unicode_eval';
 
+if ($] >= 5.008) {
+       my $builder = Test::More->builder;
+       binmode $builder->output,         ":encoding(utf8)";
+       binmode $builder->failure_output, ":encoding(utf8)";
+       binmode $builder->todo_output,    ":encoding(utf8)";
+}
+
 sub compile_named_sub {
     my ( $fullname, $body ) = @_;
     my $sub = eval "sub $fullname { $body }" . '\\&{$fullname}';
@@ -50,6 +57,8 @@ sub caller3_ok {
 
 #######################################################################
 
+use Sub::Name 'subname';
+
 my @ordinal = ( 1 .. 255 );
 
 # 5.14 is the first perl to start properly handling \0 in identifiers
@@ -64,7 +73,7 @@ push @ordinal,
     0x1f4a9,  # PILE OF POO
     unless $] < 5.008;
 
-plan tests => @ordinal * 2;
+plan tests => @ordinal * 2 * 2;
 
 my $legal_ident_char = "A-Z_a-z0-9'";
 $legal_ident_char .= join '', map chr, 0x100, 0x498
@@ -76,6 +85,9 @@ for my $ord (@ordinal) {
     my $subname  = sprintf 'SOME_%c_NAME', $ord;
     my $fullname = join '::', $pkg, $subname;
 
+    $sub = subname $fullname => sub { (caller(0))[3] };
+    caller3_ok $sub, $fullname, 'renamed closure', $ord;
+
     # test that we can *always* compile at least within the correct package
     my $expected;
     if ( chr($ord) =~ m/^[$legal_ident_char]$/o ) { # compile directly