forked from andk/cpanpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path43distroprefspref.t
123 lines (102 loc) · 1.86 KB
/
43distroprefspref.t
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
use strict;
use Test::More;
use CPAN::Distroprefs;
plan tests => 21;
my $p;
# start with something simple
$p = CPAN::Distroprefs::Pref->new({
data => {
match => {
distribution => "^XML",
},
},
});
ok($p->data);
ok($p->has_match("distribution"));
ok(!$p->has_match("perl"));
ok($p->has_any_match);
ok($p->has_valid_subkeys);
ok($p->matches({
distribution => "XML::Parser",
}));
ok(!$p->matches({
distribution => "Foo::XML",
}));
# still simple, but now a negated match
$p = CPAN::Distroprefs::Pref->new({
data => {
match => {
not_distribution => "^XML",
},
},
});
ok($p->data);
ok($p->has_match("distribution"));
ok(!$p->has_match("perl"));
ok($p->has_any_match);
ok($p->has_valid_subkeys);
ok(!$p->matches({
distribution => "XML::Parser",
}));
ok($p->matches({
distribution => "Foo::XML",
}));
# try some complicated matches
$p = CPAN::Distroprefs::Pref->new({
data => {
match => {
distribution => "^XML",
not_distribution => "Parser",
perlconfig => {
osname => "linux",
not_cc => "^gcc\$",
},
},
},
});
ok(!$p->matches({
distribution => "XML::Parser",
}));
ok($p->matches({
distribution => "XML::Foo",
perlconfig => {
osname => "linux",
cc => "cc",
},
}));
ok(!$p->matches({
distribution => "XML::Foo",
perlconfig => {
osname => "linux",
cc => "gcc",
},
}));
ok(!$p->matches({
distribution => "XML::Foo",
perlconfig => {
osname => "darwin",
cc => "cc",
},
}));
# try match on module
$p = CPAN::Distroprefs::Pref->new({
data => {
match => {
module => "^LWP",
not_module => "Foo",
},
},
});
ok($p->matches({
module => ["LWP::UserAgent"],
}));
ok(!$p->matches({
module => ["LWP::UserAgent", "LWP::Foo"],
}));
ok(!$p->matches({
module => ["Bar"],
}));
# Local Variables:
# mode: cperl
# cperl-indent-level: 2
# End: