X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fexotic_names.t;h=c41b18e7a3809ba316d498c2a6ac641351a3255d;hb=b7d4922617711f35923a28d802618c2757bfafca;hp=00a8b467b6815b32f518414e00119e3c49980bb4;hpb=ea5fecfc8b0e069db0afa4587e0af7e40563895a;p=p5sagit%2FSub-Name.git diff --git a/t/exotic_names.t b/t/exotic_names.t index 00a8b46..c41b18e 100644 --- a/t/exotic_names.t +++ b/t/exotic_names.t @@ -9,7 +9,14 @@ use B 'svref_2object'; # and remains unclear past 5.16 with evalbytes and feature unicode_eval # In any case - Sub::Name needs to *somehow* work with this, so we will do # a heuristic with ambiguous eval and looking for octets in the stash -use if $] >= 5.016, feature => 'unicode_eval'; +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 ) = @_; @@ -40,7 +47,7 @@ sub caller3_ok { $expected =~ s/'/::/g; # this is apparently how things worked before 5.16 - utf8::encode($expected) if $] < 5.016 and $ord > 255; + utf8::encode($expected) if "$]" < 5.016 and $ord > 255; my $stash_name = join '::', map { $_->STASH->NAME, $_->NAME } svref_2object($sub)->GV; @@ -50,11 +57,13 @@ sub caller3_ok { ####################################################################### +use Sub::Name 'subname'; + my @ordinal = ( 1 .. 255 ); # 5.14 is the first perl to start properly handling \0 in identifiers unshift @ordinal, 0 - unless $] < 5.014; + unless "$]" < 5.014; # Unicode in 5.6 is not sane (crashes etc) push @ordinal, @@ -62,13 +71,13 @@ push @ordinal, 0x498, # CYRILLIC CAPITAL LETTER ZE WITH DESCENDER 0x2122, # TRADE MARK SIGN 0x1f4a9, # PILE OF POO - unless $] < 5.008; + 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 - unless $] < 5.008; + unless "$]" < 5.008; for my $ord (@ordinal) { my $sub; @@ -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