File Coverage

blib/lib/CXC/Number/Sequence/Types.pm
Criterion Covered Total %
statement 27 27 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod n/a
total 37 37 100.0


line stmt bran cond sub pod time code
1             package CXC::Number::Sequence::Types;
2              
3             # ABSTRACT: Type::Tiny types for CXC::Number::Sequence
4              
5 13     13   671048 use v5.28;
  13         54  
6 13     13   73 use strict;
  13         30  
  13         379  
7 13     13   64 use warnings;
  13         26  
  13         1989  
8              
9             our $VERSION = '0.13';
10              
11 13     13   12776 use Math::BigInt upgrade => 'Math::BigFloat';
  13         394126  
  13         117  
12 13     13   278377 use Math::BigFloat;
  13         472701  
  13         85  
13 13     13   10542 use Type::Utils -all;
  13         404325  
  13         206  
14 13     13   44600 use Types::Standard qw[ Num Int Enum Tuple Any InstanceOf Dict ArrayRef Value ];
  13         542471  
  13         134  
15 13     13   65715 use Types::Common::Numeric qw[ PositiveNum PositiveOrZeroNum PositiveInt ];
  13         286575  
  13         157  
16              
17 13         88 use Type::Library -base, -declare => qw(
18             Alignment
19             Sequence
20             Spacing
21             Ratio
22 13     13   19070 );
  13         32  
23              
24 13     13   12496 BEGIN { extends 'CXC::Number::Types' }
25              
26              
27              
28              
29              
30              
31              
32              
33              
34              
35              
36              
37              
38             declare Alignment, as Tuple [ BigNum, BigPositiveOrZeroNum ], where { $_->[1] < 1 }, coercion => 1;
39              
40             coerce Alignment, from Num, via { [ Math::BigFloat->new( $_ ), Math::BigFloat->new( 0.5 ) ] };
41              
42              
43              
44              
45              
46              
47              
48              
49             declare Sequence, as ArrayRef [ BigNum, 2 ], where {
50             my $arr = $_;
51             $arr->[$_] < $arr->[ $_ + 1 ] || return for 0 .. ( $arr->@* - 2 );
52             1;
53             }, message {
54             ArrayRef( [ BigNum, 2 ] )->validate( $_ )
55             or 'Must be an array of monotonically increasing numbers with at lest two elements'
56             }, coercion => 1;
57              
58              
59              
60              
61              
62              
63              
64              
65             declare Spacing, as BigNum,
66             where { $_ != 0 },
67             message { BigNum->validate( $_ ) or 'Must be a non-zero number' },
68             coercion => 1;
69              
70              
71              
72              
73              
74              
75              
76              
77             declare Ratio, as BigNum,
78             where { $_ > 0 && $_ != 1 },
79             message { BigNum->validate( $_ ) or 'Number must be > 0 && != 1' },
80             coercion => 1;
81              
82             #
83             # This file is part of CXC-Number
84             #
85             # This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory.
86             #
87             # This is free software, licensed under:
88             #
89             # The GNU General Public License, Version 3, June 2007
90             #
91              
92             1;
93              
94             __END__
95              
96             =pod
97              
98             =for :stopwords Diab Jerius Smithsonian Astrophysical Observatory bignum
99              
100             =head1 NAME
101              
102             CXC::Number::Sequence::Types - Type::Tiny types for CXC::Number::Sequence
103              
104             =head1 VERSION
105              
106             version 0.13
107              
108             =head1 TYPES
109              
110             =head2 Alignment
111              
112             A Tuple containing two elements, the first of which is a C<BigNum>,
113             the second of which is a C<BigNum> in the range [0,1).
114              
115             =head2 Sequence
116              
117             A array of numbers with at lest two members which is sorted by increasing value
118              
119             =head2 Spacing
120              
121             A non-zero BigNum
122              
123             =head2 Ratio
124              
125             A positive number greater than 1.
126              
127             =head1 INTERNALS
128              
129             =head1 SUPPORT
130              
131             =head2 Bugs
132              
133             Please report any bugs or feature requests to bug-cxc-number@rt.cpan.org or through the web interface at: L<https://rt.cpan.org/Public/Dist/Display.html?Name=CXC-Number>
134              
135             =head2 Source
136              
137             Source is available at
138              
139             https://gitlab.com/djerius/cxc-number
140              
141             and may be cloned from
142              
143             https://gitlab.com/djerius/cxc-number.git
144              
145             =head1 SEE ALSO
146              
147             Please see those modules/websites for more information related to this module.
148              
149             =over 4
150              
151             =item *
152              
153             L<CXC::Number|CXC::Number>
154              
155             =back
156              
157             =head1 AUTHOR
158              
159             Diab Jerius <djerius@cpan.org>
160              
161             =head1 COPYRIGHT AND LICENSE
162              
163             This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory.
164              
165             This is free software, licensed under:
166              
167             The GNU General Public License, Version 3, June 2007
168              
169             =cut