| 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
| |||||||||||||
| 16 | 1 | ▶ | $location =~ /(.*?)([^\/]+?)_?\z/s or die "?"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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 FP::Lazy; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | 1 | ▶ | use FP::List; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | 1 | ▶ | use PXML::Serialize; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 25 | |||||||||||||
| 26 | 1 | ▶ | use utf8; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 27 | |||||||||||||
| 28 | 1 | $| = 1; | |||||||||||
| 29 | |||||||||||||
| 30 | 12 | ▶ | sub countdown { | ||||||||||
|
Subroutine
countdown: called CC=1 SCAR=0.0
| |||||||||||||
| 31 | 12 | my ($i) = @_; | |||||||||||
| 32 | 12 | ▶ | lazyLight { | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||
| 33 | |||||||||||||
| 34 | #sleep 1; | ||||||||||||
| 35 | 12 | ▶ | if ($i >= 0) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | 11 | cons(P($i), countdown($i - 1)); | |||||||||||
| 37 | } else { | ||||||||||||
| 38 | 1 | null | |||||||||||
| 39 | |||||||||||||
| 40 | # XX should test undef here, too | ||||||||||||
| 41 | } | ||||||||||||
| 42 | } | ||||||||||||
| 43 | 12 | } | |||||||||||
| 44 | |||||||||||||
| 45 | 1 | ▶ | sub page { | ||||||||||
|
Subroutine
page: called CC=1 SCAR=0.0
| |||||||||||||
| 46 | 1 | my ($title, $mtime, $main) = @_; | |||||||||||
| 47 | 1 | HTML( | |||||||||||
| 48 | HEAD(TITLE($title)), | ||||||||||||
| 49 | BODY( | ||||||||||||
| 50 | $main, | ||||||||||||
| 51 | HR(), | ||||||||||||
| 52 | P( | ||||||||||||
| 53 | "By ", | ||||||||||||
| 54 | A({ href => "http://christianjaeger.ch" }, "Christian Jaeger"), | ||||||||||||
| 55 | ", last modified at ", | ||||||||||||
| 56 | gmtime($mtime) . "", | ||||||||||||
| 57 | " (or something)." | ||||||||||||
| 58 | ) | ||||||||||||
| 59 | ) | ||||||||||||
| 60 | ) | ||||||||||||
| 61 | } | ||||||||||||
| 62 | |||||||||||||
| 63 | 1 | our $numbers = { 1 => "one", 2 => "two", 3 => "three" }; | |||||||||||
| 64 | |||||||||||||
| 65 | 1 | ▶ | sub examplepage { | ||||||||||
|
Subroutine
examplepage: called CC=3 SCAR=11.7
| |||||||||||||
| 66 | 1 | my ($title) = @_; | |||||||||||
| 67 | page( | ||||||||||||
| 68 | "example page - $title", | ||||||||||||
| 69 | $ENV{T} // time, | ||||||||||||
| 70 | [ | ||||||||||||
| 71 | H1($title), | ||||||||||||
| 72 | P( | ||||||||||||
| 73 | "Garçon méchanique, \"1 < 2\" is true. ", | ||||||||||||
| 74 | A({ href => "\"1 < 2\"" }, "this will be 404") | ||||||||||||
| 75 | ), | ||||||||||||
| 76 | TABLE( | ||||||||||||
| 77 | { border => 1 }, | ||||||||||||
| 78 | 3 | ▶ | map { TR(TD($_), TD($$numbers{$_})) } (1 .. 3) | ||||||||||
|
Condition50%1/2
$ENV{'N'} || 1000000000.0
MC/DC0%0/1
$ENV{'N'} || 1000000000.0
$ENV{'N'}
Truth table50%1/2
A
A= $ENV{'N'}
| |||||||||||||
| 79 | ), | ||||||||||||
| 80 | 1 | ▶ | countdown($ENV{N} || 1e9), | ||||||||||
|
Condition50%1/2
$ENV{"T"} // time
MC/DC0%0/1
$ENV{"T"} // time
$ENV{"T"}
Truth table50%1/2
A
A= $ENV{"T"}
| |||||||||||||
| 81 | ] | ||||||||||||
| 82 | ) | ||||||||||||
| 83 | } | ||||||||||||
| 84 | |||||||||||||
| 85 | 1 | pxml_xhtml_print examplepage("Hello World"), *STDOUT{IO}, "en"; | |||||||||||
| 86 | |||||||||||||