Use Test::Exception in this test
[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' => (
14 reader => 'read_attr',
15 writer => 'write_attr',
16 );;
17};
18
19my $object = Class->new;
20
3b10730c 21TODO: {
22 local $TODO = 'requires some refactoring to implement';
41ceffa1 23
3b10730c 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");
41ceffa1 30
3b10730c 31 # eliminate these eval{} when out of TODO
32 eval { $object->write_attr(2); };
41ceffa1 33
3b10730c 34 is(
35 eval { $object->read_attr },
36 2,
37 "writing to the object worked",
38 );
39}