]> git.vpit.fr Git - perl/modules/Regexp-Wildcards.git/blob - t/24-anchors.t
Update VPIT::TestHelpers to 15e8aee3
[perl/modules/Regexp-Wildcards.git] / t / 24-anchors.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 16;
7
8 use Regexp::Wildcards;
9
10 my $rw = Regexp::Wildcards->new(do => 'anchors');
11
12 is($rw->convert('\\^'),     '\\^',     'anchor: escape ^ 1');
13 is($rw->convert('\\\\\\^'), '\\\\\\^', 'anchor: escape ^ 2');
14 is($rw->convert('\\$'),     '\\$',     'anchor: escape $ 1');
15 is($rw->convert('\\\\\\$'), '\\\\\\$', 'anchor: escape $ 2');
16
17 is($rw->convert('^a?b*'),    '^a\\?b\\*',    'anchor: ^');
18 is($rw->convert('a?b*$'),    'a\\?b\\*$',    'anchor: $');
19 is($rw->convert('^a?b*$'),   '^a\\?b\\*$',   'anchor: ^$');
20 is($rw->convert('x^a?b*$y'), 'x^a\\?b\\*$y', 'anchor: intermediate ^$');
21
22 $rw->do(add => 'jokers');
23
24 is($rw->convert('^a?b*'),    '^a.b.*',   'anchor: ^ with jokers');
25 is($rw->convert('a?b*$'),    'a.b.*$',   'anchor: $ with jokers');
26 is($rw->convert('^a?b*$'),   '^a.b.*$',  'anchor: ^$ with jokers');
27 is($rw->convert('x^a?b*$y'), 'x^a.b.*$y','anchor: intermediate ^$ with jokers');
28
29 $rw->do(add => 'brackets');
30
31 is($rw->convert('{^,a}?b*'),    '(?:^|a).b.*',      'anchor: ^ with brackets');
32 is($rw->convert('a?{b*,$}'),    'a.(?:b.*|$)',      'anchor: $ with brackets');
33 is($rw->convert('{^a,?}{b,*$}'),'(?:^a|.)(?:b|.*$)','anchor: ^$ with brackets');
34 is($rw->convert('x{^,a}?b{*,$}y'), 'x(?:^|a).b(?:.*|$)y',
35                                    'anchor: intermediate ^$ with brackets');