Subject: | Predicates return value, not bool |
Predicate methods return the value, just like a getter, rather than a
strictly Boolean value. This is only really noticeable if the value is 0.
Subject: | predicate.patch |
diff --git a/t/03hash_predicate.t b/t/03hash_predicate.t
index a7d45a4..4a3fed1 100644
--- a/t/03hash_predicate.t
+++ b/t/03hash_predicate.t
@@ -5,9 +5,9 @@ package Class::XSAccessor::Test;
use Class::XSAccessor
accessors => { bar => 'bar' },
- getters => { get_foo => 'foo' },
+ getters => { get_foo => 'foo', get_zero => 'zero' },
setters => { set_foo => 'foo' },
- predicates => { has_foo => 'foo', has_bar => 'bar' };
+ predicates => { has_foo => 'foo', has_bar => 'bar', has_zero => 'zero' };
use Class::XSAccessor
predicates => 'single';
@@ -16,12 +16,12 @@ use Class::XSAccessor
sub new {
my $class = shift;
- bless { bar => 'baz' }, $class;
+ bless { bar => 'baz', zero => 0 }, $class;
}
package main;
-use Test::More tests => 18;
+use Test::More tests => 20;
my $obj = Class::XSAccessor::Test->new();
@@ -43,6 +43,9 @@ is($obj->bar(undef), undef);
ok(!$obj->has_foo());
ok(!$obj->has_bar());
+is($obj->get_zero, 0);
+ok($obj->has_zero);
+
ok(!$obj->single);
ok(!$obj->mult);
ok(!$obj->iple);