Support is => 'bare' for compatibility
[gitmo/Mouse.git] / t / 007-attributes.t
CommitLineData
c3398f5b 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More tests => 10;
eab81545 5use Test::Exception;
c3398f5b 6
7do {
8 package Class;
9 use Mouse;
10
11d41528 11 has 'x' => (
12 is => 'bare',
13 );
c3398f5b 14
15 has 'y' => (
16 is => 'ro',
17 );
18
19 has 'z' => (
20 is => 'rw',
21 );
22};
23
24ok(!Class->can('x'), "No accessor is injected if 'is' has no value");
25can_ok('Class', 'y', 'z');
26
27my $object = Class->new;
28
29ok(!$object->can('x'), "No accessor is injected if 'is' has no value");
30can_ok($object, 'y', 'z');
31
32is($object->y, undef);
636c002e 33
34throws_ok {
35 $object->y(10);
36} qr/Cannot assign a value to a read-only accessor/;
37
c3398f5b 38is($object->y, undef);
39
40is($object->z, undef);
41is($object->z(10), 10);
42is($object->z, 10);
43