summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRicardo Signes <rjbs@cpan.org>2007-07-19 02:25:25 +0000
committerRicardo Signes <rjbs@cpan.org>2007-07-19 02:25:25 +0000
commit2b47439787063a5d07027b20b96eb53ac78731d8 (patch)
tree7fa81f9ab61a815604a4ea461cc967a25a605665 /t
parent09194b3ab184d0d1688afd4c8ae163b0786d3057 (diff)
r32112@knight: rjbs | 2007-07-18 22:22:50 -0400
test coverage
Diffstat (limited to 't')
-rw-r--r--t/abstractions.t16
-rw-r--r--t/unknown.t28
2 files changed, 38 insertions, 6 deletions
diff --git a/t/abstractions.t b/t/abstractions.t
index e699db1..9d97f6f 100644
--- a/t/abstractions.t
+++ b/t/abstractions.t
@@ -10,8 +10,8 @@ my @classes
= qw(Email::MIME Email::Simple MIME::Entity Mail::Internet Mail::Message);
plan tests => 2
- + (@classes + 1) * Test::EmailAbstract->tests_per_object
- + (@classes + 1) * Test::EmailAbstract->tests_per_class
+ + (@classes * 2 + 1) * Test::EmailAbstract->tests_per_object
+ + (@classes + 2) * Test::EmailAbstract->tests_per_class
+ 1;
use_ok("Email::Abstract");
@@ -43,6 +43,13 @@ for my $class (@classes) {
}
{
+ my $simple = Email::Simple->new($message);
+ my $obj = Email::Abstract->cast($simple, $class);
+ my $email_abs = Email::Abstract->new($obj);
+ $tester->object_ok($class, $email_abs, 0);
+ }
+
+ {
my $obj = Email::Abstract->cast($message, $class);
$tester->class_ok($class, $obj, 0);
}
@@ -56,6 +63,11 @@ for my $class (@classes) {
}
{
+ my $email_abs = Email::Abstract->new($message);
+ $tester->class_ok('Email::Abstract', $email_abs, 0);
+}
+
+{
# Ensure that we can use Email::Abstract->header($abstract, 'foo')
my $email_abs = Email::Abstract->new($message);
diff --git a/t/unknown.t b/t/unknown.t
index 36bc507..f457e1d 100644
--- a/t/unknown.t
+++ b/t/unknown.t
@@ -1,13 +1,33 @@
+#!perl -T
use strict;
use Test::More;
-plan tests => 2;
+plan tests => 4;
use_ok("Email::Abstract");
-my $object = bless [] => "Totally::Unknown";
+BEGIN {
+ package Totally::Unknown::ToAll;
+ @Totally::Unknown::ToAll::ISA = ('Totally::Unknown');
+}
-my $abs = eval { Email::Abstract->new($object); };
+for my $class ('Totally::Unknown', 'Totally::Unknown::ToAll') {
+ my $object = bless [] => $class;
+ my $abs = eval { Email::Abstract->new($object); };
+ like($@, qr/handle/, "exception on unknown object type");
+}
-like($@, qr/handle/, "exception on unknown object type");
+open FILE, '<t/example.msg';
+my $message = do { local $/; <FILE>; };
+close FILE;
+
+# 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;
+
+require Email::Simple;
+my $simple = Email::Simple->new($message);
+
+eval { Email::Abstract->cast($simple, 'Totally::Unknown::ToAll') };
+like($@, qr/don't know/i, "can't cast an object to an unknown class");