summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-04-25 01:36:31 -0500
committerJesse Luehrs <doy@tozt.net>2012-04-25 01:37:24 -0500
commitc700061c7b00d18778389d0850d21f966bd25ec6 (patch)
tree20ff7b852f4742f68a81599cb601a02ce64cbe3f /t
parent9a6b074c9ed600e402e0bfe09ff43dc9138bfaa8 (diff)
downloadmoosex-abc-c700061c7b00d18778389d0850d21f966bd25ec6.tar.gz
moosex-abc-c700061c7b00d18778389d0850d21f966bd25ec6.zip
cleanups
Diffstat (limited to 't')
-rw-r--r--t/01-basic.t40
-rw-r--r--t/02-immutable.t46
-rw-r--r--t/03-custom-constructor.t24
-rw-r--r--t/04-abstract-subclass.t35
-rw-r--r--t/abstract-subclass.t50
-rw-r--r--t/basic.t60
-rw-r--r--t/custom-constructor.t29
-rw-r--r--t/immutable.t66
8 files changed, 205 insertions, 145 deletions
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;