1#!/usr/bin/perl -w 2# HARNESS-NO-STREAM 3 4# Test Test::Builder->reset; 5 6BEGIN { 7 if( $ENV{PERL_CORE} ) { 8 chdir 't'; 9 @INC = ('../lib', 'lib'); 10 } 11 else { 12 unshift @INC, 't/lib'; 13 } 14} 15chdir 't'; 16 17 18use Test::Builder; 19my $Test = Test::Builder->new; 20my $tb = Test::Builder->create; 21 22# We'll need this later to know the outputs were reset 23my %Original_Output; 24$Original_Output{$_} = $tb->$_ for qw(output failure_output todo_output); 25 26# Alter the state of Test::Builder as much as possible. 27my $output = ''; 28$tb->output(\$output); 29$tb->failure_output(\$output); 30$tb->todo_output(\$output); 31 32$tb->plan(tests => 14); 33$tb->level(0); 34 35$tb->ok(1, "Running a test to alter TB's state"); 36 37# This won't print since we just sent output off to oblivion. 38$tb->ok(0, "And a failure for fun"); 39 40$Test::Builder::Level = 3; 41 42$tb->exported_to('Foofer'); 43 44$tb->use_numbers(0); 45$tb->no_header(1); 46$tb->no_ending(1); 47 48$tb->done_testing; # make sure done_testing gets reset 49 50# Now reset it. 51$tb->reset; 52 53 54# Test the state of the reset builder 55$Test->ok( !defined $tb->exported_to, 'exported_to' ); 56$Test->is_eq( $tb->expected_tests, 0, 'expected_tests' ); 57$Test->is_eq( $tb->level, 1, 'level' ); 58$Test->is_eq( $tb->use_numbers, 1, 'use_numbers' ); 59$Test->is_eq( $tb->no_header, 0, 'no_header' ); 60$Test->is_eq( $tb->no_ending, 0, 'no_ending' ); 61$Test->is_eq( $tb->current_test, 0, 'current_test' ); 62$Test->is_eq( scalar $tb->summary, 0, 'summary' ); 63$Test->is_eq( scalar $tb->details, 0, 'details' ); 64$Test->is_eq( fileno $tb->output, 65 fileno $Original_Output{output}, 'output' ); 66$Test->is_eq( fileno $tb->failure_output, 67 fileno $Original_Output{failure_output}, 'failure_output' ); 68$Test->is_eq( fileno $tb->todo_output, 69 fileno $Original_Output{todo_output}, 'todo_output' ); 70 71# The reset Test::Builder will take over from here. 72$Test->no_ending(1); 73 74 75$tb->current_test($Test->current_test); 76$tb->level(0); 77$tb->ok(1, 'final test to make sure output was reset'); 78 79$tb->done_testing; 80