Regenerate test files
[gitmo/Mouse.git] / t / 010_basics / 015_buildargs.t
1 #!/usr/bin/perl
2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
5
6 use strict;
7 use warnings;
8
9 use Test::More;
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
30 foreach 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
46 done_testing;