Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify the diag() test

  • Loading branch information...
commit fc9eb4b26de7350ea04a08e91612c06c0c586064 1 parent 634c327
@schwern schwern authored
Showing with 23 additions and 21 deletions.
  1. +23 −21 t/diag.t
View
44 t/diag.t
@@ -27,47 +27,49 @@ use strict;
use Test::More tests => 5;
-my $Test = Test::More->builder;
+my $test = Test::Builder->create;
# now make a filehandle where we can send data
use TieOut;
my $output = tie *FAKEOUT, 'TieOut';
-# force diagnostic output to a filehandle, glad I added this to
-# Test::Builder :)
-my $ret;
-{
- local $TODO = 1;
- $Test->todo_output(\*FAKEOUT);
-
- diag("a single line");
- $ret = diag("multiple\n", "lines");
-}
+# Test diag() goes to todo_output() in a todo test.
+{
+ $test->todo_start();
+ $test->todo_output(\*FAKEOUT);
-is( $output->read, <<'DIAG', 'diag() with todo_output set' );
+ $test->diag("a single line");
+ is( $output->read, <<'DIAG', 'diag() with todo_output set' );
# a single line
+DIAG
+
+ my $ret = $test->diag("multiple\n", "lines");
+ is( $output->read, <<'DIAG', ' multi line' );
# multiple
# lines
DIAG
+ ok( !$ret, 'diag returns false' );
+
+ $test->todo_end();
+}
-ok( !$ret, 'diag returns false' );
+$test->reset_outputs();
+
+# Test diagnostic formatting
+$test->failure_output(\*FAKEOUT);
{
- $Test->failure_output(\*FAKEOUT);
- $ret = diag("# foo");
+ $test->diag("# foo");
+
+ is( $output->read, "# # foo\n", "diag() adds # even if there's one already" );
}
-$Test->failure_output(\*STDERR);
-is( $output->read, "# # foo\n", "diag() adds # even if there's one already" );
-ok( !$ret, 'diag returns false' );
# [rt.cpan.org 8392]
{
- $Test->failure_output(\*FAKEOUT);
- diag(qw(one two));
+ $test->diag(qw(one two));
}
-$Test->failure_output(\*STDERR);
is( $output->read, <<'DIAG' );
# onetwo
DIAG
Please sign in to comment.
Something went wrong with that request. Please try again.