Show quoted text> As far as the test goes: I think the test could be simplified and more
> robust if it didn't use
> utf8 functions since it varies greatly between perl versions and
> usually does not do what you
> think it is doing.
`git show HEAD` attached
before 'use bytes' fix:
[dmuey@multivac IPC-Run (RT14078)]$ prove -wlv t/utf8.t
t/utf8....1..4
ok 1 - Encode::decode_utf8() does not lvalue our bytes string var
ok 2 - byte string and unicode string same string as far as humans are concerned
ok 3 - run() w/ byte string
# Failed test 'run() w/ unicode string'
not ok 4 - run() w/ unicode string
# at t/utf8.t line 26.
Wide character in print at /System/Library/Perl/5.10.0/Test/Builder.pm line 1266.
# got: 'string�'
# expected: 'string…'
# Looks like you failed 1 test of 4.
dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 4
Failed 1/4 tests, 75.00% okay
Failed Test Stat Wstat Total Fail List of Failed
-------------------------------------------------------------------------------
t/utf8.t 1 256 4 1 4
Failed 1/1 test scripts. 1/4 subtests failed.
Files=1, Tests=4, 0 wallclock secs ( 0.05 cusr + 0.01 csys = 0.06 CPU)
Failed 1/1 test programs. 1/4 subtests failed.
after 'use bytes' fix:
[dmuey@multivac IPC-Run (RT14078)]$ prove -wlv t/utf8.t
t/utf8....1..4
ok 1 - Encode::decode_utf8() does not lvalue our bytes string var
ok 2 - byte string and unicode string same string as far as humans are concerned
ok 3 - run() w/ byte string
ok 4 - run() w/ unicode string
ok
All tests successful.
Files=1, Tests=4, 0 wallclock secs ( 0.05 cusr + 0.01 csys = 0.06 CPU)
commit 4b2111afd1beb4121d3c2a4e7b85586373cffc65
Author: Daniel Muey <dmuey@multivac.local>
Date: Wed Jun 29 10:26:48 2011 -0500
simplify/robustify tests regarding utf-8 (via byte strings and unicode strings)
diff --git a/t/utf8.t b/t/utf8.t
index 75b5a59..9b0d668 100644
--- a/t/utf8.t
+++ b/t/utf8.t
@@ -1,30 +1,26 @@
-use Test;
-BEGIN { plan tests => 3 };
+use Test::More tests => 4;
-use IPC::Run qw(run);
use strict;
-require utf8;
-use Encode;
+use warnings;
+use IPC::Run ();
+use Encode ();
-my $utf_in = do { use utf8; "râ©sumâ©..." };
-my $bytes_in = pack("C*", unpack("C*", $utf_in));
+##### data setup and sanity check
+my $unicode_string = "string\x{2026}";
+my $byte_string = "string\xE2\x80\xA6";
-# $utf_in and $bytes_in now contain the same bytes in Perl's memory
-# (as per the pack/unpack above), and differ only by the UTF-8 flag.
-# Let's make sure about the latter ($utf_in should have the flag set,
-# and $bytes_in should have it cleared):
-skip ( (! utf8->can("is_utf8") ?
- "Skipped - Perl 5.8 required for this sub-test" : undef),
- sub { utf8::is_utf8($utf_in) && ! utf8::is_utf8($bytes_in) });
+## make sure what we're doing doesn't incidentally change the data and that the data is what we expect
+my $x = Encode::decode_utf8($byte_string);
+isnt( $x, $byte_string, "Encode::decode_utf8() does not lvalue our bytes string var" );
+is( $unicode_string, Encode::decode_utf8($byte_string), "byte string and unicode string same string as far as humans are concerned" );
+##### actual IPC::Run::run() tests
my $bytes_out;
-# Test using the byte string: "cat" should be transparent.
-run ["cat"], \$bytes_in, \$bytes_out;
-ok($bytes_out, $bytes_in,
- "non-transparent IPC::Run (or runaway cat ?)");
+## Test using the byte string: "cat" should be transparent.
+IPC::Run::run( ["cat"], \$byte_string, \$bytes_out );
+is( $bytes_out, $byte_string, "run() w/ byte string" );
-# Same test using the UTF-8 string
-run ["cat"], \$utf_in, \$bytes_out;
-ok(decode_utf8($bytes_out), $utf_in,
- "non-transparent IPC::Run when using UTF-8");
+## Same test using the Unicode string
+IPC::Run::run( ["cat"], \$unicode_string, \$bytes_out );
+is( Encode::decode_utf8($bytes_out), $unicode_string, "run() w/ unicode string" );