tests with perl 5.14 produce deprecation warnings (Todd Rinaldo)
[gitmo/Mouse.git] / t / 010_basics / 015_buildargs.t
CommitLineData
60ad2cb7 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
9864f0e4 6use Test::More tests => 14;
60ad2cb7 7
8{
9 package Foo;
10 use Mouse;
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 Bar;
22 use Mouse;
23
24 extends qw(Foo);
25}
26
031f47ef 27foreach my $class (qw(Foo Bar)) {
60ad2cb7 28 is( $class->new->bar, undef, "no args" );
29 is( $class->new( bar => 42 )->bar, 42, "normal args" );
30 is( $class->new( 37 )->bar, 37, "single arg" );
31 {
32 my $o = $class->new(bar => 42, baz => 47);
33 is($o->bar, 42, '... got the right bar');
34 is($o->baz, 47, '... got the right bar');
35 }
36 {
37 my $o = $class->new(42, baz => 47);
38 is($o->bar, 42, '... got the right bar');
39 is($o->baz, 47, '... got the right bar');
40 }
41}
42
9864f0e4 43