X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F200_examples%2F001_example.t;h=d7dd836553022f5ac1363f49f975d523da2b5685;hb=9d010f57f95d0b16078339ddea88e9f69b2067df;hp=33f90587f4149556648764d203f166eeca97889f;hpb=e59a5c292a333cac504b65ebd4bba20b5e98d796;p=gitmo%2FMoose.git diff --git a/t/200_examples/001_example.t b/t/200_examples/001_example.t index 33f9058..d7dd836 100644 --- a/t/200_examples/001_example.t +++ b/t/200_examples/001_example.t @@ -3,12 +3,10 @@ use strict; use warnings; -use Test::More tests => 21; +use Test::More tests => 20; use Test::Exception; -BEGIN { - use_ok('Moose'); -} + ## Roles @@ -22,16 +20,16 @@ BEGIN { 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; @@ -44,11 +42,11 @@ BEGIN { override 'error_message' => sub { my $self = shift; return super() . ' ' . $self->units; - }; + }; } -## Classes +## Classes { package Constraint::AtLeast; @@ -80,12 +78,12 @@ BEGIN { 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); @@ -114,8 +112,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');