File: 33array_predicate.t

package info (click to toggle)
libclass-xsaccessor-perl 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 520 kB
  • sloc: perl: 841; ansic: 359; makefile: 6
file content (40 lines) | stat: -rw-r--r-- 698 bytes parent folder | download | duplicates (5)
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
34
35
36
37
38
39
40
use strict;
use warnings;

package Class::XSAccessor::Test;

use Class::XSAccessor::Array
  accessors  => { bar => 0 },
  getters    => { get_foo => 1 },
  setters    => { set_foo => 1 },
  predicates => { has_foo => 1, has_bar => 0 };

sub new {
  my $class = shift;
  bless [ 'baz' ], $class;
}

package main;

use Test::More tests => 12;

my $obj = Class::XSAccessor::Test->new();

ok($obj->can('has_foo'));
ok($obj->can('has_bar'));

ok(!$obj->has_foo());
ok($obj->has_bar());

is($obj->set_foo('bar'), 'bar');
is($obj->bar('quux'), 'quux');

ok($obj->has_foo());
ok($obj->has_bar());

is($obj->set_foo(undef), undef);
is($obj->bar(undef), undef);

ok(!$obj->has_foo());
ok(!$obj->has_bar());