Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 103e65a78a
Fetching contributors…

Cannot retrieve contributors at this time

38 lines (32 sloc) 0.814 kb
use strict;
use warnings;
use Test::More;
use Scope::Upper qw/unwind/;
BEGIN {
eval { require MooseX::Types::Structured; };
if ($@) {
plan skip_all => "This test requires MooseX::Types::Structured"
} else {
plan tests => 3;
}
}
BEGIN { use_ok "TryCatch" or BAIL_OUT("Cannot load TryCatch") };
use MooseX::Types::Structured qw/Dict/;
sub throw_struct {
my @args = @_;
try {
die { code => $args[0] };
}
catch (Dict[code => Int] $err where { $_->{code} >= 200 } ) {
return "Code over 200";
}
catch (Dict[code => Int] $err where { $_->{code} < 200 } ) {
return "Code less than 200";
}
catch {
return "otherwise";
}
return "no error";
}
is throw_struct(200), "Code over 200", "where condition 1";
is throw_struct(100), "Code less than 200", "where condition 2";
Jump to Line
Something went wrong with that request. Please try again.