Permalink
Browse files

t/isa.t working

  • Loading branch information...
1 parent 80f71c5 commit 3bf1a2cbd843f80bdbd85b23bb54c1766a4b9c6d @bobtfish committed Mar 29, 2009
Showing with 11 additions and 34 deletions.
  1. +11 −34 t/isa.t
View
45 t/isa.t
@@ -1,6 +1,7 @@
use strict;
-use Test::More tests => 11;
+use Test::More tests => 8;
use Test::Exception;
+use MooseX::StrictAttributes ();
throws_ok {
package Some::Class;
@@ -10,13 +11,6 @@ throws_ok {
} qr/Can't create a class type constraint for isa on attribute foo because 'Does::Not::Exist' is not a class name/,
'Used as a trait on attributes';
-throws_ok {
- package Another::Class;
- use Moose -traits => [qw/ StrictAttributeIsas /];
- has foo => ( isa => 'Still::Does::Not::Exist' );
-} qr/Can't create a class type constraint for isa on attribute foo because 'Still::Does::Not::Exist' is not a class name/,
- 'Used as a trait on a class';
-
lives_ok {
package Some::Other::Class;
use Moose;
@@ -39,41 +33,24 @@ lives_ok {
lives_ok {
package TestClass::UnionTypes::OK;
- use Moose -traits => [qw/ StrictAttributeIsas /];
-
- has foo => ( isa => 'Some::Class|Some::Other::Class' );
+ use Moose;
+
+ has foo => ( isa => 'Some::Class|Some::Other::Class', traits => [qw/ StrictIsa /] );
+ has bar => ( isa => 'Maybe[Some::Class]', traits => [qw/ StrictIsa /] );
+ has baz => ( isa => 'ArrayRef', traits => [qw/ StrictIsa /] );
} 'Create class with union type constraint';
-lives_ok {
- package TestClass::ParamTypes::OK;
- use Moose -traits => [qw/ StrictAttributeIsas /];
-
- has foo => ( isa => 'Maybe[Some::Class]' );
- has bar => ( isa => 'ArrayRef' );
-} 'Create class with param type constraint';
-
throws_ok {
package Yet::Another::Class;
- use Moose -traits => [qw/ StrictAttributeIsas /];
+ use Moose;
- has 'bar' => ( is => 'rw', isa => 'Maybe[Some::Class::Which::Does::Not::Exist]' );
+ has 'bar' => ( is => 'rw', traits => [qw/ StrictIsa /], isa => 'Maybe[Some::Class::Which::Does::Not::Exist]' );
} qr/is not a class name/, 'Create class with param type constraint throws';
throws_ok {
package TestClass::UnionTypes::Throws;
- use Moose -traits => [qw/ StrictAttributeIsas /];
+ use Moose;
- has foo => ( isa => 'Some::NonExistant::Class|Some::Other::Class' );
+ has foo => ( isa => 'Some::NonExistant::Class|Some::Other::Class', traits => [qw/ StrictIsa /] );
} qr/Could not locate type constraint \(Some::NonExistant::Class\) for the union/, 'Create class with union type constraint throws';
-{
- {
- package Running::Out::Of::Names;
- use Moose -traits => [qw/ StrictAttributeIsas /];
- }
- my $i = Running::Out::Of::Names->new;
- TODO: {
- local $TODO = 'Should be using Moose::Exporter sugar that can be namespace::cleand';
- ok(!$i->meta->can('__generate_attribute_trait_appender'), 'Clean namespace in metaclass');
- }
-}

0 comments on commit 3bf1a2c

Please sign in to comment.