From 3380df6862fe07ccaf17c7ba30616167bb6e880d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 28 May 2009 23:22:24 -0500 Subject: add a test for immutability --- t/002-immutable.t | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 t/002-immutable.t 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'; -- cgit v1.2.3