blib/lib/URI/Fast/Test.pm

filter: Statementstmt 100% 22 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 100% 33 / 33 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Fast.xs ↑ Summary
1 package URI::Fast::Test;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Test2::V0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use URI::Fast qw(uri);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our @EXPORT = qw(is_same_uri isnt_same_uri);
11  
12 sub export_uri {
13 return {
14 8 ▶ scheme => $_[0]->scheme,
Subroutine export_uri: called CC=1 SCAR=0.0
Pod documented
15 usr => $_[0]->usr,
16 pwd => $_[0]->pwd,
17 host => $_[0]->host,
18 port => $_[0]->port,
19 path => [$_[0]->path],
20 query => $_[0]->query_hash,
21 frag => $_[0]->frag,
22 },
23 }
24  
25 sub is_same_uri {
26 2 ▶ my ($got, $expected, $msg) = @_;
Subroutine is_same_uri: called CC=1 SCAR=0.0
Pod documented
27 2 is export_uri(uri("$got")), export_uri(uri("$expected")), $msg;
28 }
29  
30 sub isnt_same_uri {
31 2 ▶ my ($got, $expected, $msg) = @_;
Subroutine isnt_same_uri: called CC=1 SCAR=0.0
Pod documented
32 2 isnt export_uri(uri("$got")), export_uri(uri("$expected")), $msg;
33 }
34  
35 1 1;
36  
37 =head1 NAME
38  
39 URI::Fast::Test - Unit test comparisons for URI::Fast objects
40  
41 =head1 SYNOPSIS
42  
43 use URI::Fast::Test;
44  
45 is_same_uri uri($got), uri($expected), 'got expected uri';
46  
47 isnt_same_uri uri($got), uri($unwanted), 'did not get unwanted uri';
48  
49 =head1 EXPORTS
50  
51 =head2 is_same_uri
52  
53 Builds a nested structure of uri components for comparison with Test2's deep
54 comparison using C<is>. The test subjects may be either L<URI::Fast> objects
55 or strings, in which case they will be parsed into L<URI::Fast> objects.
56  
57 =head2 isnt_same_uri
58  
59 Builds a nested structure of uri components for comparison with Test2's deep
60 comparison using C<isnt>. The test subjects may be either L<URI::Fast> objects
61 or strings, in which case they will be parsed into L<URI::Fast> objects.
62  
63 =head1 SUBROUTINES
64  
65 =head2 export_uri
66  
67 Exports a L<URI::Fast> object as a hash ref for use with L<Test2>'s comparison
68 functions. The return value's structure is:
69  
70 {
71 scheme => $uri->scheme,
72 usr => $uri->usr,
73 pwd => $uri->pwd,
74 host => $uri->host,
75 port => $uri->port,
76 path => [$uri->path],
77 query => $uri->query_hash,
78 frag => $uri->frag,
79 }
80  
81 =head1 AUTHOR
82  
83 Jeff Ober <sysread@fastmail.fm>
84  
85 =head1 COPYRIGHT AND LICENSE
86  
87 This software is copyright (c) 2018 by Jeff Ober. This is free software; you
88 can redistribute it and/or modify it under the same terms as the Perl 5
89 programming language system itself.
90  
91 =cut
« Fast.xs ↑ Summary