66 lines
1.8 KiB
Perl
66 lines
1.8 KiB
Perl
#!/usr/bin/env perl
|
|
|
|
use v5.36.0;
|
|
use strict;
|
|
use warnings;
|
|
|
|
use feature 'signatures';
|
|
|
|
use Scalar::Util qw/blessed/;
|
|
|
|
use Test::Most tests => 11, qw/bail/;
|
|
|
|
{
|
|
require LasTres::Planets;
|
|
my $planets = LasTres::Planets->new;
|
|
my $planets_hash = $planets->hash;
|
|
for my $planet_identifier (keys %$planets_hash) {
|
|
my $planet = $planets_hash->{$planet_identifier};
|
|
test_planet($planet);
|
|
}
|
|
}
|
|
|
|
done_testing;
|
|
|
|
sub test_planet($planet) {
|
|
my $super_areas_hash = $planet->super_areas;
|
|
is ref($super_areas_hash), 'HASH', (blessed $planet)
|
|
. ' super_areas method returns a hashref.';
|
|
|
|
for my $super_area_identifier (keys %$super_areas_hash) {
|
|
my $super_area = $super_areas_hash->{$super_area_identifier};
|
|
test_super_area($super_area);
|
|
}
|
|
}
|
|
|
|
sub test_super_area($super_area) {
|
|
ok $super_area->does('LasTres::SuperArea'),
|
|
(blessed $super_area) . ' implements LasTres::SuperArea.';
|
|
my $areas_hash = $super_area->areas;
|
|
is ref($areas_hash), 'HASH', (blessed $super_area)
|
|
. ' areas method returns a hashref.';
|
|
|
|
for my $area_identifier (keys %$areas_hash) {
|
|
my $area = $areas_hash->{$area_identifier};
|
|
test_area($area);
|
|
}
|
|
}
|
|
|
|
sub test_area($area) {
|
|
ok $area->does('LasTres::Area'),
|
|
(blessed $area) . ' implements LasTres::Area.';
|
|
my $locations_hash = $area->locations;
|
|
is ref($locations_hash), 'HASH', (blessed $area)
|
|
. ' locations method returns a hashref.';
|
|
|
|
for my $location_identifier (keys %$locations_hash) {
|
|
my $location = $locations_hash->{$location_identifier};
|
|
test_location($location);
|
|
}
|
|
}
|
|
|
|
sub test_location($location) {
|
|
ok $location->does('LasTres::Location'),
|
|
(blessed $location) . ' implements LasTres::Location.';
|
|
}
|