File Coverage

blib/lib/Test/Sort/Sub.pm
Criterion Covered Total %
statement 49 49 100.0
branch 20 24 83.3
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 78 82 95.1


line stmt bran cond sub pod time code
1             package Test::Sort::Sub;
2              
3             ## no critic: Modules::ProhibitAutomaticExportation
4              
5             our $DATE = '2020-02-28'; # DATE
6             our $VERSION = '0.117'; # VERSION
7              
8 13     13   1186859 use 5.010001;
  13         163  
9 13     13   64 use strict 'subs', 'vars';
  13         24  
  13         369  
10 13     13   75 use warnings;
  13         32  
  13         398  
11              
12 13     13   63 use Exporter 'import';
  13         19  
  13         403  
13 13     13   5551 use Sort::Sub ();
  13         31  
  13         294  
14 13     13   80 use Test::More 0.98;
  13         172  
  13         62  
15              
16             our @EXPORT = qw(sort_sub_ok);
17              
18             sub sort_sub_ok {
19 14     14 1 4110 my %args = @_;
20              
21 14         35 my $subname = $args{subname};
22             subtest "sort_sub_ok $subname" => sub {
23 14     14   17615 my $res;
24              
25 14 100       55 if ($args{output}) {
26 13 100       114 Sort::Sub->import("$subname", ($args{args} ? $args{args} : ()));
27 13         24 $res = [sort {&{$subname}} @{ $args{input} }];
  83         113  
  83         217  
  13         75  
28 13 50       63 is_deeply($res, $args{output}, 'result') or diag explain $res;
29             }
30              
31 14 100       10112 if ($args{output_i}) {
32 8 100       72 Sort::Sub->import("$subname<i>", ($args{args} ? $args{args} : ()));
33 8         17 $res = [sort {&{$subname}} @{ $args{input} }];
  49         201  
  49         115  
  8         35  
34 8 50       97 is_deeply($res, $args{output_i}, 'result i') or diag explain $res;
35             }
36              
37 14 100       5198 if ($args{output_r}) {
38 2 100       16 Sort::Sub->import("$subname<r>", ($args{args} ? $args{args} : ()));
39 2         5 $res = [sort {&{$subname}} @{ $args{input} }];
  6         9  
  6         13  
  2         8  
40 2 50       9 is_deeply($res, $args{output_r}, 'result r') or diag explain $res;
41             };
42              
43 14 100       1483 if ($args{output_ir}) {
44 10 100       88 Sort::Sub->import("$subname<ir>", ($args{args} ? $args{args} : ()));
45 10         20 $res = [sort {&{$subname}} @{ $args{input} }];
  51         192  
  51         101  
  10         41  
46 10 50       103 is_deeply($res, $args{output_ir}, 'result ir') or diag explain $res;
47             };
48 14         118 };
49             }
50              
51             1;
52             # ABSTRACT: Test Sort::Sub::* subroutine
53              
54             __END__
55              
56             =pod
57              
58             =encoding UTF-8
59              
60             =head1 NAME
61              
62             Test::Sort::Sub - Test Sort::Sub::* subroutine
63              
64             =head1 VERSION
65              
66             This document describes version 0.117 of Test::Sort::Sub (from Perl distribution Sort-Sub), released on 2020-02-28.
67              
68             =head1 FUNCTIONS
69              
70             =head2 sort_sub_ok(%args) => bool
71              
72             =head1 HOMEPAGE
73              
74             Please visit the project's homepage at L<https://metacpan.org/release/Sort-Sub>.
75              
76             =head1 SOURCE
77              
78             Source repository is at L<https://github.com/perlancar/perl-Sort-Sub>.
79              
80             =head1 BUGS
81              
82             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Sort-Sub>
83              
84             When submitting a bug or request, please include a test-file or a
85             patch to an existing test-file that illustrates the bug or desired
86             feature.
87              
88             =head1 AUTHOR
89              
90             perlancar <perlancar@cpan.org>
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             This software is copyright (c) 2020, 2019, 2018, 2016, 2015 by perlancar@cpan.org.
95              
96             This is free software; you can redistribute it and/or modify it under
97             the same terms as the Perl 5 programming language system itself.
98              
99             =cut