File Coverage

tests/changes-1
Criterion Covered Total %
statement 37 37 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 43 43 100.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2              
3             # The script tests Arch::Changes methods.
4              
5 1     1   5 use strict;
  1         4  
  1         45  
6              
7 1     1   1003 use FindBin;
  1         1072  
  1         53  
8 1     1   820 use lib "$FindBin::Bin/../perllib";
  1         635  
  1         9  
9              
10 1     1   1470 use Test::More tests => 12;
  1         19943  
  1         11  
11 1     1   536 BEGIN { use_ok("Arch::Changes", ":type"); }
  1     1   781  
  1         3  
  1         18  
  1         143  
12              
13 1         13 my $changes = Arch::Changes->new;
14              
15 1         7 $changes->add(ADD, 1, "dir1");
16 1         6 $changes->add(RENAME, 0, "oldfile", "newfile");
17 1         6 $changes->add(MODIFY, 0, "modfile");
18 1         4 $changes->add(META_MODIFY, 0, "modfile");
19 1         4 $changes->add(META_MODIFY, 1, "metadir");
20 1         5 $changes->add(DELETE, 0, "delfile");
21              
22 1         5 is($changes->count, 6, "good count");
23              
24 1         395 my $ch = $changes->get(1);
25              
26 1         5 ok(defined $ch, "change no. 1 defined");
27              
28 1         250 is($ch->{type}, RENAME, "is rename");
29 1         241 is($ch->{is_dir}, 0, "is file");
30 1         307 is($ch->{arguments}->[0], "oldfile", "correct old name");
31 1         250 is($ch->{arguments}->[1], "newfile", "correct new name");
32              
33 1         254 is_deeply($changes->is_changed('from', "dir1", 1),
34             { ADD, 1 }, "is_changed(dir1)");
35 1         561 is_deeply($changes->is_changed(0, "oldfile"),
36             { RENAME, "newfile" }, "is_changed(oldfile)");
37 1         524 is_deeply($changes->is_changed(1, "newfile"),
38             { RENAME, "oldfile" }, "is_changed(newfile)");
39 1         582 is_deeply($changes->is_changed('to', "modfile"),
40             { MODIFY, 1, META_MODIFY, 1 }, "is_changed(modfile)");
41              
42 1         556 my $listing = q{A/ dir1
43             => oldfile newfile
44             M modfile
45             -- modfile
46             -/ metadir
47             D delfile
48             };
49              
50 1         6 is($changes->get_listing, $listing, "get_listing");