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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use Type::Tiny::Bitfield;
use Types::Common qw( ArrayRef );
like(
exception {
Type::Tiny::Bitfield->new( parent => ArrayRef, values => {} ),
},
qr/cannot have a parent constraint passed to the constructor/i,
);
like(
exception {
Type::Tiny::Bitfield->new( constraint => sub { 0 }, values => {} ),
},
qr/cannot have a constraint coderef passed to the constructor/i,
);
like(
exception {
Type::Tiny::Bitfield->new( inlined => sub { 0 }, values => {} ),
},
qr/cannot have a inlining coderef passed to the constructor/i,
);
like(
exception {
Type::Tiny::Bitfield->new(),
},
qr/Need to supply hashref of values/i,
);
like(
exception {
Type::Tiny::Bitfield->new( values => { foo => 2 } ),
},
qr/Not an all-caps name in a bitfield/i,
);
like(
exception {
Type::Tiny::Bitfield->new( values => { FOO => 3 } ),
},
qr/Not a positive power of 2 in a bitfield/i,
);
like(
exception {
Type::Tiny::Bitfield->new( values => { FOO => 1, BAR => 1 } ),
},
qr/Duplicate value in a bitfield/i,
);
done_testing;
|