Changelogging
[gitmo/Mouse.git] / t / 010_basics / 015_buildargs.t
CommitLineData
60ad2cb7 1#!/usr/bin/perl
fde8e43f 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
60ad2cb7 5
6use strict;
7use warnings;
8
fde8e43f 9use Test::More;
60ad2cb7 10
11{
12 package Foo;
13 use Mouse;
14
15 has bar => ( is => "rw" );
16 has baz => ( is => "rw" );
17
18 sub BUILDARGS {
19 my ( $self, @args ) = @_;
20 unshift @args, "bar" if @args % 2 == 1;
21 return {@args};
22 }
23
24 package Bar;
25 use Mouse;
26
27 extends qw(Foo);
28}
29
30foreach my $class qw(Foo Bar) {
31 is( $class->new->bar, undef, "no args" );
32 is( $class->new( bar => 42 )->bar, 42, "normal args" );
33 is( $class->new( 37 )->bar, 37, "single arg" );
34 {
35 my $o = $class->new(bar => 42, baz => 47);
36 is($o->bar, 42, '... got the right bar');
37 is($o->baz, 47, '... got the right bar');
38 }
39 {
40 my $o = $class->new(42, baz => 47);
41 is($o->bar, 42, '... got the right bar');
42 is($o->baz, 47, '... got the right bar');
43 }
44}
45
fde8e43f 46done_testing;