alltests pass!
[gitmo/MooseX-Types-Data-GUID.git] / t / basic.t
CommitLineData
63491692 1#!/usr/bin/perl -w
2
3use strict;
4use warnings;
5
6use Test::More tests => 10;
7use Moose::Util::TypeConstraints;
8use MooseX::Types::Data::GUID qw/GUID/;
9
10for my $key ( GUID, 'Data::GUID' ){
11 if(my $constraint = find_type_constraint($key) ){
12 isa_ok( $constraint, "Moose::Meta::TypeConstraint" );
13 if ( $constraint->has_coercion ){
14 ok(1, 'has coercion');
15 my $coercion = $constraint->coercion;
16 ok( $coercion->has_coercion_for_type('Str'), 'has coercion for Str');
17 my $original_str = 'C6A9FE9A-72FE-11DD-B3B4-B2EC1DADD46B';
18 if( my $guid = $coercion->coerce($original_str) ){
19 isa_ok($guid, 'Data::GUID');
20 is($guid->as_string, $original_str, 'Same GUID was built');
21 }
22 } else {
23 ok(0, 'Failed to find type coercion');
24 }
25 } else {
26 ok(0, "Failed to find type constraint '${key}'");
27 }
28}