X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F200_examples%2F001_example.t;h=a08aa38aa03e5d158b0d0ac4126077dadaaec392;hb=8d3bb22c39392fe041e520ae3f5259d4c85aaf90;hp=473da12d6794d7c28c22b6b9cee09741a38da2d2;hpb=e606ae5f848070d889472329819c95f5ba763ca3;p=gitmo%2FMoose.git diff --git a/t/200_examples/001_example.t b/t/200_examples/001_example.t index 473da12..a08aa38 100644 --- a/t/200_examples/001_example.t +++ b/t/200_examples/001_example.t @@ -3,9 +3,7 @@ use strict; use warnings; -use Test::More tests => 20; -use Test::Exception; - +use Test::More; ## Roles @@ -20,16 +18,16 @@ use Test::Exception; my $c = shift; my ($self, $field) = @_; return undef if $c->($self, $self->validation_value($field)); - return $self->error_message; + return $self->error_message; }; - + sub validation_value { my ($self, $field) = @_; return $field; } - + sub error_message { confess "Abstract method!" } - + package Constraint::OnLength; use Moose::Role; @@ -42,11 +40,11 @@ use Test::Exception; override 'error_message' => sub { my $self = shift; return super() . ' ' . $self->units; - }; + }; } -## Classes +## Classes { package Constraint::AtLeast; @@ -78,12 +76,12 @@ use Test::Exception; extends 'Constraint::NoMoreThan'; with 'Constraint::OnLength'; - + package Constraint::LengthAtLeast; use Moose; - + extends 'Constraint::AtLeast'; - with 'Constraint::OnLength'; + with 'Constraint::OnLength'; } my $no_more_than_10 = Constraint::NoMoreThan->new(value => 10); @@ -112,8 +110,8 @@ ok($no_more_than_10_chars->does('Constraint'), '... Constraint::LengthNoMoreThan ok($no_more_than_10_chars->does('Constraint::OnLength'), '... Constraint::LengthNoMoreThan does Constraint::OnLength'); ok(!defined($no_more_than_10_chars->validate('foo')), '... validated correctly'); -is($no_more_than_10_chars->validate('foooooooooo'), - 'must be no more than 10 chars', +is($no_more_than_10_chars->validate('foooooooooo'), + 'must be no more than 10 chars', '... validation failed correctly'); my $at_least_10_chars = Constraint::LengthAtLeast->new(value => 10, units => 'chars'); @@ -126,3 +124,4 @@ ok($at_least_10_chars->does('Constraint::OnLength'), '... Constraint::LengthAtLe ok(!defined($at_least_10_chars->validate('barrrrrrrrr')), '... validated correctly'); is($at_least_10_chars->validate('bar'), 'must be at least 10 chars', '... validation failed correctly'); +done_testing;