Perltidy this code a bit.
[gitmo/Moose.git] / t / 020_attributes / 018_no_init_arg.t
CommitLineData
625d571f 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 5;
7use Test::Exception;
8
9BEGIN {
10 use_ok('Moose');
11}
12
13{
14 package Foo;
15 use Moose;
16
17 eval {
18 has 'foo' => (
19 is => "rw",
20 init_arg => undef,
21 );
22 };
23 ::ok(!$@, '... created the attr okay');
24}
25
26{
27 my $foo = Foo->new( foo => "bar" );
28 isa_ok($foo, 'Foo');
29
30 is( $foo->foo, undef, "field is not set via init arg" );
31
32 $foo->foo("blah");
33
34 is( $foo->foo, "blah", "field is set via setter" );
35}