summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorGregor Herrmann <gregoa@debian.org>2007-11-17 15:46:42 +0000
committerGregor Herrmann <gregoa@debian.org>2007-11-17 15:46:42 +0000
commitd174319d751440af21b1147fe0d0ca19a34b1359 (patch)
treeefbb286ef994c64465e4336afa3fef8b20c31262 /t
parentbea49c7f0b8e82b1f1a5ad59442d3d5cab277538 (diff)
[svn-upgrade] Integrating new upstream version, libemail-abstract-perl (2.134)
Diffstat (limited to 't')
-rw-r--r--t/abs-object.t156
-rw-r--r--t/abstractions.t79
-rw-r--r--t/classy.t138
-rw-r--r--t/example.msg42
-rw-r--r--t/lib/Test/EmailAbstract.pm142
-rw-r--r--t/subclass.t8
-rw-r--r--t/unknown.t33
7 files changed, 253 insertions, 345 deletions
diff --git a/t/abs-object.t b/t/abs-object.t
deleted file mode 100644
index c524ce9..0000000
--- a/t/abs-object.t
+++ /dev/null
@@ -1,156 +0,0 @@
-
-use strict;
-
-use Test::More;
-
-use lib 't/lib';
-
-use Test::EmailAbstract;
-
-my @classes
- = qw(Email::MIME Email::Simple MIME::Entity Mail::Internet Mail::Message);
-
-plan tests => 1 + 6 * @classes + 5 * 2 + 1;
-
-use_ok("Email::Abstract");
-
-my $message = do { local $/; <DATA>; };
-
-for my $class (@classes) {
- SKIP: {
- eval "require $class";
- skip "$class can't be loaded", 6 if $@;
-
- my $obj = Email::Abstract->cast($message, $class);
-
- my $email_abs = Email::Abstract->new($obj);
-
- isa_ok($email_abs, 'Email::Abstract', "wrapped $class object");
-
- Test::EmailAbstract::wrapped_ok($class, $email_abs, 0);
- }
-}
-
-{
- my $email_abs = Email::Abstract->new($message);
- Test::EmailAbstract::wrapped_ok('plaintext', $email_abs, 0);
-}
-
-{
- # Ensure that we can use Email::Abstract->header($abstract, 'foo')
- my $email_abs = Email::Abstract->new($message);
- Test::EmailAbstract::class_ok('plaintext (via class)', $email_abs, 0);
-
- my $email_abs_new = Email::Abstract->new($email_abs);
- ok(
- $email_abs == $email_abs_new,
- "trying to wrap a wrapper returns the wrapper; it doesn't re-wrap",
- );
-}
-
-__DATA__
-Received: from mailman.opengroup.org ([192.153.166.9])
- by deep-dark-truthful-mirror.pad with smtp (Exim 3.36 #1 (Debian))
- id 18Buh5-0006Zr-00
- for <posix@simon-cozens.org>; Wed, 13 Nov 2002 10:24:23 +0000
-Received: (qmail 1679 invoked by uid 503); 13 Nov 2002 10:10:49 -0000
-Resent-Date: 13 Nov 2002 10:10:49 -0000
-Date: Wed, 13 Nov 2002 10:06:51 GMT
-From: Andrew Josey <ajosey@rdg.opengroup.org>
-Message-Id: <1021113100650.ZM12997@skye.rdg.opengroup.org>
-In-Reply-To: Joanna Farley's message as of Nov 13, 9:56am.
-References: <200211120937.JAA28130@xoneweb.opengroup.org>
- <1021112125524.ZM7503@skye.rdg.opengroup.org>
- <3DD221BB.13116D47@sun.com>
-X-Mailer: Z-Mail (5.0.0 30July97)
-To: austin-group-l@opengroup.org
-Subject: Re: Defect in XBD lround
-MIME-Version: 1.0
-Resent-Message-ID: <gZGK1B.A.uY.iUi09@mailman>
-Resent-To: austin-group-l@opengroup.org
-Resent-From: austin-group-l@opengroup.org
-X-Mailing-List: austin-group-l:archive/latest/4823
-X-Loop: austin-group-l@opengroup.org
-Precedence: list
-X-Spam-Status: No, hits=-1.6 required=5.0
-Resent-Sender: austin-group-l-request@opengroup.org
-Content-Type: text/plain; charset=us-ascii
-
-Joanna, All
-
-Thanks. I got the following response from Fred Tydeman.
-
-C99 Defect Report (DR) 240 covers this. The main body of C99
-(7.12.9.7) says range error, while Annex F (F.9.6.7 and F.9.6.5)
-says "invalid" (domain error). The result was to change 7.12.9.7
-to allow for either range or domain error. The preferred error
-is domain error (so as match Annex F). So, no need to change XBD.
-
-regards
-Andrew
-
-On Nov 13, 9:56am in "Re: Defect in XBD lr", Joanna Farley wrote:
-> Sun's expert in this area after some discussions with a colleague
-> outside of Sun concluded that for lround, to align with both C99 and SUS
-> changes of the following form were necessary:
->
-> + If x is +/-Inf/NaN, a domain error occurs, and
-> + errno is set to EDOM in MATH_ERRNO mode;
-> + the invalid exception is raised in MATH_ERREXCEPT mode.
-> [to align with C99 Annex F.4]
->
-> + If x is too large to be represented as a long, a *range* error
-> may occur, and
-> + errno *may be* set to ERANGE in MATH_ERRNO mode;
-> [to align with C99 7.12.9.7]
-> + the invalid exception *is* raised in MATH_ERREXCEPT mode.
-> [to align with C99 Annex F.4]
->
-> They believe it is a bit awkward to have errno set to ERANGE in
-> MATH_ERRNO mode yet the invalid exception raised in MAH_ERREXCEPT mode,
-> but that just reflects an imperfect mapping of the C notion of errno to
-> the IEEE 754 notion of data conversion.
->
-> I'll work with our expert to draft text refecting the above to suggest
-> replacement text for lines 23678-23684 on lround page 721 of XSH6.
->
-> Thanks
->
-> Joanna
->
->
-> Andrew Josey wrote:
-> >
-> > The text referred to is MX shaded and part of the ISO 60559 floating
-> > point option. I do not think changing the Domain Error to a Range Error
-> > is the fix or at least not the fix for the NaN and +-Inf cases. ISO C
-> > 99 describes the range error case if the magnitude of x is too large as a
-> > may fail. I'll ask Fred T for his thoughts on this one...
-> > regards
-> > Andrew
-> >
-> > On Nov 12, 9:37am in "Defect in XBD lround", Erwin.Unruh@fujitsu-siemens.com wrote:
-> > > Defect report from : Erwin Unruh , Fujitsu Siemens Computers
-> > >
-> > > (Please direct followup comments direct to austin-group-l@opengroup.org)
-> > >
-> > > @ page 0 line 0 section lround objection {0}
-> > >
-> > > Problem:
-> > >
-> > > Defect code : 1. Error
-> > >
-> > > The function lround is described in http://www.opengroup.org/onlinepubs/007904975/functions/lround.html
-> > > On Error it is specified that errno has to be set to EDOM. However, the C99 standard ISO/IEC 9899:1999 (E) specifies this as a range error, which would result in a value of ERANGE. So an implementation could not be conformant to both these standards.
-> > >
-> > > Action:
-> > >
-> > > Change the value of errno to ERANGE, if the result is not represantable. More specific: In the description of the function, replace all occurences of "domain error" with "range error" and replace "EDOM" with "ERANGE"
-> > >-- End of excerpt from Erwin.Unruh@fujitsu-siemens.com
-> >
-
------
-Andrew Josey The Open Group
-Austin Group Chair Apex Plaza,Forbury Road,
-Email: a.josey@opengroup.org Reading,Berks.RG1 1AX,England
-Tel: +44 118 9508311 ext 2250 Fax: +44 118 9500110
diff --git a/t/abstractions.t b/t/abstractions.t
new file mode 100644
index 0000000..9d97f6f
--- /dev/null
+++ b/t/abstractions.t
@@ -0,0 +1,79 @@
+#!perl -T
+use strict;
+
+use Test::More;
+
+use lib 't/lib';
+use Test::EmailAbstract;
+
+my @classes
+ = qw(Email::MIME Email::Simple MIME::Entity Mail::Internet Mail::Message);
+
+plan tests => 2
+ + (@classes * 2 + 1) * Test::EmailAbstract->tests_per_object
+ + (@classes + 2) * Test::EmailAbstract->tests_per_class
+ + 1;
+
+use_ok("Email::Abstract");
+
+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;
+
+my $tester = Test::EmailAbstract->new($message);
+
+is(
+ substr($message, -2, 2),
+ "\x0d\x0a",
+ "the message ends in a CRLF",
+);
+
+for my $class (@classes) {
+ SKIP: {
+ $tester->load($class);
+
+ {
+ my $obj = Email::Abstract->cast($message, $class);
+ my $email_abs = Email::Abstract->new($obj);
+ $tester->object_ok($class, $email_abs, 0);
+ }
+
+ {
+ 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);
+ }
+ }
+}
+
+{
+ my $email_abs = Email::Abstract->new($message);
+ $tester->object_ok('plaintext', $email_abs, 0);
+ $tester->class_ok('plaintext (class)', $message, 1);
+}
+
+{
+ 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);
+
+ my $email_abs_new = Email::Abstract->new($email_abs);
+ ok(
+ $email_abs == $email_abs_new,
+ "trying to wrap a wrapper returns the wrapper; it doesn't re-wrap",
+ );
+}
diff --git a/t/classy.t b/t/classy.t
deleted file mode 100644
index 3e769c9..0000000
--- a/t/classy.t
+++ /dev/null
@@ -1,138 +0,0 @@
-use Test::More;
-
-use lib 't/lib';
-
-use Test::EmailAbstract;
-
-my @classes
- = qw(Email::MIME Email::Simple MIME::Entity Mail::Internet Mail::Message);
-
-plan tests => 1 + 6 * @classes + 5;
-
-use_ok("Email::Abstract");
-
-my $message = do { local $/; <DATA>; };
-
-for my $class (
- qw(Email::MIME Email::Simple MIME::Entity Mail::Internet Mail::Message)
-) {
- SKIP: {
- eval "require $class";
- skip "$class can't be loaded", 6 if $@;
-
- my $obj = Email::Abstract->cast($message, $class);
-
- isa_ok($obj, $class, "string cast to $class");
-
- Test::EmailAbstract::class_ok($class, $obj, 0);
- }
-}
-
-Test::EmailAbstract::class_ok('plaintext', $message, 1);
-
-__DATA__
-Received: from mailman.opengroup.org ([192.153.166.9])
- by deep-dark-truthful-mirror.pad with smtp (Exim 3.36 #1 (Debian))
- id 18Buh5-0006Zr-00
- for <posix@simon-cozens.org>; Wed, 13 Nov 2002 10:24:23 +0000
-Received: (qmail 1679 invoked by uid 503); 13 Nov 2002 10:10:49 -0000
-Resent-Date: 13 Nov 2002 10:10:49 -0000
-Date: Wed, 13 Nov 2002 10:06:51 GMT
-From: Andrew Josey <ajosey@rdg.opengroup.org>
-Message-Id: <1021113100650.ZM12997@skye.rdg.opengroup.org>
-In-Reply-To: Joanna Farley's message as of Nov 13, 9:56am.
-References: <200211120937.JAA28130@xoneweb.opengroup.org>
- <1021112125524.ZM7503@skye.rdg.opengroup.org>
- <3DD221BB.13116D47@sun.com>
-X-Mailer: Z-Mail (5.0.0 30July97)
-To: austin-group-l@opengroup.org
-Subject: Re: Defect in XBD lround
-MIME-Version: 1.0
-Resent-Message-ID: <gZGK1B.A.uY.iUi09@mailman>
-Resent-To: austin-group-l@opengroup.org
-Resent-From: austin-group-l@opengroup.org
-X-Mailing-List: austin-group-l:archive/latest/4823
-X-Loop: austin-group-l@opengroup.org
-Precedence: list
-X-Spam-Status: No, hits=-1.6 required=5.0
-Resent-Sender: austin-group-l-request@opengroup.org
-Content-Type: text/plain; charset=us-ascii
-
-Joanna, All
-
-Thanks. I got the following response from Fred Tydeman.
-
-C99 Defect Report (DR) 240 covers this. The main body of C99
-(7.12.9.7) says range error, while Annex F (F.9.6.7 and F.9.6.5)
-says "invalid" (domain error). The result was to change 7.12.9.7
-to allow for either range or domain error. The preferred error
-is domain error (so as match Annex F). So, no need to change XBD.
-
-regards
-Andrew
-
-On Nov 13, 9:56am in "Re: Defect in XBD lr", Joanna Farley wrote:
-> Sun's expert in this area after some discussions with a colleague
-> outside of Sun concluded that for lround, to align with both C99 and SUS
-> changes of the following form were necessary:
->
-> + If x is +/-Inf/NaN, a domain error occurs, and
-> + errno is set to EDOM in MATH_ERRNO mode;
-> + the invalid exception is raised in MATH_ERREXCEPT mode.
-> [to align with C99 Annex F.4]
->
-> + If x is too large to be represented as a long, a *range* error
-> may occur, and
-> + errno *may be* set to ERANGE in MATH_ERRNO mode;
-> [to align with C99 7.12.9.7]
-> + the invalid exception *is* raised in MATH_ERREXCEPT mode.
-> [to align with C99 Annex F.4]
->
-> They believe it is a bit awkward to have errno set to ERANGE in
-> MATH_ERRNO mode yet the invalid exception raised in MAH_ERREXCEPT mode,
-> but that just reflects an imperfect mapping of the C notion of errno to
-> the IEEE 754 notion of data conversion.
->
-> I'll work with our expert to draft text refecting the above to suggest
-> replacement text for lines 23678-23684 on lround page 721 of XSH6.
->
-> Thanks
->
-> Joanna
->
->
-> Andrew Josey wrote:
-> >
-> > The text referred to is MX shaded and part of the ISO 60559 floating
-> > point option. I do not think changing the Domain Error to a Range Error
-> > is the fix or at least not the fix for the NaN and +-Inf cases. ISO C
-> > 99 describes the range error case if the magnitude of x is too large as a
-> > may fail. I'll ask Fred T for his thoughts on this one...
-> > regards
-> > Andrew
-> >
-> > On Nov 12, 9:37am in "Defect in XBD lround", Erwin.Unruh@fujitsu-siemens.com wrote:
-> > > Defect report from : Erwin Unruh , Fujitsu Siemens Computers
-> > >
-> > > (Please direct followup comments direct to austin-group-l@opengroup.org)
-> > >
-> > > @ page 0 line 0 section lround objection {0}
-> > >
-> > > Problem:
-> > >
-> > > Defect code : 1. Error
-> > >
-> > > The function lround is described in http://www.opengroup.org/onlinepubs/007904975/functions/lround.html
-> > > On Error it is specified that errno has to be set to EDOM. However, the C99 standard ISO/IEC 9899:1999 (E) specifies this as a range error, which would result in a value of ERANGE. So an implementation could not be conformant to both these standards.
-> > >
-> > > Action:
-> > >
-> > > Change the value of errno to ERANGE, if the result is not represantable. More specific: In the description of the function, replace all occurences of "domain error" with "range error" and replace "EDOM" with "ERANGE"
-> > >-- End of excerpt from Erwin.Unruh@fujitsu-siemens.com
-> >
-
------
-Andrew Josey The Open Group
-Austin Group Chair Apex Plaza,Forbury Road,
-Email: a.josey@opengroup.org Reading,Berks.RG1 1AX,England
-Tel: +44 118 9508311 ext 2250 Fax: +44 118 9500110
diff --git a/t/example.msg b/t/example.msg
new file mode 100644
index 0000000..bb8c106
--- /dev/null
+++ b/t/example.msg
@@ -0,0 +1,42 @@
+Received: from mailman.opengroup.org ([192.153.166.9])
+ by deep-dark-truthful-mirror.pad with smtp (Exim 3.36 #1 (Debian))
+ id 18Buh5-0006Zr-00
+ for <posix@simon-cozens.org>; Wed, 13 Nov 2002 10:24:23 +0000
+Received: (qmail 1679 invoked by uid 503); 13 Nov 2002 10:10:49 -0000
+Resent-Date: 13 Nov 2002 10:10:49 -0000
+Date: Wed, 13 Nov 2002 10:06:51 GMT
+From: Andrew Josey <ajosey@rdg.opengroup.org>
+Message-Id: <1021113100650.ZM12997@skye.rdg.opengroup.org>
+In-Reply-To: Joanna Farley's message as of Nov 13, 9:56am.
+References: <200211120937.JAA28130@xoneweb.opengroup.org>
+ <1021112125524.ZM7503@skye.rdg.opengroup.org>
+ <3DD221BB.13116D47@sun.com>
+X-Mailer: Z-Mail (5.0.0 30July97)
+To: austin-group-l@opengroup.org
+Subject: Re: Defect in XBD lround
+MIME-Version: 1.0
+Resent-Message-ID: <gZGK1B.A.uY.iUi09@mailman>
+Resent-To: austin-group-l@opengroup.org
+Resent-From: austin-group-l@opengroup.org
+X-Mailing-List: austin-group-l:archive/latest/4823
+X-Loop: austin-group-l@opengroup.org
+Precedence: list
+X-Spam-Status: No, hits=-1.6 required=5.0
+Resent-Sender: austin-group-l-request@opengroup.org
+Content-Type: text/plain; charset=us-ascii
+
+Joanna, All
+
+Thanks. I got the following response from Fred Tydeman.
+
+On Nov 13, 9:56am in "Re: Defect in XBD lr", Joanna Farley wrote:
+> Sun's expert in this area after some discussions with a colleague
+> outside of Sun concluded that for lround, to align with both C99 and SUS
+> changes of the following form were necessary:
+> this line of text is really long and no one need worry about it but why was such a long text chosen to begin with i mean really??
+
+-----
+Andrew Josey The Open Group
+Austin Group Chair Apex Plaza,Forbury Road,
+Email: a.josey@opengroup.org Reading,Berks.RG1 1AX,England
+Tel: +44 118 9508311 ext 2250 Fax: +44 118 9500110
diff --git a/t/lib/Test/EmailAbstract.pm b/t/lib/Test/EmailAbstract.pm
index c192cd6..e498a30 100644
--- a/t/lib/Test/EmailAbstract.pm
+++ b/t/lib/Test/EmailAbstract.pm
@@ -1,9 +1,16 @@
use strict;
-use warnings;
package Test::EmailAbstract;
use Test::More;
+sub new {
+ my ($class, $message) = @_;
+ my $simple = Email::Simple->new($message);
+ bless { simple => $simple } => $class;
+}
+
+sub simple { $_[0]->{simple} }
+
sub _call {
my ($wrapped, $object, $method, @args) = @_;
@@ -14,60 +21,97 @@ sub _call {
}
}
-# This is responsible for running 5 tests.
-sub _test_object {
- my ($wrapped, $class, $obj, $readonly) = @_;
+sub tests_per_class { 7 }
+sub tests_per_object { 8 }
+sub tests_per_module {
+ + 1
+ + 2 * $_[0]->tests_per_class
+ + 1 * $_[0]->tests_per_object
+}
+
+sub _do_tests {
+ my ($self, $is_wrapped, $class, $obj, $readonly) = @_;
- like(
- _call($wrapped, $obj, 'get_header', 'Subject'),
- qr/Re: Defect in XBD lround/,
- "Subject OK with $class"
- );
+ if ($is_wrapped) {
+ isa_ok($obj, 'Email::Abstract', "wrapped $class object");
+ }
+
+ is(
+ _call($is_wrapped, $obj, 'get_header', 'Subject'),
+ 'Re: Defect in XBD lround',
+ "Subject OK with $class"
+ );
+
+ eval { _call($is_wrapped, $obj, set_header => "Subject", "New Subject"); };
+
+ if ($readonly) {
+ like($@, qr/can't alter string/, "can't alter an unwrapped string");
+ } else {
+ ok(!$@, "no exception on altering object via Email::Abstract");
+ }
+
+ my @receiveds = (
+ q{from mailman.opengroup.org ([192.153.166.9]) by deep-dark-truthful-mirror.pad with smtp (Exim 3.36 #1 (Debian)) id 18Buh5-0006Zr-00 for <posix@simon-cozens.org>; Wed, 13 Nov 2002 10:24:23 +0000},
+ q{(qmail 1679 invoked by uid 503); 13 Nov 2002 10:10:49 -0000},
+ );
+
+ my @got = _call($is_wrapped, $obj, get_header => 'Received');
+ s/\t/ /g for @got;
+ is_deeply(
+ \@got,
+ \@receiveds,
+ "$class: received headers match up list context get_header",
+ );
+
+ my $got_body = _call($is_wrapped, $obj, 'get_body');
+ my $simple_body = $self->simple->body;
+
+ # I very much do not like doing this. Why is it needed?
+ $got_body =~ s/\x0d?\x0a?\z//;
+ $simple_body =~ s/\x0d?\x0a?\z//;
+
+ is(
+ $got_body,
+ $simple_body,
+ "correct stringification of $class; same as reference object",
+ );
+
+ is(
+ length $got_body,
+ length $simple_body,
+ "correct body length for $class",
+ );
+
+ eval { _call($is_wrapped, $obj, set_body => "A completely new body"); };
+
+ if ($readonly) {
+ like($@, qr/can't alter string/, "can't alter an unwrapped string");
+ } else {
+ ok(!$@, "no exception on altering object via Email::Abstract");
+ }
+
+ if ($readonly) {
+ pass("(no test; can't check altering unalterable alteration)");
+ } else {
like(
- _call($wrapped, $obj, 'get_body'),
- qr/Fred Tydeman/,
- "Body OK with $class"
+ _call($is_wrapped, $obj, 'as_string'),
+ qr/Subject: New Subject.*completely new body$/ms,
+ "set subject and body, restringified ok with $class"
);
-
- eval {
- _call($wrapped, $obj, set_header =>
- "Subject",
- "New Subject"
- );
- };
-
- if ($readonly) {
- like($@, qr/can't alter string/, "can't alter an unwrapped string");
- } else {
- ok(!$@, "no exception on altering object via Email::Abstract");
- }
-
- eval {
- _call($wrapped, $obj, set_body =>
- "A completely new body"
- );
- };
-
- if ($readonly) {
- like($@, qr/can't alter string/, "can't alter an unwrapped string");
- } else {
- ok(!$@, "no exception on altering object via Email::Abstract");
- }
-
- if ($readonly) {
- pass("(no test; can't check altering unalterable alteration)");
- } else {
- like(
- _call($wrapped, $obj, 'as_string'),
- qr/Subject: New Subject.*completely new body$/ms,
- "set subject and body, restringified ok with $class"
- );
- }
+ }
}
-sub class_ok { _test_object(0, @_); }
-sub wrapped_ok { _test_object(1, @_); }
+sub class_ok { shift->_do_tests(0, @_); }
+sub object_ok { shift->_do_tests(1, @_); }
+sub load {
+ my ($self, $class) = @_;
+ if (eval "require $class; Email::Abstract->__class_for('$class')") {
+ diag "testing $class with " . $class->VERSION;
+ } else {
+ skip "$class: unavailable", $self->tests_per_module;
+ }
+}
1;
diff --git a/t/subclass.t b/t/subclass.t
index 0fa38b2..1f78492 100644
--- a/t/subclass.t
+++ b/t/subclass.t
@@ -1,6 +1,7 @@
{
package MyMail;
- use base "Email::Simple";
+ use Email::Simple;
+ BEGIN { @MyMail::ISA = 'Email::Simple'; }
}
package main;
@@ -16,7 +17,10 @@ like($y->as_string, qr/Farley's/, "Round trip subclass via object wrapped");
SKIP: {
skip "this test requires MIME::Entity", 1
- unless eval { require MIME::Entity; 1 };
+ unless eval {
+ require Email::Abstract::MIMEEntity;
+ Email::Abstract::MIMEEntity->is_available;
+ };
{ # should always adapt as if it's MIME::Entity, the nearest class
package MultiHopMail;
require MIME::Entity;
diff --git a/t/unknown.t b/t/unknown.t
new file mode 100644
index 0000000..f457e1d
--- /dev/null
+++ b/t/unknown.t
@@ -0,0 +1,33 @@
+#!perl -T
+use strict;
+
+use Test::More;
+
+plan tests => 4;
+
+use_ok("Email::Abstract");
+
+BEGIN {
+ package Totally::Unknown::ToAll;
+ @Totally::Unknown::ToAll::ISA = ('Totally::Unknown');
+}
+
+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");
+}
+
+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");