5 use Method::Generate::Constructor;
7 my $gen = Method::Generate::Constructor->new;
9 $gen->generate_method('Foo', 'new', {
11 two => { init_arg => undef },
12 three => { init_arg => 'THREE' }
15 my $first = Foo->new({
24 { %$first }, { one => 1, three => 3 },
25 'init_arg handling ok'
28 $gen->generate_method('Bar', 'new' => {
29 one => { required => 1 },
30 three => { init_arg => 'THREE', required => 1 }
34 exception { Bar->new },
35 qr/Missing required arguments: THREE, one/,
36 'two missing args reported correctly'
40 exception { Bar->new(THREE => 3) },
41 qr/Missing required arguments: one/,
42 'one missing arg reported correctly'
46 exception { Bar->new(one => 1, THREE => 3) },
48 'pass with both required args'