File: 04-clearer-and-predicate.t

package info (click to toggle)
libmoosex-attributeshortcuts-perl 0.010-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 204 kB
  • sloc: perl: 294; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 856 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use strict;
use warnings;

{
    package TestClass;

    use Moose;
    use namespace::autoclean;
    use MooseX::AttributeShortcuts;

    has foo  => (is => 'rw', clearer => 1);
    has _foo => (is => 'rw', clearer => 1);

    has bar  => (is => 'rw', predicate => 1);
    has _bar => (is => 'rw', predicate => 1);
}

use Test::More;
use Test::Moose;

require 't/funcs.pm' unless eval { require funcs };

with_immutable {

    test_class_sanity_checks('TestClass');
    check_attribute('TestClass', foo  => (accessor => 'foo',  clearer   => 'clear_foo'));
    check_attribute('TestClass', _foo => (accessor => '_foo', clearer   => '_clear_foo'));
    check_attribute('TestClass', bar  => (accessor => 'bar',  predicate => 'has_bar'));
    check_attribute('TestClass', _bar => (accessor => '_bar', predicate => '_has_bar'));

} 'TestClass';

done_testing;