Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test blockless PRE and POST
  • Loading branch information
moritz committed Mar 20, 2012
1 parent 70ba2f8 commit 2023f06
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion S04-phasers/pre-post.t
Expand Up @@ -6,7 +6,7 @@ use Test;
# L<S04/Phasers/"assert precondition at every block ">
# L<S06/Subroutine traits/PRE/POST>

plan 19;
plan 22;

sub foo(Int $i) {
PRE {
Expand Down Expand Up @@ -168,4 +168,15 @@ dies_ok { $pt.test(1) }, 'POST receives return value as $_ (failure)';
# is $!.pending.[-1], 'a POST exception', 'does push onto $!.pending';
}

{
my sub blockless($x) {
PRE $x >= 0;
POST $_ == 4;
return $x;
}
lives_ok { blockless(4) }, 'blockless PRE/POST (+)';
dies_ok { blockless -4 }, 'blockless PRE/POST (-, 1)';
dies_ok { blockless 14 }, 'blockless PRE/POST (-, 2)';
}

# vim: ft=perl6

0 comments on commit 2023f06

Please sign in to comment.