xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Test/t/todo.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate# -*-perl-*-
2*0Sstevel@tonic-gateuse strict;
3*0Sstevel@tonic-gateuse Test qw(:DEFAULT $TESTOUT $TESTERR $ntest);
4*0Sstevel@tonic-gate
5*0Sstevel@tonic-gate### This test is crafted in such a way as to prevent Test::Harness from
6*0Sstevel@tonic-gate### seeing the todo tests, otherwise you get people sending in bug reports
7*0Sstevel@tonic-gate### about Test.pm having "UNEXPECTEDLY SUCCEEDED" tests.
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gateopen F, ">todo";
10*0Sstevel@tonic-gate$TESTOUT = *F{IO};
11*0Sstevel@tonic-gate$TESTERR = *F{IO};
12*0Sstevel@tonic-gatemy $tests = 5;
13*0Sstevel@tonic-gateplan tests => $tests, todo => [2..$tests];
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gate
16*0Sstevel@tonic-gate# tests to go to the output file
17*0Sstevel@tonic-gateok(1);
18*0Sstevel@tonic-gateok(1);
19*0Sstevel@tonic-gateok(0,1);
20*0Sstevel@tonic-gateok(0,1,"need more tuits");
21*0Sstevel@tonic-gateok(1,1);
22*0Sstevel@tonic-gate
23*0Sstevel@tonic-gateclose F;
24*0Sstevel@tonic-gate$TESTOUT = *STDOUT{IO};
25*0Sstevel@tonic-gate$TESTERR = *STDERR{IO};
26*0Sstevel@tonic-gate$ntest = 1;
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gateopen F, "todo";
29*0Sstevel@tonic-gatemy $out = join '', <F>;
30*0Sstevel@tonic-gateclose F;
31*0Sstevel@tonic-gateunlink "todo";
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gatemy $expect = <<"EXPECT";
34*0Sstevel@tonic-gate1..5 todo 2 3 4 5;
35*0Sstevel@tonic-gateok 1
36*0Sstevel@tonic-gateok 2 # ($0 at line 18 TODO?!)
37*0Sstevel@tonic-gatenot ok 3
38*0Sstevel@tonic-gate# Test 3 got: '0' ($0 at line 19 *TODO*)
39*0Sstevel@tonic-gate#   Expected: '1'
40*0Sstevel@tonic-gatenot ok 4
41*0Sstevel@tonic-gate# Test 4 got: '0' ($0 at line 20 *TODO*)
42*0Sstevel@tonic-gate#   Expected: '1' (need more tuits)
43*0Sstevel@tonic-gateok 5 # ($0 at line 21 TODO?!)
44*0Sstevel@tonic-gateEXPECT
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gate
47*0Sstevel@tonic-gatesub commentless {
48*0Sstevel@tonic-gate  my $in = $_[0];
49*0Sstevel@tonic-gate  $in =~ s/^#[^\n]*\n//mg;
50*0Sstevel@tonic-gate  $in =~ s/\n#[^\n]*$//mg;
51*0Sstevel@tonic-gate  return $in;
52*0Sstevel@tonic-gate}
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gateprint "1..1\n";
55*0Sstevel@tonic-gateok( commentless($out), commentless($expect) );
56