6 use Test::More tests => 27;
10 my $rw = Regexp::Wildcards->new(qw/do brackets/);
12 is($rw->convert('a{b\\\\,c\\\\}d', 'jokers'), 'a\\{b\\\\\\,c\\\\\\}d','jokers');
14 is($rw->convert('a{b\\\\,c\\\\}d', 'sql'), 'a\\{b\\\\\\,c\\\\\\}d', 'sql');
16 is($rw->convert('a{b\\\\,c\\\\}d', 'win32'), '(?:a\\{b\\\\|c\\\\\\}d)','win32');
18 is($rw->convert('{}'), '(?:)', 'empty brackets');
19 is($rw->convert('{a}'), '(?:a)', 'brackets 1');
20 is($rw->convert('{a,b}'), '(?:a|b)', 'brackets 2');
21 is($rw->convert('{a,b,c}'), '(?:a|b|c)', 'brackets 3');
23 is($rw->convert('a{b,c}d'), 'a(?:b|c)d',
25 is($rw->convert('a{b,c}d{e,,f}'), 'a(?:b|c)d(?:e||f)',
26 '2 bracketed blocks');
27 is($rw->convert('a{b,c}d{e,,f}{g,h,}'), 'a(?:b|c)d(?:e||f)(?:g|h|)',
28 '3 bracketed blocks');
30 is($rw->convert('{a{b}}'), '(?:a(?:b))',
31 '2 nested bracketed blocks 1');
32 is($rw->convert('{a,{b},c}'), '(?:a|(?:b)|c)',
33 '2 nested bracketed blocks 2');
34 is($rw->convert('{a,{b{d}e},c}'), '(?:a|(?:b(?:d)e)|c)',
35 '3 nested bracketed blocks');
36 is($rw->convert('{a,{b{d{}}e,f,,},c}'), '(?:a|(?:b(?:d(?:))e|f||)|c)',
37 '4 nested bracketed blocks');
38 is($rw->convert('{a,{b{d{}}e,f,,},c}{,g{{}h,i}}'), '(?:a|(?:b(?:d(?:))e|f||)|c)(?:|g(?:(?:)h|i))',
39 '4+3 nested bracketed blocks');
41 is($rw->convert('\\{\\\\}'), '\\{\\\\\\}',
43 is($rw->convert('\\{a,b,c\\\\\\}'), '\\{a\\,b\\,c\\\\\\}',
45 is($rw->convert('\\{a\\\\,b\\,c}'), '\\{a\\\\\\,b\\,c\\}',
47 is($rw->convert('\\{a\\\\,b\\,c\\}'), '\\{a\\\\\\,b\\,c\\}',
49 is($rw->convert('\\{a\\\\,b\\,c\\\\}'), '\\{a\\\\\\,b\\,c\\\\\\}',
50 'escaping brackets and commas');
52 is($rw->convert('{a\\},b\\{,c}'), '(?:a\\}|b\\{|c)',
53 'overlapping brackets');
54 is($rw->convert('{a\\{b,c}d,e}'), '(?:a\\{b|c)d\\,e\\}',
55 'partial unbalanced catching 1');
56 is($rw->convert('{a\\{\\\\}b,c\\\\}'), '(?:a\\{\\\\)b\\,c\\\\\\}',
57 'partial unbalanced catching 2');
58 is($rw->convert('{a{b,c\\}d,e}'), '\\{a\\{b\\,c\\}d\\,e\\}',
59 'no partial unbalanced catching');
60 is($rw->convert('{a,\\{,\\},b}'), '(?:a|\\{|\\}|b)',
61 'substituting commas 1');
62 is($rw->convert('{a,\\{d,e,,\\}b,c}'), '(?:a|\\{d|e||\\}b|c)',
63 'substituting commas 2');
64 is($rw->convert('{a,\\{d,e,,\\}b,c}\\\\{f,g,h,i}'), '(?:a|\\{d|e||\\}b|c)\\\\(?:f|g|h|i)',