Permalink
Browse files

charnames.t: Fix to work with new charnames.pm

Version 1.33 of charnames.pm is changing in conjunction with core Perl
to make \N{ANY UNKNOWN CHARACTER} fatal, instead of merely being a
warning.  This will now conform to the behavior that Unicode recommends.

This commit causes charnames.t to expect a warning from versions of
charnames.pm earlier than 1.33, and a fatal error beginning with 1.33.
  • Loading branch information...
Karl Williamson
Karl Williamson committed Oct 23, 2012
1 parent f1446e5 commit eeb170da2eb88145c52a383585fc3e986b1a7ce1
Showing with 12 additions and 5 deletions.
  1. +12 −5 t/charnames.t
View
@@ -49,12 +49,19 @@ BEGIN {
is "\N{DIGIT SIX}", "6";
{
- my $x = "\N{UNKNOWN CHARACTER}";
- $x = vianame('DoCoMo Foo');
+ my $v_charnames_version = pack "C*", split /\./, $charnames::VERSION;
+ my $backslash_N_fatal = $v_charnames_version ge v1.33;
+
+ my $x = vianame('DoCoMo Foo');
+ $x = eval '"\N{UNKNOWN CHARACTER}"';
+ my $eval_failure = $@;
@WARN = grep !/^Use of uninitialized value/, @WARN; # remove UUV warnings
- is scalar(@WARN), 2, 'check warn num';
- like $WARN[0], qr{Unknown charname 'UNKNOWN CHARACTER'}, 'wanrings when unkown character';
- like $WARN[1], qr{unknown charnames: Foo}, 'warning when unkown character';
+
+ is scalar(@WARN), (($backslash_N_fatal) ? 1 : 2), 'check warn num';
+ like $WARN[0], qr{unknown charnames: Foo}, 'warning when unkown character';
+ like (($backslash_N_fatal)
+ ? $eval_failure
+ : $WARN[1], qr{Unknown charname 'UNKNOWN CHARACTER'}, 'warning when unkown \N{} character');
}
eval { unicode2name() }; like $@, qr{^missing code}, "validation";
eval { unicode2name_en() }; like $@, qr{^missing code}, "validation";

0 comments on commit eeb170d

Please sign in to comment.