209adc0ff98100f5206414740e71b9a824582b8a
[gitmo/Mouse.git] / t / 032-buildargs.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More tests => 3;
5
6 use lib 't/lib';
7
8 {
9     package Foo;
10     use Mouse;
11
12     has foo => ( is => "rw" );
13
14     sub BUILDARGS {
15         my ( $self, @args ) = @_;
16         return { @args % 2 ? ( foo => @args ) : @args };
17     }
18 }
19
20 is( Foo->new->foo, undef, "no value" );
21 is( Foo->new("bar")->foo, "bar", "single arg" );
22 is( Foo->new(foo => "bar")->foo, "bar", "twoargs" );
23