#!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 $template = do { local $/ = undef; ; }; $gmaze->mock( make => sub { my $self = shift; $self->{entry} = [2,0]; $self->{exit} = [2,5]; }, to_ascii => sub { < } ); my $maze = Games::Maze::SVG->new( 'Rect', cols => 3, rows => 3 ); $maze->set_interactive(); is_string( $maze->toString(), $output, "Full transform, default wall style." ); #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' ); $maze->set_interactive(); 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' ); $maze->set_interactive(); my $got = $maze->toString(); is_string( $got, $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' ); $maze->set_interactive(); 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' ); $maze->set_interactive(); 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__ A Playable 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 1111111 1010101 1111111 1010101 1111111 1010101 1111111 {{walldefs}} Entry Exit Begin Save Back Move View Click Begin button to start Use the arrow keys to move the sprite Hold the shift to move quickly. The mouse must remain over the maze for the keys to work. Use arrow buttons to shift the maze Center button centers view on sprite Save button saves current position Back button restores last position Solved!