From: Dave Rolsky Date: Wed, 28 Jan 2009 18:47:23 +0000 (+0000) Subject: A subtype should not ignore the parent type name. It should do X-Git-Tag: 0.66~32 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4c252d25683a888151a7b794abfbcb0e7b4268d2;p=gitmo%2FMoose.git A subtype should not ignore the parent type name. It should do _something_ (and we've decided it will auto-vivify as a class type constraint). --- diff --git a/t/040_type_constraints/031_subtype_auto_vivify_parent.t b/t/040_type_constraints/031_subtype_auto_vivify_parent.t new file mode 100644 index 0000000..9f446d6 --- /dev/null +++ b/t/040_type_constraints/031_subtype_auto_vivify_parent.t @@ -0,0 +1,31 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More 'no_plan'; + +use Moose::Util::TypeConstraints; + + +{ + package Foo; + + sub new { + my $class = shift; + + return bless {@_}, $class; + } +} + +subtype 'FooWithSize' + => as 'Foo' + => where { $_[0]->{size} }; + + +my $type = find_type_constraint('FooWithSize'); +ok( $type, 'made a FooWithSize constraint' ); +ok( $type->parent, 'type has a parent type' ); +is( $type->parent->name, 'Foo', 'parent type is Foo' ); +isa_ok( $type->parent, 'Moose::Meta::TypeConstraint::Class', + 'parent type constraint is a class type' );