#!perl use Test::More; eval 'use Test::MockModule;'; if($@) { plan( skip_all => q{missing Test::MockModule} ); } else { plan( tests => 4 ); } use FindBin; use lib "$FindBin::Bin/lib"; use MazeTestUtils; use TestString; use Games::Maze::SVG; use strict; use warnings; my $gmaze = Test::MockModule->new( 'Games::Maze' ); my $template = do { local $/ = undef; ; }; $gmaze->mock( make => sub { my $self = shift; $self->{entry} = [2,1]; $self->{exit} = [6,8]; }, to_ascii => sub { normalize_maze( <<'EOM' ); }, __ __ / \__/ \ \ / __ \ / \ / __/ \ / \__ \ / \__ \ / \ / __/ \ / \ / \ / \__ \__ \ \__/ \ / EOM ); # Default constructor. my $maze = Games::Maze::SVG->new( 'RectHex', cols => 3, rows => 3 ); #open( my $fh, '>recthex1.svg' ) or die; #print $fh $maze->toString(); my $output = resolve_template( qq{ }); is_string( $maze->toString(), $output, "Full transform works." ); # ---- Round Corners ---- $output = resolve_template( qq{ } ); $maze = Games::Maze::SVG->new( 'RectHex', cols => 3, rows => 3 ); $maze->set_wall_form( 'roundcorners' ); is_string( $maze->toString(), $output, "Full transform, roundcorners wall style." ); # ---- Round ---- $output = resolve_template( qq{ } ); $maze = Games::Maze::SVG->new( 'RectHex', cols => 3, rows => 3 ); $maze->set_wall_form( 'round' ); is_string( $maze->toString(), $output, "Full transform, round wall style." ); # ---- Straight ---- $output = resolve_template( qq{ } ); $maze = Games::Maze::SVG->new( 'RectHex', cols => 3, rows => 3 ); $maze->set_wall_form( 'straight' ); is_string( $maze->toString(), $output, "Full transform, straight wall style." ); # # Convert the template into a complete svg page. # # walldefs a string containing the wall piece definitions # # Returns the complete output. sub resolve_template { my $walldefs = shift; my $output = $template; $output =~ s/\{\{walldefs\}\}/$walldefs/sm; $output; } __DATA__ An SVG Maze This maze was generated using the Games::Maze::SVG Perl module. SVG Maze 2006 An SVG-based Game G. Wade Johnson G. Wade Johnson {{walldefs}} Entry Exit