| 1 | # Copyrights 2001-2022 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||||||||||
| 5 | # This code is part of distribution Mail-Message. Meta-POD processed with | ||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||
| 8 | |||||||||||
| 9 | package Mail::Message::Test; | ||||||||||
| 10 | 53 | ▶ | use vars '$VERSION'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 53 | $VERSION = '3.012'; | |||||||||
| 12 | |||||||||||
| 13 | 53 | ▶ | use base 'Exporter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 53 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 53 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 53 | ▶ | use File::Copy 'copy'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 53 | ▶ | use List::Util 'first'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 53 | ▶ | use IO::File; # to overrule open() | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 53 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 53 | ▶ | use Cwd qw(getcwd); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 53 | ▶ | use Sys::Hostname qw(hostname); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 53 | ▶ | use Test::More; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | 53 | our @EXPORT = | |||||||||
| 28 | qw/compare_message_prints reproducable_text | ||||||||||
| 29 | $raw_html_data | ||||||||||
| 30 | $crlf_platform | ||||||||||
| 31 | /; | ||||||||||
| 32 | |||||||||||
| 33 | 53 | our $crlf_platform = $^O =~ m/mswin32/i; | |||||||||
| 34 | |||||||||||
| 35 | # | ||||||||||
| 36 | # Compare the text of two messages, rather strict. | ||||||||||
| 37 | # On CRLF platforms, the Content-Length may be different. | ||||||||||
| 38 | # | ||||||||||
| 39 | |||||||||||
| 40 | sub compare_message_prints($$$) | ||||||||||
| 41 | 8 | ▶ | { my ($first, $second, $label) = @_; | ||||||||
|
Subroutine
compare_message_prints: called CC=2 SCAR=8.4
Pod
undocumented
| |||||||||||
| 42 | |||||||||||
| 43 | 8 | ▶ | if($crlf_platform) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 0 | { $first =~ s/Content-Length: (\d+)/Content-Length: <removed>/g; | |||||||||
| 45 | 0 | $second =~ s/Content-Length: (\d+)/Content-Length: <removed>/g; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 8 | is($first, $second, $label); | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | # | ||||||||||
| 52 | # Strip message text down the things which are the same on all | ||||||||||
| 53 | # platforms and all situations. | ||||||||||
| 54 | # | ||||||||||
| 55 | |||||||||||
| 56 | sub reproducable_text($) | ||||||||||
| 57 | 4 | ▶ | { my $text = shift; | ||||||||
|
Subroutine
reproducable_text: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 58 | 4 | my @lines = split /^/m, $text; | |||||||||
| 59 | 4 | foreach (@lines) | |||||||||
| 60 | 97 | { s/((?:references|message-id|date|content-length)\: ).*/$1<removed>/i; | |||||||||
| 61 | 97 | s/boundary-\d+/boundary-<removed>/g; | |||||||||
| 62 | } | ||||||||||
| 63 | 4 | join '', @lines; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | # | ||||||||||
| 67 | # A piece of HTML text which is used in some tests. | ||||||||||
| 68 | # | ||||||||||
| 69 | |||||||||||
| 70 | 53 | our $raw_html_data = <<'TEXT'; | |||||||||
| 71 | <HTML> | ||||||||||
| 72 | <HEAD> | ||||||||||
| 73 | <TITLE>My home page</TITLE> | ||||||||||
| 74 | </HEAD> | ||||||||||
| 75 | <BODY BGCOLOR=red> | ||||||||||
| 76 | |||||||||||
| 77 | <H1>Life according to Brian</H1> | ||||||||||
| 78 | |||||||||||
| 79 | This is normal text, but not in a paragraph.<P>New paragraph | ||||||||||
| 80 | in a bad way. | ||||||||||
| 81 | |||||||||||
| 82 | And this is just a continuation. When texts get long, they must be | ||||||||||
| 83 | auto-wrapped; and even that is working already. | ||||||||||
| 84 | |||||||||||
| 85 | <H3>Silly subsection at once</H3> | ||||||||||
| 86 | <H1>and another chapter</H1> | ||||||||||
| 87 | <H2>again a section</H2> | ||||||||||
| 88 | <P>Normal paragraph, which contains an <IMG | ||||||||||
| 89 | SRC=image.gif>, some | ||||||||||
| 90 | <I>italics with linebreak | ||||||||||
| 91 | </I> and <TT>code</TT> | ||||||||||
| 92 | |||||||||||
| 93 | <PRE> | ||||||||||
| 94 | And now for the preformatted stuff | ||||||||||
| 95 | it should stay as it was | ||||||||||
| 96 | even with strange blanks | ||||||||||
| 97 | and indentations | ||||||||||
| 98 | </PRE> | ||||||||||
| 99 | |||||||||||
| 100 | And back to normal text... | ||||||||||
| 101 | <UL> | ||||||||||
| 102 | <LI>list item 1 | ||||||||||
| 103 | <OL> | ||||||||||
| 104 | <LI>list item 1.1 | ||||||||||
| 105 | <LI>list item 1.2 | ||||||||||
| 106 | </OL> | ||||||||||
| 107 | <LI>list item 2 | ||||||||||
| 108 | </UL> | ||||||||||
| 109 | </BODY> | ||||||||||
| 110 | </HTML> | ||||||||||
| 111 | TEXT | ||||||||||
| 112 | |||||||||||
| 113 | 53 | 1; | |||||||||