From: Shawn M Moore Date: Sun, 9 Nov 2008 07:35:34 +0000 (+0000) Subject: More tests for application X-Git-Tag: 0.05~84 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=09156b037c16c627ef409299d31e1b1031d94bb0;p=gitmo%2FMooseX-Role-Parameterized.git More tests for application --- diff --git a/t/003-apply.t b/t/003-apply.t index 51f155a..6b3d81e 100644 --- a/t/003-apply.t +++ b/t/003-apply.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 1; +use Test::More tests => 14; use Test::Exception; do { @@ -69,3 +69,61 @@ do { }; }; +can_ok('MyClass::Dumper' => qw(freeze_Dumper thaw_Dumper)); +cant_ok('MyClass::Storable' => qw(freeze_Storable thaw_Storable)); + +do { + package MyClass::Storable; + use Moose; + with 'MyRole::Storage' => { + format => 'Storable', + }; +}; + +can_ok('MyClass::Storable' => qw(freeze_Storable thaw_Storable)); +cant_ok('MyClass::Storable' => qw(freeze_Dumper thaw_Dumper)); + +do { + package MyClass::DumperRenamed; + use Moose; + with 'MyRole::Storage' => { + format => 'Dumper', + freeze_method => 'save', + thaw_method => 'load', + }; +}; + +can_ok('MyClass::DumperRenamed' => qw(save load)); +cant_ok('MyClass::DumperRenamed' => qw(freeze_Dumper freeze_Storable thaw_Dumper thaw_Storable)); + +do { + package MyClass::Both; + use Moose; + with 'MyRole::Storage' => { format => 'Dumper' }; + with 'MyRole::Storage' => { format => 'Storable' }; +}; + +can_ok('MyClass::Both' => qw(freeze_Dumper freeze_Storable thaw_Dumper thaw_Storable)); + +do { + package MyClass::Three; + use Moose; + with 'MyRole::Storage' => { format => 'Dumper' }; + with 'MyRole::Storage' => { format => 'Storable' }; + with 'MyRole::Storage' => { + format => 'Storable', + freeze_method => 'store', + thaw_method => 'dump', + }; +}; + +can_ok('MyClass::Three' => qw(freeze_Dumper freeze_Storable thaw_Dumper thaw_Storable store dump)); + +sub cant_ok { + local $Test::Builder::Level = $Test::Builder::Level + 1; + my $instance = shift; + for my $method (@_) { + ok(!$instance->can($method), "$instance cannot $method"); + } +} +