#!/usr/bin/perl
+
use strict;
use warnings;
-use Test::More tests => 18;
+use Test::More tests => 26;
BEGIN {
use_ok('MooseX::AttributeHelpers');
isa => 'Int',
default => sub { 5 },
provides => {
- set => 'set',
- add => 'add',
- sub => 'sub',
- mul => 'mul',
- div => 'div',
- mod => 'mod',
- abs => 'abs',
+ set => 'set',
+ add => 'add',
+ sub => 'sub',
+ mul => 'mul',
+ div => 'div',
+ mod => 'mod',
+ abs => 'abs',
+ },
+ curries => {
+ add => {inc => [ 1 ]},
+ sub => {dec => [ 1 ]},
+ mod => {odd => [ 2 ]},
+ div => {cut_in_half => [ 2 ]}
}
);
}
isa_ok($real, 'Real');
can_ok($real, $_) for qw[
- set add sub mul div mod abs
+ set add sub mul div mod abs inc dec odd cut_in_half
];
is $real->integer, 5, 'Default to five';
$real->abs;
-is $real->integer, 1, 'abs 1'
\ No newline at end of file
+is $real->integer, 1, 'abs 1';
+
+$real->set(12);
+
+$real->inc;
+
+is $real->integer, 13, 'inc 12';
+
+$real->dec;
+
+is $real->integer, 12, 'dec 13';
+
+## test the meta
+
+my $attr = $real->meta->get_attribute('integer');
+isa_ok($attr, 'MooseX::AttributeHelpers::Number');
+
+is_deeply($attr->provides, {
+ set => 'set',
+ add => 'add',
+ sub => 'sub',
+ mul => 'mul',
+ div => 'div',
+ mod => 'mod',
+ abs => 'abs',
+}, '... got the right provides mapping');
+