#!perl use Test::More; eval 'use Test::MockModule;'; if($@) { plan( skip_all => q{missing Test::MockModule} ); } else { plan( tests => 5 ); } use FindBin; use lib "$FindBin::Bin/lib"; use TestString; use Games::Maze::SVG; use strict; use warnings; my $gmaze = Test::MockModule->new( 'Games::Maze' ); my $rectgrid = my $template = do { local $/ = undef; ; }; $gmaze->mock( make => sub { my $self = shift; $self->{entry} = [2,1]; $self->{exit} = [6,8]; }, to_ascii => sub { <new( 'Rect', cols => 3, rows => 3 ); my $output = resolve_template( qq{ } ); is_string( $maze->toString(), $output, "Full transform works." ); #open( my $fh, '>rect1.svg' ) or die; #print $fh $maze->toString(); # ---- Bevel ---- # Because of the outside edge effects, I can't use the template in the # same way. $maze = Games::Maze::SVG->new( 'Rect', cols => 3, rows => 3 ); $maze->set_wall_form( 'bevel' ); like( $maze->toString(), qr{ }, "Full transform, bevel wall style." ); # ---- Round Corners ---- $output = resolve_template( qq{ } ); $maze = Games::Maze::SVG->new( 'Rect', 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( 'Rect', 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( 'Rect', 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