From c700061c7b00d18778389d0850d21f966bd25ec6 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 25 Apr 2012 01:36:31 -0500 Subject: cleanups --- .gitignore | 6 ++++- dist.ini | 9 +++---- lib/MooseX/ABC.pm | 3 ++- t/01-basic.t | 40 ---------------------------- t/02-immutable.t | 46 --------------------------------- t/03-custom-constructor.t | 24 ----------------- t/04-abstract-subclass.t | 35 ------------------------- t/abstract-subclass.t | 50 +++++++++++++++++++++++++++++++++++ t/basic.t | 60 ++++++++++++++++++++++++++++++++++++++++++ t/custom-constructor.t | 29 +++++++++++++++++++++ t/immutable.t | 66 +++++++++++++++++++++++++++++++++++++++++++++++ weaver.ini | 36 -------------------------- 12 files changed, 216 insertions(+), 188 deletions(-) delete mode 100644 t/01-basic.t delete mode 100644 t/02-immutable.t delete mode 100644 t/03-custom-constructor.t delete mode 100644 t/04-abstract-subclass.t create mode 100644 t/abstract-subclass.t create mode 100644 t/basic.t create mode 100644 t/custom-constructor.t create mode 100644 t/immutable.t delete mode 100644 weaver.ini diff --git a/.gitignore b/.gitignore index 5030425..b3029d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ cover_db -META.yml +META.* +MYMETA.* Makefile blib inc @@ -9,5 +10,8 @@ Makefile.old nytprof.out MANIFEST.bak *.sw[po] +.DS_Store .build MooseX-ABC-* +*.bs +*.o diff --git a/dist.ini b/dist.ini index a20475c..0bc90d7 100644 --- a/dist.ini +++ b/dist.ini @@ -4,10 +4,9 @@ license = Perl_5 copyright_holder = Jesse Luehrs [@DOY] +:version = 0.08 dist = MooseX-ABC +repository = github -[Prereq] -Moose = 0.94 - -[Prereq / TestRequires] -Test::Exception = 0 +[AutoPrereqs] +skip = Foo diff --git a/lib/MooseX/ABC.pm b/lib/MooseX/ABC.pm index 452446a..fd8e4c8 100644 --- a/lib/MooseX/ABC.pm +++ b/lib/MooseX/ABC.pm @@ -1,5 +1,5 @@ package MooseX::ABC; -use Moose (); +use Moose 0.94 (); use Moose::Exporter; # ABSTRACT: abstract base classes for Moose @@ -74,6 +74,7 @@ sub init_meta { =head1 SEE ALSO L + L =begin Pod::Coverage diff --git a/t/01-basic.t b/t/01-basic.t deleted file mode 100644 index d5951d4..0000000 --- a/t/01-basic.t +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More tests => 9; -use Test::Exception; - -package Foo; -use Moose; -use MooseX::ABC; - -requires 'bar', 'baz'; - -package Foo::Sub1; -use Moose; -::lives_ok { extends 'Foo' } 'extending works when the requires are fulfilled'; -sub bar { } -sub baz { } - -package Foo::Sub2; -use Moose; -::throws_ok { extends 'Foo' } qr/Foo requires Foo::Sub2 to implement baz/, - 'extending fails with the correct error when requires are not fulfilled'; -sub bar { } - -package Foo::Sub::Sub; -use Moose; -::lives_ok { extends 'Foo::Sub1' } 'extending twice works'; - -package main; -my $foosub; -lives_ok { $foosub = Foo::Sub1->new } - 'instantiating concrete subclasses works'; -isa_ok($foosub, 'Foo', 'inheritance is correct'); -my $foosubsub; -lives_ok { $foosubsub = Foo::Sub::Sub->new } - 'instantiating deeper concrete subclasses works'; -isa_ok($foosubsub, 'Foo', 'inheritance is correct'); -isa_ok($foosubsub, 'Foo::Sub1', 'inheritance is correct'); -throws_ok { Foo->new } qr/Foo is abstract, it cannot be instantiated/, - 'instantiating abstract classes fails'; diff --git a/t/02-immutable.t b/t/02-immutable.t deleted file mode 100644 index 66424da..0000000 --- a/t/02-immutable.t +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More tests => 9; -use Test::Exception; - -package Foo; -use Moose; -use MooseX::ABC; - -requires 'bar', 'baz'; - -__PACKAGE__->meta->make_immutable; - -package Foo::Sub1; -use Moose; -::lives_ok { extends 'Foo' } 'extending works when the requires are fulfilled'; -sub bar { } -sub baz { } - -__PACKAGE__->meta->make_immutable; - -package Foo::Sub2; -use Moose; -::throws_ok { extends 'Foo' } qr/Foo requires Foo::Sub2 to implement baz/, - 'extending fails with the correct error when requires are not fulfilled'; -sub bar { } - -package Foo::Sub::Sub; -use Moose; -::lives_ok { extends 'Foo::Sub1' } 'extending twice works'; - -__PACKAGE__->meta->make_immutable; - -package main; -my $foosub; -lives_ok { $foosub = Foo::Sub1->new } - 'instantiating concrete subclasses works'; -isa_ok($foosub, 'Foo', 'inheritance is correct'); -my $foosubsub; -lives_ok { $foosubsub = Foo::Sub::Sub->new } - 'instantiating deeper concrete subclasses works'; -isa_ok($foosubsub, 'Foo', 'inheritance is correct'); -isa_ok($foosubsub, 'Foo::Sub1', 'inheritance is correct'); -throws_ok { Foo->new } qr/Foo is abstract, it cannot be instantiated/, - 'instantiating abstract classes fails'; diff --git a/t/03-custom-constructor.t b/t/03-custom-constructor.t deleted file mode 100644 index cb12835..0000000 --- a/t/03-custom-constructor.t +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More tests => 1; - -our $custom_constructor_called = 0; - -package Foo; -use Moose; -use MooseX::ABC; - -requires 'bar', 'baz'; - -package Foo::Sub; -use Moose; -extends 'Foo'; - -sub bar { } -sub baz { } -sub new { $::custom_constructor_called++; shift->SUPER::new(@_) } - -package main; -my $foosub = Foo::Sub->new; -ok($custom_constructor_called, 'custom constructor was called'); diff --git a/t/04-abstract-subclass.t b/t/04-abstract-subclass.t deleted file mode 100644 index 3542d07..0000000 --- a/t/04-abstract-subclass.t +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More tests => 3; -use Test::Exception; - -package Foo; -use Moose; -use MooseX::ABC; - -requires 'foo'; -requires 'bar'; - -package Foo::Sub; -use Moose; -use MooseX::ABC; -extends 'Foo'; - -requires 'baz'; - -sub bar { 'BAR' } - -package Foo::Sub::Sub; -use Moose; -extends 'Foo::Sub'; - -sub foo { 'FOO' } -sub baz { 'BAZ' } - -package main; - -dies_ok { Foo->new } "can't create Foo objects"; -dies_ok { Foo::Sub->new } "can't create Foo::Sub objects"; -my $foo = Foo::Sub::Sub->new; -is($foo->foo, 'FOO', 'successfully created a Foo::Sub::Sub object'); diff --git a/t/abstract-subclass.t b/t/abstract-subclass.t new file mode 100644 index 0000000..f2cc65c --- /dev/null +++ b/t/abstract-subclass.t @@ -0,0 +1,50 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Fatal; + +{ + package Foo; + use Moose; + use MooseX::ABC; + + requires 'foo'; + requires 'bar'; +} + +{ + package Foo::Sub; + use Moose; + use MooseX::ABC; + extends 'Foo'; + + requires 'baz'; + + sub bar { 'BAR' } +} + +{ + package Foo::Sub::Sub; + use Moose; + extends 'Foo::Sub'; + + sub foo { 'FOO' } + sub baz { 'BAZ' } +} + +like( + exception { Foo->new }, + qr/Foo is abstract, it cannot be instantiated/, + "can't create Foo objects" +); +like( + exception { Foo::Sub->new }, + qr/Foo::Sub is abstract, it cannot be instantiated/, + "can't create Foo::Sub objects" +); + +my $foo = Foo::Sub::Sub->new; +is($foo->foo, 'FOO', 'successfully created a Foo::Sub::Sub object'); + +done_testing; diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..85b0047 --- /dev/null +++ b/t/basic.t @@ -0,0 +1,60 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Fatal; + +{ + package Foo; + use Moose; + use MooseX::ABC; + + requires 'bar', 'baz'; +} + +{ + package Foo::Sub1; + use Moose; + ::is(::exception { extends 'Foo' }, undef, + "extending works when the requires are fulfilled"); + sub bar { } + sub baz { } +} + +{ + package Foo::Sub2; + use Moose; + ::like( + ::exception { extends 'Foo' }, + qr/Foo requires Foo::Sub2 to implement baz/, + "extending fails with the correct error when requires are not fulfilled" + ); + sub bar { } +} + +{ + package Foo::Sub::Sub; + use Moose; + ::is(::exception { extends 'Foo::Sub1' }, undef, + "extending twice works"); +} + +{ + my $foosub; + is(exception { $foosub = Foo::Sub1->new }, undef, + "instantiating concrete subclasses works"); + isa_ok($foosub, 'Foo', 'inheritance is correct'); +} + +{ + my $foosubsub; + is(exception { $foosubsub = Foo::Sub::Sub->new }, undef, + "instantiating deeper concrete subclasses works"); + isa_ok($foosubsub, 'Foo', 'inheritance is correct'); + isa_ok($foosubsub, 'Foo::Sub1', 'inheritance is correct'); +} + +like(exception { Foo->new }, qr/Foo is abstract, it cannot be instantiated/, + "instantiating abstract classes fails"); + +done_testing; diff --git a/t/custom-constructor.t b/t/custom-constructor.t new file mode 100644 index 0000000..6289787 --- /dev/null +++ b/t/custom-constructor.t @@ -0,0 +1,29 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +our $custom_constructor_called = 0; + +{ + package Foo; + use Moose; + use MooseX::ABC; + + requires 'bar', 'baz'; +} + +{ + package Foo::Sub; + use Moose; + extends 'Foo'; + + sub bar { } + sub baz { } + sub new { $::custom_constructor_called++; shift->SUPER::new(@_) } +} + +my $foosub = Foo::Sub->new; +ok($custom_constructor_called, 'custom constructor was called'); + +done_testing; diff --git a/t/immutable.t b/t/immutable.t new file mode 100644 index 0000000..e26d908 --- /dev/null +++ b/t/immutable.t @@ -0,0 +1,66 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Fatal; + +{ + package Foo; + use Moose; + use MooseX::ABC; + + requires 'bar', 'baz'; + + __PACKAGE__->meta->make_immutable; +} + +{ + package Foo::Sub1; + use Moose; + ::is(::exception { extends 'Foo' }, undef, + "extending works when the requires are fulfilled"); + sub bar { } + sub baz { } + + __PACKAGE__->meta->make_immutable; +} + +{ + package Foo::Sub2; + use Moose; + ::like( + ::exception { extends 'Foo' }, + qr/Foo requires Foo::Sub2 to implement baz/, + "extending fails with the correct error when requires are not fulfilled" + ); + sub bar { } +} + +{ + package Foo::Sub::Sub; + use Moose; + ::is(::exception { extends 'Foo::Sub1' }, undef, + "extending twice works"); + + __PACKAGE__->meta->make_immutable; +} + +{ + my $foosub; + is(exception { $foosub = Foo::Sub1->new }, undef, + "instantiating concrete subclasses works"); + isa_ok($foosub, 'Foo', 'inheritance is correct'); +} + +{ + my $foosubsub; + is(exception { $foosubsub = Foo::Sub::Sub->new }, undef, + "instantiating deeper concrete subclasses works"); + isa_ok($foosubsub, 'Foo', 'inheritance is correct'); + isa_ok($foosubsub, 'Foo::Sub1', 'inheritance is correct'); +} + +like(exception { Foo->new }, qr/Foo is abstract, it cannot be instantiated/, + "instantiating abstract classes fails"); + +done_testing; diff --git a/weaver.ini b/weaver.ini deleted file mode 100644 index 219a165..0000000 --- a/weaver.ini +++ /dev/null @@ -1,36 +0,0 @@ -[@CorePrep] - -[Name] -[Version] - -[Region / prelude] - -[Generic / SYNOPSIS] -[Generic / DESCRIPTION] -[Generic / OVERVIEW] - -[Collect / ATTRIBUTES] -command = attr - -[Collect / METHODS] -command = method - -[Collect / FUNCTIONS] -command = func - -[Leftovers] - -[Region / postlude] - -[Template / BUGS] -template = ~/.dzil/pod_templates/bugs.section -main_module_only = 1 - -[SeeAlso] - -[Template / SUPPORT] -template = ~/.dzil/pod_templates/support.section -main_module_only = 1 - -[Authors] -[Legal] -- cgit v1.2.3-54-g00ecf