Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] removing a non-existent disk

Should give the appropriate exception NoSuchDisk.
  • Loading branch information...
commit 45fb27113b9d47d1a65ce446ea9b517e25328f6c 1 parent 289fb0c
Carl Mäsak authored July 02, 2012

Showing 1 changed file with 19 additions and 0 deletions. Show diff stats Hide diff stats

  1. 19  bin/crypt
19  bin/crypt
@@ -161,6 +161,8 @@ class Hanoi::Game {
161 161
     }
162 162
 
163 163
     method remove($disk) {
  164
+        die X::Hanoi::NoSuchDisk.new(:action<remove>, :$disk)
  165
+            unless $disk eq any(@disks);
164 166
         my $source = self!rod_with_disk($disk, 'remove');
165 167
         die X::Hanoi::ForbiddenDiskRemoval.new(:$disk)
166 168
             unless $disk eq 'tiny disk';
@@ -596,5 +598,22 @@ multi MAIN('test', 'hanoi') {
596 598
             };
597 599
     }
598 600
 
  601
+    {
  602
+        my $game = Hanoi::Game.new();
  603
+
  604
+        throws_exception
  605
+            { $game.remove('masakian disk') },
  606
+            X::Hanoi::NoSuchDisk,
  607
+            'removing a disk (-) the disk does not exist',
  608
+            {
  609
+                is .action, 'remove', '.action attribute';
  610
+                is .disk, 'masakian disk', '.disk attribute';
  611
+                is .message,
  612
+                   'Cannot remove a masakian disk because there is no such disk',
  613
+                   '.message attribute';
  614
+            };
  615
+
  616
+    }
  617
+
599 618
     done;
600 619
 }

0 notes on commit 45fb271

Please sign in to comment.
Something went wrong with that request. Please try again.