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
CommitLineData
30e302f8 1#!/usr/bin/perl -w
2
3# Test Test::Builder->reset;
4
5BEGIN {
6 if( $ENV{PERL_CORE} ) {
7 chdir 't';
8 @INC = ('../lib', 'lib');
9 }
10 else {
11 unshift @INC, 't/lib';
12 }
13}
14chdir 't';
15
16
17use Test::Builder;
18my $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
25my $tmpfile = 'foo.tmp';
26
27$tb->output($tmpfile);
28$tb->failure_output($tmpfile);
29$tb->todo_output($tmpfile);
4e7ee149 30END { 1 while unlink $tmpfile }
30e302f8 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
47my $test_num = 2; # since we already printed 1
48# Utility testing functions.
49sub 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
63ok( !defined $tb->exported_to, 'exported_to' );
64ok( $tb->expected_tests == 0, 'expected_tests' );
65ok( $tb->level == 1, 'level' );
66ok( $tb->use_numbers == 1, 'use_numbers' );
67ok( $tb->no_header == 0, 'no_header' );
68ok( $tb->no_ending == 0, 'no_ending' );
69ok( fileno $tb->output == fileno *Test::Builder::TESTOUT,
70 'output' );
71ok( fileno $tb->failure_output == fileno *Test::Builder::TESTERR,
72 'failure_output' );
73ok( fileno $tb->todo_output == fileno *Test::Builder::TESTOUT,
74 'todo_output' );
75ok( $tb->current_test == 0, 'current_test' );
76ok( $tb->summary == 0, 'summary' );
77ok( $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');