8 use Unicode::UCD qw(prop_invlist);
10 sub truth($) { # Converts values so is() works
11 return (shift) ? 1 : 0;
15 # name => Lookup-property name
24 idfirst => '_Perl_IDStart',
27 psxspc => 'XPosixSpace',
28 punct => 'XPosixPunct',
29 quotemeta => '_Perl_Quotemeta',
30 space => 'XPerlSpace',
31 vertws => 'VertSpace',
37 local $SIG{__WARN__} = sub { push @warnings, @_ };
40 foreach my $name (sort keys %properties) {
41 my $property = $properties{$name};
42 my @invlist = prop_invlist($property, '_perl_core_internal_ok');
44 fail("No inversion list found for $property");
48 # Include all the Latin1 code points, plus 0x100.
49 my @code_points = (0 .. 256);
51 # Then include the next few boundaries above those from this property
53 foreach my $range_start (@invlist) {
54 next if $range_start < 257;
55 push @code_points, $range_start - 1, $range_start;
57 last if $above_latins > 5;
60 # And finally one non-Unicode code point.
61 push @code_points, 0x110000; # Above Unicode, no prop should match
62 no warnings 'non_unicode';
64 for my $i (@code_points) {
65 my $function = uc($name);
67 my $matches = Unicode::UCD::_search_invlist(\@invlist, $i);
68 if (! defined $matches) {
72 $matches = truth(! ($matches % 2));
76 my $char_name = charnames::viacode($i) // "No name";
77 my $display_name = sprintf "\\N{U+%02X, %s}", $i, $char_name;
79 if ($name eq 'quotemeta') { # There is only one macro for this, and is
80 # defined only for Latin1 range
81 $ret = truth eval "test_is${function}($i)";
86 my $truth = truth($matches && $i < 256);
87 is ($ret, $truth, "is${function}( $display_name ) == $truth");
91 if ($name ne 'vertws') {
92 $ret = truth eval "test_is${function}_A($i)";
97 my $truth = truth($matches && $i < 128);
98 is ($ret, $truth, "is${function}_A( $display_name ) == $truth");
100 $ret = truth eval "test_is${function}_L1($i)";
105 my $truth = truth($matches && $i < 256);
106 is ($ret, $truth, "is${function}_L1( $display_name ) == $truth");
109 next if $name eq 'alnumc';
111 $ret = truth eval "test_is${function}_uni($i)";
116 is ($ret, $matches, "is${function}_uni( $display_name ) == $matches");
120 utf8::upgrade($char);
121 $char = quotemeta $char if $char eq '\\' || $char eq "'";
122 $ret = truth eval "test_is${function}_utf8('$char')";
127 is ($ret, $matches, "is${function}_utf8( $display_name ) == $matches");
132 # This is primarily to make sure that no non-Unicode warnings get generated
133 is(scalar @warnings, 0, "No warnings were generated " . join ", ", @warnings);