Clear up test based on line number differences between the core and the
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / reset.t
1 #!/usr/bin/perl -w
2
3 # Test Test::Builder->reset;
4
5 BEGIN {
6     if( $ENV{PERL_CORE} ) {
7         chdir 't';
8         @INC = ('../lib', 'lib');
9     }
10     else {
11         unshift @INC, 't/lib';
12     }
13 }
14 chdir 't';
15
16
17 use Test::Builder;
18 my $tb = Test::Builder->new;
19 $tb->plan(tests => 14);
20 $tb->level(0);
21
22 # Alter the state of Test::Builder as much as possible.
23 $tb->ok(1, "Running a test to alter TB's state");
24
25 my $tmpfile = 'foo.tmp';
26
27 $tb->output($tmpfile);
28 $tb->failure_output($tmpfile);
29 $tb->todo_output($tmpfile);
30 END { 1 while unlink $tmpfile }
31
32 # This won't print since we just sent output off to oblivion.
33 $tb->ok(0, "And a failure for fun");
34
35 $Test::Builder::Level = 3;
36
37 $tb->exported_to('Foofer');
38
39 $tb->use_numbers(0);
40 $tb->no_header(1);
41 $tb->no_ending(1);
42
43
44 # Now reset it.
45 $tb->reset;
46
47 my $test_num = 2;   # since we already printed 1
48 # Utility testing functions.
49 sub ok ($;$) {
50     my($test, $name) = @_;
51     my $ok = '';
52     $ok .= "not " unless $test;
53     $ok .= "ok $test_num";
54     $ok .= " - $name" if defined $name;
55     $ok .= "\n";
56     print $ok;
57     $test_num++;
58
59     return $test;
60 }
61
62
63 ok( !defined $tb->exported_to,          'exported_to' );
64 ok( $tb->expected_tests == 0,           'expected_tests' );
65 ok( $tb->level          == 1,           'level' );
66 ok( $tb->use_numbers    == 1,           'use_numbers' );
67 ok( $tb->no_header      == 0,           'no_header' );
68 ok( $tb->no_ending      == 0,           'no_ending' );
69 ok( fileno $tb->output         == fileno *Test::Builder::TESTOUT,    
70                                         'output' );
71 ok( fileno $tb->failure_output == fileno *Test::Builder::TESTERR,    
72                                         'failure_output' );
73 ok( fileno $tb->todo_output    == fileno *Test::Builder::TESTOUT,
74                                         'todo_output' );
75 ok( $tb->current_test   == 0,           'current_test' );
76 ok( $tb->summary        == 0,           'summary' );
77 ok( $tb->details        == 0,           'details' );
78
79 $tb->no_ending(1);
80 $tb->no_header(1);
81 $tb->plan(tests => 14);
82 $tb->current_test(13);
83 $tb->level(0);
84 $tb->ok(1, 'final test to make sure output was reset');