File: changes-1

package info (click to toggle)
libarch-perl 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 576 kB
  • ctags: 430
  • sloc: perl: 6,145; makefile: 31
file content (50 lines) | stat: -rwxr-xr-x 1,314 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl -w

# The script tests Arch::Changes methods.

use strict;

use FindBin;
use lib "$FindBin::Bin/../perllib";

use Test::More tests => 12;
BEGIN { use_ok("Arch::Changes", ":type"); }

my $changes = Arch::Changes->new;

$changes->add(ADD,         1, "dir1");
$changes->add(RENAME,      0, "oldfile", "newfile");
$changes->add(MODIFY,      0, "modfile");
$changes->add(META_MODIFY, 0, "modfile");
$changes->add(META_MODIFY, 1, "metadir");
$changes->add(DELETE,      0, "delfile");

is($changes->count, 6, "good count");

my $ch = $changes->get(1);

ok(defined $ch, "change no. 1 defined");

is($ch->{type}, RENAME, "is rename");
is($ch->{is_dir}, 0, "is file");
is($ch->{arguments}->[0], "oldfile", "correct old name");
is($ch->{arguments}->[1], "newfile", "correct new name");

is_deeply($changes->is_changed('from', "dir1", 1),
	{ ADD, 1 }, "is_changed(dir1)");
is_deeply($changes->is_changed(0, "oldfile"),
	{ RENAME, "newfile" }, "is_changed(oldfile)");
is_deeply($changes->is_changed(1, "newfile"),
	{ RENAME, "oldfile" }, "is_changed(newfile)");
is_deeply($changes->is_changed('to', "modfile"),
	{ MODIFY, 1, META_MODIFY, 1 }, "is_changed(modfile)");

my $listing = q{A/ dir1
=> oldfile	newfile
M  modfile
-- modfile
-/ metadir
D  delfile
};

is($changes->get_listing, $listing, "get_listing");