[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-831-gd69371b
? sunnavy
sunnavy at bestpractical.com
Mon Sep 20 20:47:25 EDT 2010
The branch, 3.9-trunk has been updated
via d69371b60d738067cafe37bf19eb4b1c00bf6a56 (commit)
from c65a66522076ad5ee344fee2650652ce75a11047 (commit)
Summary of changes:
t/mail/wrong_mime_charset.t | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
- Log -----------------------------------------------------------------
commit d69371b60d738067cafe37bf19eb4b1c00bf6a56
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Sep 21 08:50:04 2010 +0800
rescue tests for the weird and different warning behavior in different perl versions
diff --git a/t/mail/wrong_mime_charset.t b/t/mail/wrong_mime_charset.t
index ca94b16..a83a4fb 100644
--- a/t/mail/wrong_mime_charset.t
+++ b/t/mail/wrong_mime_charset.t
@@ -1,8 +1,7 @@
#!/usr/bin/perl
use strict;
use warnings;
-use RT::Test nodb => 1, tests => 4;
-use Test::Warn;
+use RT::Test nodb => 1, tests => 6;
use_ok('RT::I18N');
use utf8;
@@ -13,15 +12,32 @@ my $mime = MIME::Entity->build(
Subject => $encoded_string,
Data => [$encoded_string],
);
-
+
# set the wrong charset mime in purpose
$mime->head->mime_attr( "Content-Type.charset" => 'utf8' );
-warnings_are {
- RT::I18N::SetMIMEEntityToEncoding( $mime, 'iso-8859-1' );
-}
-[ ('Encoding error: "\x{fffd}" does not map to iso-8859-1') x 2, ],
-" We can't encode something into the wrong encoding without Encode complaining";
+my @warnings;
+local $SIG{__WARN__} = sub {
+ push @warnings, "@_";
+};
+
+RT::I18N::SetMIMEEntityToEncoding( $mime, 'iso-8859-1' );
+
+# this is a weird behavior for different perl versions, 5.12 warns twice,
+# which is correct since we do the encoding thing twice, for Subject
+# and Data respectively.
+# but 5.8 and 5.10 warns only once.
+ok( @warnings == 1 || @warnings == 2, "1 or 2 warnings are ok" );
+ok(
+ @warnings == 1 || $warnings[1] == $warnings[0],
+ 'if there are 2 warnings, they should be same'
+);
+
+like(
+ $warnings[0],
+ qr/\QEncoding error: "\x{fffd}" does not map to iso-8859-1/,
+"We can't encode something into the wrong encoding without Encode complaining"
+);
my $subject = decode( 'iso-8859-1', $mime->head->get('Subject') );
chomp $subject;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list