summaryrefslogtreecommitdiff
path: root/lib/Unicode
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2015-02-18 11:57:02 -0700
committerKarl Williamson <khw@cpan.org>2015-02-18 12:51:34 -0700
commit5c1d8161bf92d6173f51e2f071ab9f34c6291591 (patch)
tree8050c37ae32ad06a65034aaad0a10b1f3b105008 /lib/Unicode
parent91e7847033aefac6cf5b500a5c72811c8d6b8fbc (diff)
downloadperl-5c1d8161bf92d6173f51e2f071ab9f34c6291591.tar.gz
Unicode::UCD::prop_value_aliases() Don't return invalid value
Prior to this commit, if you said prop_value_aliases("Any", "foo") it would return "foo". But there really aren't any synonyms for the "Any" property values, so it should return undef instead.
Diffstat (limited to 'lib/Unicode')
-rw-r--r--lib/Unicode/UCD.pm13
-rw-r--r--lib/Unicode/UCD.t2
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/Unicode/UCD.pm b/lib/Unicode/UCD.pm
index 5d3115dcfe..da2e1c36f8 100644
--- a/lib/Unicode/UCD.pm
+++ b/lib/Unicode/UCD.pm
@@ -2130,7 +2130,18 @@ sub prop_value_aliases ($$) {
# anything, like most (if not all) string properties. These don't have
# synonyms anyway. Simply return the input. For example, there is no
# synonym for ('Uppercase_Mapping', A').
- return $value if ! exists $prop_value_aliases{$prop};
+ if (! exists $prop_value_aliases{$prop}) {
+
+ # Here, we have a legal property, but an unknown value. Since the
+ # property is legal, if it isn't in the prop_aliases hash, it must be
+ # a Perl-extension All perl extensions are binary, hence are
+ # enumerateds, which means that we know that the input unknown value
+ # is illegal.
+ return if ! exists $Unicode::UCD::prop_aliases{$prop};
+
+ # Otherwise, we assume it's valid, as documented.
+ return $value;
+ }
# The value name may be loosely or strictly matched; we don't know yet.
# But both types use lower-case.
diff --git a/lib/Unicode/UCD.t b/lib/Unicode/UCD.t
index e54c5ee4fc..419c338dd6 100644
--- a/lib/Unicode/UCD.t
+++ b/lib/Unicode/UCD.t
@@ -727,6 +727,8 @@ is(prop_value_aliases(undef, undef), undef,
is((prop_value_aliases("na", "A")), "A", "test that prop_value_aliases returns its input for properties that don't have synonyms");
is(prop_value_aliases("isgc", "C"), undef, "prop_value_aliases('isgc', 'C') returns <undef> since is not covered Perl extension");
is(prop_value_aliases("gc", "isC"), undef, "prop_value_aliases('gc', 'isC') returns <undef> since is not covered Perl extension");
+is(prop_value_aliases("Any", "None"), undef, "prop_value_aliases('Any', 'None') returns <undef> since is Perl extension and 'None' is not valid");
+is(prop_value_aliases("lc", "A"), "A", "prop_value_aliases('lc', 'A') returns its input, as docs say it does");
# We have no way of knowing if mktables omitted a Perl extension that it
# shouldn't have, but we can check if it omitted an official Unicode property