#!/usr/bin/perl
-# This is automatically generated by author/import-moose-test.pl.
-# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
-use t::lib::MooseCompat;
use strict;
use warnings;
use Test::More;
use Test::Exception;
-use Test::Requires {
- 'IO::String' => '0.01', # skip all if not installed
- 'IO::File' => '0.01',
-};
+BEGIN {
+ eval "use IO::String; use IO::File;";
+ plan skip_all => "IO::String and IO::File are required for this test" if $@;
+ plan tests => 28;
+}
+
+
{
package Email::Mouse;
# create the alias
- subtype 'IO::StringOrFile' => as 'IO::String | IO::File';
+ my $st = subtype 'IO::StringOrFile' => as 'IO::String | IO::File';
+ #::diag $st->dump;
# attributes
sub as_string {
my ($self) = @_;
my $fh = $self->raw_body();
+
return do { local $/; <$fh> };
}
}
is($email->raw_body, $fh, '... and it is the one we expected');
}
-{
- package Foo;
-
- use Mouse;
- use Mouse::Util::TypeConstraints;
-
- subtype 'Coerced' => as 'ArrayRef';
- coerce 'Coerced'
- => from 'Value'
- => via { [ $_ ] };
-
- has carray => (
- is => 'ro',
- isa => 'Coerced | Coerced',
- coerce => 1,
- );
-}
-
-{
- my $foo;
- lives_ok { $foo = Foo->new( carray => 1 ) }
- 'Can pass non-ref value for carray';
- is_deeply(
- $foo->carray, [1],
- 'carray was coerced to an array ref'
- );
- throws_ok { Foo->new( carray => {} ) }
- qr/\QValidation failed for 'Coerced|Coerced' with value \E(?!undef)/,
- 'Cannot pass a hash ref for carray attribute, and hash ref is not coerced to an undef';
-}
-done_testing;