Skip Menu |

This queue is for tickets about the Sub-Name CPAN distribution.

Report information
The Basics
Id: 69422
Status: rejected
Priority: 0/
Queue: Sub-Name

People
Owner: Nobody in particular
Requestors: ribasushi [...] leporine.io
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Test (and fails) of exotic characters in sub names
The attached test raises 3 issues: * S::N should probably check for \0 in the supplied string * Is unicode allowed or not? See comment in-test, seems to work * What is so special about q{'} that it breaks everything...? My results: t/exotic_names.t .. 1/517 # Failed test 'null-in-name throws correctly' # at t/exotic_names.t line 22. # Failed test 'Sub named properly when name contains \x{27}' # at t/exotic_names.t line 38. # got: 'test::E' # expected: 'test::B'E' # Failed test 'caller() works' # at t/exotic_names.t line 46. # got: '__ANON__::E' # expected: 'test::B'E' # Looks like you failed 3 tests of 517. t/exotic_names.t .. Dubious, test returned 3 (wstat 768, 0x300) Failed 3/517 subtests Test Summary Report ------------------- t/exotic_names.t (Wstat: 768 Tests: 517 Failed: 3) Failed tests: 1, 78-79 Non-zero exit status: 3 Files=1, Tests=517, 0 wallclock secs ( 0.10 usr 0.03 sys + 0.15 cusr 0.02 csys = 0.30 CPU) Result: FAIL
Subject: exotic_names.t
#!/usr/bin/perl use Sub::Name 'subname'; use B 'svref_2object'; use Test::More; # ascii + some unicode my @test_chars = ( 1 .. 255 ); # add unicode if the perl is capable if ($] > 5.008) { push @test_chars, 256, 338, 1176; } plan tests => @test_chars * 2 + 1; # The GV-related strings are read until first \0, as such # the code should sanity check and throw instead of effectively # truncating the resulting name eval { my $c = subname "B\x00E" => sub { 1 } }; ok ($@, 'null-in-name throws correctly'); for (@test_chars) { my $expected = my $name = sprintf ('test::B%cE', $_); # REVIEW - there is no unicode flag in the GV, so we will get # back the raw bytes. Imho it is still benefitial to do high-char # assignments, given that they will render properly on-screen and # in logs if ($_ > 255) { # check for 5.008 sbove guarantees availability utf8::encode($expected); } my $me; my $c = subname $name => sub { $me = (caller(0))[3] }; is ( 'test::' . svref_2object($c)->GV->NAME, $expected, sprintf ('Sub named properly when name contains \x{%X}', $_ ) ); $c->(); is ( $me, $expected, 'caller() works', ); }
On Tue Jul 12 04:40:27 2011, RIBASUSHI wrote: Show quoted text
> * What is so special about q{'} that it breaks everything...?
Is it because ' is a package separator from the Perl4 error?
As of 5.16 at least, unicode characters are permitted in all symbol names.
I finally updated this with the proper incantations: https://github.com/karenetheridge/Sub-Name/pull/4
RT-Send-CC: MITHALDU [...] cpan.org
Closing this (and the related GH ticket https://github.com/karenetheridge/Sub-Name/pull/4). Discussion is possibly going to proceed on https://github.com/karenetheridge/Sub-Name/pull/7