oops... i forgot s/Moose/Mouse/ orz
[gitmo/Mouse.git] / t / 300_immutable / 009_buildargs.t
CommitLineData
fc1d8369 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 14;
7
8{
9 package Foo;
b0000b3d 10 use Mouse;
fc1d8369 11
12 has bar => ( is => "rw" );
13 has baz => ( is => "rw" );
14
15 sub BUILDARGS {
16 my ( $self, @args ) = @_;
17 unshift @args, "bar" if @args % 2 == 1;
18 return {@args};
19 }
20
21 __PACKAGE__->meta->make_immutable;
22
23 package Bar;
b0000b3d 24 use Mouse;
fc1d8369 25
26 extends qw(Foo);
27
28 __PACKAGE__->meta->make_immutable;
29}
30
31foreach my $class qw(Foo Bar) {
32 is( $class->new->bar, undef, "no args" );
33 is( $class->new( bar => 42 )->bar, 42, "normal args" );
b0000b3d 34 SKIP: {
35 skip "this feature doesn't supported by Mouse", 1;
36 is( $class->new( 37 )->bar, 37, "single arg" );
37 };
fc1d8369 38 {
39 my $o = $class->new(bar => 42, baz => 47);
40 is($o->bar, 42, '... got the right bar');
41 is($o->baz, 47, '... got the right bar');
42 }
b0000b3d 43 SKIP: {
44 skip "this feature doesn't supported by Mouse", 2;
45 {
46 my $o = $class->new(42, baz => 47);
47 is($o->bar, 42, '... got the right bar');
48 is($o->baz, 47, '... got the right bar');
49 }
50 };
fc1d8369 51}
52
53