xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Test/t/mix.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, ">mix";
10*0Sstevel@tonic-gate$TESTOUT = *F{IO};
11*0Sstevel@tonic-gate$TESTERR = *F{IO};
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gateplan tests => 4, todo => [2,3];
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gate# line 15
16*0Sstevel@tonic-gateok(sub {
17*0Sstevel@tonic-gate       my $r = 0;
18*0Sstevel@tonic-gate       for (my $x=0; $x < 10; $x++) {
19*0Sstevel@tonic-gate	   $r += $x*($r+1);
20*0Sstevel@tonic-gate       }
21*0Sstevel@tonic-gate       $r
22*0Sstevel@tonic-gate   }, 3628799);
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gateok(0);
25*0Sstevel@tonic-gateok(1);
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gateskip(1,0);
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gateclose F;
30*0Sstevel@tonic-gate$TESTOUT = *STDOUT{IO};
31*0Sstevel@tonic-gate$TESTERR = *STDERR{IO};
32*0Sstevel@tonic-gate$ntest = 1;
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gateopen F, "mix";
35*0Sstevel@tonic-gatemy $out = join '', <F>;
36*0Sstevel@tonic-gateclose F;
37*0Sstevel@tonic-gateunlink "mix";
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gatemy $expect = <<"EXPECT";
40*0Sstevel@tonic-gate1..4 todo 2 3;
41*0Sstevel@tonic-gateok 1
42*0Sstevel@tonic-gatenot ok 2
43*0Sstevel@tonic-gate# Failed test 2 in $0 at line 23 *TODO*
44*0Sstevel@tonic-gateok 3 # ($0 at line 24 TODO?!)
45*0Sstevel@tonic-gateok 4 # skip
46*0Sstevel@tonic-gateEXPECT
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gatesub commentless {
50*0Sstevel@tonic-gate  my $in = $_[0];
51*0Sstevel@tonic-gate  $in =~ s/^#[^\n]*\n//mg;
52*0Sstevel@tonic-gate  $in =~ s/\n#[^\n]*$//mg;
53*0Sstevel@tonic-gate  return $in;
54*0Sstevel@tonic-gate}
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gateprint "1..1\n";
58*0Sstevel@tonic-gateok( commentless($out), commentless($expect) );
59