Skip to content

Commit

Permalink
something turned warnings on, probably the test suite…
Browse files Browse the repository at this point in the history
  • Loading branch information
jettero committed Jun 11, 2011
1 parent c194275 commit 49f152b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions MANIFEST
Expand Up @@ -66,3 +66,8 @@ xmllint.test/bad.xml
xmllint.test/map.xml
xmllint.test/t2/MapGen.dtd
xmllint.test/t2/MapGen.xsl
t/05_export.t
t/05_perfect.t
t/05_save_load_files.t
t/05_save_load_strings.t
t/05_z_freeze_thaw.t
1 change: 1 addition & 0 deletions MapGen.pm
Expand Up @@ -6,6 +6,7 @@ use strict;
use AutoLoader;
use Carp;
use Storable;
no warnings;

our $VERSION = '1.5000';

Expand Down
42 changes: 42 additions & 0 deletions t/05_z_freeze_thaw.t
@@ -0,0 +1,42 @@

use strict;
use Test;

my ($x, $y) = (25, 25);

plan tests => ($x * $y);

use Games::RolePlay::MapGen;
use Storable qw(freeze thaw);

my $map = new Games::RolePlay::MapGen({bounding_box => join("x", $x, $y) });

$map->generate;
my $saved_string = freeze($map);

my %checksums = ();
for my $i (0..$x-1) {
for my $j (0..$y-1) {
$checksums{$i}{$j} = &a_kind_of_checksum( $i, $j, $map );
}
}

delete $map->{_the_map};
delete $map->{_the_groups};

$map = thaw($saved_string);

for my $i (0..$x-1) {
for my $j (0..$y-1) {
ok( &a_kind_of_checksum($i, $j, $map), $checksums{$i}{$j} );
}
}

sub a_kind_of_checksum {
my ($x, $y, $map) = @_;

my $tile = $map->{_the_map}[$y][$x];

return "nothin' there" if not exists $tile->{type};
return sprintf('%d-%d-%s-%d%d%d%d', $x, $y, $tile->{type}, map($tile->{od}{$_}, qw(n e s w)));
}

0 comments on commit 49f152b

Please sign in to comment.