File Coverage

blib/lib/Assert/Refute/T/Deep.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition 2 3 66.6
subroutine 7 7 100.0
pod n/a
total 28 29 96.5


line stmt bran cond sub pod time code
1             package Assert::Refute::T::Deep;
2              
3 1     1   79245 use 5.006;
  1         4  
4 1     1   5 use strict;
  1         2  
  1         17  
5 1     1   4 use warnings;
  1         1  
  1         49  
6             our $VERSION = '0.02';
7              
8             =head1 NAME
9              
10             Assert::Refute::T::Deep - Test::Deep plugin for Assert::Refute
11              
12             =head1 SYNOPSIS
13              
14             See L for what a C block is for.
15             In a nutshell, it's a set of L-like assertions
16             that appends its results to a "report" object
17             rather than standard output.
18              
19             This module allows to use L with L:
20              
21             use Assert::Refute;
22             use Assert::Refute::T::Deep;
23              
24             my $report = try_refute {
25             cmp_deeply $my_data, $spec, "Data is as expected";
26             };
27              
28             if (!$report->is_passing) {
29             warn $report->get_tap;
30             };
31              
32              
33             =head1 EXPORT
34              
35             Whatever is exported by L is also re-exported by this module.
36              
37             =cut
38              
39 1     1   5 use parent qw(Exporter);
  1         2  
  1         5  
40 1     1   56 use Assert::Refute::Build;
  1         4  
  1         46  
41 1     1   353 use Test::Deep::NoTest qw(:all);
  1         9253  
  1         6  
42              
43             # Blindly reexport whatever Test::Deep has
44             our @EXPORT = @Test::Deep::EXPORT;
45             our @EXPORT_OK = @Test::Deep::EXPORT_OK;
46             our %EXPORT_TAGS = %Test::Deep::EXPORT_TAGS;
47              
48             =head2 cmp_deeply $got, $expected, "Message"
49              
50             Compare data and report discrepancies if found.
51             This only works if an L contract in being executed.
52              
53             =cut
54              
55             # Remove the implementation imported from Test::Deep
56             # to avoid redefine warnings.
57             undef *cmp_deeply;
58              
59             build_refute cmp_deeply => sub {
60 2     2   3677 my ($ok, $stack) = cmp_details( @_ );
61 2   66     9198 return !$ok && deep_diag($stack);
62             }, args => 2, export => 1;
63              
64             =head1 AUTHOR
65              
66             Konstantin S. Uvarin, C<< >>
67              
68             =head1 BUGS
69              
70             This module should be merged into either Assert::Refute or Test::Deep.
71             Suggestions welcome.
72              
73             Please report bugs via github or RT:
74              
75             =over
76              
77             =item * L
78              
79             =item * C
80              
81             =item * L
82              
83             =back
84              
85             =head1 SUPPORT
86              
87             You can find documentation for this module with the C command.
88              
89             perldoc Assert::Refute::T::Deep
90              
91             You can also look for information at:
92              
93             =over 4
94              
95             =item * RT: CPAN's request tracker (report bugs here)
96              
97             L
98              
99             =item * AnnoCPAN: Annotated CPAN documentation
100              
101             L
102              
103             =item * CPAN Ratings
104              
105             L
106              
107             =item * Search CPAN
108              
109             L
110              
111             =back
112              
113              
114             =head1 ACKNOWLEDGEMENTS
115              
116              
117             =head1 LICENSE AND COPYRIGHT
118              
119             Copyright 2018 Konstantin S. Uvarin.
120              
121             This program is free software; you can redistribute it and/or modify it
122             under the terms of the the Artistic License (2.0). You may obtain a
123             copy of the full license at:
124              
125             L
126              
127             Any use, modification, and distribution of the Standard or Modified
128             Versions is governed by this Artistic License. By using, modifying or
129             distributing the Package, you accept this license. Do not use, modify,
130             or distribute the Package, if you do not accept this license.
131              
132             If your Modified Version has been derived from a Modified Version made
133             by someone other than you, you are nevertheless required to ensure that
134             your Modified Version complies with the requirements of this license.
135              
136             This license does not grant you the right to use any trademark, service
137             mark, tradename, or logo of the Copyright Holder.
138              
139             This license includes the non-exclusive, worldwide, free-of-charge
140             patent license to make, have made, use, offer to sell, sell, import and
141             otherwise transfer the Package with respect to any patent claims
142             licensable by the Copyright Holder that are necessarily infringed by the
143             Package. If you institute patent litigation (including a cross-claim or
144             counterclaim) against any party alleging that the Package constitutes
145             direct or contributory patent infringement, then this Artistic License
146             to you shall terminate on the date that such litigation is filed.
147              
148             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
149             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
150             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
151             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
152             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
153             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
154             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
155             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
156              
157              
158             =cut
159              
160             1; # End of Assert::Refute::T::Deep