From: gfx Date: Tue, 22 Sep 2009 07:50:45 +0000 (+0900) Subject: CRLF to LF X-Git-Tag: 0.32~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b88483474b62665f14e3a3663be5bba38292a2d6;p=gitmo%2FMouse.git CRLF to LF --- diff --git a/t/400_mouse_util/002_mouse_util_does_role.t b/t/400_mouse_util/002_mouse_util_does_role.t index 5447418..10e71e4 100644 --- a/t/400_mouse_util/002_mouse_util_does_role.t +++ b/t/400_mouse_util/002_mouse_util_does_role.t @@ -1,81 +1,81 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 8; - -BEGIN { - use_ok('Mouse::Util', ':all'); -} - -{ - package Foo; - - use Mouse::Role; -} - -{ - package Bar; - - use Mouse; - - with qw/Foo/; -} - -{ - package Baz; - - use Mouse; -} - -{ - package Quux; - - use metaclass; -} - -{ - package Foo::Foo; - - use Mouse::Role; - - with 'Foo'; -} - -# Classes - -ok(does_role('Bar', 'Foo'), '... Bar does Foo'); - -ok(!does_role('Baz', 'Foo'), '... Baz doesnt do Foo'); - -# Objects - -my $bar = Bar->new; - -ok(does_role($bar, 'Foo'), '... $bar does Foo'); - -my $baz = Baz->new; - -ok(!does_role($baz, 'Foo'), '... $baz doesnt do Foo'); - -# Invalid values - -ok(!does_role(undef,'Foo'), '... undef doesnt do Foo'); - -ok(!does_role(1,'Foo'), '... 1 doesnt do Foo'); - -# non Mouse metaclass - -ok(!does_role('Quux', 'Foo'), '... Quux doesnt do Foo (does not die tho)'); - -# TODO: make the below work, maybe? - -# Self - -#ok(does_role('Foo', 'Foo'), '... Foo does do Foo'); - -# sub-Roles - -#ok(does_role('Foo::Foo', 'Foo'), '... Foo::Foo does do Foo'); - +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 8; + +BEGIN { + use_ok('Mouse::Util', ':all'); +} + +{ + package Foo; + + use Mouse::Role; +} + +{ + package Bar; + + use Mouse; + + with qw/Foo/; +} + +{ + package Baz; + + use Mouse; +} + +{ + package Quux; + + use metaclass; +} + +{ + package Foo::Foo; + + use Mouse::Role; + + with 'Foo'; +} + +# Classes + +ok(does_role('Bar', 'Foo'), '... Bar does Foo'); + +ok(!does_role('Baz', 'Foo'), '... Baz doesnt do Foo'); + +# Objects + +my $bar = Bar->new; + +ok(does_role($bar, 'Foo'), '... $bar does Foo'); + +my $baz = Baz->new; + +ok(!does_role($baz, 'Foo'), '... $baz doesnt do Foo'); + +# Invalid values + +ok(!does_role(undef,'Foo'), '... undef doesnt do Foo'); + +ok(!does_role(1,'Foo'), '... 1 doesnt do Foo'); + +# non Mouse metaclass + +ok(!does_role('Quux', 'Foo'), '... Quux doesnt do Foo (does not die tho)'); + +# TODO: make the below work, maybe? + +# Self + +#ok(does_role('Foo', 'Foo'), '... Foo does do Foo'); + +# sub-Roles + +#ok(does_role('Foo::Foo', 'Foo'), '... Foo::Foo does do Foo'); + diff --git a/t/lib/Test/Mouse.pm b/t/lib/Test/Mouse.pm index 14f20ef..c166c7b 100644 --- a/t/lib/Test/Mouse.pm +++ b/t/lib/Test/Mouse.pm @@ -1,76 +1,76 @@ -package Test::Mouse; - -use strict; -use warnings; -use Carp qw(croak); -use Mouse::Util qw(find_meta does_role); - -use base qw(Test::Builder::Module); - -our @EXPORT = qw(meta_ok does_ok has_attribute_ok); - -sub meta_ok ($;$) { - my ($class_or_obj, $message) = @_; - - $message ||= "The object has a meta"; - - if (find_meta($class_or_obj)) { - return __PACKAGE__->builder->ok(1, $message) - } - else { - return __PACKAGE__->builder->ok(0, $message); - } -} - -sub does_ok ($$;$) { - my ($class_or_obj, $does, $message) = @_; - - if(!defined $does){ - croak "You must pass a role name"; - } - $message ||= "The object does $does"; - - if (does_ok($class_or_obj)) { - return __PACKAGE__->builder->ok(1, $message) - } - else { - return __PACKAGE__->builder->ok(0, $message); - } -} - -sub has_attribute_ok ($$;$) { - my ($class_or_obj, $attr_name, $message) = @_; - - $message ||= "The object does has an attribute named $attr_name"; - - my $meta = find_meta($class_or_obj); - - if ($meta->find_attribute_by_name($attr_name)) { - return __PACKAGE__->builder->ok(1, $message) - } - else { - return __PACKAGE__->builder->ok(0, $message); - } -} - -1; - -__END__ - -=pod - -=head1 NAME - -Test::Mouse - Test functions for Mouse specific features - -=head1 SYNOPSIS - - use Test::More plan => 1; - use Test::Mouse; - - meta_ok($class_or_obj, "... Foo has a ->meta"); - does_ok($class_or_obj, $role, "... Foo does the Baz role"); - has_attribute_ok($class_or_obj, $attr_name, "... Foo has the 'bar' attribute"); - -=cut - +package Test::Mouse; + +use strict; +use warnings; +use Carp qw(croak); +use Mouse::Util qw(find_meta does_role); + +use base qw(Test::Builder::Module); + +our @EXPORT = qw(meta_ok does_ok has_attribute_ok); + +sub meta_ok ($;$) { + my ($class_or_obj, $message) = @_; + + $message ||= "The object has a meta"; + + if (find_meta($class_or_obj)) { + return __PACKAGE__->builder->ok(1, $message) + } + else { + return __PACKAGE__->builder->ok(0, $message); + } +} + +sub does_ok ($$;$) { + my ($class_or_obj, $does, $message) = @_; + + if(!defined $does){ + croak "You must pass a role name"; + } + $message ||= "The object does $does"; + + if (does_ok($class_or_obj)) { + return __PACKAGE__->builder->ok(1, $message) + } + else { + return __PACKAGE__->builder->ok(0, $message); + } +} + +sub has_attribute_ok ($$;$) { + my ($class_or_obj, $attr_name, $message) = @_; + + $message ||= "The object does has an attribute named $attr_name"; + + my $meta = find_meta($class_or_obj); + + if ($meta->find_attribute_by_name($attr_name)) { + return __PACKAGE__->builder->ok(1, $message) + } + else { + return __PACKAGE__->builder->ok(0, $message); + } +} + +1; + +__END__ + +=pod + +=head1 NAME + +Test::Mouse - Test functions for Mouse specific features + +=head1 SYNOPSIS + + use Test::More plan => 1; + use Test::Mouse; + + meta_ok($class_or_obj, "... Foo has a ->meta"); + does_ok($class_or_obj, $role, "... Foo does the Baz role"); + has_attribute_ok($class_or_obj, $attr_name, "... Foo has the 'bar' attribute"); + +=cut +