1#!/usr/bin/perl -w 2 3BEGIN { 4 if( $ENV{PERL_CORE} ) { 5 chdir 't'; 6 @INC = ('../lib', 'lib'); 7 } 8 else { 9 unshift @INC, 't/lib'; 10 } 11} 12 13use Test::More; 14use Test::Builder; 15my $Test = Test::Builder->new; 16 17$Test->plan( tests => 8 ); 18$Test->level(0); 19 20my @Expected_Details; 21 22$Test->is_num( scalar $Test->summary(), 0, 'no tests yet, no summary' ); 23push @Expected_Details, { 'ok' => 1, 24 actual_ok => 1, 25 name => 'no tests yet, no summary', 26 type => '', 27 reason => '' 28 }; 29 30# Inline TODO tests will confuse pre 1.20 Test::Harness, so we 31# should just avoid the problem and not print it out. 32my $out_fh = $Test->output; 33my $start_test = $Test->current_test + 1; 34require TieOut; 35tie *FH, 'TieOut'; 36$Test->output(\*FH); 37 38SKIP: { 39 $Test->skip( 'just testing skip' ); 40} 41push @Expected_Details, { 'ok' => 1, 42 actual_ok => 1, 43 name => '', 44 type => 'skip', 45 reason => 'just testing skip', 46 }; 47 48TODO: { 49 local $TODO = 'i need a todo'; 50 $Test->ok( 0, 'a test to todo!' ); 51 52 push @Expected_Details, { 'ok' => 1, 53 actual_ok => 0, 54 name => 'a test to todo!', 55 type => 'todo', 56 reason => 'i need a todo', 57 }; 58 59 $Test->todo_skip( 'i need both' ); 60} 61push @Expected_Details, { 'ok' => 1, 62 actual_ok => 0, 63 name => '', 64 type => 'todo_skip', 65 reason => 'i need both' 66 }; 67 68for ($start_test..$Test->current_test) { print "ok $_\n" } 69$Test->output($out_fh); 70 71$Test->is_num( scalar $Test->summary(), 4, 'summary' ); 72push @Expected_Details, { 'ok' => 1, 73 actual_ok => 1, 74 name => 'summary', 75 type => '', 76 reason => '', 77 }; 78 79$Test->current_test(6); 80print "ok 6 - current_test incremented\n"; 81push @Expected_Details, { 'ok' => 1, 82 actual_ok => undef, 83 name => undef, 84 type => 'unknown', 85 reason => 'incrementing test number', 86 }; 87 88my @details = $Test->details(); 89$Test->is_num( scalar @details, 6, 90 'details() should return a list of all test details'); 91 92$Test->level(1); 93is_deeply( \@details, \@Expected_Details ); 94