forked from tsee/Games-Lacuna-Client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Buildings_Load.t
49 lines (38 loc) · 1.08 KB
/
Buildings_Load.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
use strict;
use warnings;
use Test::More tests => 5;
our( $package, @load );
BEGIN {
$package = 'Games::Lacuna::Client::Buildings';
use_ok( $package );
};
{ no strict 'refs';
*load = *{$package.'::BuildingTypes'};
}
ok scalar @load, 'Make sure there is a list of buildings to load';
use List::MoreUtils qw'uniq none';
my @sorted = sort { lc $a cmp lc $b } @load;
is_deeply \@load, \@sorted, 'Check if simple list is sorted';
is_deeply \@sorted, [uniq @sorted], 'Look for duplicates in simple list';
{
use FindBin;
use File::Spec::Functions qw'catdir updir';
my $dir_name = catdir $FindBin::Bin, updir, 'lib', split /::/, $package;
my @skip = 'Modules';
my @fail;
opendir my($dir_h), $dir_name;
for my $file( readdir $dir_h ){
next unless $file =~ /(.*)[.]pm$/;
next if $file eq 'Simple.pm';
my $p = $1;
if( none { $p eq $_ } @load, @skip ){
push @fail, $p;
}
}
closedir $dir_h;
ok !@fail, 'Make sure that ::Buildings is loading all of the special buildings';
if( @fail ){
diag 'fails to load:';
diag ' ', $_ for sort @fail;
}
}