Extra ;
[gitmo/Mouse.git] / t / 033-readwrite.t
CommitLineData
41ceffa1 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More tests => 4;
1ab26dbb 5use Test::Exception;
41ceffa1 6
7do {
8 package Class;
9 use Mouse;
10
11 # We want this attr to have a reader and writer with unconventional names,
12 # and not the default rw_attr method. -- rjbs, 2008-12-04
13 has 'rw_attr' => (
b9553333 14 is => 'rw',
41ceffa1 15 reader => 'read_attr',
16 writer => 'write_attr',
815f725a 17 );
41ceffa1 18};
19
20my $object = Class->new;
21
3b10730c 22TODO: {
23 local $TODO = 'requires some refactoring to implement';
41ceffa1 24
3b10730c 25 ok(
26 !$object->can('rw_attr'),
27 "no rw_attr method because wasn't 'is' ro or rw"
28 );
29 ok($object->can('read_attr'), "did get a reader");
30 ok($object->can('write_attr'), "did get a writer");
41ceffa1 31
3b10730c 32 # eliminate these eval{} when out of TODO
33 eval { $object->write_attr(2); };
41ceffa1 34
3b10730c 35 is(
36 eval { $object->read_attr },
37 2,
38 "writing to the object worked",
39 );
40}