diff options
author | Nuno Carvalho <smash@cpan.org> | 2013-09-25 14:54:40 +0100 |
---|---|---|
committer | Nuno Carvalho <smash@cpan.org> | 2013-09-25 14:54:40 +0100 |
commit | a61e56c3cc012053d17f7cc61c024d5abe04bbd8 (patch) | |
tree | 51ef05fefa3e6ba7ed3d6c4043ae3858ac4041bf /t | |
parent | b3135b8a486622a785f0a5ea23adec53369daad4 (diff) |
Imported Upstream version 3.006
Diffstat (limited to 't')
-rw-r--r-- | t/00-compile.t | 45 | ||||
-rw-r--r-- | t/000-report-versions-tiny.t | 84 | ||||
-rw-r--r-- | t/abstractions.t | 36 | ||||
-rw-r--r-- | t/lib/Test/EmailAbstract.pm | 4 | ||||
-rw-r--r-- | t/multipart.msg | 94 |
5 files changed, 256 insertions, 7 deletions
diff --git a/t/00-compile.t b/t/00-compile.t new file mode 100644 index 0000000..ad2e6a8 --- /dev/null +++ b/t/00-compile.t @@ -0,0 +1,45 @@ +use strict; +use warnings; + +# This test was generated via Dist::Zilla::Plugin::Test::Compile 2.018 + +use Test::More 0.88; + + + +use Capture::Tiny qw{ capture }; + +my @module_files = qw( +Email/Abstract.pm +Email/Abstract/EmailMIME.pm +Email/Abstract/EmailSimple.pm +Email/Abstract/MIMEEntity.pm +Email/Abstract/MailInternet.pm +Email/Abstract/MailMessage.pm +Email/Abstract/Plugin.pm +); + +my @scripts = qw( + +); + +# no fake home requested + +my @warnings; +for my $lib (@module_files) +{ + my ($stdout, $stderr, $exit) = capture { + system($^X, '-Mblib', '-e', qq{require q[$lib]}); + }; + is($?, 0, "$lib loaded ok"); + warn $stderr if $stderr; + push @warnings, $stderr if $stderr; +} + + + +is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; + + + +done_testing; diff --git a/t/000-report-versions-tiny.t b/t/000-report-versions-tiny.t new file mode 100644 index 0000000..98d8c55 --- /dev/null +++ b/t/000-report-versions-tiny.t @@ -0,0 +1,84 @@ +use strict; +use warnings; +use Test::More 0.88; +# This is a relatively nice way to avoid Test::NoWarnings breaking our +# expectations by adding extra tests, without using no_plan. It also helps +# avoid any other test module that feels introducing random tests, or even +# test plans, is a nice idea. +our $success = 0; +END { $success && done_testing; } + +# List our own version used to generate this +my $v = "\nGenerated by Dist::Zilla::Plugin::ReportVersions::Tiny v1.09\n"; + +eval { # no excuses! + # report our Perl details + my $want = '5.006'; + $v .= "perl: $] (wanted $want) on $^O from $^X\n\n"; +}; +defined($@) and diag("$@"); + +# Now, our module version dependencies: +sub pmver { + my ($module, $wanted) = @_; + $wanted = " (want $wanted)"; + my $pmver; + eval "require $module;"; + if ($@) { + if ($@ =~ m/Can't locate .* in \@INC/) { + $pmver = 'module not found.'; + } else { + diag("${module}: $@"); + $pmver = 'died during require.'; + } + } else { + my $version; + eval { $version = $module->VERSION; }; + if ($@) { + diag("${module}: $@"); + $pmver = 'died during VERSION check.'; + } elsif (defined $version) { + $pmver = "$version"; + } else { + $pmver = '<undef>'; + } + } + + # So, we should be good, right? + return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n"); +} + +eval { $v .= pmver('Capture::Tiny','any version') }; +eval { $v .= pmver('Carp','any version') }; +eval { $v .= pmver('Email::Simple','1.998') }; +eval { $v .= pmver('ExtUtils::MakeMaker','6.30') }; +eval { $v .= pmver('MIME::Parser','any version') }; +eval { $v .= pmver('MRO::Compat','any version') }; +eval { $v .= pmver('Module::Pluggable','1.5') }; +eval { $v .= pmver('Scalar::Util','any version') }; +eval { $v .= pmver('Test::More','0.96') }; +eval { $v .= pmver('Test::Pod','1.41') }; +eval { $v .= pmver('blib','any version') }; +eval { $v .= pmver('lib','any version') }; +eval { $v .= pmver('strict','any version') }; +eval { $v .= pmver('version','0.9901') }; +eval { $v .= pmver('warnings','any version') }; + + +# All done. +$v .= <<'EOT'; + +Thanks for using my code. I hope it works for you. +If not, please try and include this output in the bug report. +That will help me reproduce the issue and solve your problem. + +EOT + +diag($v); +ok(1, "we really didn't test anything, just reporting data"); +$success = 1; + +# Work around another nasty module on CPAN. :/ +no warnings 'once'; +$Template::Test::NO_FLUSH = 1; +exit 0; diff --git a/t/abstractions.t b/t/abstractions.t index 6e61b33..bdc4556 100644 --- a/t/abstractions.t +++ b/t/abstractions.t @@ -1,4 +1,4 @@ -#!perl -T +#!perl use strict; use Test::More; @@ -12,13 +12,13 @@ my @classes plan tests => 2 + (@classes * 2 + 2) * Test::EmailAbstract->tests_per_object + (@classes + 4) * Test::EmailAbstract->tests_per_class - + 2; + + 3; use_ok("Email::Abstract"); -open FILE, '<t/example.msg'; -my $message = do { local $/; <FILE>; }; -close FILE; +open my $fh, '<', 't/example.msg' or die "can't open t/example.msg: $!"; +my $message = do { local $/; <$fh>; }; +close $fh or die "error closing t/example.msg after read: $!"; # Let's be generous and start with real CRLF, no matter what stupid thing the # VCS or archive tools have done to the message. @@ -84,3 +84,29 @@ for my $ref (0..1) { ); } } + +{ + SKIP: { + $tester->load('MIME::Entity'); # cheating!!! -- rjbs, 2013-07-30 + + open my $fh, '<', 't/multipart.msg' or die "can't open t/multipart.msg: $!"; + my $message = do { local $/; <$fh>; }; + close $fh or die "error closing t/multipart.msg after read: $!"; + + # Let's be generous and start with real CRLF, no matter what stupid thing the + # VCS or archive tools have done to the message. + $message =~ s/\x0a\x0d|\x0d\x0a|\x0d|\x0a/\x0d\x0a/g; + + my $parser = MIME::Parser->new; + $parser->output_to_core(1); + my $entity = $parser->parse_data($message); + + my $abstract = Email::Abstract->new($entity); + + like( + $abstract->get_body, + qr/us-ascii/, + "minimal body test on MIME::Entity", + ); + } +} diff --git a/t/lib/Test/EmailAbstract.pm b/t/lib/Test/EmailAbstract.pm index e498a30..43c1291 100644 --- a/t/lib/Test/EmailAbstract.pm +++ b/t/lib/Test/EmailAbstract.pm @@ -47,7 +47,7 @@ sub _do_tests { if ($readonly) { like($@, qr/can't alter string/, "can't alter an unwrapped string"); } else { - ok(!$@, "no exception on altering object via Email::Abstract"); + is($@, '', "no exception on altering object via Email::Abstract"); } my @receiveds = ( @@ -88,7 +88,7 @@ sub _do_tests { if ($readonly) { like($@, qr/can't alter string/, "can't alter an unwrapped string"); } else { - ok(!$@, "no exception on altering object via Email::Abstract"); + is($@, '', "no exception on altering object via Email::Abstract"); } if ($readonly) { diff --git a/t/multipart.msg b/t/multipart.msg new file mode 100644 index 0000000..fbd9fbc --- /dev/null +++ b/t/multipart.msg @@ -0,0 +1,94 @@ +Return-Path: <SRS0=KeFK=RM=cpan.org=rjbs@bounce2.pobox.com> +X-Original-To: rjbs@[70.87.222.20] +Delivered-To: rjbs@[70.87.222.20] +Received: from gold.pobox.com (gold.pobox.com [208.72.237.26]) by + cancer.codesimply.com (Postfix) with ESMTP id 51C1742273E for + <rjbs@[70.87.222.20]>; Tue, 30 Jul 2013 08:55:58 -0400 (EDT) +Received: from localhost.localdomain (localhost [127.0.0.1]) by + gold.pobox.com (Postfix) with ESMTP id 869DF40B516; Tue, 30 Jul 2013 08:55:56 + -0400 (EDT) +X-Pobox-Filter-Version: 3 +Delivered-To: cpan@rjbs.manxome.org +X-Pobox-Orig-Sender: <rjbs@cpan.org> +X-Pobox-Delivery-ID: + 5ECC6E8A-F917-11E2-BC38-91E4A95B95DF-07314517!gold.pobox.com +x-pobox-client-address: 207.171.7.70 +x-pobox-client-name: x1.develooper.com +Received: from x1.develooper.com (x1.develooper.com [207.171.7.70]) by + gold.pobox.com (Postfix) with SMTP id 900E240A7BB for + <cpan@rjbs.manxome.org>; Tue, 30 Jul 2013 08:55:53 -0400 (EDT) +Received: (qmail 7015 invoked by uid 225); 30 Jul 2013 12:55:52 -0000 +Delivered-To: rjbs@cpan.org +Received: (qmail 7011 invoked by uid 103); 30 Jul 2013 12:55:51 -0000 +Received: from xx1.dev (10.0.100.115) by x1.dev with QMQP; 30 Jul 2013 + 12:55:51 -0000 +Received: from localhost (HELO xx1.develooper.com) (127.0.0.1) by + xx1.develooper.com (qpsmtpd/0.84/v0.84-36-g0b0e4e9) with ESMTP; Tue, 30 Jul + 2013 05:55:51 -0700 +Received: from xx1.develooper.com (xx1.develooper.com [127.0.0.1]) by + localhost (Postfix) with SMTP id B2D9D11FB91 for <rjbs@cpan.org>; Tue, 30 Jul + 2013 05:55:51 -0700 (PDT) +Received: from smtp.pobox.com (b-pb-sasl-quonix.pobox.com [208.72.237.35]) by + xx1.develooper.com (Postfix) with ESMTP id 5248F11FB89 for <rjbs@cpan.org>; + Tue, 30 Jul 2013 05:55:51 -0700 (PDT) +Received: from smtp.pobox.com (unknown [127.0.0.1]) by + b-sasl-quonix.pobox.com (Postfix) with ESMTP id 5656333B7B for + <rjbs@cpan.org>; Tue, 30 Jul 2013 12:55:50 +0000 (UTC) +DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from + :content-type:subject:message-id:date:to:mime-version; s=sasl; + bh=8y5A5fJ5PreQxsLHjgB27fxj+Og=; b=hOKuPVvtMKC87qv6ziDC3DNULjHh + RP0aLBHXUYxJ2YNksTe11d6pJmj/dB1XRR60c/8C48siLnQrBMwX+BjH+aFSi6bE + ZYkZtWxqPZBcSdfVlArkR5UMgh3ERSnlWx/YpeWtMsmqJ3r1rO1hoC44n9rM/VHx + +cW2KqR+tgB3ouk= +Received: from b-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by + b-sasl-quonix.pobox.com (Postfix) with ESMTP id 4B79A33B7A for + <rjbs@cpan.org>; Tue, 30 Jul 2013 12:55:50 +0000 (UTC) +Received: from [172.16.1.202] (unknown [64.121.172.235]) (using TLSv1 with + cipher AES128-SHA (128/128 bits)) (No client certificate requested) by + b-sasl-quonix.pobox.com (Postfix) with ESMTPSA id DABAE33B78 for + <rjbs@cpan.org>; Tue, 30 Jul 2013 12:55:49 +0000 (UTC) +From: Ricardo Signes <rjbs@cpan.org> +Content-Type: multipart/alternative; boundary="Apple-Mail=_FAFF19B4-3BF3-4D29-930E-9D87CEC03F01" +Subject: test of mutipart +Message-Id: <8A1869F4-2A06-4155-8E9C-1B9CEB13D297@cpan.org> +Date: Tue, 30 Jul 2013 08:55:49 -0400 +To: rjbs@cpan.org +Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) +X-Mailer: Apple Mail (2.1508) +X-Pobox-Relay-ID: + 5C183962-F917-11E2-917A-E84251E3A03C-07314517!b-pb-sasl-quonix.pobox.com +X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: + 2013.7.30.124527 +X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' HTML_70_90 0.1, + HTML_NO_HTTP 0.1, FROM_SAME_AS_TO 0.05, MIME_LOWER_CASE 0.05, + BODYTEXTH_SIZE_10000_LESS 0, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1000_LESS + 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_600_699 0, + BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, DKIM_SIGNATURE 0, NO_URI_FOUND 0, + SMALL_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, + __CTYPE_MULTIPART_ALT 0, __FROM_SAME_AS_TO2 0, __HAS_FROM 0, __HAS_HTML 0, + __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_HTML 0, __MIME_VERSION 0, + __MSGID_APPLEMAIL 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_START + 0, __TAG_EXISTS_HTML 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, + __USER_AGENT_APPLEMAIL 0, __X_MAILER_APPLEMAIL 0, __zen.spamhaus.org_ERROR ' +X-Pobox-Pass: rjbs@cpan.org is whitelisted +Lines: 19 + + +--Apple-Mail=_FAFF19B4-3BF3-4D29-930E-9D87CEC03F01 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=us-ascii + + +This is a multipart test. + +-- +rjbs +--Apple-Mail=_FAFF19B4-3BF3-4D29-930E-9D87CEC03F01 +Content-Transfer-Encoding: 7bit +Content-Type: text/html; + charset=us-ascii + +<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br> +This is a <b>multipart</b> test.<div><br></div><div>-- </div><div>rjbs</div></body></html> +--Apple-Mail=_FAFF19B4-3BF3-4D29-930E-9D87CEC03F01-- |