File: test.pl

package info (click to toggle)
libenv-path-perl 0.19-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 104 kB
  • sloc: perl: 443; makefile: 8
file content (50 lines) | stat: -rwxr-xr-x 1,215 bytes parent folder | download | duplicates (4)
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
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

my $final = 0;

# Automatically generates an ok/nok msg, incrementing the test number.
BEGIN {
    my($next, @msgs);
    sub printok {
	push @msgs, ($_[0] ? '' : 'not ') . "ok @{[++$next]}\n";
	return !$_[0];
    }
    END {
	if ($loaded) {
	    print "\n1..", scalar @msgs, "\n", @msgs;
	} else {
	    print "not ok 1\n";
	}
    }
}

use Env::Path;
$loaded = 1;
$final += printok(1);

my $p1 = Env::Path->XXXPATH(qw(aaa bbb ccc));
printok($p1->Name eq 'XXXPATH' && !@XXXPATH::ISA);

my $p2 = Env::Path->new('YYYPATH', qw(aaa bbb ccc xxx yyy zzz c123));
$p2->Replace('^c.*', qw(/CC /XX));
printok($p2->Name eq 'YYYPATH');

$p1->Append($p2->List);
$p1->Uniqify;
$p1->DeleteNonexistent;
printok($p1->List eq 0);

Env::Path->PATH;
PATH->Uniqify;
PATH->DeleteNonexistent;
printok(@PATH::ISA);

Env::Path->ZZZPATH(PATH->List);
ZZZPATH->Append('/nosuchdir');
ZZZPATH->Assign(ZZZPATH->List, $ENV{ZZZPATH});
printok(PATH->List eq (ZZZPATH->List - 2)/2);
ZZZPATH->Uniqify;
printok(PATH->List eq ZZZPATH->List - 1);
ZZZPATH->DeleteNonexistent;
printok(PATH->List eq ZZZPATH->List);