From: gfx Date: Mon, 21 Sep 2009 02:14:30 +0000 (+0900) Subject: Add a test file for throw_error() X-Git-Tag: 0.32~38 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bf8497ea04511714983c1e914d758ca19ccdf39d;hp=fce211ae5c3943a1b041b9c0985c4daf189fb8a8;p=gitmo%2FMouse.git Add a test file for throw_error() --- diff --git a/t/051_throw_error.t b/t/051_throw_error.t new file mode 100755 index 0000000..ffa3897 --- /dev/null +++ b/t/051_throw_error.t @@ -0,0 +1,43 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Test::More tests => 4; +use Test::Exception; + +{ + package Role; + use Mouse::Role; + + sub rmethod{ + $_[0]->meta->throw_error('bar'); + } + + package Class; + use Mouse; + + with 'Role'; + + sub cmethod{ + $_[0]->meta->throw_error('foo'); + } +} + + +throws_ok { + Class->new->cmethod(); +} qr/\b foo \b/xms; + +throws_ok { + Class->cmethod(); +} qr/\b foo \b/xms; + + + +throws_ok { + Class->new->rmethod(); +} qr/\b bar \b/xms; + +throws_ok { + Class->rmethod(); +} qr/\b bar \b/xms; +