summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-09-28 14:56:36 -0600
committerKarl Williamson <public@khwilliamson.com>2011-10-01 09:58:10 -0600
commitb289b443840217f6eabfcc3ae622f08f4ef76487 (patch)
tree6b0b47a068052807a95bb6f70d4ce11c786e8a83 /t
parentb6912c02aa553169d6b7158ab7a2ddc26d60974f (diff)
downloadperl-b289b443840217f6eabfcc3ae622f08f4ef76487.tar.gz
Add tests for isIDFirst
Diffstat (limited to 't')
-rw-r--r--t/re/pat.t29
1 files changed, 28 insertions, 1 deletions
diff --git a/t/re/pat.t b/t/re/pat.t
index 988c23e01d..ed87f07701 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -21,7 +21,7 @@ BEGIN {
require './test.pl';
}
-plan tests => 455; # Update this when adding/deleting tests.
+plan tests => 463; # Update this when adding/deleting tests.
run_tests() unless caller;
@@ -1181,6 +1181,33 @@ sub run_tests {
like($str, qr/\P{ASCII_Hex_Digit=False}/, "Non-Unicode matches \\P{}");
}
+ {
+ # Test that IDstart works, but doing because the author (khw) knows
+ # regexes much better than the rest of the core, it is being done here
+ # in the context of a regex which relies on buffer names beginng with
+ # IDStarts.
+ use utf8;
+ my $str = "abc";
+ like($str, qr/(?<a>abc)/, "'a' is legal IDStart");
+ like($str, qr/(?<_>abc)/, "'_' is legal IDStart");
+ like($str, qr/(?<ß>abc)/, "U+00DF is legal IDStart");
+ like($str, qr/(?<ℕ>abc)/, "U+2115' is legal IDStart");
+
+ # This test works on Unicode 6.0 in which U+2118 and U+212E are legal
+ # IDStarts there, but are not Word characters, and therefore Perl
+ # doesn't allow them to be IDStarts. But there is no guarantee that
+ # Unicode won't change things around in the future so that at some
+ # future Unicode revision these tests would need to be revised.
+ foreach my $char ("%", "×", chr(0x2118), chr(0x212E)) {
+ my $prog = <<"EOP";
+use utf8;;
+"abc" =~ qr/(?<$char>abc)/;
+EOP
+ utf8::encode($prog);
+ fresh_perl_like($prog, qr!Sequence.* not recognized!, "",
+ sprintf("'U+%04X not legal IDFirst'", ord($char)));
+ }
+ }
} # End of sub run_tests
1;