Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_text/tests/regex_oracle/props.pl

2.2 KiB, 1 run

created by r1870400018:60342, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1#!/usr/bin/env perl
2# Writes props_expected.txt: Perl's own Unicode property data (Unicode::UCD), which
3# tests/regex.rs compares with the tables fe2o3_text generates from the UCD. Perl parses the UCD
4# with its own code, so agreement is evidence about the generator and the lookups, not a
5# restatement of them. Perl's Unicode version is older than the tables', so the test compares only
6# the code points Perl has assigned and reports what changed since.
7#
8# Run from this directory: perl props.pl > props_expected.txt
9use strict;
10use warnings;
11use Unicode::UCD qw(prop_invmap prop_invlist);
12
13binmode STDOUT, ':utf8';
14print "V\t", Unicode::UCD::UnicodeVersion(), "\n";
15
16for my $p (['GC', 'General_Category'], ['SC', 'Script'], ['SCX', 'Script_Extensions']) {
17 my ($tag, $name) = @$p;
18 my ($list, $map) = prop_invmap($name);
19 for my $i (0 .. $#$list) {
20 my $v = $map->[$i];
21 $v = join(' ', sort @$v) if ref $v;
22 printf "%s\t%X\t%s\n", $tag, $list->[$i], $v;
23 }
24}
25
26# Every binary property the tables carry, by the names the generator gives them. One Perl does
27# not know is listed as unknown rather than silently dropped.
28my @bins = qw(
29 ASCII_Hex_Digit Alphabetic Bidi_Control Case_Ignorable Cased Changes_When_Casefolded
30 Changes_When_Casemapped Changes_When_Lowercased Changes_When_Titlecased
31 Changes_When_Uppercased Dash Default_Ignorable_Code_Point Deprecated Diacritic Emoji
32 Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extended_Pictographic
33 Extender Grapheme_Base Grapheme_Extend Hex_Digit Hyphen IDS_Binary_Operator
34 IDS_Trinary_Operator IDS_Unary_Operator ID_Compat_Math_Continue ID_Compat_Math_Start
35 ID_Continue ID_Start Ideographic Join_Control Logical_Order_Exception Lowercase Math
36 Modifier_Combining_Mark Noncharacter_Code_Point Pattern_Syntax Pattern_White_Space
37 Prepended_Concatenation_Mark Quotation_Mark Radical Regional_Indicator Sentence_Terminal
38 Soft_Dotted Terminal_Punctuation Unified_Ideograph Uppercase Variation_Selector White_Space
39 XID_Continue XID_Start
40);
41for my $b (@bins) {
42 my @inv = eval { prop_invlist($b) };
43 if ($@ || !@inv) {
44 print "BIN\t$b\tunknown\n";
45 next;
46 }
47 print "BIN\t$b\t", join(' ', map { sprintf '%X', $_ } @inv), "\n";
48}