Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[bin/crypt] removing a non-existent disk
Should give the appropriate exception NoSuchDisk.
  • Loading branch information
Carl Masak committed Jul 2, 2012
1 parent 289fb0c commit 45fb271
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bin/crypt
Expand Up @@ -161,6 +161,8 @@ class Hanoi::Game {
}

method remove($disk) {
die X::Hanoi::NoSuchDisk.new(:action<remove>, :$disk)
unless $disk eq any(@disks);
my $source = self!rod_with_disk($disk, 'remove');
die X::Hanoi::ForbiddenDiskRemoval.new(:$disk)
unless $disk eq 'tiny disk';
Expand Down Expand Up @@ -596,5 +598,22 @@ multi MAIN('test', 'hanoi') {
};
}

{
my $game = Hanoi::Game.new();

throws_exception
{ $game.remove('masakian disk') },
X::Hanoi::NoSuchDisk,
'removing a disk (-) the disk does not exist',
{
is .action, 'remove', '.action attribute';
is .disk, 'masakian disk', '.disk attribute';
is .message,
'Cannot remove a masakian disk because there is no such disk',
'.message attribute';
};

}

done;
}

0 comments on commit 45fb271

Please sign in to comment.