diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-06-06 17:50:16 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-06-06 17:50:16 +0000 |
commit | 5ac2026f7eed78958d69d051e7a8e993dcf51205 (patch) | |
tree | 298c3d2f08bdfe5689998b11892d72a897985be1 /t/attributes/no_init_arg.t | |
download | Moose-tarball-5ac2026f7eed78958d69d051e7a8e993dcf51205.tar.gz |
Moose-2.1405HEADMoose-2.1405master
Diffstat (limited to 't/attributes/no_init_arg.t')
-rw-r--r-- | t/attributes/no_init_arg.t | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/t/attributes/no_init_arg.t b/t/attributes/no_init_arg.t new file mode 100644 index 0000000..181e0c2 --- /dev/null +++ b/t/attributes/no_init_arg.t @@ -0,0 +1,32 @@ +use strict; +use warnings; + +use Test::More; + + + +{ + package Foo; + use Moose; + + eval { + has 'foo' => ( + is => "rw", + init_arg => undef, + ); + }; + ::ok(!$@, '... created the attr okay'); +} + +{ + my $foo = Foo->new( foo => "bar" ); + isa_ok($foo, 'Foo'); + + is( $foo->foo, undef, "field is not set via init arg" ); + + $foo->foo("blah"); + + is( $foo->foo, "blah", "field is set via setter" ); +} + +done_testing; |