-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy path10.resolve.t
66 lines (53 loc) · 2.02 KB
/
10.resolve.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
#!/usr/bin/env perl
use Test2::V0;
use Test2::Tools::Spec;
use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require "test2_helpers.pl";
mock_perlbrew_install("perl-5.8.9");
mock_perlbrew_install("perl-5.14.0");
mock_perlbrew_install("perl-5.8.9", "--as" => "5.8.9");
mock_perlbrew_install("perl-5.14.0", "--as" => "perl-shiny", "perl-5.14.0");
{
no warnings 'redefine';
sub App::perlbrew::current_perl { "perl-5.14.0" }
}
## spec
describe "App::perlbrew->resolve_installation_name" => sub {
my $app;
before_each new_perlbrew => sub {
$app = App::perlbrew->new;
};
it "takes exactly one argument, which means the `shortname` that needs to be resolved to a `longname`", sub {
ok $app->resolve_installation_name("5.8.9");
ok dies {
$app->resolve_installation_name; # no args
};
};
it "returns the same value as the argument if there is an installation with exactly the same name", sub {
is $app->resolve_installation_name("5.8.9"), "5.8.9";
is $app->resolve_installation_name("perl-5.8.9"), "perl-5.8.9";
is $app->resolve_installation_name("perl-5.14.0"), "perl-5.14.0";
};
it "returns `perl-\$shortname` if that happens to be a proper installation name.", sub {
is $app->resolve_installation_name("5.14.0"), "perl-5.14.0";
is $app->resolve_installation_name("shiny"), "perl-shiny";
};
it "returns undef if no proper installation can be found", sub {
is $app->resolve_installation_name("nihao"), undef;
};
describe 'with lib names' => sub {
it 'returns both perl version and libnames' => sub {
my ($v, $l) = $app->resolve_installation_name('perl-5.14.0@soya');
is $v, "perl-5.14.0";
is $l, "soya";
};
it 'returns current perl version when only a libname is given' => sub {
my ($v, $l) = $app->resolve_installation_name('@soya');
is $v, $app->current_perl;
is $l, "soya";
};
};
};
done_testing;