some doc cleanup
[gitmo/Moose.git] / t / 300_immutable / 009_buildargs.t
CommitLineData
a136705d 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More 'no_plan';
7
8{
9 package Foo;
10 use Moose;
11
12 has bar => ( is => "rw" );
13
14 sub BUILDARGS {
15 my ( $self, @args ) = @_;
16 unshift @args, "bar" if @args % 2 == 1;
17 return {@args};
18 }
19
20 package Bar;
21 use Moose;
22
23 extends qw(Foo);
24
25 __PACKAGE__->meta->make_immutable;
26}
27
28foreach my $class qw(Foo Bar) {
29 is( $class->new->bar, undef, "no args" );
30 is( $class->new( bar => 42 )->bar, 42, "normal args" );
31 is( $class->new( 37 )->bar, 37, "single arg" );
32}