Upgrade to Test-Simple-0.82.
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / fail_one.t
CommitLineData
30e302f8 1#!/usr/bin/perl -w
ccbd73a4 2# $Id: /mirror/googlecode/test-more/t/fail_one.t 57943 2008-08-18T02:09:22.275428Z brooklyn.kid51 $
30e302f8 3
4BEGIN {
5 if( $ENV{PERL_CORE} ) {
6 chdir 't';
7 @INC = ('../lib', 'lib');
8 }
9 else {
10 unshift @INC, 't/lib';
11 }
12}
13
14use strict;
15
16require Test::Simple::Catch;
17my($out, $err) = Test::Simple::Catch::caught();
18local $ENV{HARNESS_ACTIVE} = 0;
19
20
21# Can't use Test.pm, that's a 5.005 thing.
22package My::Test;
23
24print "1..2\n";
25
26my $test_num = 1;
27# Utility testing functions.
28sub ok ($;$) {
29 my($test, $name) = @_;
30 my $ok = '';
31 $ok .= "not " unless $test;
32 $ok .= "ok $test_num";
33 $ok .= " - $name" if defined $name;
34 $ok .= "\n";
35 print $ok;
36 $test_num++;
37
38 return $test ? 1 : 0;
39}
40
41
42package main;
43
44require Test::Simple;
45Test::Simple->import(tests => 1);
46
47#line 45
48ok(0);
49
50END {
51 My::Test::ok($$out eq <<OUT);
521..1
53not ok 1
54OUT
55
7483b81c 56 My::Test::ok($$err eq <<ERR) || print $$err;
b7f9bbeb 57# Failed test at $0 line 45.
30e302f8 58# Looks like you failed 1 test of 1.
59ERR
60
61 # Prevent Test::Simple from existing with non-zero
62 exit 0;
63}