From: Dave Rolsky Date: Thu, 18 Mar 2010 05:03:18 +0000 (-0500) Subject: Update test style X-Git-Tag: 0.14~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e79becc3c4c2ebdee6479a1a98fe89457a4ac1f2;p=gitmo%2FMooseX-Params-Validate.git Update test style --- diff --git a/t/010.overloaded.t b/t/010.overloaded.t index 6fca960..6c861de 100644 --- a/t/010.overloaded.t +++ b/t/010.overloaded.t @@ -1,30 +1,42 @@ +use Test::More tests => 4; +use strict; +use warnings; -package Foo; -use Moose; -use MooseX::Params::Validate; -use overload ( - qw{""} => 'to_string', -); +{ + package Foo; -has 'id' => ( is => 'ro', isa => 'Str', default => '1.10.100' ); + use Moose; + use MooseX::Params::Validate; + use overload ( + qw{""} => 'to_string', + ); -sub to_string { - my ($self, %args) = validated_hash( \@_, - padded => { isa => 'Bool', optional => 1, default => 0 }, + has 'id' => ( + is => 'ro', + isa => 'Str', + default => '1.10.100', ); - - # 1.10.100 => 0001.0010.0100 - my $id = $args{ padded } - ? join( '.', map { sprintf( "%04d", $_ ) } split( /\./, $self->id ) ) - : $self->id; - - return $id; -} -package main; -use Test::More tests => 4; -use strict; -use warnings; + sub to_string { + my ( $self, %args ) = validated_hash( + \@_, + padded => { + isa => 'Bool', + optional => 1, + default => 0, + }, + ); + + # 1.10.100 => 0001.0010.0100 + my $id + = $args{padded} + ? join( '.', + map { sprintf( "%04d", $_ ) } split( /\./, $self->id ) ) + : $self->id; + + return $id; + } +} isa_ok( my $foo = Foo->new(), 'Foo', 'new' ); @@ -32,5 +44,8 @@ is( $foo->id, '1.10.100', 'id' ); is( $foo->to_string, '1.10.100', 'to_string' ); -is( $foo->to_string( padded => 1 ), '0001.0010.0100', 'to_string( padded => 1 )' ); +is( + $foo->to_string( padded => 1 ), '0001.0010.0100', + 'to_string( padded => 1 )' +);