Add failing test for cloning attrs with weak refs
[gitmo/Moose.git] / t / attributes / accessor_override_method.t
CommitLineData
baf17065 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More;
5
4d438a84 6use Test::Requires {
7 'Test::Output' => '0.01', # skip all if not installed
8};
baf17065 9
10{
11 package Foo;
12 use Moose;
13
14 sub get_a { }
15 sub set_b { }
16 sub has_c { }
17 sub clear_d { }
18 sub e { }
19}
20
21my $foo_meta = Foo->meta;
22stderr_like(sub { $foo_meta->add_attribute(a => (reader => 'get_a')) },
1d18c898 23 qr/^You are overwriting a locally defined method \(get_a\) with an accessor/, 'reader overriding gives proper warning');
baf17065 24stderr_like(sub { $foo_meta->add_attribute(b => (writer => 'set_b')) },
1d18c898 25 qr/^You are overwriting a locally defined method \(set_b\) with an accessor/, 'writer overriding gives proper warning');
baf17065 26stderr_like(sub { $foo_meta->add_attribute(c => (predicate => 'has_c')) },
1d18c898 27 qr/^You are overwriting a locally defined method \(has_c\) with an accessor/, 'predicate overriding gives proper warning');
baf17065 28stderr_like(sub { $foo_meta->add_attribute(d => (clearer => 'clear_d')) },
1d18c898 29 qr/^You are overwriting a locally defined method \(clear_d\) with an accessor/, 'clearer overriding gives proper warning');
baf17065 30stderr_like(sub { $foo_meta->add_attribute(e => (is => 'rw')) },
1d18c898 31 qr/^You are overwriting a locally defined method \(e\) with an accessor/, 'accessor overriding gives proper warning');
a28e50e4 32
3968746e 33stderr_like(sub { $foo_meta->add_attribute(has => (is => 'rw')) },
34 qr/^You are overwriting a locally defined function \(has\) with an accessor/, 'function overriding gives proper warning');
35
a28e50e4 36done_testing;