File: 11-opts.t

package info (click to toggle)
libregexp-wildcards-perl 1.05-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 184 kB
  • sloc: perl: 489; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,191 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!perl -T

use strict;
use warnings;

use Test::More tests => 10;

use Regexp::Wildcards;

my $rw = Regexp::Wildcards->new();

my $wc     = 'a,b{c,d}e*f?(g)';
my $none   = quotemeta $wc;
my $unix   = 'a\\,b(?:c|d)e.*f.\\(g\\)';
my $win32  = '(?:a|b\{c|d\}e.*f.\\(g\\))';
my $jokers = 'a\\,b\\{c\\,d\\}e.*f.\\(g\\)';
my $groups = 'a\\,b\\{c\\,d\\}e\\*f\\?(g)';
my $jok_gr = 'a\\,b\\{c\\,d\\}e.*f.(g)';

is($rw->convert($wc), $unix,  'nothing defaults to unix');
$rw->type('win32');
is($rw->convert($wc), $win32, 'set to win32');
$rw->type('darwin');
is($rw->convert($wc), $unix,  'set to darwin');
$rw->type('MSWin32');
is($rw->convert($wc), $win32, 'reset to win32');
$rw->type();
is($rw->convert($wc), $unix,  'reset to unix');

$rw = Regexp::Wildcards->new(do => [ qw<jokers> ], type => 'win32');
is($rw->convert($wc), $jokers, 'do overrides type in new');
$rw->do(add => 'groups');
is($rw->convert($wc), $jok_gr, 'added groups to jokers');
$rw->do(add => 'jokers');
is($rw->convert($wc), $jok_gr, 'added jokers but it already exists');
$rw->do(rem => 'jokers');
is($rw->convert($wc), $groups, 'removed jokers, only groups remains');
$rw->do();
is($rw->convert($wc), $none,   'reset do');