Rename IsDefaults to HasDefaults
[gitmo/MooseX-HasDefaults.git] / t / 001-ro.t
CommitLineData
8adff614 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More tests => 7;
5use Test::Exception;
6
7do {
8 package Person;
9 use Moose;
e24f444c 10 use MooseX::HasDefaults::RO;
8adff614 11
12 has name => (
13 isa => 'Str',
14 );
15
16 has birth_year => (
17 isa => 'Int',
18 );
19
20 has favorite_language => (
21 is => 'rw',
22 isa => 'Str',
23 default => 'Perl',
24 );
25};
26
27can_ok(Person => qw(name birth_year favorite_language));
28
29my $whacko = Person->new(name => 'Stevan', birth_year => 1924);
30is($whacko->name, 'Stevan');
31is($whacko->birth_year, 1924);
32is($whacko->favorite_language, 'Perl');
33
34throws_ok {
35 $whacko->name('Stevan Little');
36} qr/read-only accessor/;
37
38throws_ok {
39 $whacko->birth_year(1922);
40} qr/read-only accessor/;
41
42$whacko->favorite_language('C#'); # he's dead to us now..
43is($whacko->favorite_language, 'C#');
44