Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[crypt.pl] cannot move a disk that has been removed

  • Loading branch information...
commit c9e01dda9cd8a4a0ca13dc3536231a5ff159e5e8 1 parent 50e0179
@masak authored
Showing with 19 additions and 5 deletions.
  1. +19 −5 crypt.pl
View
24 crypt.pl
@@ -113,6 +113,8 @@
last;
}
}
+ die X::Hanoi::DiskHasBeenRemoved.new(:action<move>, :$disk)
+ unless @source_rod;
}
else {
die X::Hanoi::NoSuchRod.new(:rod<source>, :name($source))
@@ -220,12 +222,12 @@ (&code, $ex_type, $message, &followup?)
is $game.move('left', 'middle'),
Hanoi::DiskMoved.new(:size<tiny>, :source<left>, :target<middle>),
- 'legal move (+)';
+ 'moving a disk (+)';
throws_exception
{ $game.move('left', 'middle') },
X::Hanoi::LargerOnSmaller,
- 'legal move (-) larger disk on smaller',
+ 'moving a disk (-) larger disk on smaller',
{
is .larger, 'small disk', '.larger attribute';
is .smaller, 'tiny disk', '.smaller attribute';
@@ -237,7 +239,7 @@ (&code, $ex_type, $message, &followup?)
throws_exception
{ $game.move('gargle', 'middle') },
X::Hanoi::NoSuchRod,
- 'legal move (-) no such source rod',
+ 'moving a disk (-) no such source rod',
{
is .rod, 'source', '.rod attribute';
is .name, 'gargle', '.name attribute';
@@ -249,7 +251,7 @@ (&code, $ex_type, $message, &followup?)
throws_exception
{ $game.move('middle', 'clown') },
X::Hanoi::NoSuchRod,
- 'legal move (-) no such target rod',
+ 'moving a disk (-) no such target rod',
{
is .rod, 'target', '.rod attribute';
is .name, 'clown', '.name attribute';
@@ -261,7 +263,7 @@ (&code, $ex_type, $message, &followup?)
throws_exception
{ $game.move('right', 'middle') },
X::Hanoi::RodHasNoDisks,
- 'legal move (-) rod has no disks',
+ 'moving a disk (-) rod has no disks',
{
is .name, 'right', '.name attribute';
is .message,
@@ -417,6 +419,18 @@ (&code, $ex_type, $message, &followup?)
'Cannot remove the tiny disk because it has been removed',
'.message attribute';
};
+
+ throws_exception
+ { $game.move('tiny disk', 'middle') },
+ X::Hanoi::DiskHasBeenRemoved,
+ 'moving a disk (-) the disk had already been removed',
+ {
+ is .disk, 'tiny disk', '.disk attribute';
+ is .action, 'move', '.action attribute';
+ is .message,
+ 'Cannot move the tiny disk because it has been removed',
+ '.message attribute';
+ };
}
done;
Please sign in to comment.
Something went wrong with that request. Please try again.