From 5198c1376b087a9fe884633b2b73800365a9b43a Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Fri, 4 Jan 2013 11:05:32 -0700 Subject: [PATCH] charnames: :alias alone implies :full The documentation says this is how it should behave, but only 1 of the three paths in the code did it, and in fact there was a test to the contrary. I'm only adding a test for one of the two fixed paths, as the other one appears to require a weird file name. --- lib/_charnames.pm | 3 ++- lib/charnames.t | 13 +++++++------ t/lib/charnames/alias | 8 -------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/_charnames.pm b/lib/_charnames.pm index 4a8aa42..5b80f96 100644 --- a/lib/_charnames.pm +++ b/lib/_charnames.pm @@ -612,6 +612,7 @@ sub import ref $alias eq "HASH" or croak "Only HASH reference supported as argument to :alias"; alias ($alias); + $promote = 1; next; } if ($alias =~ m{:(\w+)$}) { @@ -620,7 +621,7 @@ sub import alias_file ($1) and $promote = 1; next; } - alias_file ($alias); + alias_file ($alias) and $promote = 1; next; } if (substr($arg, 0, 1) eq ':' diff --git a/lib/charnames.t b/lib/charnames.t index 63cfc25..c58ccbe 100644 --- a/lib/charnames.t +++ b/lib/charnames.t @@ -62,12 +62,13 @@ EOE { - use charnames ':full', ":alias" => { mychar1 => "0xE8000", - mychar2 => 983040, # U+F0000 - mychar3 => "U+100000", - myctrl => 0x80, - mylarge => "U+111000", - }; + use charnames ":alias" => { mychar1 => "0xE8000", + mychar2 => 983040, # U+F0000 + mychar3 => "U+100000", + myctrl => 0x80, + mylarge => "U+111000", + }; + is ("\N{PILE OF POO}", chr(0x1F4A9), "Verify :alias alone implies :full"); is ("\N{mychar1}", chr(0xE8000), "Verify that can define hex alias"); is (charnames::viacode(0xE8000), "mychar1", "And that can get the alias back"); is ("\N{mychar2}", chr(0xF0000), "Verify that can define decimal alias"); diff --git a/t/lib/charnames/alias b/t/lib/charnames/alias index ddf797d..d5c589e 100644 --- a/t/lib/charnames/alias +++ b/t/lib/charnames/alias @@ -56,14 +56,6 @@ EXPECT OPTIONS regex :alias cannot use existing pragma :full \(reversed order\?\) at ######## -# NAME alias with hashref but no :full -use warnings; -use charnames ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" }; -"Here: \N{e_ACUTE}!\n"; -EXPECT -OPTIONS regex fatal -Unknown charname 'e_ACUTE' at - line \d+, within string -######## # NAME alias with hashref but with :short use warnings; no warnings 'void'; -- 2.7.4