r3346 - in /packages/libemail-abstract-perl/branches/upstream/current: ./ lib/Email/ lib/Email/Abstract/ t/ t/lib/ t/lib/Test/

ntyni-guest at users.alioth.debian.org ntyni-guest at users.alioth.debian.org
Thu Jul 27 20:36:24 UTC 2006


Author: ntyni-guest
Date: Thu Jul 27 20:36:22 2006
New Revision: 3346

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=3346
Log:
Load /tmp/tmp.SQRCoL9562/libemail-abstract-perl-2.13 into
packages/libemail-abstract-perl/branches/upstream/current.

Added:
    packages/libemail-abstract-perl/branches/upstream/current/t/abs-object.t
    packages/libemail-abstract-perl/branches/upstream/current/t/classy.t
    packages/libemail-abstract-perl/branches/upstream/current/t/lib/
    packages/libemail-abstract-perl/branches/upstream/current/t/lib/Test/
    packages/libemail-abstract-perl/branches/upstream/current/t/lib/Test/EmailAbstract.pm
Removed:
    packages/libemail-abstract-perl/branches/upstream/current/t/1.t
Modified:
    packages/libemail-abstract-perl/branches/upstream/current/Changes
    packages/libemail-abstract-perl/branches/upstream/current/MANIFEST
    packages/libemail-abstract-perl/branches/upstream/current/META.yml
    packages/libemail-abstract-perl/branches/upstream/current/Makefile.PL
    packages/libemail-abstract-perl/branches/upstream/current/README
    packages/libemail-abstract-perl/branches/upstream/current/lib/Email/Abstract.pm
    packages/libemail-abstract-perl/branches/upstream/current/lib/Email/Abstract/EmailSimple.pm
    packages/libemail-abstract-perl/branches/upstream/current/t/subclass.t

Modified: packages/libemail-abstract-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/Changes?rev=3346&op=diff
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/Changes (original)
+++ packages/libemail-abstract-perl/branches/upstream/current/Changes Thu Jul 27 20:36:22 2006
@@ -1,14 +1,39 @@
 Revision history for Perl extension Email::Abstract.
 
-2.01    2004-11-04
+2.12     2006-07-24
+
+  - test for and permit passing Email::Abstract objects to Email::Abstract
+    class methods
+
+2.12     2006-07-24
+
+  - don't use MIME::Entity in test if it's not available
+
+2.11     2006-07-22
+
+  - better test planning
+
+2.10     2006-07-21
+
+  - add a new method to create wrapper objects
+  - handle subclasses /properly/ (correct ISA order)
+  - improved tests and test coverage
+  - miscellaneous refactoring
+  - update PEP URL
+  - update documentation
+
+2.01     2004-11-04
 
   - Minor Documentation Fix
   - Author Change
   - PEP Contact Added
 
-2.0   Wed Aug 25 12:12:37 BST 2004
-    - Handle subclasses
-0.01  Wed May 26 16:47:20 2004
+2.0      2004-08-25 12:12:37 BST
+
+  - Handle subclasses
+
+0.01     2004-05-26 16:47 20
+
 	- original version; created by h2xs 1.22 with options
 		-AX -b 5.6.0 -n Email::Abstract
 

Modified: packages/libemail-abstract-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/MANIFEST?rev=3346&op=diff
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/MANIFEST (original)
+++ packages/libemail-abstract-perl/branches/upstream/current/MANIFEST Thu Jul 27 20:36:22 2006
@@ -7,7 +7,9 @@
 lib/Email/Abstract/MIMEEntity.pm
 Makefile.PL
 MANIFEST			This list of files
-META.yml
 README
-t/1.t
+t/abs-object.t
+t/classy.t
+t/lib/Test/EmailAbstract.pm
 t/subclass.t
+META.yml                                 Module meta-data (added by MakeMaker)

Modified: packages/libemail-abstract-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/META.yml?rev=3346&op=diff
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/META.yml (original)
+++ packages/libemail-abstract-perl/branches/upstream/current/META.yml Thu Jul 27 20:36:22 2006
@@ -1,13 +1,14 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         Email-Abstract
-version:      2.01
+version:      2.13
 version_from: lib/Email/Abstract.pm
 installdirs:  site
 requires:
+    Class::ISA:                    0.20
     Email::Simple:                 1.91
     Module::Pluggable:             1.5
     Test::More:                    0.47
 
 distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+generated_by: ExtUtils::MakeMaker version 6.30

