X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F107_union_bug.t;h=a1d4b7c8e6b360bf40927a7847e6d3c06f9df908;hb=6522bce9db4da59a483ebac15db58d85d90f2f64;hp=f3283c771f733cd7aec3f92e3351476af822fb64;hpb=416dcb2e6a856f9263b043704ddfdf247b050185;p=gitmo%2FMooseX-Getopt.git diff --git a/t/107_union_bug.t b/t/107_union_bug.t index f3283c7..a1d4b7c 100644 --- a/t/107_union_bug.t +++ b/t/107_union_bug.t @@ -1,41 +1,40 @@ -#!/usr/bin/perl - use strict; use warnings; -use Test::Most tests => 5; +use Test::More tests => 6; +use Test::NoWarnings 1.04 ':early'; { package example; - + use Moose; use Moose::Util::TypeConstraints; with qw( MooseX::Getopt ); - - subtype 'ResultSet' + + subtype 'ResultSet' => as 'DBIx::Class::ResultSet'; - - subtype 'ResultList' + + subtype 'ResultList' => as 'ArrayRef[Int]'; MooseX::Getopt::OptionTypeMap->add_option_type_to_map( 'ResultList' => '=s', ); - - coerce 'ResultList' - => from 'Str' + + coerce 'ResultList' + => from 'Str' => via { return [ grep { m/^\d+$/ } split /\D/,$_ ]; # <- split string into arrayref }; - + has 'results' => ( is => 'rw', isa => 'ResultList | ResultSet', # <- union constraint coerce => 1, ); - + has 'other' => ( is => 'rw', isa => 'Str', @@ -49,8 +48,7 @@ use Test::Most tests => 5; other => 'test', }); isa_ok($example, 'example'); - explain($example->results); - cmp_deeply($example->results, [qw(1234 5678 9012)], 'result as expected'); + is_deeply($example->results, [qw(1234 5678 9012)], 'result as expected'); } # With MooseX::Getopt @@ -58,8 +56,8 @@ use Test::Most tests => 5; local @ARGV = ('--results','1234,5678,9012','--other','test'); my $example = example->new_with_options; isa_ok($example, 'example'); - - explain($example->results); + is($example->other,'test'); - cmp_deeply($example->results, [qw(1234 5678 9012)], 'result as expected'); -} \ No newline at end of file + is_deeply($example->results, [qw(1234 5678 9012)], 'result as expected'); +} +