functional_XML/test

filter: Statementstmt 100% 37 / 37 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 91.3% 53 / 58 CC 4 SCAR 4.8
CC
4
Cov
89%
BEGIN
3.2
examplepage
2.0
BEGIN
1.0
CRAP 1.6
« intro/basics ↑ Summary lib/FP/fix.pm »
1 #!/usr/bin/env perl
2  
3 # Copyright (c) 2015 Christian Jaeger, copying@christianjaeger.ch
4 # This is free software. See the file COPYING.md that came bundled
5 # with this file.
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Cwd 'abs_path';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 our ($mydir, $myname);
13  
14 1 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=11.7
15 1 ▶ my $location = (-l $0) ? abs_path($0) : $0;
Branch: 1 branch
BranchTrueFalseTotal
-l $0 ? : 0 1 1
16 1 ▶ $location =~ /(.*?)([^\/]+?)_?\z/s or die "?";
Branch: 1 branch
BranchTrueFalseTotal
$location =~ m[(.*?)([^/]+?)_?\z]s or die "?" 1 0 1
17 1 ($mydir, $myname) = ($1, $2);
18 }
19 1 ▶use lib "$mydir/../lib";
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use PXML::XHTML ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use PXML::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 1 ▶sub page {
Subroutine page: called CC=1 SCAR=0.0
27 1 my ($title, $mtime, $main) = @_;
28 1 HTML(
29 HEAD(TITLE($title)),
30 BODY(
31 $main,
32 HR(),
33 P(
34 "By ",
35 A({ href => "http://christianjaeger.ch" }, "Christian Jaeger"),
36 ", last modified at ",
37 gmtime($mtime) . "",
38 " (or something)."
39 )
40 )
41 )
42 }
43  
44 1 our $numbers = { 1 => "one", 2 => "two", 3 => "three" };
45  
46 1 ▶sub examplepage {
Subroutine examplepage: called CC=2 SCAR=7.1
47 1 my ($title) = @_;
48 page(
49 "example page - $title",
50 @ARGV ? $ARGV[0] : time,
51 [
52 H1($title),
53 P(
54 "Garçon méchanique, \"1 < 2\" is true. ",
55 A({ href => "\"1 < 2\"" }, "this will be 404")
56 ),
57 TABLE(
58 { border => 1 },
59 1 ▶ map { TR(TD($_), TD($$numbers{$_})) } (1 .. 3)
Branch: 1 branch
BranchTrueFalseTotal
@ARGV ? : 1 0 1
60 )
61 ]
62 )
63 }
64  
65 1 ▶open my $o, ">:utf8", "out.xhtml" or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $o, ">:utf8", "out.xhtml" or die $! 1 0 1
66 1 pxml_xhtml_print examplepage("Hello World"), $o, "en";
67 1 ▶close $o or die $!;
Branch: 1 branch
BranchTrueFalseTotal
close $o or die $! 1 0 1
68  
« intro/basics ↑ Summary lib/FP/fix.pm »