diff options
author | Rafael Kitover <rkitover@cpan.org> | 2009-06-15 15:23:03 -0700 |
---|---|---|
committer | Rafael Kitover <rkitover@cpan.org> | 2009-06-15 15:23:03 -0700 |
commit | ad1917d79f5490b78c921ce0e7ae708c300d97e4 (patch) | |
tree | a340a9fa5c76803e17d4b056977f941443f838e2 /t | |
parent | 7a603ffaf368e45a344d029e716ea36b10794e40 (diff) | |
download | mx-alwayscoerce-ad1917d79f5490b78c921ce0e7ae708c300d97e4.tar.gz mx-alwayscoerce-ad1917d79f5490b78c921ce0e7ae708c300d97e4.zip |
first release
Diffstat (limited to 't')
-rw-r--r-- | t/01-basic.t | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/t/01-basic.t b/t/01-basic.t new file mode 100644 index 0000000..f056dd9 --- /dev/null +++ b/t/01-basic.t @@ -0,0 +1,28 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Test::More tests => 3; + +{ + package MyClass; + use Moose; + use MooseX::ClassAttribute; + use MooseX::AlwaysCoerce; + use Moose::Util::TypeConstraints; + + subtype 'MyType', as 'Int'; + coerce 'MyType', from 'Str', via { length $_ }; + + has foo => (is => 'rw', isa => 'MyType'); + + class_has bar => (is => 'rw', isa => 'MyType'); +} + +ok( (my $instance = MyClass->new), 'instance' ); + +eval { $instance->foo('bar') }; +ok( (!$@), 'attribute coercion ran' ); + +eval { $instance->bar('baz') }; +ok( (!$@), 'class attribute coercion ran' ); |