Require Dist::Zilla 4.200016+
[gitmo/Moose.git] / t / attributes / no_init_arg.t
CommitLineData
625d571f 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
a28e50e4 6use 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
34done_testing;