Permalink
Browse files

[bin/crypt] moved throws_exception down one step

To the MAIN multi that actually uses it.
  • Loading branch information...
1 parent ed7110e commit 18cbfdc02e6c9eeaa63320f458caf6596d9c3837 @masak committed Jul 2, 2012
Showing with 23 additions and 23 deletions.
  1. +23 −23 bin/crypt
View
@@ -223,29 +223,6 @@ class Hanoi::Game {
}
}
-sub throws_exception(&code, $ex_type, $message, &followup?) {
- &code();
- ok 0, $message;
- if &followup {
- diag 'Not running followup because an exception was not triggered';
- }
- CATCH {
- default {
- ok 1, $message;
- my $type_ok = $_.WHAT === $ex_type;
- ok $type_ok , "right exception type ({$ex_type.^name})";
- if $type_ok {
- &followup($_);
- } else {
- diag "Got: {$_.WHAT.gist}\n"
- ~"Expected: {$ex_type.gist}";
- diag "Exception message: $_.message()";
- diag 'Not running followup because type check failed';
- }
- }
- }
-}
-
multi MAIN('hanoi') {
my Hanoi::Game $game .= new;
my @disks = <tiny small medium large huge> X~ ' disk';
@@ -348,6 +325,29 @@ multi MAIN('hanoi') {
}
}
+sub throws_exception(&code, $ex_type, $message, &followup?) {
+ &code();
+ ok 0, $message;
+ if &followup {
+ diag 'Not running followup because an exception was not triggered';
+ }
+ CATCH {
+ default {
+ ok 1, $message;
+ my $type_ok = $_.WHAT === $ex_type;
+ ok $type_ok , "right exception type ({$ex_type.^name})";
+ if $type_ok {
+ &followup($_);
+ } else {
+ diag "Got: {$_.WHAT.gist}\n"
+ ~"Expected: {$ex_type.gist}";
+ diag "Exception message: $_.message()";
+ diag 'Not running followup because type check failed';
+ }
+ }
+ }
+}
+
multi MAIN('test', 'hanoi') {
{
my $game = Hanoi::Game.new();

0 comments on commit 18cbfdc

Please sign in to comment.