Permalink
Browse files

test blockless PRE and POST

  • Loading branch information...
1 parent 70ba2f8 commit 2023f06895ee048bb218441edd2bd47006aaaefd @moritz moritz committed Mar 20, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 S04-phasers/pre-post.t
View
@@ -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 {
@@ -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.