Modified: packages/libemail-abstract-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/Makefile.PL?rev=3346&op=diff
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/Makefile.PL (original)
+++ packages/libemail-abstract-perl/branches/upstream/current/Makefile.PL Thu Jul 27 20:36:22 2006
@@ -5,9 +5,10 @@
 WriteMakefile(
     NAME              => 'Email::Abstract',
     VERSION_FROM      => 'lib/Email/Abstract.pm', # finds $VERSION
-               PREREQ_PM     => {
-                                 'Email::Simple' => '1.91',
-                                 'Module::Pluggable' => '1.5',
-                                 'Test::More' => '0.47',
-                                },
+    PREREQ_PM     => {
+        'Class::ISA'        => '0.20', # first release
+        'Email::Simple'     => '1.91', # avoid undef body
+        'Module::Pluggable' => '1.5',
+        'Test::More'        => '0.47',
+    },
 );

Modified: packages/libemail-abstract-perl/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/README?rev=3346&op=diff
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/README (original)
+++ packages/libemail-abstract-perl/branches/upstream/current/README Thu Jul 27 20:36:22 2006
@@ -62,5 +62,5 @@
     under the same terms as Perl itself.
 
 SEE ALSO
-    http://pep.kwiki.org
+    http://emailproject.perl.org/wiki/Email::Abstract
 

Modified: packages/libemail-abstract-perl/branches/upstream/current/lib/Email/Abstract.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/lib/Email/Abstract.pm?rev=3346&op=diff
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/lib/Email/Abstract.pm (original)
+++ packages/libemail-abstract-perl/branches/upstream/current/lib/Email/Abstract.pm Thu Jul 27 20:36:22 2006
@@ -4,75 +4,118 @@
 use 5.006;
 use strict;
 use warnings;
-our $VERSION = '2.01';
+our $VERSION = '2.13';
 use Module::Pluggable search_path => [ __PACKAGE__ ], require => 1;
+
 my @plugins = __PACKAGE__->plugins(); # Requires them.
