use Cname;
ok 'fooB' =~ /\N{foo}[\N{B}\N{b}]/, "Passthrough charname";
+ my $name = "foo\xDF";
+ my $result = eval "'A${name}B' =~ /^A\\N{$name}B\$/";
+ ok !$@ && $result, "Passthrough charname of non-ASCII, Latin1";
#
# Why doesn't must_warn work here?
#
ok "\N{LONG-STR}" =~ /^\N{LONG-STR}$/, 'Verify that long string works';
ok "\N{LONG-STR}" =~ /^\N{LONG-STR}$/i, 'Verify under folding that long string works';
+ eval '/(?[[\N{EMPTY-STR}]])/';
+ ok $@ && $@ =~ /Zero length \\N\{}/;
+
+ undef $w;
+ eval q [is("\N{TOO MANY SPACES}", "TOO MANY SPACES", "Multiple spaces in character name works")];
+ like ($w, qr/A sequence of multiple spaces in a charnames alias definition is deprecated/, "... but returns a deprecation warning");
+ eval q [use utf8; is("\N{TOO MANY SPACES}", "TOO MANY SPACES", "Same under 'use utf8': they work")];
+ like ($w, qr/A sequence of multiple spaces in a charnames alias definition is deprecated/, "... but return a deprecation warning");
+ {
+ no warnings 'deprecated';
+ undef $w;
+ eval q ["\N{TOO MANY SPACES}"];
+ ok (! defined $w, "... and no warning if warnings are off");
+ eval q [use utf8; "\N{TOO MANY SPACES}"];
+ ok (! defined $w, "... same under 'use utf8'");
+ }
+
+ undef $w;
+ eval q [is("\N{TRAILING SPACE }", "TRAILING SPACE ", "Trailing space in character name works")];
+ like ($w, qr/Trailing white-space in a charnames alias definition is deprecated/, "... but returns a deprecation warning");
+ eval q [use utf8; is("\N{TRAILING SPACE }", "TRAILING SPACE ", "Same under 'use utf8': they work")];
+ like ($w, qr/Trailing white-space in a charnames alias definition is deprecated/, "... but returns a deprecation warning");
+ {
+ no warnings 'deprecated';
+ undef $w;
+ eval q ["\N{TRAILING SPACE }"];
+ ok (! defined $w, "... and no warning if warnings are off");
+ eval q [use utf8; "\N{TRAILING SPACE }"];
+ ok (! defined $w, "... same under 'use utf8'");
+ }
+
# If remove the limitation in regcomp code these should work
# differently
undef $w;
ok $@ && $@ =~ /Invalid character/, 'Verify that leading digit in name gives error';
eval 'q() =~ /\N{COM,MA}/';
ok $@ && $@ =~ /Invalid character/, 'Verify that comma in name gives error';
- my $name = "A\x{D7}O";
+ $name = "A\x{D7}O";
eval "q(W) =~ /\\N{$name}/";
ok $@ && $@ =~ /Invalid character/, 'Verify that latin1 symbol in name gives error';
+ my $utf8_name = "7 CITIES OF GOLD";
+ utf8::upgrade($utf8_name);
+ eval "use utf8; q(W) =~ /\\N{$utf8_name}/";
+ ok $@ && $@ =~ /Invalid character/, 'Verify that leading digit in utf8 name gives error';
+ $utf8_name = "SHARP #";
+ utf8::upgrade($utf8_name);
+ eval "use utf8; q(W) =~ /\\N{$utf8_name}/";
+ ok $@ && $@ =~ /Invalid character/, 'Verify that ASCII symbol in utf8 name gives error';
+ $utf8_name = "A HOUSE \xF7 AGAINST ITSELF";
+ utf8::upgrade($utf8_name);
+ eval "use utf8; q(W) =~ /\\N{$utf8_name}/";
+ ok $@ && $@ =~ /Invalid character/, 'Verify that latin1 symbol in utf8 name gives error';
+ $utf8_name = "\x{664} HORSEMEN}";
+ eval "use utf8; q(W) =~ /\\N{$utf8_name}/";
+ ok $@ && $@ =~ /Invalid character/, 'Verify that leading above Latin1 digit in utf8 name gives error';
+ $utf8_name = "A \x{1F4A9} WOULD SMELL AS SWEET}";
+ eval "use utf8; q(W) =~ /\\N{$utf8_name}/";
+ ok $@ && $@ =~ /Invalid character/, 'Verify that above Latin1 symbol in utf8 name gives error';
+
undef $w;
$name = "A\x{D1}O";
eval "q(W) =~ /\\N{$name}/";
ok ! $w, 'Verify that latin1 letter in name doesnt give warning';
+ # This tests the code path that restarts the parse when the recursive
+ # call to S_reg() from within S_grok_bslash_N() discovers that the
+ # pattern needs to be recalculated as UTF-8. use eval to avoid
+ # needing literal Unicode in this source file:
+ my $r = eval "qr/\\N{\x{100}\x{100}}/";
+ isnt $r, undef, "Generated regex for multi-char UTF-8 charname"
+ or diag($@);
+ ok "\x{100}\x{100}" =~ $r, "which matches";
}
{
{
# \, breaks {3,4}
- no warnings qw{deprecated regexp};
ok "xaaay" !~ /xa{3\,4}y/, '\, in a pattern';
ok "xa{3,4}y" =~ /xa{3\,4}y/, '\, in a pattern';
{
# Test for keys in %+ and %-
my $message = 'Test keys in %+ and %-';
- no warnings 'uninitialized';
+ no warnings 'uninitialized', 'deprecated', 'experimental::lexical_topic';
my $_ = "abcdef";
/(?<foo>a)|(?<foo>b)/;
is((join ",", sort keys %+), "foo", $message);
{
# length() on captures, the numbered ones end up in Perl_magic_len
+ no warnings 'deprecated', 'experimental::lexical_topic';
my $_ = "aoeu \xe6var ook";
/^ \w+ \s (?<eek>\S+)/x;
'IsPunct disagrees with [:punct:] outside ASCII');
my @isPunctLatin1 = eval q {
+ no warnings 'deprecated';
use encoding 'latin1';
grep {/[[:punct:]]/ != /\p{IsPunct}/} map {chr} 0x80 .. 0xff;
};
ok(! $failed, "Matched multi-char fold across EXACTFish node boundaries; if failed, was at count $failed");
}
+ {
+ fresh_perl_is('print eval "\"\x{101}\" =~ /[[:lower:]]/", "\n"; print eval "\"\x{100}\" =~ /[[:lower:]]/i", "\n";',
+ "1\n1", # Both re's should match
+ "",
+ "get [:lower:] swash in first eval; test under /i in second");
+ }
+
#
# Keep the following tests last -- they may crash perl
#
my $p = qr/^[\x{FFFF_FFFF}]$/;
ok(chr(0xFFFF_FFFF) =~ $p,
"chr(0xFFFF_FFFF) can match itself in a [class]");
+ ok(chr(0xFFFF_FFFF) =~ $p, # Tests any caching
+ "chr(0xFFFF_FFFF) can match itself in a [class] subsequently");
}
else {
no warnings 'overflow';
my $p = qr/^[\x{FFFF_FFFF_FFFF_FFFF}]$/;
ok(chr(0xFFFF_FFFF_FFFF_FFFF) =~ $p,
"chr(0xFFFF_FFFF_FFFF_FFFF) can match itself in a [class]");
+ ok(chr(0xFFFF_FFFF_FFFF_FFFF) =~ $p, # Tests any caching
+ "chr(0xFFFF_FFFF_FFFF_FFFF) can match itself in a [class] subsequently");
# This test is because something was declared as 32 bits, but
# should have been cast to 64; only a problem where