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.159 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.158 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.157 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.156 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.155 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.154 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.153 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.152 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.151 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.150 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.149 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.148 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.147 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.146 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.145 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.144 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.143 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.142 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.141 tracks/perl5/exercises/robot-name/robot_name.t
trackler-2.2.1.140 tracks/perl5/exercises/robot-name/robot_name.t