File Coverage

tests/name-2
Criterion Covered Total %
statement 78 78 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 83 83 100.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2              
3             # The script tests Arch::Name methods.
4              
5 1     1   6 use strict;
  1         2  
  1         33  
6              
7 1     1   859 use FindBin;
  1         1116  
  1         42  
8 1     1   815 use lib "$FindBin::Bin/../perllib";
  1         598  
  1         7  
9              
10 1     1   1055 use Test::More tests => 42;
  1         18364  
  1         8  
11 1     1   9 use_ok("Arch::Name");
  1         931  
  1         3  
  1         1  
  1         42  
12              
13 1         815 my $archive = 'some@archive';
14 1         2 my $category = 'cat-meow';
15 1         5 my $branchless = "$archive/$category--5.6.7.8--patch-1";
16 1         14 my @branchless_items = split('--|/', $branchless);
17 1         4 splice(@branchless_items, 2, 0, '');
18 1         3 my $branchless2 = join('--', @branchless_items); $branchless2 =~ s!--!/!;
  1         4  
19              
20             # test branchless names
21 1         501 my $name = Arch::Name->new($branchless);
22 1         5 isa_ok($name, "Arch::Name", "branchless");
23 1         583 is($name->branch, '', "branchless branch");
24 1         510 is($name->level(1), "revision", "branchless level");
25 1         438 is($name->fqn, $branchless, "branchless name");
26 1         494 is(join('|', $name->get), join('|', @branchless_items), "branchless items");
27              
28 1         488 $name->set([@branchless_items]);
29 1         4 is($branchless, $name->fqn, "branchless set");
30 1         591 is(Arch::Name->new("$archive/$category--0")->branch, '', "branchless branch");
31              
32 1         425 my $name2 = Arch::Name->new($branchless2);
33 1         4 is($name2->branch, '', "branchless2 branch");
34 1         422 isa_ok($name, "Arch::Name", "branchless2");
35 1         466 is($name2->fqn, $branchless, "branchless2 name");
36              
37             # test is_valid thoroughly
38 1         424 ok($name->is_valid, "is_valid");
39 1         401 ok($name->is_valid('revision'), "is_valid revision");
40 1         420 ok(!$name->is_valid('category'), "is_valid category");
41 1         410 ok(!$name->is_valid('archive'), "is_valid archive");
42 1         216 ok($name->is_valid('branch+'), "is_valid branch+");
43 1         416 ok($name->is_valid('archive+'), "is_valid archive+");
44              
45             # test new/set/apply thoroughly
46 1         696 $name = Arch::Name->new([ $archive ]);
47 1         8 isa_ok($name, "Arch::Name", "new with archive arrayref");
48 1         633 is($name->level, 1, "level");
49 1         277 is($name->archive, $archive, "archive");
50              
51 1         392 $name2 = Arch::Name->new({ archive => $archive });
52 1         7 isa_ok($name2, "Arch::Name", "new with archive hashref");
53 1         269 is($name2->level, 1, "level");
54 1         298 is($name2->archive, $archive, "archive");
55              
56 1         237 $name->apply($category);
57 1         3 is($name->level, 2, "apply category level");
58 1         234 $name2->apply({ category => $category });
59 1         5 is($name->level, 2, "apply category level");
60 1         248 is($name->fqn, $name2->fqn, "compare two names");
61              
62 1         231 $name->new([ $archive, $category ]);
63 1         5 isa_ok($name, "Arch::Name", "new from object");
64 1         286 is($name->fqn, $name2->fqn, "compare two names");
65              
66 1         499 $name->set($archive);
67 1         4 $name2->apply([undef]);
68 1         5 is($name->fqn, $name2->fqn, "compare two names");
69              
70             # test clone/cast thoroughly
71 1         241 my $name3 = $name->clone($category, "branch", "0", "base-0");
72 1         4 isa_ok($name3, "Arch::Name", "clone with apply");
73 1         313 is($name3->level, 5, "level");
74 1         434 isnt($name->fqn, $name3->fqn, "compare two names");
75              
76 1         576 my $name4 = $name3->cast(5);
77 1         4 isa_ok($name4, "Arch::Name", "valid cast to 5");
78 1         282 is($name4->level, 5, "level");
79 1         239 is($name->cast(5), undef, "invalid cast to 5");
80 1         241 is($name3->fqn, $name4->fqn, "compare two names");
81              
82 1         224 $name4 = $name3->cast("version");
83 1         4 isa_ok($name4, "Arch::Name", "valid cast to version");
84 1         290 is($name4->level, 4, "level");
85 1         231 is($name->cast("version"), undef, "invalid cast to version");
86 1         211 isnt($name3->fqn, $name4->fqn, "compare two names");
87              
88 1         233 is($name->clone->fqn, $name3->cast(1)->fqn, "compare clone and cast names");
89 1         232 isnt($name->fqn, $name3->fqn, "compare two names");
90              
91             # test all setters thoroughly
92              
93             # test errors thoroughly
94              
95             # test multiple objects thoroughly
96