Convert all tests to done_testing.
[gitmo/Moose.git] / t / 020_attributes / 027_accessor_override_method.t
CommitLineData
baf17065 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More;
5
6BEGIN {
7 eval "use Test::Output;";
8 plan skip_all => "Test::Output is required for this test" if $@;
baf17065 9}
10
11{
12 package Foo;
13 use Moose;
14
15 sub get_a { }
16 sub set_b { }
17 sub has_c { }
18 sub clear_d { }
19 sub e { }
20}
21
22my $foo_meta = Foo->meta;
23stderr_like(sub { $foo_meta->add_attribute(a => (reader => 'get_a')) },
1d18c898 24 qr/^You are overwriting a locally defined method \(get_a\) with an accessor/, 'reader overriding gives proper warning');
baf17065 25stderr_like(sub { $foo_meta->add_attribute(b => (writer => 'set_b')) },
1d18c898 26 qr/^You are overwriting a locally defined method \(set_b\) with an accessor/, 'writer overriding gives proper warning');
baf17065 27stderr_like(sub { $foo_meta->add_attribute(c => (predicate => 'has_c')) },
1d18c898 28 qr/^You are overwriting a locally defined method \(has_c\) with an accessor/, 'predicate overriding gives proper warning');
baf17065 29stderr_like(sub { $foo_meta->add_attribute(d => (clearer => 'clear_d')) },
1d18c898 30 qr/^You are overwriting a locally defined method \(clear_d\) with an accessor/, 'clearer overriding gives proper warning');
baf17065 31stderr_like(sub { $foo_meta->add_attribute(e => (is => 'rw')) },
1d18c898 32 qr/^You are overwriting a locally defined method \(e\) with an accessor/, 'accessor overriding gives proper warning');
a28e50e4 33
34done_testing;