File Coverage

blib/lib/Acme/Types/NonStandard.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 32 32 100.0


line stmt bran cond sub pod time code
1             package Acme::Types::NonStandard;
2             $Acme::Types::NonStandard::VERSION = '0.002002';
3 1     1   25041 use strict; use warnings;
  1     1   2  
  1         34  
  1         4  
  1         2  
  1         25  
4              
5 1     1   5 use Scalar::Util 'isdual';
  1         2  
  1         62  
6              
7 1     1   484 use Type::Library -base;
  1         15166  
  1         9  
8 1     1   738 use Type::Utils -all;
  1         3353  
  1         9  
9 1     1   2063 use Types::TypeTiny ();
  1         1  
  1         19  
10 1     1   530 use Types::Standard -types;
  1         33056  
  1         15  
11              
12 1     1   3777 use Devel::Cycle;
  1         2990  
  1         8  
13              
14             declare ConfusingDualVar =>
15             where { isdual($_) && "$_" =~ /^[0-9.]+$/ && $_+0 ne "$_" };
16              
17             declare FortyTwo => as Int() => where { $_ == 42 };
18             coerce FortyTwo => from Any() => via { 42 };
19              
20             declare RefRefRef => where { ref $_ && ref ${ $_ } && ref ${ ${ $_ } } };
21              
22             declare ReallySparseArray => as ArrayRef[Undef];
23              
24             declare ProbableMemoryLeak =>
25             where {
26             my $yeah_probably = 0;
27             find_cycle($_, sub { $yeah_probably++ });
28             $yeah_probably
29             };
30              
31              
32             print "I'm not sorry.\n" unless caller; 1;
33              
34             =pod
35              
36             =head1 NAME
37              
38             Acme::Types::NonStandard - unbundled set of stupid types for Type::Tiny
39              
40             =head1 SYNOPSIS
41              
42             use Acme::Types::NonStandard -types;
43              
44             =head1 DESCRIPTION
45              
46             An attempt to provide totally useless types that L does not.
47              
48             =head3 ConfusingDualVar
49              
50             A dualvar (see L) whose stringy value must be a floating
51             point number or integer distinct from the numeric value (to maximize debugging
52             confusion).
53              
54             =head3 FortyTwo
55              
56             The number 42. Always.
57              
58             Can be coerced from Any (to the number 42).
59              
60             =head3 ProbableMemoryLeak
61              
62             An object that contains cyclic references (per L).
63              
64             =head3 ReallySparseArray
65              
66             An array that only contains C (but as many of them as you'd like!)
67              
68             =head3 RefRefRef
69              
70             A reference to a reference to a reference (to ensure adequate levels of
71             indirection; see also: Cargill's quandry).
72              
73             =head1 AUTHOR
74              
75             Jon Portnoy , but I'm going to loudly deny while pointing
76             fingers at C and C on C.
77              
78             Licensed under the same terms as Perl.
79              
80             Patches or suggestions regarding other completely stupid types welcome, as
81             long as they're not in any way useful.
82              
83             =cut