X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fexotic_names.t;h=06d64842dec47eabb16f0725b8fc7c63767a414e;hb=3f1762c7005f1669dbfde6bff7a204d3bfc72f72;hp=893978d2f6412fc3d5565cdfff38a1cee2e7c8f4;hpb=9f96c17f08ef98580d48f7f47a0101adacdaa1ba;p=p5sagit%2FSub-Name.git diff --git a/t/exotic_names.t b/t/exotic_names.t index 893978d..06d6484 100644 --- a/t/exotic_names.t +++ b/t/exotic_names.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use B 'svref_2object'; +BEGIN { $^P |= 0x210 } # This is a mess. The stash can supposedly handle Unicode but the behavior # is literally undefined before 5.16 (with crashes beyond the basic plane), @@ -53,6 +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"; + 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"; + } } ####################################################################### @@ -73,16 +81,18 @@ push @ordinal, 0x1f4a9, # PILE OF POO unless "$]" < 5.008; -plan tests => @ordinal * 2 * 2; +plan tests => @ordinal * 2 * 3; my $legal_ident_char = "A-Z_a-z0-9'"; $legal_ident_char .= join '', map chr, 0x100, 0x498 unless "$]" < 5.008; +my $uniq = 'A000'; for my $ord (@ordinal) { my $sub; - my $pkg = sprintf 'test::SOME_%c_STASH', $ord; - my $subname = sprintf 'SOME_%c_NAME', $ord; + $uniq++; + my $pkg = sprintf 'test::%s::SOME_%c_STASH', $uniq, $ord; + my $subname = sprintf 'SOME_%s_%c_NAME', $uniq, $ord; my $fullname = join '::', $pkg, $subname; $sub = subname $fullname => sub { (caller(0))[3] }; @@ -91,13 +101,22 @@ for my $ord (@ordinal) { # test that we can *always* compile at least within the correct package my $expected; if ( chr($ord) =~ m/^[$legal_ident_char]$/o ) { # compile directly - $expected = $fullname; - $sub = compile_named_sub $fullname => '(caller(0))[3]'; + $expected = "native::$fullname"; + $sub = compile_named_sub $expected => '(caller(0))[3]'; } else { # not a legal identifier but at least test the package name by aliasing - $expected = "${pkg}::foo"; - { no strict 'refs'; *palatable:: = *{"${pkg}::"} } # now palatable:: literally means ${pkg}:: - $sub = compile_named_sub 'palatable::foo' => '(caller(0))[3]'; + $expected = "aliased::native::$fullname"; + { + no strict 'refs'; + *palatable:: = *{"aliased::native::${pkg}::"}; + # now palatable:: literally means aliased::native::${pkg}:: + 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]'; } caller3_ok $sub, $expected, 'natively compiled sub', $ord; }