lib/Pod/POM/Test.pm

filter: Statementstmt 78.0% 32 / 41 Branchbran 50.0% 5 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 4 totaltotal 68.6% 46 / 67 CC 7 SCAR 11.8
CC
7
Cov
70%
assert
6.5
ok
4.5
match
3.2
CRAP 3.2
« blib/lib/Pod/POM/View/Text.pm ↑ Summary blib/lib/Pod/POM/Node/Text.pm »
1 #============================================================= -*-Perl-*-
2 #
3 # Pod::POM::Test
4 #
5 # DESCRIPTION
6 # Module implementing some useful subroutines for testing.
7 #
8 # AUTHOR
9 # Andy Wardley <abw@kfs.org>
10 #
11 # COPYRIGHT
12 # Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved.
13 #
14 # This module is free software; you can redistribute it and/or
15 # modify it under the same terms as Perl itself.
16 #
17 # REVISION
18 # $Id: Test.pm 14 2009-03-13 08:19:40Z ford $
19 #
20 #========================================================================
21  
22 package Pod::POM::Test;
23 13 $Pod::POM::Test::VERSION = '2.01';
24 13 require 5.006;
25  
26 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 13 ▶use Pod::POM;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 13 ▶use parent qw( Exporter );
Subroutine BEGIN: called CC=1 SCAR=0.0
31 13 ▶use vars qw( @EXPORT );
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 13 @EXPORT = qw( ntests ok match assert );
34  
35 13 my $ok_count;
36  
37 13 ▶sub ntests {
Subroutine ntests: called CC=1 SCAR=0.0
Pod undocumented
38 13 my $ntests = shift;
39 13 $ok_count = 1;
40 13 print "1..$ntests\n";
41 }
42  
43 88 ▶sub ok {
Subroutine ok: called CC=3 SCAR=15.1
Pod undocumented
44 88 my ($ok, $msg) = @_;
45 88 ▶ if ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ok) { } 88 0 88
46 88 print "ok ", $ok_count++, "\n";
47 }
48 else {
49 0 ▶ print "FAILED $ok_count: $msg\n" if defined $msg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $msg 0 0 0
50 0 print "not ok ", $ok_count++, "\n";
51 }
52 }
53  
54 23 ▶sub assert {
Subroutine assert: called CC=3 SCAR=18.7
Pod undocumented
55 23 my ($ok, $err) = @_;
56 23 ▶ return ok(1) if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 23 0 23
57  
58 # failed
59 0 my ($pkg, $file, $line) = caller();
60 0 ▶ $err ||= "assert failed";
Condition0%0/2
$err ||= "assert failed"
l!l
00
MC/DC0%0/1
$err ||= "assert failed"
$err
Truth table0%0/2
A
A= $err
Aresult
11
00
61 0 $err .= " at $file line $line\n";
62 0 ok(0);
63 0 die $err;
64 }
65  
66  
67 61 ▶sub match {
Subroutine match: called CC=3 SCAR=11.8
Pod undocumented
68 61 my ($result, $expect) = @_;
69  
70 # force stringification of $result to avoid 'no eq method' overload errors
71 61 ▶ $result = "$result" if ref $result;
Branch: 1 branch
BranchTrueFalseTotal
if ref $result 10 51 61
72  
73 61 ▶ if ($result eq $expect) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result eq $expect) { } 61 0 61
74 61 ok(1);
75 }
76 else {
77 0 print "FAILED $ok_count:\n expect: [$expect]\n result: [$result]\n";
78 0 ok(0);
79 }
80 }
81  
82  
83 13 1;
« blib/lib/Pod/POM/View/Text.pm ↑ Summary blib/lib/Pod/POM/Node/Text.pm »