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