Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit c9e01dda9cd8a4a0ca13dc3536231a5ff159e5e8 1 parent 50e0179
Carl Mäsak authored July 01, 2012

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

  1. 24  crypt.pl
24  crypt.pl
@@ -113,6 +113,8 @@
113 113
                     last;
114 114
                 }
115 115
             }
  116
+            die X::Hanoi::DiskHasBeenRemoved.new(:action<move>, :$disk)
  117
+                unless @source_rod;
116 118
         }
117 119
         else {
118 120
             die X::Hanoi::NoSuchRod.new(:rod<source>, :name($source))
@@ -220,12 +222,12 @@ (&code, $ex_type, $message, &followup?)
220 222
 
221 223
         is $game.move('left', 'middle'),
222 224
            Hanoi::DiskMoved.new(:size<tiny>, :source<left>, :target<middle>),
223  
-           'legal move (+)';
  225
+           'moving a disk (+)';
224 226
 
225 227
         throws_exception
226 228
             { $game.move('left', 'middle') },
227 229
             X::Hanoi::LargerOnSmaller,
228  
-            'legal move (-) larger disk on smaller',
  230
+            'moving a disk (-) larger disk on smaller',
229 231
             {
230 232
                 is .larger, 'small disk', '.larger attribute';
231 233
                 is .smaller, 'tiny disk', '.smaller attribute';
@@ -237,7 +239,7 @@ (&code, $ex_type, $message, &followup?)
237 239
         throws_exception
238 240
             { $game.move('gargle', 'middle') },
239 241
             X::Hanoi::NoSuchRod,
240  
-            'legal move (-) no such source rod',
  242
+            'moving a disk (-) no such source rod',
241 243
             {
242 244
                 is .rod, 'source', '.rod attribute';
243 245
                 is .name, 'gargle', '.name attribute';
@@ -249,7 +251,7 @@ (&code, $ex_type, $message, &followup?)
249 251
         throws_exception
250 252
             { $game.move('middle', 'clown') },
251 253
             X::Hanoi::NoSuchRod,
252  
-            'legal move (-) no such target rod',
  254
+            'moving a disk (-) no such target rod',
253 255
             {
254 256
                 is .rod, 'target', '.rod attribute';
255 257
                 is .name, 'clown', '.name attribute';
@@ -261,7 +263,7 @@ (&code, $ex_type, $message, &followup?)
261 263
         throws_exception
262 264
             { $game.move('right', 'middle') },
263 265
             X::Hanoi::RodHasNoDisks,
264  
-            'legal move (-) rod has no disks',
  266
+            'moving a disk (-) rod has no disks',
265 267
             {
266 268
                 is .name, 'right', '.name attribute';
267 269
                 is .message,
@@ -417,6 +419,18 @@ (&code, $ex_type, $message, &followup?)
417 419
                    'Cannot remove the tiny disk because it has been removed',
418 420
                    '.message attribute';
419 421
             };
  422
+
  423
+        throws_exception
  424
+            { $game.move('tiny disk', 'middle') },
  425
+            X::Hanoi::DiskHasBeenRemoved,
  426
+            'moving a disk (-) the disk had already been removed',
  427
+            {
  428
+                is .disk, 'tiny disk', '.disk attribute';
  429
+                is .action, 'move', '.action attribute';
  430
+                is .message,
  431
+                    'Cannot move the tiny disk because it has been removed',
  432
+                    '.message attribute';
  433
+            };
420 434
     }
421 435
 
422 436
     done;

0 notes on commit c9e01dd

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