summaryrefslogtreecommitdiff
path: root/lib/Test/t/onfail.t
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Test/t/onfail.t')
-rw-r--r--lib/Test/t/onfail.t31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/Test/t/onfail.t b/lib/Test/t/onfail.t
new file mode 100644
index 0000000000..dce4373401
--- /dev/null
+++ b/lib/Test/t/onfail.t
@@ -0,0 +1,31 @@
+# -*-perl-*-
+
+use strict;
+use Test qw($ntest plan ok $TESTOUT);
+use vars qw($mycnt);
+
+BEGIN { plan test => 6, onfail => \&myfail }
+
+$mycnt = 0;
+
+my $why = "zero != one";
+# sneak in a test that Test::Harness wont see
+open J, ">junk";
+$TESTOUT = *J{IO};
+ok(0, 1, $why);
+$TESTOUT = *STDOUT{IO};
+close J;
+unlink "junk";
+$ntest = 1;
+
+sub myfail {
+ my ($f) = @_;
+ ok(@$f, 1);
+
+ my $t = $$f[0];
+ ok($$t{diagnostic}, $why);
+ ok($$t{'package'}, 'main');
+ ok($$t{repetition}, 1);
+ ok($$t{result}, 0);
+ ok($$t{expected}, 1);
+}