-for my $func (qw(get_header get_body 
-                 set_header set_body 
-                 as_string)) {
+my %adapter_for = map { $_->target => $_ } @plugins;
+
+sub object {
+    my ($self) = @_;
+    return unless ref $self;
+    return $$self;
+}
+
+sub new {
+    my ($class, $foreign) = @_;
+
+    return $foreign if eval { $foreign->isa($class) };
+
+    $class = ref($class) || $class;
+
+    $foreign = Email::Simple->new($foreign) unless ref $foreign;
+
+    if (
+      $adapter_for{ref $foreign} or grep { $foreign->isa($_) } keys %adapter_for
+    ) {
+      return bless \$foreign => $class;
+    }
+
+    croak "Don't know how to handle " . ref $foreign;
+}
+
+sub __class_for {
+    my ($self, $foreign, $method) = @_;
+
+    my $f_class = ref($foreign) || $foreign;
+
+    return $adapter_for{ $f_class } if exists $adapter_for{ $f_class };
+
+    require Class::ISA;
+    for my $base (Class::ISA::super_path($f_class)) {
+        return $adapter_for{ $base } if exists $adapter_for{ $base }
+    }
+
+    croak "Don't know how to handle " . $f_class;
+}
+
+sub _obj_and_args {
+  my $self = shift;
+
+  return @_ unless my $thing = $self->object;
+  return ($thing, @_);
+}
+
+for my $func (qw(get_header get_body set_header set_body as_string)) {
     no strict 'refs';
     *$func  = sub { 
-        my ($class, $thing, @args) = @_;
-        $thing = Email::Simple->new($thing) unless ref $thing;
-        my $target = ref $thing;
-        $target =~ s/:://g;
-        $class .= "::".$target;
-        if ($class->can($func)) {
-            $class->$func($thing, @args);
-        } else {
-            for my $class (@plugins) { 
-                if ($class->can("target") and $thing->isa($class->target)) {
-                    return $class->$func($thing, @args);
-                }
-            }
-            croak "Don't know how to handle ".ref($thing);
+        my $self = shift;
+        my ($thing, @args) = $self->_obj_and_args(@_);
+
+        # In the event of Email::Abstract->get_body($email_abstract), convert
+        # it into an object method call.
+        $thing = $thing->object if eval { $thing->isa($self) };
+
+        unless (ref $thing) {
+            croak "can't alter string in place" if substr($func, 0, 3) eq 'set';
+            $thing = Email::Simple->new($thing)
         }
+
+        my $class = $self->__class_for($thing, $func);
+        return $class->$func($thing, @args);
     };
 }
 
 sub cast {
-    my ($class, $thing, $target) = @_;
-    $thing = $class->as_string($thing) if ref $thing;
-    $target =~ s/:://g;
-    $class .= "::".$target;
-    if ($class->can("construct")) {
-        $class->construct($thing);
-    } else {
-        for my $class (@plugins) { 
-            if ($class->can("target") and $thing->isa($class->target)) {
-                return $class->construct($thing);
-            }
-        }
-        croak "Don't know how to handle $class";
-    }
+    my $self = shift;
+    my ($from, $to) = $self->_obj_and_args(@_);
+
+    croak "Don't know how to construct $to objects"
+      unless $adapter_for{ $to } and $adapter_for{ $to }->can('construct');
+
+    my $from_string = ref($from) ? $self->as_string($from) : $from;
+
+    return $adapter_for{ $to }->construct($from_string);
 }
 
 # Preloaded methods go here.
 
 1;
 __END__
-# Below is stub documentation for your module. You'd better edit it!
 
 =head1 NAME
 
-Email::Abstract - Unified interface to mail representations
+Email::Abstract - unified interface to mail representations
 
 =head1 SYNOPSIS
 
   my $message = Mail::Message->read($rfc822)
-                || Email::Simple->new($rfc822)
-                || Mail::Internet->new([split /\n/, $rfc822])
-                || ...;
-
-  my $subject = Email::Abstract->get_header($message, "Subject");
-  Email::Abstract->set_header($message, "Subject", "My new subject");
-
-  my $body = Email::Abstract->get_body($message);
-  Email::Abstract->set_body($message, "Hello\nTest message\n");
-
-  $rfc822 = Email::Abstract->as_string($message);
-
-  my $mail_message = Email::Abstract->cast($message, "Mail::Message");
+             || Email::Simple->new($rfc822)
+             || Mail::Internet->new([split /\n/, $rfc822])
+             || ...
+             || $rfc822;
+
+  my $email = Email::Abstract->new($message);
+
+  my $subject = $email->get_header("Subject");
+  $email->set_header(Subject => "My new subject");
+
+  my $body = $email->get_body;
+  $email->set_body("Hello\nTest message\n");
+
+  $rfc822 = $email->as_string;
+
+  my $mail_message = $email->cast("Mail::Message");
 
 =head1 DESCRIPTION
 
@@ -94,31 +137,95 @@
 
 =head1 METHODS
 
-=head2 get_header($obj, $header)
+All of these methods may be called either as object methods or as class
+methods.  When called as class methods, the email object (of any class
+supported by Email::Abstract) must be prepended to the list of arguments.
+
+=head2 new
+
+  my $email = Email::Abstract->new($message);
+
+Given a message, either as a string or as an object for which an adapter is
+installed, this method will return a Email::Abstract object wrapping the
+message.
+
+If the message is given as a string, it will be used to construct an object,
+which will then be wrapped.
+
+=head2 get_header
+
+  my $header  = $email->get_header($header_name);
+  my $header  = Email::Abstract->get_header($message, $header_name);
+
+  my @headers = $email->get_header($header_name);
+  my @headers = Email::Abstract->get_header($message, $header_name);
 
 This returns the value or list of values of the given header.
 
-=head2 set_header($obj, $header, @lines)
+=head2 set_header
+
+  $email->set_header($header => @lines);
+  Email::Abstract->set_header($message, $header => @lines);
 
 This sets the C<$header> header to the given one or more values.
 
-=head2 get_body($obj)
+=head2 get_body
+
+  my $body = $email->get_body;
+
+  my $body = Email::Abstract->get_body($message);
 
 This returns the body as a string.
 
-=head2 set_body($obj, $string)
+=head2 set_body
+
+  $email->set_body($string);
+
+  Email::Abstract->set_body($message, $string);
 
 This changes the body of the email to the given string.
 
-=head2 as_string($obj)
+=head2 as_string
+
+  my $string = $email->as_string;
+
+  my $string = Email::Abstract->as_string($message);
 
 This returns the whole email as a string.
 
+=head2 cast
+
+  my $mime_entity = $email->cast('MIME::Entity');
+  my $mime_entity = Email::Abstract->cast($message, 'MIME::Entity');
+
+This method will convert a message from one message class to another.  It will
+throw an exception if no adapter for the target class is known, or if the
+adapter does not provide a C<construct> method.
+
+=head2 object
+
+  my $message = $email->object;
+
+This method returns the message object wrapped by Email::Abstract.  If called
+as a class method, it returns false.
+
+Note that, because strings are converted to message objects before wrapping,
+this method will return an object when the Email::Abstract was constructed from
+a string. 
+
+=head1 PERL EMAIL PROJECT
+
+This module is maintained by the Perl Email Project
+
+  L<http://emailproject.perl.org/wiki/Email::Abstract>
+
 =head1 AUTHOR
 
 Casey West, <F<casey at geeknest.com>>
 
 Simon Cozens, <F<simon at cpan.org>>
+
+Ricardo SIGNES, <F<rjbs at cpan.org>>
 
 =head1 COPYRIGHT AND LICENSE
 
@@ -127,8 +234,4 @@
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself. 
 
-=head1 SEE ALSO
-
-http://pep.kwiki.org
-
 =cut

Modified: packages/libemail-abstract-perl/branches/upstream/current/lib/Email/Abstract/EmailSimple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/lib/Email/Abstract/EmailSimple.pm?rev=3346&op=diff
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/lib/Email/Abstract/EmailSimple.pm (original)
+++ packages/libemail-abstract-perl/branches/upstream/current/lib/Email/Abstract/EmailSimple.pm Thu Jul 27 20:36:22 2006
@@ -7,12 +7,13 @@
     my ($class, $rfc822) = @_;
     Email::Simple->new($rfc822);
 }
+
 sub get_header { 
     my ($class, $obj, $header) = @_; 
     $obj->header($header); 
 }
 
-sub get_body   { 
+sub get_body { 
     my ($class, $obj) = @_; 
     $obj->body();
 }

Added: packages/libemail-abstract-perl/branches/upstream/current/t/abs-object.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/t/abs-object.t?rev=3346&op=file
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/t/abs-object.t (added)
+++ packages/libemail-abstract-perl/branches/upstream/current/t/abs-object.t Thu Jul 27 20:36:22 2006
@@ -1,0 +1,156 @@
+
+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 at 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 at rdg.opengroup.org>
+Message-Id: <1021113100650.ZM12997 at skye.rdg.opengroup.org>
+In-Reply-To: Joanna Farley's message as of Nov 13,  9:56am.
+References: <200211120937.JAA28130 at xoneweb.opengroup.org> 
+	<1021112125524.ZM7503 at skye.rdg.opengroup.org> 
+	<3DD221BB.13116D47 at sun.com>
+X-Mailer: Z-Mail (5.0.0 30July97)
+To: austin-group-l at opengroup.org
+Subject: Re: Defect in XBD lround
+MIME-Version: 1.0
+Resent-Message-ID: <gZGK1B.A.uY.iUi09 at mailman>
+Resent-To: austin-group-l at opengroup.org
+Resent-From: austin-group-l at opengroup.org
+X-Mailing-List: austin-group-l:archive/latest/4823
+X-Loop: austin-group-l at opengroup.org
+Precedence: list
+X-Spam-Status: No, hits=-1.6 required=5.0
+Resent-Sender: austin-group-l-request at 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 at fujitsu-siemens.com wrote:
+> > >       Defect report from : Erwin Unruh , Fujitsu Siemens Computers
+> > >
+> > > (Please direct followup comments direct to austin-group-l at 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 at fujitsu-siemens.com
+> > 
+
+-----
+Andrew Josey                                The Open Group  
+Austin Group Chair                          Apex Plaza,Forbury Road,
+Email: a.josey at opengroup.org                Reading,Berks.RG1 1AX,England
+Tel:   +44 118 9508311 ext 2250             Fax: +44 118 9500110

Added: packages/libemail-abstract-perl/branches/upstream/current/t/classy.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/t/classy.t?rev=3346&op=file
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/t/classy.t (added)
+++ packages/libemail-abstract-perl/branches/upstream/current/t/classy.t Thu Jul 27 20:36:22 2006
@@ -1,0 +1,138 @@
+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 at 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 at rdg.opengroup.org>
+Message-Id: <1021113100650.ZM12997 at skye.rdg.opengroup.org>
+In-Reply-To: Joanna Farley's message as of Nov 13,  9:56am.
+References: <200211120937.JAA28130 at xoneweb.opengroup.org> 
+	<1021112125524.ZM7503 at skye.rdg.opengroup.org> 
+	<3DD221BB.13116D47 at sun.com>
+X-Mailer: Z-Mail (5.0.0 30July97)
+To: austin-group-l at opengroup.org
+Subject: Re: Defect in XBD lround
+MIME-Version: 1.0
+Resent-Message-ID: <gZGK1B.A.uY.iUi09 at mailman>
+Resent-To: austin-group-l at opengroup.org
+Resent-From: austin-group-l at opengroup.org
+X-Mailing-List: austin-group-l:archive/latest/4823
+X-Loop: austin-group-l at opengroup.org
+Precedence: list
+X-Spam-Status: No, hits=-1.6 required=5.0
+Resent-Sender: austin-group-l-request at 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 at fujitsu-siemens.com wrote:
+> > >       Defect report from : Erwin Unruh , Fujitsu Siemens Computers
+> > >
+> > > (Please direct followup comments direct to austin-group-l at 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 at fujitsu-siemens.com
+> > 
+
+-----
+Andrew Josey                                The Open Group  
+Austin Group Chair                          Apex Plaza,Forbury Road,
+Email: a.josey at opengroup.org                Reading,Berks.RG1 1AX,England
+Tel:   +44 118 9508311 ext 2250             Fax: +44 118 9500110

Added: packages/libemail-abstract-perl/branches/upstream/current/t/lib/Test/EmailAbstract.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/t/lib/Test/EmailAbstract.pm?rev=3346&op=file
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/t/lib/Test/EmailAbstract.pm (added)
+++ packages/libemail-abstract-perl/branches/upstream/current/t/lib/Test/EmailAbstract.pm Thu Jul 27 20:36:22 2006
@@ -1,0 +1,73 @@
+use strict;
+use warnings;
+
+package Test::EmailAbstract;
+use Test::More;
+
+sub _call {
+  my ($wrapped, $object, $method, @args) = @_;
+
+  if ($wrapped) {
+    return $object->$method(@args);
+  } else {
+    return Email::Abstract->$method($object, @args);
+  }
+}
+
+# This is responsible for running 5 tests.
+sub _test_object {
+    my ($wrapped, $class, $obj, $readonly) = @_;
+
+    like(
+      _call($wrapped, $obj, 'get_header', 'Subject'),
+      qr/Re: Defect in XBD lround/,
+      "Subject OK with $class"
+    );
+
+    like(
+      _call($wrapped, $obj, 'get_body'),
+      qr/Fred Tydeman/,
+      "Body 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, @_); }
+
+
+1;

Modified: packages/libemail-abstract-perl/branches/upstream/current/t/subclass.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-abstract-perl/branches/upstream/current/t/subclass.t?rev=3346&op=diff
==============================================================================
--- packages/libemail-abstract-perl/branches/upstream/current/t/subclass.t (original)
+++ packages/libemail-abstract-perl/branches/upstream/current/t/subclass.t Thu Jul 27 20:36:22 2006
@@ -1,13 +1,37 @@
-package MyMail;
-use base "Email::Simple";
-1;
+{
+  package MyMail;
+  use base "Email::Simple";
+}
 
 package main;
-use Test::More tests => 1;
+use Test::More tests => 4;
 use Email::Abstract;
 my $message = do { local $/; <DATA>; };
 my $x = MyMail->new($message);
-like (Email::Abstract->as_string($x), qr/Farley's/, "Round trip with subclass");
+like(Email::Abstract->as_string($x), qr/Farley's/, "Round trip with subclass");
+
+my $y = Email::Abstract->new($x);
+isa_ok($y, 'Email::Abstract');
+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 };
+  { # should always adapt as if it's MIME::Entity, the nearest class
+    package MultiHopMail;
+    require MIME::Entity;
+    @MultiHopMail::ISA = qw(MIME::Entity);
+  }
+
+  # We're digging deep into the guts, here.  Wear gloves.
+  # In previous versions, this could return Email::Abstract::MailInternet,
+  # because inheritance order was not respected.
+  is(
+    Email::Abstract->__class_for('MultiHopMail'),
+    'Email::Abstract::MIMEEntity',
+    "we get the nearest path in inheritance order",
+  );
+}
 
 __DATA__
 Received: from mailman.opengroup.org ([192.153.166.9])




More information about the Pkg-perl-cvs-commits mailing list