Skip distro which requires rpm
[gitmo/Moose.git] / t / basics / buildargs.t
CommitLineData
977a86ba 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
a28e50e4 6use Test::More;
977a86ba 7
8{
9 package Foo;
10 use Moose;
11
12 has bar => ( is => "rw" );
d03bd989 13 has baz => ( is => "rw" );
977a86ba 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 Moose;
23
24 extends qw(Foo);
25}
26
94e4f66a 27foreach my $class (qw(Foo Bar)) {
977a86ba 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');
d03bd989 40 }
977a86ba 41}
42
a28e50e4 43done_testing;