clean up some test stuff
[gitmo/Moose.git] / t / todo_tests / immutable_n_around.t
CommitLineData
58630bf0 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
a28e50e4 6use Test::More;
58630bf0 7
af45f9d0 8# if make_immutable is removed from the following code the tests pass
9
58630bf0 10{
11 package Foo;
12 use Moose;
13
14 has foo => ( is => "ro" );
15
58630bf0 16 package Bar;
17 use Moose;
18
19 extends qw(Foo);
20
21 around new => sub {
22 my $next = shift;
23 my ( $self, @args ) = @_;
24 $self->$next( foo => 42 );
25 };
26
58630bf0 27 package Gorch;
28 use Moose;
29
30 extends qw(Bar);
31
6f5dbcd5 32 package Zoink;
33 use Moose;
d03bd989 34
6f5dbcd5 35 extends qw(Gorch);
36
58630bf0 37}
38
6f5dbcd5 39my @classes = qw(Foo Bar Gorch Zoink);
40
57b3546f 41tests: {
6f5dbcd5 42 is( Foo->new->foo, undef, "base class (" . (Foo->meta->is_immutable ? "immutable" : "mutable") . ")" );
43 is( Bar->new->foo, 42, "around new called on Bar->new (" . (Bar->meta->is_immutable ? "immutable" : "mutable") . ")" );
44 is( Gorch->new->foo, 42, "around new called on Gorch->new (" . (Gorch->meta->is_immutable ? "immutable" : "mutable") . ")" );
45 is( Zoink->new->foo, 42, "around new called Zoink->new (" . (Zoink->meta->is_immutable ? "immutable" : "mutable") . ")" );
46
57b3546f 47 if ( @classes ) {
77ed022c 48 local $SIG{__WARN__} = sub {};
57b3546f 49 ( shift @classes )->meta->make_immutable;
50 redo tests;
51 }
52}
a28e50e4 53
54done_testing;