This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: extract charnames code from S_new_constant
The code for dealing with charnames is intertwined and special cased in
S_new_constant. My guess is it was originally to offer customized,
better error messages when things go wrong. Much later the function was
changed so that a message could be returned instead of output, and the
code didn't really need the customization any longer. But by then
autoloading of charnames had been added when a \N[} was parsed, meaning
that more special casing was added instead, as that had been the logical
place to do it.
This commit extracts the special charnames handling to the one place it
is actually used, and the disentangled S_new_constant is then called.
This is in preparation for future commits, and makes the code cleaner.
This adds testing of the new syntax to lib/charnames.t. That file
randomly generates some tests, simply because there are too many names
to test reasonably at once. To compensate for the added tests, I
lowered the percentage per run of characters tested so that this file
takes about the same amount of time as before.