From cb170931288a0dbef03fece2a0fa01decbd5dfbb Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 18 Jul 2010 23:58:56 -0500 Subject: update dzil stuff --- t/000-load.t | 9 --------- t/001-basic.t | 40 ---------------------------------------- t/002-immutable.t | 46 ---------------------------------------------- t/003-custom-constructor.t | 24 ------------------------ t/004-abstract-subclass.t | 35 ----------------------------------- t/01-basic.t | 40 ++++++++++++++++++++++++++++++++++++++++ t/02-immutable.t | 46 ++++++++++++++++++++++++++++++++++++++++++++++ t/03-custom-constructor.t | 24 ++++++++++++++++++++++++ t/04-abstract-subclass.t | 35 +++++++++++++++++++++++++++++++++++ 9 files changed, 145 insertions(+), 154 deletions(-) delete mode 100644 t/000-load.t delete mode 100644 t/001-basic.t delete mode 100644 t/002-immutable.t delete mode 100644 t/003-custom-constructor.t delete mode 100644 t/004-abstract-subclass.t create mode 100644 t/01-basic.t create mode 100644 t/02-immutable.t create mode 100644 t/03-custom-constructor.t create mode 100644 t/04-abstract-subclass.t (limited to 't') diff --git a/t/000-load.t b/t/000-load.t deleted file mode 100644 index 2854494..0000000 --- a/t/000-load.t +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More tests => 1; - -package Foo; -use Moose; -::use_ok('MooseX::ABC') - or ::BAIL_OUT("couldn't load MooseX::ABC"); diff --git a/t/001-basic.t b/t/001-basic.t deleted file mode 100644 index d5951d4..0000000 --- a/t/001-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/002-immutable.t b/t/002-immutable.t deleted file mode 100644 index 66424da..0000000 --- a/t/002-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/003-custom-constructor.t b/t/003-custom-constructor.t deleted file mode 100644 index cb12835..0000000 --- a/t/003-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/004-abstract-subclass.t b/t/004-abstract-subclass.t deleted file mode 100644 index 3542d07..0000000 --- a/t/004-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/01-basic.t b/t/01-basic.t new file mode 100644 index 0000000..d5951d4 --- /dev/null +++ b/t/01-basic.t @@ -0,0 +1,40 @@ +#!/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 new file mode 100644 index 0000000..66424da --- /dev/null +++ b/t/02-immutable.t @@ -0,0 +1,46 @@ +#!/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 new file mode 100644 index 0000000..cb12835 --- /dev/null +++ b/t/03-custom-constructor.t @@ -0,0 +1,24 @@ +#!/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 new file mode 100644 index 0000000..3542d07 --- /dev/null +++ b/t/04-abstract-subclass.t @@ -0,0 +1,35 @@ +#!/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'); -- cgit v1.2.3-54-g00ecf