summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-05-28 23:22:24 -0500
committerJesse Luehrs <doy@tozt.net>2009-05-28 23:22:24 -0500
commit3380df6862fe07ccaf17c7ba30616167bb6e880d (patch)
tree460582e262bdfa1ff5846ba1556a1364527f882e
parentba4ad16b04fa9bb89ce6fe89493ebfdf76163320 (diff)
downloadmoosex-abc-3380df6862fe07ccaf17c7ba30616167bb6e880d.tar.gz
moosex-abc-3380df6862fe07ccaf17c7ba30616167bb6e880d.zip
add a test for immutability
-rw-r--r--t/002-immutable.t37
1 files changed, 37 insertions, 0 deletions
diff --git a/t/002-immutable.t b/t/002-immutable.t
new file mode 100644
index 0000000..0f4bce8
--- /dev/null
+++ b/t/002-immutable.t
@@ -0,0 +1,37 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 5;
+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__->meta->make_immutable;
+
+package main;
+my $foosub;
+lives_ok { $foosub = Foo::Sub1->new }
+ 'instantiating concrete subclasses works';
+isa_ok($foosub, 'Foo', 'inheritance is correct');
+throws_ok { Foo->new } qr/Foo is abstract, it cannot be instantiated/,
+ 'instantiating abstract classes fails';