Revert autogenerated tests. Tests should not changed radically.
[gitmo/Mouse.git] / t / 040_type_constraints / 009_union_types_and_coercions.t
index 91f7cc8..ca8fcab 100644 (file)
@@ -1,7 +1,4 @@
 #!/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;
@@ -9,10 +6,13 @@ 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;
@@ -47,7 +47,8 @@ use Test::Requires {
 
     # 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
 
@@ -61,6 +62,7 @@ use Test::Requires {
     sub as_string {
         my ($self) = @_;
         my $fh = $self->raw_body();
+
         return do { local $/; <$fh> };
     }
 }
@@ -158,36 +160,5 @@ use Test::Requires {
     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;