Sha256: 1f7a4b17f247fe6ffb2ce35fab8e1099c3e4bdec38e77c39945fe51461099847

Contents?: true

Size: 1.06 KB

Versions: 73

Compression:

Stored size: 1.06 KB

Contents

#!/usr/bin/env perl
use strict;
use warnings;

use Test::More;
use FindBin;
my $dir;
BEGIN { $dir = $FindBin::Bin . '/' };
use lib $dir;

my $module = 'RobotName';

plan tests => 9;

ok -e "${dir}${module}.pm", "Missing $module.pm"
    or BAIL_OUT("You need to create a module called $module.pm with a constructor and methods called name() and reset_name().");

eval "use $module";
ok !$@, "Cannot load $module.pm"
    or BAIL_OUT("Does $module.pm compile?  Does it end with 1; ?");

can_ok($module, 'new')  or BAIL_OUT("Missing package $module with sub sub new()");
can_ok($module, 'name')  or BAIL_OUT("Missing package $module with sub sub name()");
can_ok($module, 'reset_name') or BAIL_OUT("Missing package $module with sub sub reset()");

# robot method tests
my $robot = $module->new;
my $name = $robot->name;

ok $robot->name =~ /[A-Z]{2}[0-9]{3}/, 'Name should match schema';
is $name, $robot->name, 'Name should be persistent';
ok $robot->name ne $module->new->name, 'Robots should have different names';
ok $robot->reset_name ne $name, 'reset_name should change the robot name';

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.118 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.117 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.116 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.115 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.114 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.113 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.111 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.110 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.109 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.108 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.107 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.106 tracks/perl5/exercises/robot-name/robot_name.t