Commit | Line | Data |
---|---|---|
625d571f | 1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
a28e50e4 | 6 | use Test::More; |
625d571f | 7 | |
7ff56534 | 8 | |
625d571f | 9 | |
10 | { | |
11 | package Foo; | |
12 | use Moose; | |
d03bd989 | 13 | |
625d571f | 14 | eval { |
15 | has 'foo' => ( | |
16 | is => "rw", | |
17 | init_arg => undef, | |
18 | ); | |
19 | }; | |
20 | ::ok(!$@, '... created the attr okay'); | |
21 | } | |
22 | ||
23 | { | |
24 | my $foo = Foo->new( foo => "bar" ); | |
25 | isa_ok($foo, 'Foo'); | |
26 | ||
27 | is( $foo->foo, undef, "field is not set via init arg" ); | |
28 | ||
29 | $foo->foo("blah"); | |
30 | ||
31 | is( $foo->foo, "blah", "field is set via setter" ); | |
32 | } | |
a28e50e4 | 33 | |
34 | done_testing; |