lib/PXML/Preserialize/t.pm

filter: Statementstmt 100% 57 / 57 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 24 / 24 Podpod n/a totaltotal 97.5% 81 / 83 CC 2 SCAR 1.2
CC
2
Cov
97%
__ANON__
2.5
__ANON__
1.1
BEGIN
1.0
CRAP 1.1
« lib/FP/Either.pm ↑ Summary lib/FP/Abstract/Compare.pm »
1 #
2 # Copyright (c) 2015 Christian Jaeger, copying@christianjaeger.ch
3 #
4 # This is free software, offered under either the same terms as perl 5
5 # or the terms of the Artistic License version 2 or the terms of the
6 # MIT License (Expat version). See the file COPYING.md that came
7 # bundled with this file.
8 #
9  
10 =head1 NAME
11  
12 PXML::Preserialize::t -- tests for PXML::Preserialize
13  
14 =head1 SYNOPSIS
15  
16 =head1 DESCRIPTION
17  
18 # is tested by `t/require_and_run_tests`
19  
20 =head1 NOTE
21  
22 This is alpha software! Read the status section in the package README
23 or on the L<website|http://functional-perl.org/>.
24  
25 =cut
26  
27 package PXML::Preserialize::t;
28  
29 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 1 ▶use Chj::TEST;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use PXML qw(pxmlbody);
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 1 ▶use PXML::Preserialize qw(pxmlfunc pxmlpre);
Subroutine BEGIN: called CC=1 SCAR=0.0
37 1 ▶use PXML::XHTML qw(A B);
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 2 ▶my $link_normal = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
40 2 my ($href, $body) = @_;
41 2 A { href => $href }, $body
42 1 };
43  
44 1 ▶my $link_fast = pxmlfunc {
Subroutine __ANON__: called CC=1 SCAR=0.0
45 1 my ($href, $body) = @_; # can take up to 10[?] arguments.
46 1 A { href => $href }, $body
47 1 };
48  
49 # the `2` is the number of arguments
50 1 my $link_fast2 = pxmlpre 2, $link_normal;
51  
52 # these expressions are all returing the same result, but the first
53 # is slower then the others:
54 1 my $res = '<a href="http://foo"><b>Foo</b>Bar</a>';
55 1 ▶TEST { &$link_normal("http://foo", [B("Foo"), "Bar"])->string } $res;
Subroutine __ANON__: called CC=1 SCAR=0.0
56  
57 1 ▶TEST { &$link_fast("http://foo", [B("Foo"), "Bar"])->string } $res;
Subroutine __ANON__: called CC=1 SCAR=0.0
58 1 ▶TEST { &$link_fast2("http://foo", [B("Foo"), "Bar"])->string } $res;
Subroutine __ANON__: called CC=1 SCAR=0.0
59  
60 1 ▶TEST {
Subroutine __ANON__: called CC=1 SCAR=0.0
61 1 ▶ pxmlfunc {1}->()->string
Subroutine __ANON__: called CC=1 SCAR=0.0
62 }
63 1 '1';
64 1 ▶TEST {
Subroutine __ANON__: called CC=1 SCAR=0.0
65 1 ▶ pxmlfunc { [1, 2] }->()->string
Subroutine __ANON__: called CC=1 SCAR=0.0
66 }
67 1 '12';
68 1 ▶TEST {
Subroutine __ANON__: called CC=1 SCAR=0.0
69 1 ▶ pxmlfunc { pxmlbody 3, 2 }->()->string
Subroutine __ANON__: called CC=1 SCAR=0.0
70 }
71 1 '32';
72  
73 1 ▶TEST_EXCEPTION {
Subroutine __ANON__: called CC=1 SCAR=0.0
74 1 ▶ pxmlfunc {
Subroutine __ANON__: called CC=1 SCAR=0.0
75 1 my ($loc, $body) = @_;
76 1 A { href => "http://$loc" }, $body
77  
78 # yes, already *that* is forbidden.
79 }
80 1 }
81 1 "tried to access a PXML::Preserialize::Argument object";
82  
83 1 ▶TEST_EXCEPTION {
Subroutine __ANON__: called CC=1 SCAR=0.0
84 1 ▶ pxmlfunc {
Subroutine __ANON__: called CC=1 SCAR=0.0
85 1 my ($loc, $body) = @_;
86 1 A { href => $loc }, 0 - $body
87 }
88 1 }
89 1 "tried to access a PXML::Preserialize::Argument object";
90  
91 1 ▶TEST_EXCEPTION {
Subroutine __ANON__: called CC=1 SCAR=0.6
92 1 ▶ pxmlfunc {
Subroutine __ANON__: called CC=2 SCAR=9.2
93 1 my ($loc, $body) = @_;
94 1 ▶ A { href => $loc }, $loc ? $body : 1
Branch: 1 branch
BranchTrueFalseTotal
$loc ? : 0 0 0
95 }
96 1 }
97 1 "tried to access a PXML::Preserialize::Argument object";
98  
99 1 1
« lib/FP/Either.pm ↑ Summary lib/FP/Abstract/Compare.pm »