From: Matt S Trout Date: Sat, 7 Apr 2018 20:11:06 +0000 (+0000) Subject: add test to ensure attributes have types X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ae884abdc56545736f05853481013dc506423e72;hp=cfae7810d594e9f9425e7c564c62f444f254fe43;p=scpubgit%2FDX.git add test to ensure attributes have types --- diff --git a/xt/all_attributes_typed.t b/xt/all_attributes_typed.t new file mode 100644 index 0000000..4e236b3 --- /dev/null +++ b/xt/all_attributes_typed.t @@ -0,0 +1,29 @@ +use strictures 2; +use Test::More; +use IO::All; +use Role::Tiny; +use Moose; + +sub check_module { + my ($module) = @_; + if ($module->isa('Moo::Object')) { + my $meta = $module->meta; + foreach my $name ($meta->get_attribute_list) { + my $attr = $meta->get_attribute($name); + if (my $tc = $attr->type_constraint) { + pass("${module}->${name} isa ${tc}"); + } else { + fail("${module}->${name} UNTYPED"); + } + } + } +} + +foreach my $file (io('lib')->all_files(0)) { + (my $name = $file->name) =~ s/^lib\///; + require $name; + (my $module = join '::', split '/', $name) =~ s/\.pm$//; + check_module($module); +} + +done_testing;