Commit | Line | Data |
fc1d8369 |
1 | #!/usr/bin/perl |
16504b15 |
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; |
fc1d8369 |
5 | |
6 | use strict; |
7 | use warnings; |
8 | |
16504b15 |
9 | use Test::More; |
fc1d8369 |
10 | |
11 | { |
12 | package Foo; |
b0000b3d |
13 | use Mouse; |
fc1d8369 |
14 | |
15 | has bar => ( is => "rw" ); |
16504b15 |
16 | has baz => ( is => "rw" ); |
fc1d8369 |
17 | |
18 | sub BUILDARGS { |
19 | my ( $self, @args ) = @_; |
20 | unshift @args, "bar" if @args % 2 == 1; |
21 | return {@args}; |
22 | } |
23 | |
24 | __PACKAGE__->meta->make_immutable; |
25 | |
26 | package Bar; |
b0000b3d |
27 | use Mouse; |
fc1d8369 |
28 | |
29 | extends qw(Foo); |
16504b15 |
30 | |
fc1d8369 |
31 | __PACKAGE__->meta->make_immutable; |
32 | } |
33 | |
34 | foreach my $class qw(Foo Bar) { |
35 | is( $class->new->bar, undef, "no args" ); |
36 | is( $class->new( bar => 42 )->bar, 42, "normal args" ); |
9dcd7d23 |
37 | is( $class->new( 37 )->bar, 37, "single arg" ); |
16504b15 |
38 | { |
39 | my $o = $class->new(bar => 42, baz => 47); |
40 | is($o->bar, 42, '... got the right bar'); |
41 | is($o->baz, 47, '... got the right bar'); |
42 | } |
43 | { |
44 | my $o = $class->new(42, baz => 47); |
45 | is($o->bar, 42, '... got the right bar'); |
46 | is($o->baz, 47, '... got the right bar'); |
47 | } |
fc1d8369 |
48 | } |
49 | |
16504b15 |
50 | done_testing; |