Upgrade to Test::Simple 0.53
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / diag.t
index 3afdc17..0b2a51f 100644 (file)
@@ -3,7 +3,10 @@
 BEGIN {
     if( $ENV{PERL_CORE} ) {
         chdir 't';
-        @INC = '../lib';
+        @INC = ('../lib', 'lib');
+    }
+    else {
+        unshift @INC, 't/lib';
     }
 }
 
@@ -21,17 +24,16 @@ BEGIN {
 
 use strict;
 
-use Test::More tests => 7;
+use Test::More tests => 5;
 
 my $Test = Test::More->builder;
 
 # now make a filehandle where we can send data
-my $output;
-tie *FAKEOUT, 'FakeOut', \$output;
+use TieOut;
+my $output = tie *FAKEOUT, 'TieOut';
 
 # force diagnostic output to a filehandle, glad I added this to
 # Test::Builder :)
-my @lines;
 my $ret;
 {
     local $TODO = 1;
@@ -39,35 +41,32 @@ my $ret;
 
     diag("a single line");
 
-    push @lines, $output;
-    $output = '';
-
     $ret = diag("multiple\n", "lines");
-    push @lines, split(/\n/, $output);
 }
 
-is( @lines, 3,              'diag() should send messages to its filehandle' );
-like( $lines[0], '/^#\s+/', '    should add comment mark to all lines' );
-is( $lines[0], "# a single line\n",   '    should send exact message' );
-is( $output, "# multiple\n# lines\n", '    should append multi messages');
+is( $output->read, <<'DIAG',   'diag() with todo_output set' );
+# a single line
+# multiple
+# lines
+DIAG
+
 ok( !$ret, 'diag returns false' );
 
 {
     $Test->failure_output(\*FAKEOUT);
-    $output = '';
     $ret = diag("# foo");
 }
 $Test->failure_output(\*STDERR);
-is( $output, "# # foo\n",   "diag() adds a # even if there's one already" );
+is( $output->read, "# # foo\n", "diag() adds # even if there's one already" );
 ok( !$ret,  'diag returns false' );
 
-package FakeOut;
-
-sub TIEHANDLE {
-       bless( $_[1], $_[0] );
-}
 
-sub PRINT {
-       my $self = shift;
-       $$self .= join('', @_);
+# [rt.cpan.org 8392]
+{
+    $Test->failure_output(\*FAKEOUT);
+    diag(qw(one two));
 }
+$Test->failure_output(\*STDERR);
+is( $output->read, <<'DIAG' );
+# onetwo
+DIAG