Mock-Data
view release on metacpan or search on metacpan
t/11-charset.t view on Meta::CPAN
[ [ 10, 20 ], [ 0, 10, 20 ] ],
=> [ 0 ],
);
while (my ($input, $output)= splice(@tests, 0, 2)) {
is( Mock::Data::Charset::Util::merge_invlists($input), $output );
}
};
subtest charset_invlist => sub {
# Perl added vertical-tab to \s in 5.12
my @space_ascii= ( 9,( $] lt '5.012'? (11,12):() ),14, 32,33 );
my @tests= (
[ 'A-Z', 0x7F,
[ 65,91 ]
],
[ 'A-Z', undef,
[ 65,91 ],
],
[ 'A-Za-z', 0x7F,
[ 65,91, 97,123 ]
],
[ 'A-Za-z', undef,
[ 65,91, 97,123 ]
],
[ '\w', 0x7F,
[ 48,58, 65,91, 95,96, 97,123 ]
],
($] ge '5.026'? ( # the definition of \w and \s varies over perl versions
[ '\w', 0x200,
[ 48,58, 65,91, 95,96, 97,123, 170,171, 181,182, 186,187, 192,215, 216,247, 248,0x201 ],
],
[ '\s', 0x7F,
[ @space_ascii ],
],
[ '\s', undef,
[ @space_ascii, 133,134, 160,161, 5760,5761,
($] lt '5.012'? (6158,6159) : ()),
8192,8203, 8232,8234, 8239,8240, 8287,8288, 12288,12289 ],
],
):()),
[ '\p{Block: Katakana}', undef,
[ 0x30A0, 0x3100 ],
],
[ '^[:digit:]', 0x7F,
[ 0,0x30, 0x3A,0x80 ],
],
($] ge '5.012'? ( # \p{digit} wasn't available until 5.12
[ '[:alpha:]\P{digit}', 0x7F,
[ 0,0x30, 0x3A,0x80 ],
],
):()),
[ '\p{alpha}\P{alpha}', undef,
[ 0 ],
],
[ '^\n', undef,
[ 0,10, 11 ]
],
t/11-charset.t view on Meta::CPAN
is( $charset->find_member($ch), $i, "found $ch at $i" );
}
$charset= charset(notation => 'A-FH-Z', max_codepoint => 127); # punct was not stable enough across perl versions
is( [ $charset->find_member("0") ], [ undef, 0 ], '0 would insert at position 0' );
is( [ $charset->find_member("G") ], [ undef, 6 ], 'G would insert at position 6' );
};
subtest lazy_attributes => sub {
skip_all "\\P{digit} not supported on 5.10"
if $] lt '5.012';
my $charset= charset('[:alpha:]\P{digit}');
ok( !$charset->find_member('0'), '"0" not in the set of alpha and non-digit' );
is( scalar $charset->find_member('a'), 87, 'member "a" found at 87' );
ok( defined $charset->{member_invlist} && defined $charset->{_invlist_index}, 'used invlist' );
ok( !defined $charset->{members}, 'did not use members[]' );
$charset= charset(classes => ['alpha','^digit']);
ok( !$charset->find_member('0'), '"0" not in the set of alpha and non-digit' );
is( scalar $charset->find_member('a'), 87, 'member "a" found at 87' );
ok( defined $charset->{member_invlist} && defined $charset->{_invlist_index}, 'used invlist' );
( run in 0.924 second using v1.01-cache-2.11-cpan-cc502c75498 )