summaryrefslogtreecommitdiffstats
path: root/t/try/when.t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-19 02:02:33 -0400
committerJesse Luehrs <doy@tozt.net>2013-07-19 02:02:33 -0400
commitbe8cfb28cb18499cf6ddfff9eff256d08537dd18 (patch)
tree375f7525e6ee6f39d1ed952edb4be17c88c9a0f6 /t/try/when.t
parent56de12a2999763ca14aefdf4ac1af1d527ccbc71 (diff)
downloadparse-keyword-be8cfb28cb18499cf6ddfff9eff256d08537dd18.tar.gz
parse-keyword-be8cfb28cb18499cf6ddfff9eff256d08537dd18.zip
add some (failing) tests
Diffstat (limited to 't/try/when.t')
-rw-r--r--t/try/when.t31
1 files changed, 31 insertions, 0 deletions
diff --git a/t/try/when.t b/t/try/when.t
new file mode 100644
index 0000000..60322b7
--- /dev/null
+++ b/t/try/when.t
@@ -0,0 +1,31 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+use lib 't/try/lib';
+use 5.014;
+
+use Try;
+
+my ( $foo, $bar, $other );
+
+$_ = "magic";
+
+try {
+ die "foo";
+} catch {
+
+ like( $_, qr/foo/ );
+
+ when (/bar/) { $bar++ };
+ when (/foo/) { $foo++ };
+ default { $other++ };
+}
+
+is( $_, "magic", '$_ not clobbered' );
+
+ok( !$bar, "bar didn't match" );
+ok( $foo, "foo matched" );
+ok( !$other, "fallback didn't match" );
+
+done_testing;