Use Test::Exception in this test
[gitmo/Mouse.git] / t / 033-readwrite.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More tests => 4;
5 use Test::Exception;
6
7 do {
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' => (
14         reader => 'read_attr',
15         writer => 'write_attr',
16     );;
17 };
18
19 my $object = Class->new;
20
21 TODO: {
22   local $TODO = 'requires some refactoring to implement';
23
24   ok(
25     !$object->can('rw_attr'),
26     "no rw_attr method because wasn't 'is' ro or rw"
27   );
28   ok($object->can('read_attr'),  "did get a reader");
29   ok($object->can('write_attr'), "did get a writer");
30
31   # eliminate these eval{} when out of TODO
32   eval { $object->write_attr(2); };
33
34   is(
35     eval { $object->read_attr },
36     2,
37     "writing to the object worked",
38   );
39 }