Mouse::Roleでちょっと途方に暮れてること
バグかどうかも分からないので、つらつらと記録。
#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 2; do { package Hoge; sub new { my $pkg = shift; my $arg = @_ > 1 ? +{@_} : $_[0]; bless $arg, $pkg; } package Parent; use Mouse::Role; use Mouse::Util::TypeConstraints; ## このsubtypeのコメントを外せば、テストが通る #subtype 'Hoge' # => as 'Object' # => where { $_->isa('Hoge') }; coerce 'Hoge' => from 'HashRef' => via { Hoge->new($_) }; has hoge => ( is => 'rw', isa => 'Hoge', coerce => 1, ); no Mouse::Role; no Mouse::Util::TypeConstraints; package My::Class; use Mouse; with 'Parent'; has fuga => ( is => 'rw', isa => 'Str' ); }; ok(my $c = My::Class->new(hoge => { foo => 'bar' })); isa_ok($c->hoge, 'Hoge');
Mouseのテストの形式に合わせました。
僕としては、このテストに通って欲しいんだけどな…