Sha256: 4f7eaaaf22e487ec96cf465a082c24a1c63d79f415e266ab08fa4c4dd1f19ece

Contents?: true

Size: 1.06 KB

Versions: 83

Compression:

Stored size: 1.06 KB

Contents

#!/usr/bin/env perl6
use v6;
use Test;
use lib $?FILE.IO.dirname;
use Robot;
plan 7;

my Version:D $version = v2;

if Robot.^ver !~~ $version {
  warn "\nExercise version mismatch. Further tests may fail!"
    ~ "\nRobot is {Robot.^ver.gist}. "
    ~ "Test is {$version.gist}.\n";
}

subtest 'Class methods', {
  ok Robot.can($_), $_ for <name reset-name>;
}

srand 1;
my $robot = Robot.?new;
my Str $name = $robot.?name;
like $name, /^^<[A..Z]>**2 <[0..9]>**3$$/, 'Name matches schema';

srand 2;
is $robot.?name, $name, 'Name is persistent';
srand 1;
isnt Robot.new.?name, $name, 'New Robot cannot claim previous Robot name';

srand 1;
$robot.?reset-name;
$robot.?reset_name; # Allows next test to still pass for older solutions

isnt $robot.?name, $name, "'reset-name' cannot use previous Robot name";

diag "\nCreating 100 robots...";
push my @names, Robot.new.name for 1..100;
is @names, @names.unique, 'All names are unique';
subtest 'Randomness', {
  plan 2;
  isnt @names, @names.sort, 'Names not ordered';
  isnt @names, @names.sort.reverse, 'Names not reverse ordered';
}

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.179 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.178 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.177 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.176 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.175 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.174 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.173 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.172 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.171 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.170 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.169 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.167 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.166 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.165 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.164 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.163 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.162 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.161 tracks/perl6/exercises/robot-name/robot-name.t
trackler-2.2.1.160 tracks/perl6/exercises/robot-name/robot-name.t