Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[crypt.pl] test function refactor

Added another parameter for nicer test messages.
  • Loading branch information...
commit 66e182d242e89ceebe087d1abdf21e160d65faa7 1 parent 96d9cf3
Carl Mäsak authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 crypt.pl
7 crypt.pl
View
@@ -94,8 +94,7 @@
}
}
-sub throws_exception(&code, $ex_type, &followup?) {
- my $message = 'code dies as expected';
+sub throws_exception(&code, $ex_type, $message, &followup?) {
&code();
ok 0, $message;
if &followup {
@@ -129,6 +128,7 @@ (&code, $ex_type, &followup?)
throws_exception
{ $game.move('left', 'middle') },
X::Hanoi::LargerOnSmaller,
+ 'legal move (-) larger disk on smaller',
{
is .larger, 'small disk', '.larger attribute';
is .smaller, 'tiny disk', '.smaller attribute';
@@ -140,6 +140,7 @@ (&code, $ex_type, &followup?)
throws_exception
{ $game.move('gargle', 'middle') },
X::Hanoi::NoSuchRod,
+ 'legal move (-) no such source rod',
{
is .rod, 'source', '.rod attribute';
is .name, 'gargle', '.name attribute';
@@ -151,6 +152,7 @@ (&code, $ex_type, &followup?)
throws_exception
{ $game.move('middle', 'clown') },
X::Hanoi::NoSuchRod,
+ 'legal move (-) no such target rod',
{
is .rod, 'target', '.rod attribute';
is .name, 'clown', '.name attribute';
@@ -162,6 +164,7 @@ (&code, $ex_type, &followup?)
throws_exception
{ $game.move('right', 'middle') },
X::Hanoi::RodHasNoDisks,
+ 'legal move (-) rod has no disks',
{
is .name, 'right', '.name attribute';
is .message,
Please sign in to comment.
Something went wrong with that request. Please try again.