Move Test::Simple from lib to ext.
[p5sagit/p5-mst-13.2.git] / ext / Test-Simple / t / Builder / details.t
CommitLineData
60ffb308 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
0257f296 17$Test->plan( tests => 9 );
60ffb308 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.
60ffb308 32my $start_test = $Test->current_test + 1;
3e887aae 33
34my $output = '';
35$Test->output(\$output);
36$Test->todo_output(\$output);
60ffb308 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" }
3e887aae 69$Test->reset_outputs;
60ffb308 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 );
0257f296 94
95
96# This test has to come last because it thrashes the test details.
97{
98 my $curr_test = $Test->current_test;
99 $Test->current_test(4);
100 my @details = $Test->details();
101
102 $Test->current_test($curr_test);
103 $Test->is_num( scalar @details, 4 );
104}