Message/Test.pm

filter: Statementstmt 97.5% 39 / 40 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 92.5% 50 / 54 CC 4 SCAR 5.3
CC
4
Cov
95%
compare_message_prints
3.3
reproducable_text
2.0
BEGIN
1.0
CRAP 1.7
« Message/Convert/TextAutoformat.pm ↑ Summary Message/Convert/HtmlFormatText.pm »
1 # This code is part of Perl distribution Mail-Message version 4.05.
2 # The POD got stripped from this file by OODoc version 3.06.
3 # For contributors see file ChangeLog.
4  
5 # This software is copyright (c) 2001-2026 by Mark Overmeer.
6  
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10  
11  
12 package Mail::Message::Test;{
13 54 our $VERSION = '4.05';
14 }
15  
16 54 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 54 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 54 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 54 ▶use Log::Report 'mail-message', import => [ qw// ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 54 ▶use File::Copy qw/copy/;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 54 ▶use List::Util qw/first/;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 54 ▶use IO::File; # to overrule open()
Subroutine BEGIN: called CC=1 SCAR=0.0
26 54 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 54 our @EXPORT = qw/compare_message_prints reproducable_text $raw_html_data $crlf_platform/;
29 54 our $crlf_platform = $^O =~ m/mswin32/i;
30  
31 #
32 # Compare the text of two messages, rather strict.
33 # On CRLF platforms, the Content-Length may be different.
34 #
35  
36 sub compare_message_prints($$$)
37 8 ▶{ my ($first, $second, $label) = @_;
Subroutine compare_message_prints: called CC=3 SCAR=12.0
Pod undocumented
38  
39 8 ▶ if($crlf_platform)
Branch: 1 branch
BranchTrueFalseTotal
if ($Mail::Message::Test::crlf_platform) 0 8 8
40 0 { s/Content-Length: (\d+)/Content-Length: <removed>/g for $first, $second;
41 }
42  
43 8 is($first, $second, $label);
44 }
45  
46 #
47 # Strip message text down the things which are the same on all
48 # platforms and all situations.
49 #
50  
51 sub reproducable_text($)
52 4 ▶{ my $text = shift;
Subroutine reproducable_text: called CC=2 SCAR=6.9
Pod undocumented
53 4 my @lines = split /^/m, $text;
54 4 foreach (@lines)
55 97 { s/((?:references|message-id|date|content-length)\: ).*/$1<removed>/i;
56 97 s/boundary-\d+/boundary-<removed>/g;
57 }
58 4 join '', @lines;
59 }
60  
61 #
62 # A piece of HTML text which is used in some tests.
63 #
64  
65 54 our $raw_html_data = <<'TEXT';
66 <HTML>
67 <HEAD>
68 <TITLE>My home page</TITLE>
69 </HEAD>
70 <BODY BGCOLOR=red>
71  
72 <H1>Life according to Brian</H1>
73  
74 This is normal text, but not in a paragraph.<P>New paragraph
75 in a bad way.
76  
77 And this is just a continuation. When texts get long, they must be
78 auto-wrapped; and even that is working already.
79  
80 <H3>Silly subsection at once</H3>
81 <H1>and another chapter</H1>
82 <H2>again a section</H2>
83 <P>Normal paragraph, which contains an <IMG
84 SRC=image.gif>, some
85 <I>italics with linebreak
86 </I> and <TT>code</TT>
87  
88 <PRE>
89 And now for the preformatted stuff
90 it should stay as it was
91 even with strange blanks
92 and indentations
93 </PRE>
94  
95 And back to normal text...
96 <UL>
97 <LI>list item 1
98 <OL>
99 <LI>list item 1.1
100 <LI>list item 1.2
101 </OL>
102 <LI>list item 2
103 </UL>
104 </BODY>
105 </HTML>
106 TEXT
107  
108 54 1;
« Message/Convert/TextAutoformat.pm ↑ Summary Message/Convert/HtmlFormatText.pm »