From 93dd811c1233c3e9d28d92a56166436a81c3e854 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 18 Aug 2012 15:08:00 -0500 Subject: first implementation --- t/when.t | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 t/when.t (limited to 't/when.t') diff --git a/t/when.t b/t/when.t new file mode 100644 index 0000000..3d9ad62 --- /dev/null +++ b/t/when.t @@ -0,0 +1,30 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +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; -- cgit v1.2.3-54-g00ecf